Pre Merge pull request !10 from ShikiSuen/upd/1.4.0

This commit is contained in:
ShikiSuen 2022-03-19 12:48:53 +00:00 committed by Gitee
commit b285348cf4
44 changed files with 261 additions and 6960 deletions

View File

@ -0,0 +1,5 @@
注意事项:
一、macOS 10.x-11.x 系统有 Bug、令该安装程式无法自动将安装目标设为当前使用者资料夹。如果您在 macOS 12 Monterey 之前的系统安装该输入法的话,请务必「手动」将安装目的地设为当前使用者资料夹。否则,当您今后(在升级系统之后)升级输入法的时候,可能会出现各种混乱情况。
二、安装完毕之后,如果输入法无法正常使用的话,请重新登入即可。

View File

@ -0,0 +1,5 @@
注意事項:
一、macOS 10.x-11.x 系統有 Bug、令該安裝程式無法自動將安裝目標設為當前使用者資料夾。如果您在 macOS 12 Monterey 之前的系統安裝該輸入法的話,請務必「手動」將安裝目的地設為當前使用者資料夾。否則,當您今後(在升級系統之後)升級輸入法的時候,可能會出現各種混亂情況。
二、安裝完畢之後,如果輸入法無法正常使用的話,請重新登入即可。

View File

@ -0,0 +1,5 @@
Notice:
Due to a bug in macOS 10.x and 11.x, if you are trying to install this input method on macOS releases earlier than macOS 12 Monterey, PLEASE manually choose the install target to the user folder. Otherwise, there will be problems when you are trying to install this input method to later versions when your OS gets upgraded to macOS 12 Monterey or later.
Also, feel free to logout and re-login if the input method doesn't work after installation.

View File

@ -0,0 +1,7 @@
ご注意:
macOS 12 Monterey 以前の OSmacOS 10.x-11.xのバグのため、macOS 10.x-11.x でインストールする場合、この入力アプリ必ずご自分でユーザーフォルダをインストール先と設定してください。然もないと、いずれ macOS 12 にアップデートし、この入力アプリのもっと新しいバージョンをインストールする時に、予測できない支障が生ずる恐れがあります。
そして、インストール直後、入力アプリがうまく使えない場合、再ログインすれば済ませることです。
よろしくお願いいたします。

View File

@ -4,3 +4,4 @@
欠 缺 欠 欠 缺 欠
糸 絲 糸 糸 絲 糸
芸 藝 芸 芸 藝 芸
浜 濱 浜

View File

@ -174,7 +174,7 @@
瀧 滝 瀧 滝
瀨 瀬 瀨 瀬
灣 湾 灣 湾
燈 灯 燈 灯
燒 焼 燒 焼
營 営 營 営

View File

@ -645,7 +645,7 @@
彨 彲 彨 彲
彩 彩 綵 彩 彩 綵
彻 徹 彻 徹
征 徵 征 征 徵 征
径 徑 径 徑
徕 徠 徕 徠
御 御 禦 御 御 禦
@ -1158,7 +1158,7 @@
疯 瘋 疯 瘋
疱 皰 疱 皰
疴 痾 疴 痾
症 症 症 症
痈 癰 痈 癰
痉 痙 痉 痙
痒 癢 痒 癢

View File

@ -1,3 +1,5 @@
征候 癥候
综合征 綜合癥
㓦划 㓦劃 㓦划 㓦劃
一丝不挂 一絲不掛 一丝不挂 一絲不掛
一了心愿 一了心願 一了心愿 一了心願
@ -294,6 +296,7 @@
七余 七餘 七余 七餘
七八下里 七八下裏 七八下里 七八下裏
七出 七出 七出 七出
七出戏 七齣戲
七出祁山 七出祁山 七出祁山 七出祁山
七分钟 七分鐘 七分钟 七分鐘
七划 七劃 七划 七劃
@ -696,6 +699,7 @@
三冬 三冬 三冬 三冬
三冬两夏 三冬兩夏 三冬两夏 三冬兩夏
三准 三準 三准 三準
三出戏 三齣戲
三出祁山 三出祁山 三出祁山 三出祁山
三分钟 三分鐘 三分钟 三分鐘
三只 三隻 三只 三隻
@ -2297,6 +2301,7 @@
九亿五千万 九億五千萬 九亿五千万 九億五千萬
九余 九餘 九余 九餘
九冬 九冬 九冬 九冬
九出戏 九齣戲
九出祁山 九出祁山 九出祁山 九出祁山
九分钟 九分鐘 九分钟 九分鐘
九划 九劃 九划 九劃
@ -5659,6 +5664,7 @@
全面禁止核试验条约 全面禁止核試驗條約 全面禁止核试验条约 全面禁止核試驗條約
全面规划 全面規劃 全面规划 全面規劃
全面进行 全面進行 全面进行 全面進行
兩出戏 兩齣戲
八万 八萬 八万 八萬
八万一千 八萬一千 八万一千 八萬一千
八万四千法门 八萬四千法門 八万四千法门 八萬四千法門
@ -5670,6 +5676,7 @@
八余 八餘 八余 八餘
八克 八克 八克 八克
八军团 八軍團 八军团 八軍團
八出戏 八齣戲
八出祁山 八出祁山 八出祁山 八出祁山
八十天环游地球 八十天環遊地球 八十天环游地球 八十天環遊地球
八十种好 八十種好 八十种好 八十種好
@ -5789,6 +5796,7 @@
六余 六餘 六余 六餘
六冲 六沖 六冲 六沖
六出奇计 六出奇計 六出奇计 六出奇計
六出戏 六齣戲
六出祁山 六出祁山 六出祁山 六出祁山
六厂 六廠 六厂 六廠
六发 六發 六发 六發
@ -7048,7 +7056,7 @@
凯特布兰琪 凱特布蘭琪 凯特布兰琪 凱特布蘭琪
凯迪拉克 凱迪拉克 凯迪拉克 凱迪拉克
凯里 凱里 凯里 凱里
凯里市 凱 凯里市 凱
凶事 凶事 凶事 凶事
凶人 兇人 凶人 兇人
凶仪 兇儀 凶仪 兇儀
@ -7366,7 +7374,7 @@
出恭 出恭 出恭 出恭
出息 出息 出息 出息
出意外 出意外 出意外 出意外
出戏 齣戲 出戏 出戏 齣戲
出战 出戰 出战 出戰
出户 出戶 出户 出戶
出手 出手 出手 出手
@ -7794,7 +7802,7 @@
切当 切當 切当 切當
切菜板 切菜板 切菜板 切菜板
切除术 切除術 切除术 切除術
切面 切面 切面 切面 切麵
切骨之仇 切骨之仇 切骨之仇 切骨之仇
刊了 刊了 刊了 刊了
刊出 刊出 刊出 刊出
@ -15533,7 +15541,7 @@
回帖 回帖 回帖 回帖
回带 迴帶 回带 迴帶
回席 回席 回席 回席
回应 回应
回府 回府 回府 回府
回廊 迴廊 回廊 迴廊
回弹 回彈 回弹 回彈
@ -16610,7 +16618,6 @@
复习考 複習考 复习考 複習考
复书 復書 复书 復書
复交 復交 复交 復交
复亩珍 複畝珍
复仇 復仇 复仇 復仇
复仇者 復仇者 复仇者 復仇者
复仇记 復仇記 复仇记 復仇記
@ -19794,9 +19801,9 @@
巴贝西亚原虫病 巴貝西亞原蟲病 巴贝西亚原虫病 巴貝西亞原蟲病
巴里 巴里 巴里 巴里
巴里坤 巴里坤 巴里坤 巴里坤
巴里坤县 巴坤縣 巴里坤县 巴坤縣
巴里坤哈萨克自治县 巴坤哈薩克自治縣 巴里坤哈萨克自治县 巴坤哈薩克自治縣
巴里坤草原 巴坤草原 巴里坤草原 巴坤草原
巴里岛 巴里島 巴里岛 巴里島
巴里库廷火山 巴里庫廷火山 巴里库廷火山 巴里庫廷火山
巴里斯 巴里斯 巴里斯 巴里斯
@ -20009,7 +20016,6 @@
布气 布氣 布气 布氣
布水 布水 布水 布水
布法罗 布法羅 布法罗 布法羅
布洒器 布灑器
布洛克 布洛克 布洛克 布洛克
布洛斯顿 布洛斯頓 布洛斯顿 布洛斯頓
布洛沙德 布洛沙德 布洛沙德 布洛沙德
@ -20028,7 +20034,6 @@
布瑞斯特 布瑞斯特 布瑞斯特 布瑞斯特
布瑞特 布瑞特 布瑞特 布瑞特
布瑞顿 布瑞頓 布瑞顿 布瑞頓
布用填 布用填
布疋 布疋 布疋 布疋
布疑阵 佈疑陣 布疑阵 佈疑陣
布痕瓦尔德 布痕瓦爾德 布痕瓦尔德 布痕瓦爾德
@ -20791,7 +20796,7 @@
平复帖 平復帖 平复帖 平復帖
平复起来 平復起來 平复起来 平復起來
平头并进 平頭並進 平头并进 平頭並進
平安里 平安 平安里 平安
平定准噶尔回部得胜图 平定準噶爾回部得勝圖 平定准噶尔回部得胜图 平定準噶爾回部得勝圖
平平当当 平平當當 平平当当 平平當當
平康里 平康里 平康里 平康里
@ -27267,6 +27272,7 @@
斗趣 鬥趣 斗趣 鬥趣
斗趣儿 鬥趣兒 斗趣儿 鬥趣兒
斗车 斗車 斗车 斗車
斗转 斗轉
斗转参横 斗轉參橫 斗转参横 斗轉參橫
斗转星移 斗轉星移 斗转星移 斗轉星移
斗酒 斗酒 斗酒 斗酒
@ -28851,7 +28857,7 @@
木薯淀粉 木薯澱粉 木薯淀粉 木薯澱粉
木蜡 木蠟 木蜡 木蠟
木表法 木表法 木表法 木表法
木里藏族自治县 木藏族自治縣 木里藏族自治县 木藏族自治縣
木钟 木鐘 木钟 木鐘
木铲 木鏟 木铲 木鏟
木雕 木雕 木雕 木雕
@ -29319,6 +29325,7 @@
李杰 李傑 李杰 李傑
李洪志 李洪志 李洪志 李洪志
李炳千 李炳千 李炳千 李炳千
李白 李白
李百药 李百藥 李百药 李百藥
李盟干 李盟乾 李盟干 李盟乾
李秋静 李秋靜 李秋静 李秋靜
@ -33301,7 +33308,7 @@
湖南师范大学 湖南師範大學 湖南师范大学 湖南師範大學
湖州师范学院 湖州師範學院 湖州师范学院 湖州師範學院
湖里 湖裏 湖里 湖裏
湖里区 湖 湖里区 湖
湖面 湖面 湖面 湖面
湘帘 湘簾 湘帘 湘簾
湘累 湘累 湘累 湘累
@ -33413,7 +33420,7 @@
满拚自尽 滿拚自盡 满拚自尽 滿拚自盡
满杯 滿杯 满杯 滿杯
满洲里 滿洲里 满洲里 滿洲里
满洲里市 滿洲 满洲里市 滿洲
满满当当 滿滿當當 满满当当 滿滿當當
满脸溅朱 滿臉濺朱 满脸溅朱 滿臉濺朱
满腹才学 滿腹才學 满腹才学 滿腹才學
@ -41968,6 +41975,7 @@
行雨朝云 行雨朝雲 行雨朝云 行雨朝雲
衍声复词 衍聲複詞 衍声复词 衍聲複詞
衍极 衍極 衍极 衍極
衍生 衍生
衍生出 衍生出 衍生出 衍生出
衍生出来 衍生出來 衍生出来 衍生出來
衔哀致诚 銜哀致誠 衔哀致诚 銜哀致誠
@ -42557,7 +42565,7 @@
角膜移植术 角膜移植術 角膜移植术 角膜移植術
角色冲突 角色衝突 角色冲突 角色衝突
角色扮演游戏 角色扮演遊戲 角色扮演游戏 角色扮演遊戲
角落 角落 角落 角落
角落里 角落裏 角落里 角落裏
角谷猜想 角谷猜想 角谷猜想 角谷猜想
角里 角里 角里 角里
@ -45219,7 +45227,7 @@
部发 部發 部发 部發
部曲 部曲 部曲 部曲
部胡林 部胡林 部胡林 部胡林
部落 部落 部落 部落
部落同盟 部落同盟 部落同盟 部落同盟
郭勇志 郭勇志 郭勇志 郭勇志
郭台成 郭臺成 郭台成 郭臺成
@ -48217,7 +48225,7 @@
香愿 香願 香愿 香願
香斗 香斗 香斗 香斗
香格里拉 香格里拉 香格里拉 香格里拉
香格里拉县 香格拉縣 香格里拉县 香格拉縣
香格里拉怡咖啡 香格里拉怡咖啡 香格里拉怡咖啡 香格里拉怡咖啡
香榭丽舍 香榭麗舍 香榭丽舍 香榭麗舍
香榭丽舍大街 香榭麗舍大街 香榭丽舍大街 香榭麗舍大街

View File

@ -1354,7 +1354,7 @@
癡 痴 癡 痴
癢 痒 癢 痒
癤 疖 癤 疖
癥 症
癧 疬 癧 疬
癩 癞 癩 癞
癬 癣 癬 癣

View File

@ -5,6 +5,8 @@
么麽 幺麽 么麽 幺麽
乾乾淨淨 干干净净 乾乾淨淨 干干净净
乾乾脆脆 干干脆脆 乾乾脆脆 干干脆脆
癥候 征候
綜合症 综合征
乾元 乾元 乾元 乾元
乾卦 乾卦 乾卦 乾卦
乾嘉 乾嘉 乾嘉 乾嘉

View File

@ -232,7 +232,7 @@ U盤 隨身碟
發送 傳送 發送 傳送
皮膚 面板 皮膚 面板
盤片 碟片 盤片 碟片
盤符 碟符 盤符 磁碟機代號
目標代碼 目的碼 目標代碼 目的碼
相冊 相簿 相冊 相簿
矢量 向量 矢量 向量
@ -300,6 +300,8 @@ U盤 隨身碟
複選框 覈取方塊 複選框 覈取方塊
視圖 檢視 視圖 檢視
視頻 影片 視訊 視頻 影片 視訊
視頻會議 視訊會議
視頻通話 視訊通話
解釋器 直譯器 解釋器 直譯器
觸摸 觸控 觸摸 觸控
觸摸屏 觸控式螢幕 觸摸屏 觸控式螢幕

View File

@ -34,3 +34,4 @@
鐦 鉲 鐦 鉲
鑥 鎦 鑥 鎦
黃宏 黃宏 黃宏 黃宏
借記卡 簽帳金融卡

View File

@ -1,31 +0,0 @@
// Copyright (c) 2015 and onwards Alexander Widerberg.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor,
except as required to fulfill notice requirements above.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
@interface AWFileHash : NSObject
+ (NSString *)sha1HashOfData:(NSData *)data;
+ (NSString *)sha512HashOfData:(NSData *)data;
+ (NSString *)crc32HashOfData:(NSData *)data;
+ (NSString *)sha1HashOfFileAtPath:(NSString *)filePath;
+ (NSString *)sha512HashOfFileAtPath:(NSString *)filePath;
+ (NSString *)crc32HashOfFileAtPath:(NSString *)filePath;
@end

View File

@ -1,348 +0,0 @@
// Copyright (c) 2015 and onwards Alexander Widerberg.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor,
except as required to fulfill notice requirements above.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Header file
#import "AWFileHash.h"
// System framework and libraries
#include <CommonCrypto/CommonDigest.h>
#include <CoreFoundation/CoreFoundation.h>
#include <stdint.h>
#include <stdio.h>
// Constants
size_t FileHashDefaultChunkSizeForReadingData = 4096; // in bytes
// Function pointer types for functions used in the computation
// of a cryptographic hash.
typedef int (*FileHashInitFunction) (uint8_t *hashObjectPointer[]);
typedef int (*FileHashUpdateFunction) (uint8_t *hashObjectPointer[], const void *data, CC_LONG len);
typedef int (*FileHashFinalFunction) (unsigned char *md, uint8_t *hashObjectPointer[]);
// Structure used to describe a hash computation context.
typedef struct _FileHashComputationContext {
FileHashInitFunction initFunction;
FileHashUpdateFunction updateFunction;
FileHashFinalFunction finalFunction;
size_t digestLength;
uint8_t **hashObjectPointer;
} FileHashComputationContext;
#define MAX_READ_STREAM_STATUS_POLLING_ATTEMPTS 10
#define FileHashComputationContextInitialize(context, hashAlgorithmName) \
CC_##hashAlgorithmName##_CTX hashObjectFor##hashAlgorithmName; \
context.initFunction = (FileHashInitFunction)&CC_##hashAlgorithmName##_Init; \
context.updateFunction = (FileHashUpdateFunction)&CC_##hashAlgorithmName##_Update; \
context.finalFunction = (FileHashFinalFunction)&CC_##hashAlgorithmName##_Final; \
context.digestLength = CC_##hashAlgorithmName##_DIGEST_LENGTH; \
context.hashObjectPointer = (uint8_t **)&hashObjectFor##hashAlgorithmName
#pragma mark - CRC32b implementation
typedef struct {
CC_LONG crc;
} CC_CRC32_CTX;
static int CC_CRC32_Init(CC_CRC32_CTX *c);
static int CC_CRC32_Update(CC_CRC32_CTX *c, const uint8_t *data, CC_LONG len);
static int CC_CRC32_Final(unsigned char *md, CC_CRC32_CTX *c);
#define CC_CRC32_DIGEST_LENGTH 4
static CC_LONG crc32_tbl[256] =
{
0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, 0x076DC419L,
0x706AF48FL, 0xE963A535L, 0x9E6495A3L, 0x0EDB8832L, 0x79DCB8A4L,
0xE0D5E91EL, 0x97D2D988L, 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L,
0x90BF1D91L, 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, 0x136C9856L,
0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, 0x14015C4FL, 0x63066CD9L,
0xFA0F3D63L, 0x8D080DF5L, 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L,
0xA2677172L, 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, 0x32D86CE3L,
0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, 0x26D930ACL, 0x51DE003AL,
0xC8D75180L, 0xBFD06116L, 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L,
0xB8BDA50FL, 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, 0x76DC4190L,
0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, 0x71B18589L, 0x06B6B51FL,
0x9FBFE4A5L, 0xE8B8D433L, 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL,
0xE10E9818L, 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, 0x6C0695EDL,
0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, 0x65B0D9C6L, 0x12B7E950L,
0x8BBEB8EAL, 0xFCB9887CL, 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L,
0xFBD44C65L, 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, 0x4369E96AL,
0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, 0x44042D73L, 0x33031DE5L,
0xAA0A4C5FL, 0xDD0D7CC9L, 0x5005713CL, 0x270241AAL, 0xBE0B1010L,
0xC90C2086L, 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, 0x59B33D17L,
0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, 0xEDB88320L, 0x9ABFB3B6L,
0x03B6E20CL, 0x74B1D29AL, 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L,
0x73DC1683L, 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, 0xF00F9344L,
0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, 0xF762575DL, 0x806567CBL,
0x196C3671L, 0x6E6B06E7L, 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL,
0x67DD4ACCL, 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, 0xD1BB67F1L,
0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, 0xD80D2BDAL, 0xAF0A1B4CL,
0x36034AF6L, 0x41047A60L, 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL,
0x4669BE79L, 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, 0xC5BA3BBEL,
0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, 0xC2D7FFA7L, 0xB5D0CF31L,
0x2CD99E8BL, 0x5BDEAE1DL, 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL,
0x026D930AL, 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, 0x92D28E9BL,
0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, 0x86D3D2D4L, 0xF1D4E242L,
0x68DDB3F8L, 0x1FDA836EL, 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L,
0x18B74777L, 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, 0xA00AE278L,
0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, 0xA7672661L, 0xD06016F7L,
0x4969474DL, 0x3E6E77DBL, 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L,
0x37D83BF0L, 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, 0xBAD03605L,
0xCDD70693L, 0x54DE5729L, 0x23D967BFL, 0xB3667A2EL, 0xC4614AB8L,
0x5D681B02L, 0x2A6F2B94L, 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL,
0x2D02EF8DL
};
int CC_CRC32_Init(CC_CRC32_CTX *c) {
c->crc = 0xFFFFFFFFL;
return 0;
}
int CC_CRC32_Update(CC_CRC32_CTX *c, const uint8_t *data, CC_LONG len) {
CC_LONG crc = c->crc;
for(CC_LONG i=0; i<len;i++) {
crc = (crc>>8) ^ crc32_tbl[(crc&0xFF) ^ *data++];
}
c->crc = crc;
return 0;
}
int CC_CRC32_Final(unsigned char *md, CC_CRC32_CTX *c) {
CC_LONG crc = c->crc;
crc = crc ^ 0xFFFFFFFFL;
md[0] = (crc & 0xff000000UL) >> 24;
md[1] = (crc & 0x00ff0000UL) >> 16;
md[2] = (crc & 0x0000ff00UL) >> 8;
md[3] = (crc & 0x000000ffUL) ;
return 0;
}
#pragma mark - Begin implementation
@implementation AWFileHash
#pragma mark -
#pragma mark private class helpers
+ (NSString *)hashOfFileAtPath:(NSString *)filePath withComputationContext:(FileHashComputationContext *)context {
NSString *result = nil;
CFURLRef fileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)filePath, kCFURLPOSIXPathStyle, (Boolean)false);
CFReadStreamRef readStream = fileURL ? CFReadStreamCreateWithFile(kCFAllocatorDefault, fileURL) : NULL;
BOOL didSucceed = readStream ? (BOOL)CFReadStreamOpen(readStream) : NO;
// Race condition while running om multiple threads patched with big thanks to Aaron Morse
if (!didSucceed) {
if (readStream) CFRelease(readStream);
if (fileURL) CFRelease(fileURL);
return nil;
}
CFStreamStatus myStreamStatus;
NSUInteger attempts = 0;
do {
sleep(1);
myStreamStatus = CFReadStreamGetStatus(readStream);
if (attempts++ > MAX_READ_STREAM_STATUS_POLLING_ATTEMPTS) {
if (readStream) CFRelease(readStream);
if (fileURL) CFRelease(fileURL);
return nil;
}
} while ((myStreamStatus != kCFStreamStatusOpen) && (myStreamStatus != kCFStreamStatusError));
if (myStreamStatus == kCFStreamStatusError) {
if (readStream) CFRelease(readStream);
if (fileURL) CFRelease(fileURL);
return nil;
}
// End race condition check
// Use default value for the chunk size for reading data.
const size_t chunkSizeForReadingData = FileHashDefaultChunkSizeForReadingData;
// Initialize the hash object
(*context->initFunction)(context->hashObjectPointer);
// Feed the data to the hash object.
BOOL hasMoreData = YES;
while (hasMoreData) {
uint8_t buffer[chunkSizeForReadingData];
CFIndex readBytesCount = CFReadStreamRead(readStream, (UInt8 *)buffer, (CFIndex)sizeof(buffer));
if (readBytesCount == -1) {
break;
} else if (readBytesCount == 0) {
hasMoreData = NO;
} else {
(*context->updateFunction)(context->hashObjectPointer, (const void *)buffer, (CC_LONG)readBytesCount);
}
}
// Compute the hash digest
unsigned char digest[context->digestLength];
(*context->finalFunction)(digest, context->hashObjectPointer);
// Close the read stream.
CFReadStreamClose(readStream);
// Proceed if the read operation succeeded.
didSucceed = !hasMoreData;
if (didSucceed) {
char hash[2 * sizeof(digest) + 1];
for (size_t i = 0; i < sizeof(digest); ++i) {
snprintf(hash + (2 * i), 3, "%02x", (int)(digest[i]));
}
result = [NSString stringWithUTF8String:hash];
}
if (readStream) CFRelease(readStream);
if (fileURL) CFRelease(fileURL);
return result;
}
+ (NSString *)hashOfNSData:(NSData *)data withComputationContext:(FileHashComputationContext *)context {
NSString *result = nil;
BOOL didSucceed = NO;
// Use default value for the chunk size for reading data.
size_t chunkSizeForReadingData = 0;
if(FileHashDefaultChunkSizeForReadingData > data.length) {
chunkSizeForReadingData = data.length;
} else {
chunkSizeForReadingData = FileHashDefaultChunkSizeForReadingData;
}
// Initialize the hash object
(*context->initFunction)(context->hashObjectPointer);
// Feed the data to the hash object.
BOOL hasMoreData = YES;
CFIndex readBytesCount = 0;
CFIndex totalOffset = 0;
NSRange range;
while (hasMoreData) {
uint8_t buffer[chunkSizeForReadingData];
readBytesCount = sizeof(buffer);
// Make sure that we read the correct amount of data
if(totalOffset+readBytesCount > data.length && !(totalOffset == data.length)) {
readBytesCount = (data.length-totalOffset);
} else if(totalOffset == data.length) {
readBytesCount = 0;
} else if(totalOffset > data.length) {
// This should not happen at any time (added for precaution)
break;
}
range = NSMakeRange(totalOffset, readBytesCount);
@try {
[data getBytes:buffer range:range];
}
@catch (NSException *exception) {
NSLog(@"%@", exception.debugDescription);
break;
}
totalOffset = totalOffset + readBytesCount;
if (readBytesCount == -1) {
} else if (readBytesCount == 0) {
hasMoreData = NO;
} else {
(*context->updateFunction)(context->hashObjectPointer, (const void *)buffer, (CC_LONG)readBytesCount);
}
}
// Compute the hash digest
unsigned char digest[context->digestLength];
(*context->finalFunction)(digest, context->hashObjectPointer);
// Proceed if the read operation succeeded.
didSucceed = !hasMoreData;
if (didSucceed) {
char hash[2 * sizeof(digest) + 1];
for (size_t i = 0; i < sizeof(digest); ++i) {
snprintf(hash + (2 * i), 3, "%02x", (int)(digest[i]));
}
result = [NSString stringWithUTF8String:hash];
}
return result;
}
#pragma mark -
#pragma mark public class accessors
+ (NSString *)sha1HashOfData:(NSData *)data {
FileHashComputationContext context;
FileHashComputationContextInitialize(context, SHA1);
return [self hashOfNSData:data withComputationContext:&context];
}
+ (NSString *)sha512HashOfData:(NSData *)data {
FileHashComputationContext context;
FileHashComputationContextInitialize(context, SHA512);
return [self hashOfNSData:data withComputationContext:&context];
}
+ (NSString *)crc32HashOfData:(NSData *)data {
FileHashComputationContext context;
FileHashComputationContextInitialize(context, CRC32);
return [self hashOfNSData:data withComputationContext:&context];
}
+ (NSString *)sha1HashOfFileAtPath:(NSString *)filePath {
FileHashComputationContext context;
FileHashComputationContextInitialize(context, SHA1);
return [self hashOfFileAtPath:filePath withComputationContext:&context];
}
+ (NSString *)sha512HashOfFileAtPath:(NSString *)filePath {
FileHashComputationContext context;
FileHashComputationContextInitialize(context, SHA512);
return [self hashOfFileAtPath:filePath withComputationContext:&context];
}
+ (NSString *)crc32HashOfFileAtPath:(NSString *)filePath {
FileHashComputationContext context;
FileHashComputationContextInitialize(context, CRC32);
return [self hashOfFileAtPath:filePath withComputationContext:&context];
}
@end

View File

@ -1,55 +0,0 @@
// Copyright (c) 2010 and onwards Sam Soffes.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor,
except as required to fulfill notice requirements above.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#include "minizip/unzip.h"
@protocol SSZipArchiveDelegate;
@interface SSZipArchive : NSObject
// Unzip
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error;
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate;
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error delegate:(id<SSZipArchiveDelegate>)delegate;
// Zip
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)filenames;
- (id)initWithPath:(NSString *)path;
- (BOOL)open;
- (BOOL)writeFile:(NSString *)path;
- (BOOL)writeData:(NSData *)data filename:(NSString *)filename;
- (BOOL)close;
@end
@protocol SSZipArchiveDelegate <NSObject>
@optional
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
- (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
@end

View File

@ -1,431 +0,0 @@
// Copyright (c) 2010 and onwards Sam Soffes.
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor,
except as required to fulfill notice requirements above.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import "SSZipArchive.h"
#include "minizip/zip.h"
#import "zlib.h"
#import "zconf.h"
#include <sys/stat.h>
#define CHUNK 16384
@interface SSZipArchive ()
+ (NSDate *)_dateWithMSDOSFormat:(UInt32)msdosDateTime;
@end
@implementation SSZipArchive {
NSString *_path;
NSString *_filename;
zipFile _zip;
}
#pragma mark - Unzipping
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination {
return [self unzipFileAtPath:path toDestination:destination delegate:nil];
}
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error {
return [self unzipFileAtPath:path toDestination:destination overwrite:overwrite password:password error:error delegate:nil];
}
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate {
return [self unzipFileAtPath:path toDestination:destination overwrite:YES password:nil error:nil delegate:delegate];
}
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error delegate:(id<SSZipArchiveDelegate>)delegate {
// Begin opening
zipFile zip = unzOpen((const char*)[path UTF8String]);
if (zip == NULL) {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"failed to open zip file" forKey:NSLocalizedDescriptionKey];
if (error) {
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-1 userInfo:userInfo];
}
return NO;
}
unz_global_info globalInfo = {0ul, 0ul};
unzGetGlobalInfo(zip, &globalInfo);
// Begin unzipping
if (unzGoToFirstFile(zip) != UNZ_OK) {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"failed to open first file in zip file" forKey:NSLocalizedDescriptionKey];
if (error) {
*error = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-2 userInfo:userInfo];
}
return NO;
}
BOOL success = YES;
int ret = 0;
unsigned char buffer[4096] = {0};
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableSet *directoriesModificationDates = [[NSMutableSet alloc] init];
// Message delegate
if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipArchiveAtPath:zipInfo:)]) {
[delegate zipArchiveWillUnzipArchiveAtPath:path zipInfo:globalInfo];
}
NSInteger currentFileNumber = 0;
do {
if ([password length] == 0) {
ret = unzOpenCurrentFile(zip);
} else {
ret = unzOpenCurrentFilePassword(zip, [password cStringUsingEncoding:NSASCIIStringEncoding]);
}
if (ret != UNZ_OK) {
success = NO;
break;
}
// Reading data and write to file
unz_file_info fileInfo;
memset(&fileInfo, 0, sizeof(unz_file_info));
ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
if (ret != UNZ_OK) {
success = NO;
unzCloseCurrentFile(zip);
break;
}
// Message delegate
if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
[delegate zipArchiveWillUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry
archivePath:path fileInfo:fileInfo];
}
char *filename = (char *)malloc(fileInfo.size_filename + 1);
unzGetCurrentFileInfo(zip, &fileInfo, filename, fileInfo.size_filename + 1, NULL, 0, NULL, 0);
filename[fileInfo.size_filename] = '\0';
//
// NOTE
// I used the ZIP spec from here:
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
//
// ...to deduce this method of detecting whether the file in the ZIP is a symbolic link.
// If it is, it is listed as a directory but has a data size greater than zero (real
// directories have it equal to 0) and the included, uncompressed data is the symbolic link path.
//
// ZIP files did not originally include support for symbolic links so the specification
// doesn't include anything in them that isn't part of a unix extension that isn't being used
// by the archivers we're testing. Most of this is figured out through trial and error and
// reading ZIP headers in hex editors. This seems to do the trick though.
//
const uLong ZipCompressionMethodStore = 0;
BOOL fileIsSymbolicLink = NO;
if((fileInfo.compression_method == ZipCompressionMethodStore) && // Is it compressed?
(S_ISDIR(fileInfo.external_fa)) && // Is it marked as a directory
(fileInfo.compressed_size > 0)) // Is there any data?
{
fileIsSymbolicLink = YES;
}
// Check if it contains directory
NSString *strPath = [NSString stringWithCString:filename encoding:NSUTF8StringEncoding];
BOOL isDirectory = NO;
if (filename[fileInfo.size_filename-1] == '/' || filename[fileInfo.size_filename-1] == '\\') {
isDirectory = YES;
}
free(filename);
// Contains a path
if ([strPath rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"/\\"]].location != NSNotFound) {
strPath = [strPath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
}
NSString *fullPath = [destination stringByAppendingPathComponent:strPath];
NSError *err = nil;
NSDate *modDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.dosDate];
NSDictionary *directoryAttr = [NSDictionary dictionaryWithObjectsAndKeys:modDate, NSFileCreationDate, modDate, NSFileModificationDate, nil];
if (isDirectory) {
[fileManager createDirectoryAtPath:fullPath withIntermediateDirectories:YES attributes:directoryAttr error:&err];
} else {
[fileManager createDirectoryAtPath:[fullPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:directoryAttr error:&err];
}
if (nil != err) {
NSLog(@"[SSZipArchive] Error: %@", err.localizedDescription);
}
if(!fileIsSymbolicLink)
[directoriesModificationDates addObject: [NSDictionary dictionaryWithObjectsAndKeys:fullPath, @"path", modDate, @"modDate", nil]];
if ([fileManager fileExistsAtPath:fullPath] && !isDirectory && !overwrite) {
unzCloseCurrentFile(zip);
ret = unzGoToNextFile(zip);
continue;
}
if(!fileIsSymbolicLink)
{
FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
while (fp) {
int readBytes = unzReadCurrentFile(zip, buffer, 4096);
if (readBytes > 0) {
fwrite(buffer, readBytes, 1, fp );
} else {
break;
}
}
if (fp) {
fclose(fp);
// Set the original datetime property
if (fileInfo.dosDate != 0) {
NSDate *orgDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.dosDate];
NSDictionary *attr = [NSDictionary dictionaryWithObject:orgDate forKey:NSFileModificationDate];
if (attr) {
if ([fileManager setAttributes:attr ofItemAtPath:fullPath error:nil] == NO) {
// Can't set attributes
NSLog(@"[SSZipArchive] Failed to set attributes");
}
}
}
}
}
else
{
// Get the path for the symbolic link
NSURL* symlinkURL = [NSURL fileURLWithPath:fullPath];
NSMutableString* destinationPath = [NSMutableString string];
int bytesRead = 0;
while((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0)
{
buffer[bytesRead] = 0;
[destinationPath appendString:[NSString stringWithUTF8String:(const char*)buffer]];
}
//NSLog(@"Symlinking to: %@", destinationPath);
NSURL* destinationURL = [NSURL fileURLWithPath:destinationPath];
// Create the symbolic link
NSError* symlinkError = nil;
[fileManager createSymbolicLinkAtURL:symlinkURL withDestinationURL:destinationURL error:&symlinkError];
if(symlinkError != nil)
{
NSLog(@"Failed to create symbolic link at \"%@\" to \"%@\". Error: %@", symlinkURL.absoluteString, destinationURL.absoluteString, symlinkError.localizedDescription);
}
}
unzCloseCurrentFile( zip );
ret = unzGoToNextFile( zip );
// Message delegate
if ([delegate respondsToSelector:@selector(zipArchiveDidUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
[delegate zipArchiveDidUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry
archivePath:path fileInfo:fileInfo];
}
currentFileNumber++;
} while(ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE);
// Close
unzClose(zip);
// The process of decompressing the .zip archive causes the modification times on the folders
// to be set to the present time. So, when we are done, they need to be explicitly set.
// set the modification date on all of the directories.
NSError * err = nil;
for (NSDictionary * d in directoriesModificationDates) {
if (![[NSFileManager defaultManager] setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[d objectForKey:@"modDate"], NSFileModificationDate, nil] ofItemAtPath:[d objectForKey:@"path"] error:&err]) {
NSLog(@"[SSZipArchive] Set attributes failed for directory: %@.", [d objectForKey:@"path"]);
}
if (err) {
NSLog(@"[SSZipArchive] Error setting directory file modification date attribute: %@",err.localizedDescription);
}
}
#if !__has_feature(objc_arc)
[directoriesModificationDates release];
#endif
// Message delegate
if (success && [delegate respondsToSelector:@selector(zipArchiveDidUnzipArchiveAtPath:zipInfo:unzippedPath:)]) {
[delegate zipArchiveDidUnzipArchiveAtPath:path zipInfo:globalInfo unzippedPath:destination];
}
return success;
}
#pragma mark - Zipping
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths {
BOOL success = NO;
SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path];
if ([zipArchive open]) {
for (path in paths) {
[zipArchive writeFile:path];
}
success = [zipArchive close];
}
#if !__has_feature(objc_arc)
[zipArchive release];
#endif
return success;
}
- (id)initWithPath:(NSString *)path {
if ((self = [super init])) {
_path = [path copy];
}
return self;
}
#if !__has_feature(objc_arc)
- (void)dealloc {
[_path release];
[super dealloc];
}
#endif
- (BOOL)open {
NSAssert((_zip == NULL), @"Attempting open an archive which is already open");
_zip = zipOpen([_path UTF8String], APPEND_STATUS_CREATE);
return (NULL != _zip);
}
- (void)zipInfo:(zip_fileinfo*)zipInfo setDate:(NSDate*)date {
NSCalendar *currentCalendar = [NSCalendar currentCalendar];
uint flags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
NSDateComponents *components = [currentCalendar components:flags fromDate:date];
zipInfo->tmz_date.tm_sec = (unsigned int)components.second;
zipInfo->tmz_date.tm_min = (unsigned int)components.minute;
zipInfo->tmz_date.tm_hour = (unsigned int)components.hour;
zipInfo->tmz_date.tm_mday = (unsigned int)components.day;
zipInfo->tmz_date.tm_mon = (unsigned int)components.month - 1;
zipInfo->tmz_date.tm_year = (unsigned int)components.year;
}
- (BOOL)writeFile:(NSString *)path {
NSAssert((_zip != NULL), @"Attempting to write to an archive which was never opened");
FILE *input = fopen([path UTF8String], "r");
if (NULL == input) {
return NO;
}
zipOpenNewFileInZip(_zip, [[path lastPathComponent] UTF8String], NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED,
Z_DEFAULT_COMPRESSION);
void *buffer = malloc(CHUNK);
unsigned int len = 0;
while (!feof(input)) {
len = (unsigned int) fread(buffer, 1, CHUNK, input);
zipWriteInFileInZip(_zip, buffer, len);
}
zipCloseFileInZip(_zip);
free(buffer);
return YES;
}
- (BOOL)writeData:(NSData *)data filename:(NSString *)filename {
if (!_zip) {
return NO;
}
if (!data) {
return NO;
}
zip_fileinfo zipInfo = {{0,0,0,0,0,0},0,0,0};
[self zipInfo:&zipInfo setDate:[NSDate date]];
zipOpenNewFileInZip(_zip, [filename UTF8String], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
zipWriteInFileInZip(_zip, data.bytes, (unsigned int)data.length);
zipCloseFileInZip(_zip);
return YES;
}
- (BOOL)close {
NSAssert((_zip != NULL), @"[SSZipArchive] Attempting to close an archive which was never opened");
zipClose(_zip, NULL);
return YES;
}
#pragma mark - Private
// Format from http://newsgroups.derkeiler.com/Archive/Comp/comp.os.msdos.programmer/2009-04/msg00060.html
// Two consecutive words, or a longword, YYYYYYYMMMMDDDDD hhhhhmmmmmmsssss
// YYYYYYY is years from 1980 = 0
// sssss is (seconds/2).
//
// 3658 = 0011 0110 0101 1000 = 0011011 0010 11000 = 27 2 24 = 2007-02-24
// 7423 = 0111 0100 0010 0011 - 01110 100001 00011 = 14 33 2 = 14:33:06
+ (NSDate *)_dateWithMSDOSFormat:(UInt32)msdosDateTime {
static const UInt32 kYearMask = 0xFE000000;
static const UInt32 kMonthMask = 0x1E00000;
static const UInt32 kDayMask = 0x1F0000;
static const UInt32 kHourMask = 0xF800;
static const UInt32 kMinuteMask = 0x7E0;
static const UInt32 kSecondMask = 0x1F;
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [[NSDateComponents alloc] init];
NSAssert(0xFFFFFFFF == (kYearMask | kMonthMask | kDayMask | kHourMask | kMinuteMask | kSecondMask), @"[SSZipArchive] MSDOS date masks don't add up");
[components setYear:1980 + ((msdosDateTime & kYearMask) >> 25)];
[components setMonth:(msdosDateTime & kMonthMask) >> 21];
[components setDay:(msdosDateTime & kDayMask) >> 16];
[components setHour:(msdosDateTime & kHourMask) >> 11];
[components setMinute:(msdosDateTime & kMinuteMask) >> 5];
[components setSecond:(msdosDateTime & kSecondMask) * 2];
NSDate *date = [NSDate dateWithTimeInterval:0 sinceDate:[gregorian dateFromComponents:components]];
#if !__has_feature(objc_arc)
[gregorian release];
[components release];
#endif
return date;
}
@end

View File

@ -1,131 +0,0 @@
/* crypt.h -- base code for crypt/uncrypt ZIPfile
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
This code is a modified version of crypting code in Infozip distribution
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
This code support the "Traditional PKWARE Encryption".
The new AES encryption added on Zip format by Winzip (see the page
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
Encryption is not supported.
*/
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
register int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
}
return c;
}
/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
{
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
while (*passwd != '\0') {
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++;
}
}
#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif
static int crypthead(const char* passwd, /* password string */
unsigned char* buf, /* where to write header */
int bufSize,
unsigned long* pkeys,
const unsigned long* pcrc_32_tab,
unsigned long crcForCrypting)
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */
if (bufSize<RAND_HEAD_LEN)
return 0;
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
return n;
}
#endif

View File

@ -1,201 +0,0 @@
/* ioapi.h -- IO base function header for compress/uncompress .zip
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
For more info read MiniZip_info.txt
Changes
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
More if/def section may be needed to support other platforms
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
(but you should use iowin32.c for windows instead)
*/
#ifndef _ZLIBIOAPI64_H
#define _ZLIBIOAPI64_H
#if (!defined(_WIN32)) && (!defined(WIN32))
// Linux needs this to support file operation on files larger then 4+GB
// But might need better if/def to select just the platforms that needs them.
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
#ifndef __USE_LARGEFILE64
#define __USE_LARGEFILE64
#endif
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#ifndef _FILE_OFFSET_BIT
#define _FILE_OFFSET_BIT 64
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include "zlib.h"
#define USE_FILE32API
#if defined(USE_FILE32API)
#define fopen64 fopen
#define ftello64 ftell
#define fseeko64 fseek
#else
#ifdef _MSC_VER
#define fopen64 fopen
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
#define ftello64 _ftelli64
#define fseeko64 _fseeki64
#else // old MSC
#define ftello64 ftell
#define fseeko64 fseek
#endif
#endif
#endif
/*
#ifndef ZPOS64_T
#ifdef _WIN32
#define ZPOS64_T fpos_t
#else
#include <stdint.h>
#define ZPOS64_T uint64_t
#endif
#endif
*/
#ifdef HAVE_MINIZIP64_CONF_H
#include "mz64conf.h"
#endif
/* a type choosen by DEFINE */
#ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else
#ifdef HAS_STDINT_H
#include "stdint.h"
typedef uint64_t ZPOS64_T;
#else
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef unsigned __int64 ZPOS64_T;
#else
typedef unsigned long long int ZPOS64_T;
#endif
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0)
#define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8)
#ifndef ZCALLBACK
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
#define ZCALLBACK CALLBACK
#else
#define ZCALLBACK
#endif
#endif
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
/* here is the "old" 32 bits structure structure */
typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell_file_func ztell_file;
seek_file_func zseek_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
typedef struct zlib_filefunc64_def_s
{
open64_file_func zopen64_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell64_file_func ztell64_file;
seek64_file_func zseek64_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc64_def;
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
/* now internal definition, only for zip.c and unzip.h */
typedef struct zlib_filefunc64_32_def_s
{
zlib_filefunc64_def zfile_func64;
open_file_func zopen32_file;
tell_file_func ztell32_file;
seek_file_func zseek32_file;
} zlib_filefunc64_32_def;
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,239 +0,0 @@
/* ioapi.h -- IO base function header for compress/uncompress .zip
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
For more info read MiniZip_info.txt
*/
#if (defined(_WIN32))
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "ioapi.h"
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
{
if (pfilefunc->zfile_func64.zopen64_file != NULL)
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
else
{
return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
}
}
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
{
if (pfilefunc->zfile_func64.zseek64_file != NULL)
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
else
{
uLong offsetTruncated = (uLong)offset;
if (offsetTruncated != offset)
return -1;
else
return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
}
}
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
{
if (pfilefunc->zfile_func64.zseek64_file != NULL)
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
else
{
uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
if ((tell_uLong) == ((uLong)-1))
return (ZPOS64_T)-1;
else
return tell_uLong;
}
}
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
{
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
p_filefunc64_32->zfile_func64.zseek64_file = NULL;
p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
#ifndef __clang_analyzer__
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
#endif
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
}
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
{
FILE* file = NULL;
const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
mode_fopen = "r+b";
else
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL))
file = fopen(filename, mode_fopen);
return file;
}
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
{
FILE* file = NULL;
const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
mode_fopen = "r+b";
else
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL))
file = fopen64((const char*)filename, mode_fopen);
return file;
}
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
{
uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
{
uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
{
long ret;
ret = ftell((FILE *)stream);
return ret;
}
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{
ZPOS64_T ret;
ret = ftello64((FILE *)stream);
return ret;
}
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
{
int fseek_origin=0;
long ret;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
fseek_origin = SEEK_CUR;
break;
case ZLIB_FILEFUNC_SEEK_END :
fseek_origin = SEEK_END;
break;
case ZLIB_FILEFUNC_SEEK_SET :
fseek_origin = SEEK_SET;
break;
default: return -1;
}
ret = 0;
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
ret = -1;
return ret;
}
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
{
int fseek_origin=0;
long ret;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
fseek_origin = SEEK_CUR;
break;
case ZLIB_FILEFUNC_SEEK_END :
fseek_origin = SEEK_END;
break;
case ZLIB_FILEFUNC_SEEK_SET :
fseek_origin = SEEK_SET;
break;
default: return -1;
}
ret = 0;
if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
ret = -1;
return ret;
}
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
{
int ret;
ret = fclose((FILE *)stream);
return ret;
}
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
{
int ret;
ret = ferror((FILE *)stream);
return ret;
}
void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
pzlib_filefunc_def->ztell_file = ftell_file_func;
pzlib_filefunc_def->zseek_file = fseek_file_func;
pzlib_filefunc_def->zclose_file = fclose_file_func;
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen64_file = fopen64_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
pzlib_filefunc_def->ztell64_file = ftell64_file_func;
pzlib_filefunc_def->zseek64_file = fseek64_file_func;
pzlib_filefunc_def->zclose_file = fclose_file_func;
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}

View File

@ -1,31 +0,0 @@
/*
Additional tools for Minizip
Code: Xavier Roche '2004
License: Same as ZLIB (www.gzip.org)
*/
#ifndef _zip_tools_H
#define _zip_tools_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#include "unzip.h"
/* Repair a ZIP file (missing central directory)
file: file to recover
fileOut: output file after recovery
fileOutTmp: temporary file name used for recovery
*/
extern int ZEXPORT unzRepair(const char* file,
const char* fileOut,
const char* fileOutTmp,
uLong* nRecovered,
uLong* bytesRecovered);
#endif

View File

@ -1,284 +0,0 @@
/*
Additional tools for Minizip
Code: Xavier Roche '2004
License: Same as ZLIB (www.gzip.org)
*/
/* Code */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "unzip.h"
#include "mztools.h"
#define READ_8(adr) ((unsigned char)*(adr))
#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )
#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) )
#define WRITE_8(buff, n) do { \
*((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \
} while(0)
#define WRITE_16(buff, n) do { \
WRITE_8((unsigned char*)(buff), n); \
WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \
} while(0)
#define WRITE_32(buff, n) do { \
WRITE_16((unsigned char*)(buff), (n) & 0xffff); \
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
} while(0)
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
const char* file;
const char* fileOut;
const char* fileOutTmp;
uLong* nRecovered;
uLong* bytesRecovered;
{
int err = Z_OK;
FILE* fpZip = fopen(file, "rb");
FILE* fpOut = fopen(fileOut, "wb");
FILE* fpOutCD = fopen(fileOutTmp, "wb");
if (fpZip != NULL && fpOut != NULL) {
int entries = 0;
uLong totalBytes = 0;
char header[30];
char filename[256];
char extra[1024];
int offset = 0;
int offsetCD = 0;
while ( fread(header, 1, 30, fpZip) == 30 ) {
int currentOffset = offset;
/* File entry */
if (READ_32(header) == 0x04034b50) {
unsigned int version = READ_16(header + 4);
unsigned int gpflag = READ_16(header + 6);
unsigned int method = READ_16(header + 8);
unsigned int filetime = READ_16(header + 10);
unsigned int filedate = READ_16(header + 12);
unsigned int crc = READ_32(header + 14); /* crc */
unsigned int cpsize = READ_32(header + 18); /* compressed size */
unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */
unsigned int fnsize = READ_16(header + 26); /* file name length */
unsigned int extsize = READ_16(header + 28); /* extra field length */
filename[0] = extra[0] = '\0';
/* Header */
if (fwrite(header, 1, 30, fpOut) == 30) {
offset += 30;
} else {
err = Z_ERRNO;
break;
}
/* Filename */
if (fnsize > 0) {
if (fread(filename, 1, fnsize, fpZip) == fnsize) {
if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {
offset += fnsize;
} else {
err = Z_ERRNO;
break;
}
} else {
err = Z_ERRNO;
break;
}
} else {
err = Z_STREAM_ERROR;
break;
}
/* Extra field */
if (extsize > 0) {
if (fread(extra, 1, extsize, fpZip) == extsize) {
if (fwrite(extra, 1, extsize, fpOut) == extsize) {
offset += extsize;
} else {
err = Z_ERRNO;
break;
}
} else {
err = Z_ERRNO;
break;
}
}
/* Data */
{
int dataSize = cpsize;
if (dataSize == 0) {
dataSize = uncpsize;
}
if (dataSize > 0) {
char* data = malloc(dataSize);
if (data != NULL) {
if ((int)fread(data, 1, dataSize, fpZip) == dataSize) {
if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) {
offset += dataSize;
totalBytes += dataSize;
} else {
err = Z_ERRNO;
}
} else {
err = Z_ERRNO;
}
free(data);
if (err != Z_OK) {
break;
}
} else {
err = Z_MEM_ERROR;
break;
}
}
}
/* Central directory entry */
{
char centralDirectoryEntryHeader[46];
//char* comment = "";
//int comsize = (int) strlen(comment);
WRITE_32(centralDirectoryEntryHeader, 0x02014b50);
WRITE_16(centralDirectoryEntryHeader + 4, version);
WRITE_16(centralDirectoryEntryHeader + 6, version);
WRITE_16(centralDirectoryEntryHeader + 8, gpflag);
WRITE_16(centralDirectoryEntryHeader + 10, method);
WRITE_16(centralDirectoryEntryHeader + 12, filetime);
WRITE_16(centralDirectoryEntryHeader + 14, filedate);
WRITE_32(centralDirectoryEntryHeader + 16, crc);
WRITE_32(centralDirectoryEntryHeader + 20, cpsize);
WRITE_32(centralDirectoryEntryHeader + 24, uncpsize);
WRITE_16(centralDirectoryEntryHeader + 28, fnsize);
WRITE_16(centralDirectoryEntryHeader + 30, extsize);
WRITE_16(centralDirectoryEntryHeader + 32, 0 /*comsize*/);
WRITE_16(centralDirectoryEntryHeader + 34, 0); /* disk # */
WRITE_16(centralDirectoryEntryHeader + 36, 0); /* int attrb */
WRITE_32(centralDirectoryEntryHeader + 38, 0); /* ext attrb */
WRITE_32(centralDirectoryEntryHeader + 42, currentOffset);
/* Header */
if (fwrite(centralDirectoryEntryHeader, 1, 46, fpOutCD) == 46) {
offsetCD += 46;
/* Filename */
if (fnsize > 0) {
if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
offsetCD += fnsize;
} else {
err = Z_ERRNO;
break;
}
} else {
err = Z_STREAM_ERROR;
break;
}
/* Extra field */
if (extsize > 0) {
if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {
offsetCD += extsize;
} else {
err = Z_ERRNO;
break;
}
}
/* Comment field */
/*
if (comsize > 0) {
if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
offsetCD += comsize;
} else {
err = Z_ERRNO;
break;
}
}
*/
} else {
err = Z_ERRNO;
break;
}
}
/* Success */
entries++;
} else {
break;
}
}
/* Final central directory */
{
int entriesZip = entries;
char finalCentralDirectoryHeader[22];
//char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
//int comsize = (int) strlen(comment);
if (entriesZip > 0xffff) {
entriesZip = 0xffff;
}
WRITE_32(finalCentralDirectoryHeader, 0x06054b50);
WRITE_16(finalCentralDirectoryHeader + 4, 0); /* disk # */
WRITE_16(finalCentralDirectoryHeader + 6, 0); /* disk # */
WRITE_16(finalCentralDirectoryHeader + 8, entriesZip); /* hack */
WRITE_16(finalCentralDirectoryHeader + 10, entriesZip); /* hack */
WRITE_32(finalCentralDirectoryHeader + 12, offsetCD); /* size of CD */
WRITE_32(finalCentralDirectoryHeader + 16, offset); /* offset to CD */
WRITE_16(finalCentralDirectoryHeader + 20, 0 /*comsize*/); /* comment */
/* Header */
if (fwrite(finalCentralDirectoryHeader, 1, 22, fpOutCD) == 22) {
/* Comment field */
/*
if (comsize > 0) {
if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
err = Z_ERRNO;
}
}
*/
} else {
err = Z_ERRNO;
}
}
/* Final merge (file + central directory) */
fclose(fpOutCD);
if (err == Z_OK) {
fpOutCD = fopen(fileOutTmp, "rb");
if (fpOutCD != NULL) {
int nRead;
char buffer[8192];
while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) {
if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) {
err = Z_ERRNO;
break;
}
}
fclose(fpOutCD);
}
}
/* Close */
fclose(fpZip);
fclose(fpOut);
/* Wipe temporary file */
(void)remove(fileOutTmp);
/* Number of recovered entries */
if (err == Z_OK) {
if (nRecovered != NULL) {
*nRecovered = entries;
}
if (bytesRecovered != NULL) {
*bytesRecovered = totalBytes;
}
}
} else {
err = Z_STREAM_ERROR;
}
return err;
}

View File

@ -1,437 +0,0 @@
/* unzip.h -- IO for uncompress .zip files using zlib
Version 1.1, February 14h, 2010
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
Modifications of Unzip for Zip64
Copyright (C) 2007-2008 Even Rouault
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
For more info read MiniZip_info.txt
---------------------------------------------------------------------------------
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
---------------------------------------------------------------------------------
Changes
See header of unzip64.c
*/
#ifndef _unz64_H
#define _unz64_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
#include "ioapi.h"
#endif
#ifdef HAVE_BZIP2
#include "bzlib.h"
#endif
#define Z_BZIP2ED 12
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
#endif
#define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)
#define UNZ_EOF (0)
#define UNZ_PARAMERROR (-102)
#define UNZ_BADZIPFILE (-103)
#define UNZ_INTERNALERROR (-104)
#define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */
typedef struct tm_unz_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_unz;
/* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */
typedef struct unz_global_info64_s
{
ZPOS64_T number_entry; /* total number of entries in
the central dir on this disk */
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info64;
typedef struct unz_global_info_s
{
uLong number_entry; /* total number of entries in
the central dir on this disk */
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info;
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info64_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
ZPOS64_T compressed_size; /* compressed size 8 bytes */
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
} unz_file_info64;
typedef struct unz_file_info_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
} unz_file_info;
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
const char* fileName2,
int iCaseSensitivity));
/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
or strcasecmp)
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
(like 1 on Unix, 2 on Windows)
*/
extern unzFile ZEXPORT unzOpen OF((const char *path));
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
"zlib/zlib113.zip".
If the zipfile cannot be opened (file don't exist or in not valid), the
return value is NULL.
Else, the return value is a unzFile Handle, usable with other function
of this unzip package.
the "64" function take a const void* pointer, because the path is just the
value passed to the open64_file_func callback.
Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
does not describe the reality
*/
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
zlib_filefunc_def* pzlib_filefunc_def));
/*
Open a Zip file, like unzOpen, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
zlib_filefunc64_def* pzlib_filefunc_def));
/*
Open a Zip file, like unz64Open, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
extern int ZEXPORT unzClose OF((unzFile file));
/*
Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
unz_global_info *pglobal_info));
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
unz_global_info64 *pglobal_info));
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
char *szComment,
uLong uSizeBuf));
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0
*/
/***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/*
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/*
Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzLocateFile OF((unzFile file,
const char *szFileName,
int iCaseSensitivity));
/*
Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare
return value :
UNZ_OK if the file is found. It becomes the current file.
UNZ_END_OF_LIST_OF_FILE if the file is not found
*/
/* ****************************************** */
/* Ryan supplied functions */
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_pos_s
{
uLong pos_in_zip_directory; /* offset in zip file directory */
uLong num_of_file; /* # of file */
} unz_file_pos;
extern int ZEXPORT unzGetFilePos(
unzFile file,
unz_file_pos* file_pos);
extern int ZEXPORT unzGoToFilePos(
unzFile file,
unz_file_pos* file_pos);
typedef struct unz64_file_pos_s
{
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
ZPOS64_T num_of_file; /* # of file */
} unz64_file_pos;
extern int ZEXPORT unzGetFilePos64(
unzFile file,
unz64_file_pos* file_pos);
extern int ZEXPORT unzGoToFilePos64(
unzFile file,
const unz64_file_pos* file_pos);
/* ****************************************** */
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
unz_file_info *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
/*
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
the current file
if szFileName!=NULL, the filemane string will be copied in szFileName
(fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
(extraFieldBufferSize is the size of the buffer).
This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer)
*/
/** Addition for GDAL : START */
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
/** Addition for GDAL : END */
/***************************************************************************/
/* for reading the content of the current zipfile, you can open it, read data
from it, and close it (you can close it before reading all the file)
*/
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/*
Open for reading data the current file in the zipfile.
If there is no error, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
const char* password));
/*
Open for reading data the current file in the zipfile.
password is a crypting password
If there is no error, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
int* method,
int* level,
int raw));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
*method will receive method of compression, *level will receive level of
compression
note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL
*/
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
int* method,
int* level,
int raw,
const char* password));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
*method will receive method of compression, *level will receive level of
compression
note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL
*/
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
voidp buf,
unsigned len));
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern z_off_t ZEXPORT unztell OF((unzFile file));
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
/*
Give the current position in uncompressed data
*/
extern int ZEXPORT unzeof OF((unzFile file));
/*
return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf,
unsigned len));
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header)
if buf==NULL, it return the size of the local extra field
if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf.
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
/***************************************************************************/
/* Get the current file offset */
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
extern uLong ZEXPORT unzGetOffset (unzFile file);
/* Set the current file offset */
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
#ifdef __cplusplus
}
#endif
#endif /* _unz64_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,362 +0,0 @@
/* zip.h -- IO on .zip files using zlib
Version 1.1, February 14h, 2010
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
For more info read MiniZip_info.txt
---------------------------------------------------------------------------
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
---------------------------------------------------------------------------
Changes
See header of zip.h
*/
#ifndef _zip12_H
#define _zip12_H
#ifdef __cplusplus
extern "C" {
#endif
//#define HAVE_BZIP2
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
#include "ioapi.h"
#endif
#ifdef HAVE_BZIP2
#include "bzlib.h"
#endif
#define Z_BZIP2ED 12
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
#endif
#define ZIP_OK (0)
#define ZIP_EOF (0)
#define ZIP_ERRNO (Z_ERRNO)
#define ZIP_PARAMERROR (-102)
#define ZIP_BADZIPFILE (-103)
#define ZIP_INTERNALERROR (-104)
#ifndef DEF_MEM_LEVEL
# if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
# else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
# endif
#endif
/* default memLevel */
/* tm_zip contain date/time info */
typedef struct tm_zip_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_zip;
typedef struct
{
tm_zip tmz_date; /* date in understandable format */
uLong dosDate; /* if dos_date == 0, tmu_date is used */
/* uLong flag; */ /* general purpose bit flag 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
} zip_fileinfo;
typedef const char* zipcharpc;
#define APPEND_STATUS_CREATE (0)
#define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2)
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
/*
Create a zipfile.
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
an Unix computer "zlib/zlib113.zip".
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
will be created at the end of the file.
(useful if the file contain a self extractor code)
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
add files in existing zip (be sure you don't add file that doesn't exist)
If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
of this zip package.
*/
/* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another
Of couse, you can use RAW reading and writing to copy the file you did not want delte
*/
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def));
extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc64_def* pzlib_filefunc_def));
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level));
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int zip64));
/*
Open a file in the ZIP for writing.
filename : the filename in zip (if NULL, '-' without quote will be used
*zipfi contain supplemental information
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
contains the extrafield data the the local header
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
contains the extrafield data the the local header
if comment != NULL, comment contain the comment string
method contain the compression method (0 for store, Z_DEFLATED for deflate)
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
this MUST be '1' if the uncompressed size is >= 0xffffffff.
*/
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw));
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int zip64));
/*
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
*/
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting));
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
int zip64
));
/*
Same than zipOpenNewFileInZip2, except
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
password : crypting password (NULL for no crypting)
crcForCrypting : crc of file to compress (needed for crypting)
*/
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase
));
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
uInt size_extrafield_local,
const void* extrafield_global,
uInt size_extrafield_global,
const char* comment,
int method,
int level,
int raw,
int windowBits,
int memLevel,
int strategy,
const char* password,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase,
int zip64
));
/*
Same than zipOpenNewFileInZip4, except
versionMadeBy : value for Version made by field
flag : value for flag field (compression level info will be added)
*/
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
const void* buf,
unsigned len));
/*
Write data in the zipfile
*/
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
/*
Close the current file in the zipfile
*/
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
uLong uncompressed_size,
uLong crc32));
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
ZPOS64_T uncompressed_size,
uLong crc32));
/*
Close the current file in the zipfile, for file opened with
parameter raw=1 in zipOpenNewFileInZip2
uncompressed_size and crc32 are value for the uncompressed size
*/
extern int ZEXPORT zipClose OF((zipFile file,
const char* global_comment));
/*
Close the zipfile
*/
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
/*
zipRemoveExtraInfoBlock - Added by Mathias Svensson
Remove extra information block from a extra information data for the local file header or central directory header
It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.
0x0001 is the signature header for the ZIP64 extra information blocks
usage.
Remove ZIP64 Extra information from a central director extra field data
zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);
Remove ZIP64 Extra information from a Local File Header extra field data
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
*/
#ifdef __cplusplus
}
#endif
#endif /* _zip64_H */

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 69dcac3e4d140325a4b37f23f423c573e4193cb8 Subproject commit 21e4163c6f6f5c9929c1dd5872d091f732f07836

View File

@ -148,7 +148,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
func helper(_ helper: FSEventStreamHelper, didReceive events: [FSEventStreamHelper.Event]) { func helper(_ helper: FSEventStreamHelper, didReceive events: [FSEventStreamHelper.Event]) {
// 100ms 使使 // 100ms 使使
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
if Preferences.shouldAutoReloadUserDataFiles { if mgrPrefs.shouldAutoReloadUserDataFiles {
mgrLangModel.loadUserPhrases() mgrLangModel.loadUserPhrases()
mgrLangModel.loadUserPhraseReplacement() mgrLangModel.loadUserPhraseReplacement()
mgrLangModel.loadUserAssociatedPhrases() mgrLangModel.loadUserAssociatedPhrases()
@ -184,7 +184,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
fsStreamHelper.delegate = self fsStreamHelper.delegate = self
_ = fsStreamHelper.start() _ = fsStreamHelper.start()
Preferences.setMissingDefaults() mgrPrefs.setMissingDefaults()
// 使 // 使
if (UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) != nil) == true { if (UserDefaults.standard.object(forKey: kCheckUpdateAutomatically) != nil) == true {
@ -200,6 +200,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
ctlPrefWindowInstance?.window?.orderFrontRegardless() // ctlPrefWindowInstance?.window?.orderFrontRegardless() //
ctlPrefWindowInstance?.window?.level = .statusBar ctlPrefWindowInstance?.window?.level = .statusBar
ctlPrefWindowInstance?.window?.titlebarAppearsTransparent = true ctlPrefWindowInstance?.window?.titlebarAppearsTransparent = true
NSApp.setActivationPolicy(.accessory)
} }
// New About Window // New About Window
@ -210,6 +211,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
ctlAboutWindowInstance?.window?.center() ctlAboutWindowInstance?.window?.center()
ctlAboutWindowInstance?.window?.orderFrontRegardless() // ctlAboutWindowInstance?.window?.orderFrontRegardless() //
ctlAboutWindowInstance?.window?.level = .statusBar ctlAboutWindowInstance?.window?.level = .statusBar
NSApp.setActivationPolicy(.accessory)
} }
@objc(checkForUpdate) @objc(checkForUpdate)
@ -257,6 +259,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
report.versionDescription) report.versionDescription)
IME.prtDebugIntel("vChewingDebug: \(content)") IME.prtDebugIntel("vChewingDebug: \(content)")
ctlNonModalAlertWindow.shared.show(title: NSLocalizedString("New Version Available", comment: ""), content: content, confirmButtonTitle: NSLocalizedString("Visit Website", comment: ""), cancelButtonTitle: NSLocalizedString("Not Now", comment: ""), cancelAsDefault: false, delegate: self) ctlNonModalAlertWindow.shared.show(title: NSLocalizedString("New Version Available", comment: ""), content: content, confirmButtonTitle: NSLocalizedString("Visit Website", comment: ""), cancelButtonTitle: NSLocalizedString("Not Now", comment: ""), cancelAsDefault: false, delegate: self)
NSApp.setActivationPolicy(.accessory)
case .noNeedToUpdate, .ignored: case .noNeedToUpdate, .ignored:
break break
} }
@ -268,6 +271,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
let buttonTitle = NSLocalizedString("Dismiss", comment: "") let buttonTitle = NSLocalizedString("Dismiss", comment: "")
IME.prtDebugIntel("vChewingDebug: \(content)") IME.prtDebugIntel("vChewingDebug: \(content)")
ctlNonModalAlertWindow.shared.show(title: title, content: content, confirmButtonTitle: buttonTitle, cancelButtonTitle: nil, cancelAsDefault: false, delegate: nil) ctlNonModalAlertWindow.shared.show(title: title, content: content, confirmButtonTitle: buttonTitle, cancelButtonTitle: nil, cancelAsDefault: false, delegate: nil)
NSApp.setActivationPolicy(.accessory)
default: default:
break break
} }
@ -296,7 +300,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
@objc public class IME: NSObject { @objc public class IME: NSObject {
// Print debug information to the console. // Print debug information to the console.
@objc static func prtDebugIntel(_ strPrint: String) { @objc static func prtDebugIntel(_ strPrint: String) {
if Preferences.isDebugModeEnabled { if mgrPrefs.isDebugModeEnabled {
NSLog("vChewingErrorCallback: %@", strPrint) NSLog("vChewingErrorCallback: %@", strPrint)
} }
} }

View File

@ -20,7 +20,7 @@ import Cocoa
@objc class AppleKeyboardConverter: NSObject { @objc class AppleKeyboardConverter: NSObject {
@objc class func isDynamicBaseKeyboardLayoutEnabled() -> Bool { @objc class func isDynamicBaseKeyboardLayoutEnabled() -> Bool {
switch Preferences.basisKeyboardLayout { switch mgrPrefs.basisKeyboardLayout {
case "com.apple.keylayout.ZhuyinBopomofo": case "com.apple.keylayout.ZhuyinBopomofo":
return true return true
case "com.apple.keylayout.ZhuyinEten": case "com.apple.keylayout.ZhuyinEten":
@ -45,7 +45,7 @@ import Cocoa
// OVMandarin OVMandarin // OVMandarin OVMandarin
if self.isDynamicBaseKeyboardLayoutEnabled() { if self.isDynamicBaseKeyboardLayoutEnabled() {
// Apple // Apple
switch Preferences.basisKeyboardLayout { switch mgrPrefs.basisKeyboardLayout {
case "com.apple.keylayout.ZhuyinBopomofo": do { case "com.apple.keylayout.ZhuyinBopomofo": do {
if (charCode == 97) {charCode = UniChar(65)} if (charCode == 97) {charCode = UniChar(65)}
if (charCode == 98) {charCode = UniChar(66)} if (charCode == 98) {charCode = UniChar(66)}
@ -166,7 +166,7 @@ import Cocoa
if (charCode == 65288) {charCode = UniChar(40)} if (charCode == 65288) {charCode = UniChar(40)}
if (charCode == 65289) {charCode = UniChar(41)} if (charCode == 65289) {charCode = UniChar(41)}
// Apple // Apple
if Preferences.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" { if mgrPrefs.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" {
if (charCode == 65343) {charCode = UniChar(95)} if (charCode == 65343) {charCode = UniChar(95)}
if (charCode == 65306) {charCode = UniChar(58)} if (charCode == 65306) {charCode = UniChar(58)}
if (charCode == 65311) {charCode = UniChar(63)} if (charCode == 65311) {charCode = UniChar(63)}
@ -181,7 +181,7 @@ import Cocoa
var strProcessed = strProcessed var strProcessed = strProcessed
if self.isDynamicBaseKeyboardLayoutEnabled() { if self.isDynamicBaseKeyboardLayoutEnabled() {
// Apple // Apple
switch Preferences.basisKeyboardLayout { switch mgrPrefs.basisKeyboardLayout {
case "com.apple.keylayout.ZhuyinBopomofo": do { case "com.apple.keylayout.ZhuyinBopomofo": do {
if (strProcessed == "a") {strProcessed = "A"} if (strProcessed == "a") {strProcessed = "A"}
if (strProcessed == "b") {strProcessed = "B"} if (strProcessed == "b") {strProcessed = "B"}
@ -302,7 +302,7 @@ import Cocoa
if (strProcessed == "") {strProcessed = "("} if (strProcessed == "") {strProcessed = "("}
if (strProcessed == "") {strProcessed = ")"} if (strProcessed == "") {strProcessed = ")"}
// Apple // Apple
if Preferences.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" { if mgrPrefs.basisKeyboardLayout == "com.apple.keylayout.ZhuyinEten" {
if (strProcessed == "_") {strProcessed = "_"} if (strProcessed == "_") {strProcessed = "_"}
if (strProcessed == "") {strProcessed = ":"} if (strProcessed == "") {strProcessed = ":"}
if (strProcessed == "") {strProcessed = "?"} if (strProcessed == "") {strProcessed = "?"}

View File

@ -150,7 +150,7 @@ class InputState: NSObject {
// MARK: - // MARK: -
private let kMinMarkRangeLength = 2 private let kMinMarkRangeLength = 2
private let kMaxMarkRangeLength = Preferences.maxCandidateLength private let kMaxMarkRangeLength = mgrPrefs.maxCandidateLength
/// Represents that the user is marking a range in the composing buffer. /// Represents that the user is marking a range in the composing buffer.
@objc (InputStateMarking) @objc (InputStateMarking)
@ -166,7 +166,7 @@ class InputState: NSObject {
return NSLocalizedString("⚠︎ Unhandlable char selected for user phrases.", comment: "") return NSLocalizedString("⚠︎ Unhandlable char selected for user phrases.", comment: "")
} }
if Preferences.phraseReplacementEnabled { if mgrPrefs.phraseReplacementEnabled {
TooltipController.backgroundColor = NSColor.purple TooltipController.backgroundColor = NSColor.purple
TooltipController.textColor = NSColor.white TooltipController.textColor = NSColor.white
return NSLocalizedString("⚠︎ Phrase replacement mode enabled, interfering user phrase entry.", comment: "") return NSLocalizedString("⚠︎ Phrase replacement mode enabled, interfering user phrase entry.", comment: "")

View File

@ -115,10 +115,10 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
ctlInputMethod.currentInputMode = newInputMode; ctlInputMethod.currentInputMode = newInputMode;
// Synchronize the Preference Setting "setPhraseReplacementEnabled" to the new LM. // Synchronize the Preference Setting "setPhraseReplacementEnabled" to the new LM.
newLanguageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled); newLanguageModel->setPhraseReplacementEnabled(mgrPrefs.phraseReplacementEnabled);
// Also other sub language models: // Also other sub language models:
newLanguageModel->setSymbolEnabled(Preferences.symbolInputEnabled); newLanguageModel->setSymbolEnabled(mgrPrefs.symbolInputEnabled);
newLanguageModel->setCNSEnabled(Preferences.cns11643Enabled); newLanguageModel->setCNSEnabled(mgrPrefs.cns11643Enabled);
// Only apply the changes if the value is changed // Only apply the changes if the value is changed
if (![_inputMode isEqualToString:newInputMode]) { if (![_inputMode isEqualToString:newInputMode]) {
@ -158,9 +158,9 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// create the lattice builder // create the lattice builder
_languageModel = [mgrLangModel lmCHT]; _languageModel = [mgrLangModel lmCHT];
_languageModel->setPhraseReplacementEnabled(Preferences.phraseReplacementEnabled); _languageModel->setPhraseReplacementEnabled(mgrPrefs.phraseReplacementEnabled);
_languageModel->setCNSEnabled(Preferences.cns11643Enabled); _languageModel->setCNSEnabled(mgrPrefs.cns11643Enabled);
_languageModel->setSymbolEnabled(Preferences.symbolInputEnabled); _languageModel->setSymbolEnabled(mgrPrefs.symbolInputEnabled);
_userOverrideModel = [mgrLangModel userOverrideModelCHT]; _userOverrideModel = [mgrLangModel userOverrideModelCHT];
_builder = new Gramambular::BlockReadingBuilder(_languageModel); _builder = new Gramambular::BlockReadingBuilder(_languageModel);
@ -174,7 +174,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
- (void)syncWithPreferences - (void)syncWithPreferences
{ {
NSInteger layout = Preferences.keyboardLayout; NSInteger layout = mgrPrefs.keyboardLayout;
switch (layout) { switch (layout) {
case KeyboardLayoutStandard: case KeyboardLayoutStandard:
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout()); _bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout());
@ -202,7 +202,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
break; break;
default: default:
_bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout()); _bpmfReadingBuffer->setKeyboardLayout(Mandarin::BopomofoKeyboardLayout::StandardLayout());
Preferences.keyboardLayout = KeyboardLayoutStandard; mgrPrefs.keyboardLayout = KeyboardLayoutStandard;
} }
} }
@ -211,7 +211,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
size_t cursorIndex = [self _actualCandidateCursorIndex]; size_t cursorIndex = [self _actualCandidateCursorIndex];
std::string stringValue(value.UTF8String); std::string stringValue(value.UTF8String);
Gramambular::NodeAnchor selectedNode = _builder->grid().fixNodeSelectedCandidate(cursorIndex, stringValue); Gramambular::NodeAnchor selectedNode = _builder->grid().fixNodeSelectedCandidate(cursorIndex, stringValue);
if (!Preferences.useSCPCTypingMode) { // 不要針對逐字選字模式啟用臨時半衰記憶模型。 if (!mgrPrefs.useSCPCTypingMode) { // 不要針對逐字選字模式啟用臨時半衰記憶模型。
// If the length of the readings and the characters do not match, // If the length of the readings and the characters do not match,
// it often means it is a special symbol and it should not be stored // it often means it is a special symbol and it should not be stored
// in the user override model. // in the user override model.
@ -231,8 +231,8 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
} }
[self _walk]; [self _walk];
if (Preferences.selectPhraseAfterCursorAsCandidate && if (mgrPrefs.selectPhraseAfterCursorAsCandidate &&
Preferences.moveCursorAfterSelectingCandidate) { mgrPrefs.moveCursorAfterSelectingCandidate) {
size_t nextPosition = 0; size_t nextPosition = 0;
for (auto node: _walkedNodes) { for (auto node: _walkedNodes) {
if (nextPosition >= cursorIndex) { if (nextPosition >= cursorIndex) {
@ -255,7 +255,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
- (std::string)_currentLayout - (std::string)_currentLayout
{ {
NSString *keyboardLayoutName = Preferences.keyboardLayoutName; NSString *keyboardLayoutName = mgrPrefs.keyboardLayoutName;
std::string layout = std::string(keyboardLayoutName.UTF8String) + std::string("_"); std::string layout = std::string(keyboardLayoutName.UTF8String) + std::string("_");
return layout; return layout;
} }
@ -387,7 +387,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
NSString *poppedText = [self _popOverflowComposingTextAndWalk]; NSString *poppedText = [self _popOverflowComposingTextAndWalk];
// get user override model suggestion // get user override model suggestion
std::string overrideValue = (Preferences.useSCPCTypingMode) ? "" : std::string overrideValue = (mgrPrefs.useSCPCTypingMode) ? "" :
_userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]); _userOverrideModel->suggest(_walkedNodes, _builder->cursorIndex(), [[NSDate date] timeIntervalSince1970]);
if (!overrideValue.empty()) { if (!overrideValue.empty()) {
@ -404,7 +404,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
inputting.poppedText = poppedText; inputting.poppedText = poppedText;
stateCallback(inputting); stateCallback(inputting);
if (Preferences.useSCPCTypingMode) { if (mgrPrefs.useSCPCTypingMode) {
InputStateChoosingCandidate *choosingCandidates = [self _buildCandidateState:inputting useVerticalMode:input.useVerticalMode]; InputStateChoosingCandidate *choosingCandidates = [self _buildCandidateState:inputting useVerticalMode:input.useVerticalMode];
if (choosingCandidates.candidates.count == 1) { if (choosingCandidates.candidates.count == 1) {
[self clear]; [self clear];
@ -412,7 +412,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:text]; InputStateCommitting *committing = [[InputStateCommitting alloc] initWithPoppedText:text];
stateCallback(committing); stateCallback(committing);
if (!Preferences.associatedPhrasesEnabled) { if (!mgrPrefs.associatedPhrasesEnabled) {
InputStateEmpty *empty = [[InputStateEmpty alloc] init]; InputStateEmpty *empty = [[InputStateEmpty alloc] init];
stateCallback(empty); stateCallback(empty);
} else { } else {
@ -441,7 +441,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
|| (input.useVerticalMode && ([input isVerticalModeOnlyChooseCandidateKey])))) { || (input.useVerticalMode && ([input isVerticalModeOnlyChooseCandidateKey])))) {
if ([input isSpace]) { if ([input isSpace]) {
// if the spacebar is NOT set to be a selection key // if the spacebar is NOT set to be a selection key
if ([input isShiftHold] || !Preferences.chooseCandidateUsingSpace) { if ([input isShiftHold] || !mgrPrefs.chooseCandidateUsingSpace) {
if (_builder->cursorIndex() >= _builder->length()) { if (_builder->cursorIndex() >= _builder->length()) {
NSString *composingBuffer = [(InputStateNotEmpty*) state composingBuffer]; NSString *composingBuffer = [(InputStateNotEmpty*) state composingBuffer];
if (composingBuffer.length) { if (composingBuffer.length) {
@ -566,7 +566,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
std::string punctuationNamePrefix; std::string punctuationNamePrefix;
if ([input isControlHold]) { if ([input isControlHold]) {
punctuationNamePrefix = std::string("_ctrl_punctuation_"); punctuationNamePrefix = std::string("_ctrl_punctuation_");
} else if (Preferences.halfWidthPunctuationEnabled) { } else if (mgrPrefs.halfWidthPunctuationEnabled) {
punctuationNamePrefix = std::string("_half_punctuation_"); punctuationNamePrefix = std::string("_half_punctuation_");
} else { } else {
punctuationNamePrefix = std::string("_punctuation_"); punctuationNamePrefix = std::string("_punctuation_");
@ -611,7 +611,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
return NO; return NO;
} }
BOOL escToClearInputBufferEnabled = Preferences.escToCleanInputBuffer; BOOL escToClearInputBufferEnabled = mgrPrefs.escToCleanInputBuffer;
if (escToClearInputBufferEnabled) { if (escToClearInputBufferEnabled) {
// if the option is enabled, we clear everything including the composing // if the option is enabled, we clear everything including the composing
@ -904,7 +904,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
inputting.poppedText = poppedText; inputting.poppedText = poppedText;
stateCallback(inputting); stateCallback(inputting);
if (Preferences.useSCPCTypingMode && _bpmfReadingBuffer->isEmpty()) { if (mgrPrefs.useSCPCTypingMode && _bpmfReadingBuffer->isEmpty()) {
InputStateChoosingCandidate *candidateState = [self _buildCandidateState:inputting useVerticalMode:useVerticalMode]; InputStateChoosingCandidate *candidateState = [self _buildCandidateState:inputting useVerticalMode:useVerticalMode];
if ([candidateState.candidates count] == 1) { if ([candidateState.candidates count] == 1) {
@ -1010,7 +1010,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
stateCallback(empty); stateCallback(empty);
} }
else if (Preferences.useSCPCTypingMode) { else if (mgrPrefs.useSCPCTypingMode) {
[self clear]; [self clear];
InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init]; InputStateEmptyIgnoringPreviousState *empty = [[InputStateEmptyIgnoringPreviousState alloc] init];
stateCallback(empty); stateCallback(empty);
@ -1040,7 +1040,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isTab]) { if ([input isTab]) {
BOOL updated = BOOL updated =
Preferences.specifyTabKeyBehavior? mgrPrefs.specifyTabKeyBehavior?
([input isShiftHold] ? [gCurrentCandidateController showPreviousPage] : [gCurrentCandidateController showNextPage]) ([input isShiftHold] ? [gCurrentCandidateController showPreviousPage] : [gCurrentCandidateController showNextPage])
: :
([input isShiftHold] ? [gCurrentCandidateController highlightPreviousCandidate] : [gCurrentCandidateController highlightNextCandidate]) ([input isShiftHold] ? [gCurrentCandidateController highlightPreviousCandidate] : [gCurrentCandidateController highlightNextCandidate])
@ -1054,7 +1054,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
if ([input isSpace]) { if ([input isSpace]) {
BOOL updated = BOOL updated =
Preferences.specifySpaceKeyBehavior? mgrPrefs.specifySpaceKeyBehavior?
([input isShiftHold] ? [gCurrentCandidateController highlightNextCandidate] : [gCurrentCandidateController showNextPage]) ([input isShiftHold] ? [gCurrentCandidateController highlightNextCandidate] : [gCurrentCandidateController showNextPage])
: :
([input isShiftHold] ? [gCurrentCandidateController showNextPage] : [gCurrentCandidateController highlightNextCandidate]) ([input isShiftHold] ? [gCurrentCandidateController showNextPage] : [gCurrentCandidateController highlightNextCandidate])
@ -1237,12 +1237,12 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
return NO; return NO;
} }
if (Preferences.useSCPCTypingMode) { if (mgrPrefs.useSCPCTypingMode) {
std::string layout = [self _currentLayout]; std::string layout = [self _currentLayout];
std::string punctuationNamePrefix; std::string punctuationNamePrefix;
if ([input isControlHold]) { if ([input isControlHold]) {
punctuationNamePrefix = std::string("_ctrl_punctuation_"); punctuationNamePrefix = std::string("_ctrl_punctuation_");
} else if (Preferences.halfWidthPunctuationEnabled) { } else if (mgrPrefs.halfWidthPunctuationEnabled) {
punctuationNamePrefix = std::string("_half_punctuation_"); punctuationNamePrefix = std::string("_half_punctuation_");
} else { } else {
punctuationNamePrefix = std::string("_punctuation_"); punctuationNamePrefix = std::string("_punctuation_");
@ -1392,7 +1392,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
// be popped out // be popped out
NSString *poppedText = @""; NSString *poppedText = @"";
NSInteger composingBufferSize = Preferences.composingBufferSize; NSInteger composingBufferSize = mgrPrefs.composingBufferSize;
if (_builder->grid().width() > (size_t) composingBufferSize) { if (_builder->grid().width() > (size_t) composingBufferSize) {
if (_walkedNodes.size() > 0) { if (_walkedNodes.size() > 0) {
@ -1432,7 +1432,7 @@ static NSString *const kGraphVizOutputfile = @"/tmp/vChewing-visualization.dot";
{ {
size_t cursorIndex = _builder->cursorIndex(); size_t cursorIndex = _builder->cursorIndex();
// MS Phonetics IME style, phrase is *after* the cursor, i.e. cursor is always *before* the phrase // MS Phonetics IME style, phrase is *after* the cursor, i.e. cursor is always *before* the phrase
if ((Preferences.selectPhraseAfterCursorAsCandidate && (cursorIndex < _builder->length())) if ((mgrPrefs.selectPhraseAfterCursorAsCandidate && (cursorIndex < _builder->length()))
|| !cursorIndex) { || !cursorIndex) {
++cursorIndex; ++cursorIndex;
} }

View File

@ -73,36 +73,36 @@ class ctlInputMethod: IMKInputController {
let useSCPCTypingModeItem = menu.addItem(withTitle: NSLocalizedString("Per-Char Select Mode", comment: ""), action: #selector(toggleSCPCTypingMode(_:)), keyEquivalent: "P") let useSCPCTypingModeItem = menu.addItem(withTitle: NSLocalizedString("Per-Char Select Mode", comment: ""), action: #selector(toggleSCPCTypingMode(_:)), keyEquivalent: "P")
useSCPCTypingModeItem.keyEquivalentModifierMask = [.command, .control] useSCPCTypingModeItem.keyEquivalentModifierMask = [.command, .control]
useSCPCTypingModeItem.state = Preferences.useSCPCTypingMode.state useSCPCTypingModeItem.state = mgrPrefs.useSCPCTypingMode.state
let useCNS11643SupportItem = menu.addItem(withTitle: NSLocalizedString("CNS11643 Mode", comment: ""), action: #selector(toggleCNS11643Enabled(_:)), keyEquivalent: "L") let useCNS11643SupportItem = menu.addItem(withTitle: NSLocalizedString("CNS11643 Mode", comment: ""), action: #selector(toggleCNS11643Enabled(_:)), keyEquivalent: "L")
useCNS11643SupportItem.keyEquivalentModifierMask = [.command, .control] useCNS11643SupportItem.keyEquivalentModifierMask = [.command, .control]
useCNS11643SupportItem.state = Preferences.cns11643Enabled.state useCNS11643SupportItem.state = mgrPrefs.cns11643Enabled.state
if keyHandler.inputMode == InputMode.imeModeCHT { if keyHandler.inputMode == InputMode.imeModeCHT {
let chineseConversionItem = menu.addItem(withTitle: NSLocalizedString("Force KangXi Writing", comment: ""), action: #selector(toggleChineseConverter(_:)), keyEquivalent: "K") let chineseConversionItem = menu.addItem(withTitle: NSLocalizedString("Force KangXi Writing", comment: ""), action: #selector(toggleChineseConverter(_:)), keyEquivalent: "K")
chineseConversionItem.keyEquivalentModifierMask = [.command, .control] chineseConversionItem.keyEquivalentModifierMask = [.command, .control]
chineseConversionItem.state = Preferences.chineseConversionEnabled.state chineseConversionItem.state = mgrPrefs.chineseConversionEnabled.state
let shiftJISConversionItem = menu.addItem(withTitle: NSLocalizedString("JIS Shinjitai Output", comment: ""), action: #selector(toggleShiftJISShinjitaiOutput(_:)), keyEquivalent: "J") let shiftJISConversionItem = menu.addItem(withTitle: NSLocalizedString("JIS Shinjitai Output", comment: ""), action: #selector(toggleShiftJISShinjitaiOutput(_:)), keyEquivalent: "J")
shiftJISConversionItem.keyEquivalentModifierMask = [.command, .control] shiftJISConversionItem.keyEquivalentModifierMask = [.command, .control]
shiftJISConversionItem.state = Preferences.shiftJISShinjitaiOutputEnabled.state shiftJISConversionItem.state = mgrPrefs.shiftJISShinjitaiOutputEnabled.state
} }
let halfWidthPunctuationItem = menu.addItem(withTitle: NSLocalizedString("Half-Width Punctuation Mode", comment: ""), action: #selector(toggleHalfWidthPunctuation(_:)), keyEquivalent: "H") let halfWidthPunctuationItem = menu.addItem(withTitle: NSLocalizedString("Half-Width Punctuation Mode", comment: ""), action: #selector(toggleHalfWidthPunctuation(_:)), keyEquivalent: "H")
halfWidthPunctuationItem.keyEquivalentModifierMask = [.command, .control] halfWidthPunctuationItem.keyEquivalentModifierMask = [.command, .control]
halfWidthPunctuationItem.state = Preferences.halfWidthPunctuationEnabled.state halfWidthPunctuationItem.state = mgrPrefs.halfWidthPunctuationEnabled.state
let userAssociatedPhrasesItem = menu.addItem(withTitle: NSLocalizedString("Per-Char Associated Phrases", comment: ""), action: #selector(toggleAssociatedPhrasesEnabled(_:)), keyEquivalent: "O") let userAssociatedPhrasesItem = menu.addItem(withTitle: NSLocalizedString("Per-Char Associated Phrases", comment: ""), action: #selector(toggleAssociatedPhrasesEnabled(_:)), keyEquivalent: "O")
userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control] userAssociatedPhrasesItem.keyEquivalentModifierMask = [.command, .control]
userAssociatedPhrasesItem.state = Preferences.associatedPhrasesEnabled.state userAssociatedPhrasesItem.state = mgrPrefs.associatedPhrasesEnabled.state
if optionKeyPressed { if optionKeyPressed {
let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "") let phaseReplacementItem = menu.addItem(withTitle: NSLocalizedString("Use Phrase Replacement", comment: ""), action: #selector(togglePhraseReplacement(_:)), keyEquivalent: "")
phaseReplacementItem.state = Preferences.phraseReplacementEnabled.state phaseReplacementItem.state = mgrPrefs.phraseReplacementEnabled.state
let toggleSymbolInputItem = menu.addItem(withTitle: NSLocalizedString("Symbol & Emoji Input", comment: ""), action: #selector(toggleSymbolEnabled(_:)), keyEquivalent: "") let toggleSymbolInputItem = menu.addItem(withTitle: NSLocalizedString("Symbol & Emoji Input", comment: ""), action: #selector(toggleSymbolEnabled(_:)), keyEquivalent: "")
toggleSymbolInputItem.state = Preferences.symbolInputEnabled.state toggleSymbolInputItem.state = mgrPrefs.symbolInputEnabled.state
} }
menu.addItem(NSMenuItem.separator()) // --------------------- menu.addItem(NSMenuItem.separator()) // ---------------------
@ -117,7 +117,7 @@ class ctlInputMethod: IMKInputController {
menu.addItem(withTitle: NSLocalizedString("Edit User Symbol & Emoji Data…", comment: ""), action: #selector(openUserSymbols(_:)), keyEquivalent: "") menu.addItem(withTitle: NSLocalizedString("Edit User Symbol & Emoji Data…", comment: ""), action: #selector(openUserSymbols(_:)), keyEquivalent: "")
} }
if (optionKeyPressed || !Preferences.shouldAutoReloadUserDataFiles) { if (optionKeyPressed || !mgrPrefs.shouldAutoReloadUserDataFiles) {
menu.addItem(withTitle: NSLocalizedString("Reload User Phrases", comment: ""), action: #selector(reloadUserPhrases(_:)), keyEquivalent: "") menu.addItem(withTitle: NSLocalizedString("Reload User Phrases", comment: ""), action: #selector(reloadUserPhrases(_:)), keyEquivalent: "")
} }
@ -140,7 +140,7 @@ class ctlInputMethod: IMKInputController {
UserDefaults.standard.synchronize() UserDefaults.standard.synchronize()
// Override the keyboard layout. Use US if not set. // Override the keyboard layout. Use US if not set.
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: Preferences.basisKeyboardLayout) (client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
// reset the state // reset the state
currentCandidateClient = nil currentCandidateClient = nil
@ -170,7 +170,7 @@ class ctlInputMethod: IMKInputController {
if keyHandler.inputMode != newInputMode { if keyHandler.inputMode != newInputMode {
UserDefaults.standard.synchronize() UserDefaults.standard.synchronize()
// Remember to override the keyboard layout again -- treat this as an activate event. // Remember to override the keyboard layout again -- treat this as an activate event.
(client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: Preferences.basisKeyboardLayout) (client as? IMKTextInput)?.overrideKeyboard(withKeyboardNamed: mgrPrefs.basisKeyboardLayout)
keyHandler.clear() keyHandler.clear()
keyHandler.inputMode = newInputMode keyHandler.inputMode = newInputMode
self.handle(state: .Empty(), client: client) self.handle(state: .Empty(), client: client)
@ -189,14 +189,14 @@ class ctlInputMethod: IMKInputController {
override func handle(_ event: NSEvent!, client: Any!) -> Bool { override func handle(_ event: NSEvent!, client: Any!) -> Bool {
if event.type == .flagsChanged { if event.type == .flagsChanged {
let functionKeyKeyboardLayoutID = Preferences.functionKeyboardLayout let functionKeyKeyboardLayoutID = mgrPrefs.functionKeyboardLayout
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout let basisKeyboardLayoutID = mgrPrefs.basisKeyboardLayout
if functionKeyKeyboardLayoutID == basisKeyboardLayoutID { if functionKeyKeyboardLayoutID == basisKeyboardLayoutID {
return false return false
} }
let includeShift = Preferences.functionKeyKeyboardLayoutOverrideIncludeShiftKey let includeShift = mgrPrefs.functionKeyKeyboardLayoutOverrideIncludeShiftKey
if event.modifierFlags.contains(.capsLock) || if event.modifierFlags.contains(.capsLock) ||
event.modifierFlags.contains(.option) || event.modifierFlags.contains(.option) ||
@ -238,35 +238,35 @@ class ctlInputMethod: IMKInputController {
} }
@objc func toggleSCPCTypingMode(_ sender: Any?) { @objc func toggleSCPCTypingMode(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Select Mode", comment: ""), "\n", Preferences.toggleSCPCTypingModeEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Select Mode", comment: ""), "\n", mgrPrefs.toggleSCPCTypingModeEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleChineseConverter(_ sender: Any?) { @objc func toggleChineseConverter(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Force KangXi Writing", comment: ""), "\n", Preferences.toggleChineseConversionEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Force KangXi Writing", comment: ""), "\n", mgrPrefs.toggleChineseConversionEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleShiftJISShinjitaiOutput(_ sender: Any?) { @objc func toggleShiftJISShinjitaiOutput(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("JIS Shinjitai Output", comment: ""), "\n", Preferences.toggleShiftJISShinjitaiOutputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("JIS Shinjitai Output", comment: ""), "\n", mgrPrefs.toggleShiftJISShinjitaiOutputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleHalfWidthPunctuation(_ sender: Any?) { @objc func toggleHalfWidthPunctuation(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Half-Width Punctuation Mode", comment: ""), "\n", Preferences.toggleHalfWidthPunctuationEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Half-Width Punctuation Mode", comment: ""), "\n", mgrPrefs.toggleHalfWidthPunctuationEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleCNS11643Enabled(_ sender: Any?) { @objc func toggleCNS11643Enabled(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("CNS11643 Mode", comment: ""), "\n", Preferences.toggleCNS11643Enabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("CNS11643 Mode", comment: ""), "\n", mgrPrefs.toggleCNS11643Enabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleSymbolEnabled(_ sender: Any?) { @objc func toggleSymbolEnabled(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Symbol & Emoji Input", comment: ""), "\n", Preferences.toggleSymbolInputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Symbol & Emoji Input", comment: ""), "\n", mgrPrefs.toggleSymbolInputEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func toggleAssociatedPhrasesEnabled(_ sender: Any?) { @objc func toggleAssociatedPhrasesEnabled(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", Preferences.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Per-Char Associated Phrases", comment: ""), "\n", mgrPrefs.toggleAssociatedPhrasesEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func togglePhraseReplacement(_ sender: Any?) { @objc func togglePhraseReplacement(_ sender: Any?) {
NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", Preferences.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: ""))) NotifierController.notify(message: String(format: "%@%@%@", NSLocalizedString("Use Phrase Replacement", comment: ""), "\n", mgrPrefs.togglePhraseReplacementEnabled() ? NSLocalizedString("NotificationSwitchON", comment: "") : NSLocalizedString("NotificationSwitchOFF", comment: "")))
} }
@objc func selfTerminate(_ sender: Any?) { @objc func selfTerminate(_ sender: Any?) {
@ -282,6 +282,7 @@ class ctlInputMethod: IMKInputController {
if !mgrLangModel.checkIfUserLanguageModelFilesExist() { if !mgrLangModel.checkIfUserLanguageModelFilesExist() {
let content = String(format: NSLocalizedString("Please check the permission at \"%@\".", comment: ""), mgrLangModel.dataFolderPath) let content = String(format: NSLocalizedString("Please check the permission at \"%@\".", comment: ""), mgrLangModel.dataFolderPath)
ctlNonModalAlertWindow.shared.show(title: NSLocalizedString("Unable to create the user phrase file.", comment: ""), content: content, confirmButtonTitle: NSLocalizedString("OK", comment: ""), cancelButtonTitle: nil, cancelAsDefault: false, delegate: nil) ctlNonModalAlertWindow.shared.show(title: NSLocalizedString("Unable to create the user phrase file.", comment: ""), content: content, confirmButtonTitle: NSLocalizedString("OK", comment: ""), cancelButtonTitle: nil, cancelAsDefault: false, delegate: nil)
NSApp.setActivationPolicy(.accessory)
return false return false
} }
return true return true
@ -363,17 +364,17 @@ extension ctlInputMethod {
func kanjiConversionIfRequired(_ text: String) -> String { func kanjiConversionIfRequired(_ text: String) -> String {
if keyHandler.inputMode == InputMode.imeModeCHT { if keyHandler.inputMode == InputMode.imeModeCHT {
if !Preferences.chineseConversionEnabled && Preferences.shiftJISShinjitaiOutputEnabled { if !mgrPrefs.chineseConversionEnabled && mgrPrefs.shiftJISShinjitaiOutputEnabled {
return vChewingKanjiConverter.cnvTradToJIS(text) return vChewingKanjiConverter.cnvTradToJIS(text)
} }
if Preferences.chineseConversionEnabled && !Preferences.shiftJISShinjitaiOutputEnabled { if mgrPrefs.chineseConversionEnabled && !mgrPrefs.shiftJISShinjitaiOutputEnabled {
return vChewingKanjiConverter.cnvTradToKangXi(text) return vChewingKanjiConverter.cnvTradToKangXi(text)
} }
// //
if Preferences.chineseConversionEnabled && Preferences.shiftJISShinjitaiOutputEnabled { if mgrPrefs.chineseConversionEnabled && mgrPrefs.shiftJISShinjitaiOutputEnabled {
return vChewingKanjiConverter.cnvTradToJIS(text) return vChewingKanjiConverter.cnvTradToJIS(text)
} }
// if (!Preferences.chineseConversionEnabled && !Preferences.shiftJISShinjitaiOutputEnabled) || (keyHandler.inputMode != InputMode.imeModeCHT); // if (!mgrPrefs.chineseConversionEnabled && !mgrPrefs.shiftJISShinjitaiOutputEnabled) || (keyHandler.inputMode != InputMode.imeModeCHT);
return text return text
} }
return text return text
@ -535,14 +536,14 @@ extension ctlInputMethod {
if useVerticalMode { if useVerticalMode {
gCurrentCandidateController = .vertical gCurrentCandidateController = .vertical
} else if Preferences.useHorizontalCandidateList { } else if mgrPrefs.useHorizontalCandidateList {
gCurrentCandidateController = .horizontal gCurrentCandidateController = .horizontal
} else { } else {
gCurrentCandidateController = .vertical gCurrentCandidateController = .vertical
} }
// set the attributes for the candidate panel (which uses NSAttributedString) // set the attributes for the candidate panel (which uses NSAttributedString)
let textSize = Preferences.candidateListTextSize let textSize = mgrPrefs.candidateListTextSize
let keyLabelSize = max(textSize / 2, kMinKeyLabelSize) let keyLabelSize = max(textSize / 2, kMinKeyLabelSize)
func labelFont(name: String?, size: CGFloat) -> NSFont { func labelFont(name: String?, size: CGFloat) -> NSFont {
@ -563,11 +564,11 @@ extension ctlInputMethod {
return finalReturnFont return finalReturnFont
} }
gCurrentCandidateController?.keyLabelFont = labelFont(name: Preferences.candidateKeyLabelFontName, size: keyLabelSize) gCurrentCandidateController?.keyLabelFont = labelFont(name: mgrPrefs.candidateKeyLabelFontName, size: keyLabelSize)
gCurrentCandidateController?.candidateFont = candidateFont(name: Preferences.candidateTextFontName, size: textSize) gCurrentCandidateController?.candidateFont = candidateFont(name: mgrPrefs.candidateTextFontName, size: textSize)
let candidateKeys = Preferences.candidateKeys let candidateKeys = mgrPrefs.candidateKeys
let keyLabels = candidateKeys.count > 4 ? Array(candidateKeys) : Array(Preferences.defaultCandidateKeys) let keyLabels = candidateKeys.count > 4 ? Array(candidateKeys) : Array(mgrPrefs.defaultCandidateKeys)
let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : "" let keyLabelSuffix = state is InputState.AssociatedPhrases ? "^" : ""
gCurrentCandidateController?.keyLabels = keyLabels.map { gCurrentCandidateController?.keyLabels = keyLabels.map {
CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix) CandidateKeyLabel(key: String($0), displayedText: String($0) + keyLabelSuffix)
@ -695,11 +696,11 @@ extension ctlInputMethod: CandidateControllerDelegate {
return return
} }
if Preferences.useSCPCTypingMode { if mgrPrefs.useSCPCTypingMode {
keyHandler.clear() keyHandler.clear()
let composingBuffer = inputting.composingBuffer let composingBuffer = inputting.composingBuffer
handle(state: .Committing(poppedText: composingBuffer), client: client) handle(state: .Committing(poppedText: composingBuffer), client: client)
if Preferences.associatedPhrasesEnabled, if mgrPrefs.associatedPhrasesEnabled,
let associatePhrases = keyHandler.buildAssociatePhraseState(withKey: composingBuffer, useVerticalMode: state.useVerticalMode) as? InputState.AssociatedPhrases { let associatePhrases = keyHandler.buildAssociatePhraseState(withKey: composingBuffer, useVerticalMode: state.useVerticalMode) as? InputState.AssociatedPhrases {
self.handle(state: associatePhrases, client: client) self.handle(state: associatePhrases, client: client)
} else { } else {
@ -714,7 +715,7 @@ extension ctlInputMethod: CandidateControllerDelegate {
if let state = state as? InputState.AssociatedPhrases { if let state = state as? InputState.AssociatedPhrases {
let selectedValue = state.candidates[Int(index)] let selectedValue = state.candidates[Int(index)]
handle(state: .Committing(poppedText: selectedValue), client: currentCandidateClient) handle(state: .Committing(poppedText: selectedValue), client: currentCandidateClient)
if Preferences.associatedPhrasesEnabled, if mgrPrefs.associatedPhrasesEnabled,
let associatePhrases = keyHandler.buildAssociatePhraseState(withKey: selectedValue, useVerticalMode: state.useVerticalMode) as? InputState.AssociatedPhrases { let associatePhrases = keyHandler.buildAssociatePhraseState(withKey: selectedValue, useVerticalMode: state.useVerticalMode) as? InputState.AssociatedPhrases {
self.handle(state: associatePhrases, client: client) self.handle(state: associatePhrases, client: client)
} else { } else {

View File

@ -212,7 +212,7 @@ struct ComposingBufferSize {
} }
// MARK: - // MARK: -
@objc public class Preferences: NSObject { @objc public class mgrPrefs: NSObject {
static var allKeys:[String] { static var allKeys:[String] {
[kIsDebugModeEnabled, [kIsDebugModeEnabled,
kKeyboardLayoutPreference, kKeyboardLayoutPreference,
@ -253,7 +253,7 @@ struct ComposingBufferSize {
// //
if UserDefaults.standard.object(forKey: kIsDebugModeEnabled) == nil { if UserDefaults.standard.object(forKey: kIsDebugModeEnabled) == nil {
UserDefaults.standard.set(Preferences.isDebugModeEnabled, forKey: kIsDebugModeEnabled) UserDefaults.standard.set(mgrPrefs.isDebugModeEnabled, forKey: kIsDebugModeEnabled)
} }
// //
@ -261,89 +261,89 @@ struct ComposingBufferSize {
UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically) UserDefaults.standard.set(false, forKey: kCheckUpdateAutomatically)
} }
// //
if UserDefaults.standard.object(forKey: kShowPageButtonsInCandidateWindow) == nil { if UserDefaults.standard.object(forKey: kShowPageButtonsInCandidateWindow) == nil {
UserDefaults.standard.set(Preferences.showPageButtonsInCandidateWindow, forKey: kShowPageButtonsInCandidateWindow) UserDefaults.standard.set(mgrPrefs.showPageButtonsInCandidateWindow, forKey: kShowPageButtonsInCandidateWindow)
} }
// //
if UserDefaults.standard.object(forKey: kSymbolInputEnabled) == nil { if UserDefaults.standard.object(forKey: kSymbolInputEnabled) == nil {
UserDefaults.standard.set(Preferences.symbolInputEnabled, forKey: kSymbolInputEnabled) UserDefaults.standard.set(mgrPrefs.symbolInputEnabled, forKey: kSymbolInputEnabled)
} }
// 18 // 18
if UserDefaults.standard.object(forKey: kCandidateListTextSize) == nil { if UserDefaults.standard.object(forKey: kCandidateListTextSize) == nil {
UserDefaults.standard.set(Preferences.candidateListTextSize, forKey: kCandidateListTextSize) UserDefaults.standard.set(mgrPrefs.candidateListTextSize, forKey: kCandidateListTextSize)
} }
// true // true
if UserDefaults.standard.object(forKey: kChooseCandidateUsingSpace) == nil { if UserDefaults.standard.object(forKey: kChooseCandidateUsingSpace) == nil {
UserDefaults.standard.set(Preferences.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpace) UserDefaults.standard.set(mgrPrefs.chooseCandidateUsingSpace, forKey: kChooseCandidateUsingSpace)
} }
// 使 // 使
if UserDefaults.standard.object(forKey: kShouldAutoReloadUserDataFiles) == nil { if UserDefaults.standard.object(forKey: kShouldAutoReloadUserDataFiles) == nil {
UserDefaults.standard.set(Preferences.shouldAutoReloadUserDataFiles, forKey: kShouldAutoReloadUserDataFiles) UserDefaults.standard.set(mgrPrefs.shouldAutoReloadUserDataFiles, forKey: kShouldAutoReloadUserDataFiles)
} }
// Tab // Tab
if UserDefaults.standard.object(forKey: kSpecifyTabKeyBehavior) == nil { if UserDefaults.standard.object(forKey: kSpecifyTabKeyBehavior) == nil {
UserDefaults.standard.set(Preferences.specifyTabKeyBehavior, forKey: kSpecifyTabKeyBehavior) UserDefaults.standard.set(mgrPrefs.specifyTabKeyBehavior, forKey: kSpecifyTabKeyBehavior)
} }
// Space // Space
if UserDefaults.standard.object(forKey: kSpecifySpaceKeyBehavior) == nil { if UserDefaults.standard.object(forKey: kSpecifySpaceKeyBehavior) == nil {
UserDefaults.standard.set(Preferences.specifySpaceKeyBehavior, forKey: kSpecifySpaceKeyBehavior) UserDefaults.standard.set(mgrPrefs.specifySpaceKeyBehavior, forKey: kSpecifySpaceKeyBehavior)
} }
// false // false
if UserDefaults.standard.object(forKey: kUseSCPCTypingMode) == nil { if UserDefaults.standard.object(forKey: kUseSCPCTypingMode) == nil {
UserDefaults.standard.set(Preferences.useSCPCTypingMode, forKey: kUseSCPCTypingMode) UserDefaults.standard.set(mgrPrefs.useSCPCTypingMode, forKey: kUseSCPCTypingMode)
} }
// false // false
if UserDefaults.standard.object(forKey: kAssociatedPhrasesEnabled) == nil { if UserDefaults.standard.object(forKey: kAssociatedPhrasesEnabled) == nil {
UserDefaults.standard.set(Preferences.associatedPhrasesEnabled, forKey: kAssociatedPhrasesEnabled) UserDefaults.standard.set(mgrPrefs.associatedPhrasesEnabled, forKey: kAssociatedPhrasesEnabled)
} }
// 0 // 0
if UserDefaults.standard.object(forKey: kSelectPhraseAfterCursorAsCandidatePreference) == nil { if UserDefaults.standard.object(forKey: kSelectPhraseAfterCursorAsCandidatePreference) == nil {
UserDefaults.standard.set(Preferences.selectPhraseAfterCursorAsCandidate, forKey: kSelectPhraseAfterCursorAsCandidatePreference) UserDefaults.standard.set(mgrPrefs.selectPhraseAfterCursorAsCandidate, forKey: kSelectPhraseAfterCursorAsCandidatePreference)
} }
// //
if UserDefaults.standard.object(forKey: kMoveCursorAfterSelectingCandidate) == nil { if UserDefaults.standard.object(forKey: kMoveCursorAfterSelectingCandidate) == nil {
UserDefaults.standard.set(Preferences.moveCursorAfterSelectingCandidate, forKey: kMoveCursorAfterSelectingCandidate) UserDefaults.standard.set(mgrPrefs.moveCursorAfterSelectingCandidate, forKey: kMoveCursorAfterSelectingCandidate)
} }
// //
if UserDefaults.standard.object(forKey: kUseHorizontalCandidateListPreference) == nil { if UserDefaults.standard.object(forKey: kUseHorizontalCandidateListPreference) == nil {
UserDefaults.standard.set(Preferences.useHorizontalCandidateList, forKey: kUseHorizontalCandidateListPreference) UserDefaults.standard.set(mgrPrefs.useHorizontalCandidateList, forKey: kUseHorizontalCandidateListPreference)
} }
// //
if UserDefaults.standard.object(forKey: kCNS11643Enabled) == nil { if UserDefaults.standard.object(forKey: kCNS11643Enabled) == nil {
UserDefaults.standard.set(Preferences.cns11643Enabled, forKey: kCNS11643Enabled) UserDefaults.standard.set(mgrPrefs.cns11643Enabled, forKey: kCNS11643Enabled)
} }
// //
if UserDefaults.standard.object(forKey: kChineseConversionEnabled) == nil { if UserDefaults.standard.object(forKey: kChineseConversionEnabled) == nil {
UserDefaults.standard.set(Preferences.chineseConversionEnabled, forKey: kChineseConversionEnabled) UserDefaults.standard.set(mgrPrefs.chineseConversionEnabled, forKey: kChineseConversionEnabled)
} }
// JIS // JIS
if UserDefaults.standard.object(forKey: kShiftJISShinjitaiOutputEnabled) == nil { if UserDefaults.standard.object(forKey: kShiftJISShinjitaiOutputEnabled) == nil {
UserDefaults.standard.set(Preferences.shiftJISShinjitaiOutputEnabled, forKey: kShiftJISShinjitaiOutputEnabled) UserDefaults.standard.set(mgrPrefs.shiftJISShinjitaiOutputEnabled, forKey: kShiftJISShinjitaiOutputEnabled)
} }
// //
if UserDefaults.standard.object(forKey: kPhraseReplacementEnabled) == nil { if UserDefaults.standard.object(forKey: kPhraseReplacementEnabled) == nil {
UserDefaults.standard.set(Preferences.phraseReplacementEnabled, forKey: kPhraseReplacementEnabled) UserDefaults.standard.set(mgrPrefs.phraseReplacementEnabled, forKey: kPhraseReplacementEnabled)
} }
// //
if UserDefaults.standard.object(forKey: kShouldNotFartInLieuOfBeep) == nil { if UserDefaults.standard.object(forKey: kShouldNotFartInLieuOfBeep) == nil {
UserDefaults.standard.set(Preferences.shouldNotFartInLieuOfBeep, forKey: kShouldNotFartInLieuOfBeep) UserDefaults.standard.set(mgrPrefs.shouldNotFartInLieuOfBeep, forKey: kShouldNotFartInLieuOfBeep)
} }
UserDefaults.standard.synchronize() UserDefaults.standard.synchronize()

View File

@ -137,16 +137,16 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
+ (void)setupDataModelValueConverter + (void)setupDataModelValueConverter
{ {
auto converter = [] (string input) { auto converter = [] (string input) {
// if (!Preferences.chineseConversionEnabled) { // if (!mgrPrefs.chineseConversionEnabled) {
// return input; // return input;
// } // }
// //
// if (Preferences.chineseConversionStyle == 0) { // if (mgrPrefs.chineseConversionStyle == 0) {
// return input; // return input;
// } // }
// //
// NSString *text = [NSString stringWithUTF8String:input.c_str()]; // NSString *text = [NSString stringWithUTF8String:input.c_str()];
// if (Preferences.chineseConversionEngine == 1) { // if (mgrPrefs.chineseConversionEngine == 1) {
// text = [VXHanConvert convertToKangXiFrom:text]; // text = [VXHanConvert convertToKangXiFrom:text];
// } // }
// else { // else {
@ -288,7 +288,7 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
// We use FSEventStream to monitor the change of the user phrase folder, // We use FSEventStream to monitor the change of the user phrase folder,
// so we don't have to load data here unless FSEventStream is disabled by user. // so we don't have to load data here unless FSEventStream is disabled by user.
if (!Preferences.shouldAutoReloadUserDataFiles) { if (!mgrPrefs.shouldAutoReloadUserDataFiles) {
[self loadUserPhrases]; [self loadUserPhrases];
} }
return YES; return YES;

View File

@ -34,7 +34,7 @@ import Cocoa
} }
// Create a new beep sound if possible // Create a new beep sound if possible
var sndBeep:String var sndBeep:String
if Preferences.shouldNotFartInLieuOfBeep == false { if mgrPrefs.shouldNotFartInLieuOfBeep == false {
sndBeep = "Fart" sndBeep = "Fart"
} else { } else {
sndBeep = "Beep" sndBeep = "Beep"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,13 +1,13 @@
{ {
"images" : [ "images" : [
{ {
"filename" : "16X16.png", "filename" : "AppIconSmallest.png",
"idiom" : "mac", "idiom" : "mac",
"scale" : "1x", "scale" : "1x",
"size" : "16x16" "size" : "16x16"
}, },
{ {
"filename" : "32X32.png", "filename" : "AppIconSmallest@2x.png",
"idiom" : "mac", "idiom" : "mac",
"scale" : "2x", "scale" : "2x",
"size" : "16x16" "size" : "16x16"

View File

@ -363,7 +363,7 @@ extension HorizontalCandidateController {
frameRect.size = newSize frameRect.size = newSize
candidateView.frame = frameRect candidateView.frame = frameRect
if pageCount > 1 && Preferences.showPageButtonsInCandidateWindow { if pageCount > 1 && mgrPrefs.showPageButtonsInCandidateWindow {
var buttonRect = nextPageButton.frame var buttonRect = nextPageButton.frame
let spacing:CGFloat = 0.0 let spacing:CGFloat = 0.0

View File

@ -369,7 +369,7 @@ extension VerticalCandidateController {
frameRect.size = newSize frameRect.size = newSize
candidateView.frame = frameRect candidateView.frame = frameRect
if pageCount > 1 && Preferences.showPageButtonsInCandidateWindow { if pageCount > 1 && mgrPrefs.showPageButtonsInCandidateWindow {
var buttonRect = nextPageButton.frame var buttonRect = nextPageButton.frame
let spacing:CGFloat = 0.0 let spacing:CGFloat = 0.0

View File

@ -49,7 +49,7 @@ extension RangeReplaceableCollection where Element: Hashable {
var chosenLanguageItem: NSMenuItem? = nil var chosenLanguageItem: NSMenuItem? = nil
uiLanguageButton.menu?.removeAllItems() uiLanguageButton.menu?.removeAllItems()
let appleLanguages = Preferences.appleLanguages let appleLanguages = mgrPrefs.appleLanguages
for language in languages { for language in languages {
let menuItem = NSMenuItem() let menuItem = NSMenuItem()
menuItem.title = NSLocalizedString(language, comment: "") menuItem.title = NSLocalizedString(language, comment: "")
@ -86,7 +86,7 @@ extension RangeReplaceableCollection where Element: Hashable {
menuItem_AppleZhuyinEten.representedObject = String("com.apple.keylayout.ZhuyinEten") menuItem_AppleZhuyinEten.representedObject = String("com.apple.keylayout.ZhuyinEten")
basisKeyboardLayoutButton.menu?.addItem(menuItem_AppleZhuyinEten) basisKeyboardLayoutButton.menu?.addItem(menuItem_AppleZhuyinEten)
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout let basisKeyboardLayoutID = mgrPrefs.basisKeyboardLayout
for source in list { for source in list {
if let categoryPtr = TISGetInputSourceProperty(source, kTISPropertyInputSourceCategory) { if let categoryPtr = TISGetInputSourceProperty(source, kTISPropertyInputSourceCategory) {
@ -150,11 +150,11 @@ extension RangeReplaceableCollection where Element: Hashable {
selectionKeyComboBox.usesDataSource = false selectionKeyComboBox.usesDataSource = false
selectionKeyComboBox.removeAllItems() selectionKeyComboBox.removeAllItems()
selectionKeyComboBox.addItems(withObjectValues: Preferences.suggestedCandidateKeys) selectionKeyComboBox.addItems(withObjectValues: mgrPrefs.suggestedCandidateKeys)
var candidateSelectionKeys = Preferences.candidateKeys var candidateSelectionKeys = mgrPrefs.candidateKeys
if candidateSelectionKeys.isEmpty { if candidateSelectionKeys.isEmpty {
candidateSelectionKeys = Preferences.defaultCandidateKeys candidateSelectionKeys = mgrPrefs.defaultCandidateKeys
} }
selectionKeyComboBox.stringValue = candidateSelectionKeys selectionKeyComboBox.stringValue = candidateSelectionKeys
@ -163,28 +163,28 @@ extension RangeReplaceableCollection where Element: Hashable {
// CNS // CNS
// //
@IBAction func toggleCNSSupport(_ sender: Any) { @IBAction func toggleCNSSupport(_ sender: Any) {
mgrLangModel.setCNSEnabled(Preferences.cns11643Enabled) mgrLangModel.setCNSEnabled(mgrPrefs.cns11643Enabled)
} }
@IBAction func toggleSymbolInputEnabled(_ sender: Any) { @IBAction func toggleSymbolInputEnabled(_ sender: Any) {
mgrLangModel.setSymbolEnabled(Preferences.symbolInputEnabled) mgrLangModel.setSymbolEnabled(mgrPrefs.symbolInputEnabled)
} }
@IBAction func toggleTrad2KangXiAction(_ sender: Any) { @IBAction func toggleTrad2KangXiAction(_ sender: Any) {
if chkTrad2KangXi.state == .on && chkTrad2JISShinjitai.state == .on { if chkTrad2KangXi.state == .on && chkTrad2JISShinjitai.state == .on {
Preferences.toggleShiftJISShinjitaiOutputEnabled() mgrPrefs.toggleShiftJISShinjitaiOutputEnabled()
} }
} }
@IBAction func toggleTrad2JISShinjitaiAction(_ sender: Any) { @IBAction func toggleTrad2JISShinjitaiAction(_ sender: Any) {
if chkTrad2KangXi.state == .on && chkTrad2JISShinjitai.state == .on { if chkTrad2KangXi.state == .on && chkTrad2JISShinjitai.state == .on {
Preferences.toggleChineseConversionEnabled() mgrPrefs.toggleChineseConversionEnabled()
} }
} }
@IBAction func updateBasisKeyboardLayoutAction(_ sender: Any) { @IBAction func updateBasisKeyboardLayoutAction(_ sender: Any) {
if let sourceID = basisKeyboardLayoutButton.selectedItem?.representedObject as? String { if let sourceID = basisKeyboardLayoutButton.selectedItem?.representedObject as? String {
Preferences.basisKeyboardLayout = sourceID mgrPrefs.basisKeyboardLayout = sourceID
} }
} }
@ -196,7 +196,7 @@ extension RangeReplaceableCollection where Element: Hashable {
} }
if let language = uiLanguageButton.selectedItem?.representedObject as? String { if let language = uiLanguageButton.selectedItem?.representedObject as? String {
if (language != "auto") { if (language != "auto") {
Preferences.appleLanguages = [language] mgrPrefs.appleLanguages = [language]
} }
else { else {
UserDefaults.standard.removeObject(forKey: "AppleLanguages") UserDefaults.standard.removeObject(forKey: "AppleLanguages")
@ -216,18 +216,18 @@ extension RangeReplaceableCollection where Element: Hashable {
return return
} }
do { do {
try Preferences.validate(candidateKeys: keys) try mgrPrefs.validate(candidateKeys: keys)
Preferences.candidateKeys = keys mgrPrefs.candidateKeys = keys
selectionKeyComboBox.stringValue = Preferences.candidateKeys selectionKeyComboBox.stringValue = mgrPrefs.candidateKeys
} }
catch Preferences.CandidateKeyError.empty { catch mgrPrefs.CandidateKeyError.empty {
selectionKeyComboBox.stringValue = Preferences.candidateKeys selectionKeyComboBox.stringValue = mgrPrefs.candidateKeys
} }
catch { catch {
if let window = window { if let window = window {
let alert = NSAlert(error: error) let alert = NSAlert(error: error)
alert.beginSheetModal(for: window) { response in alert.beginSheetModal(for: window) { response in
self.selectionKeyComboBox.stringValue = Preferences.candidateKeys self.selectionKeyComboBox.stringValue = mgrPrefs.candidateKeys
} }
clsSFX.beep() clsSFX.beep()
} }

View File

@ -7,8 +7,8 @@
<key>UpdateInfoSite</key> <key>UpdateInfoSite</key>
<string>https://gitee.com/vChewing/vChewing-macOS/releases</string> <string>https://gitee.com/vChewing/vChewing-macOS/releases</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1931</string> <string>1940</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.3.9</string> <string>1.4.0</string>
</dict> </dict>
</plist> </plist>

View File

@ -724,7 +724,7 @@
<key>USE_HFS+_COMPRESSION</key> <key>USE_HFS+_COMPRESSION</key>
<false/> <false/>
<key>VERSION</key> <key>VERSION</key>
<string>1.3.9</string> <string>1.4.0</string>
</dict> </dict>
<key>TYPE</key> <key>TYPE</key>
<integer>0</integer> <integer>0</integer>
@ -925,7 +925,52 @@
<key>INTRODUCTION</key> <key>INTRODUCTION</key>
<dict> <dict>
<key>LOCALIZATIONS</key> <key>LOCALIZATIONS</key>
<array/> <array>
<dict>
<key>LANGUAGE</key>
<string>English</string>
<key>VALUE</key>
<dict>
<key>PATH</key>
<string>Installer/pkgTextWarning-ENU.txt</string>
<key>PATH_TYPE</key>
<integer>1</integer>
</dict>
</dict>
<dict>
<key>LANGUAGE</key>
<string>Simplified Chinese</string>
<key>VALUE</key>
<dict>
<key>PATH</key>
<string>Installer/pkgTextWarning-CHS.txt</string>
<key>PATH_TYPE</key>
<integer>1</integer>
</dict>
</dict>
<dict>
<key>LANGUAGE</key>
<string>Japanese</string>
<key>VALUE</key>
<dict>
<key>PATH</key>
<string>Installer/pkgTextWarning-JPN.txt</string>
<key>PATH_TYPE</key>
<integer>1</integer>
</dict>
</dict>
<dict>
<key>LANGUAGE</key>
<string>Traditional Chinese</string>
<key>VALUE</key>
<dict>
<key>PATH</key>
<string>Installer/pkgTextWarning-CHT.txt</string>
<key>PATH_TYPE</key>
<integer>1</integer>
</dict>
</dict>
</array>
</dict> </dict>
<key>LICENSE</key> <key>LICENSE</key>
<dict> <dict>
@ -944,11 +989,11 @@
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
<string>Traditional Chinese</string> <string>Simplified Chinese</string>
<key>VALUE</key> <key>VALUE</key>
<dict> <dict>
<key>PATH</key> <key>PATH</key>
<string>LICENSE-CHT.txt</string> <string>LICENSE-CHS.txt</string>
<key>PATH_TYPE</key> <key>PATH_TYPE</key>
<integer>1</integer> <integer>1</integer>
</dict> </dict>
@ -966,11 +1011,11 @@
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
<string>Simplified Chinese</string> <string>Traditional Chinese</string>
<key>VALUE</key> <key>VALUE</key>
<dict> <dict>
<key>PATH</key> <key>PATH</key>
<string>LICENSE-CHS.txt</string> <string>LICENSE-CHT.txt</string>
<key>PATH_TYPE</key> <key>PATH_TYPE</key>
<integer>1</integer> <integer>1</integer>
</dict> </dict>
@ -1001,9 +1046,9 @@
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
<string>Simplified Chinese</string> <string>Traditional Chinese</string>
<key>VALUE</key> <key>VALUE</key>
<string>威注音入法</string> <string>威注音入法</string>
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
@ -1013,9 +1058,9 @@
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
<string>Traditional Chinese</string> <string>Simplified Chinese</string>
<key>VALUE</key> <key>VALUE</key>
<string>威注音入法</string> <string>威注音入法</string>
</dict> </dict>
</array> </array>
</dict> </dict>
@ -1052,11 +1097,11 @@
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
<string>Simplified Chinese</string> <string>Traditional Chinese</string>
<key>SECONDARY_VALUE</key> <key>SECONDARY_VALUE</key>
<string>至少 macOS 10.11.5 方可满足威注音对系统内的万国码版本支援的需要。</string> <string>至少 macOS 10.11.5 方可滿足威注音對系統內的萬國碼版本支援的需要。</string>
<key>VALUE</key> <key>VALUE</key>
<string>作业系统版本太旧</string> <string>作業系統版本太舊</string>
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
@ -1068,11 +1113,11 @@
</dict> </dict>
<dict> <dict>
<key>LANGUAGE</key> <key>LANGUAGE</key>
<string>Traditional Chinese</string> <string>Simplified Chinese</string>
<key>SECONDARY_VALUE</key> <key>SECONDARY_VALUE</key>
<string>至少 macOS 10.11.5 方可滿足威注音對系統內的萬國碼版本支援的需要。</string> <string>至少 macOS 10.11.5 方可满足威注音对系统内的万国码版本支援的需要。</string>
<key>VALUE</key> <key>VALUE</key>
<string>作業系統版本太舊</string> <string>作业系统版本太旧</string>
</dict> </dict>
</array> </array>
<key>NAME</key> <key>NAME</key>
@ -1084,7 +1129,7 @@
<key>RESOURCES</key> <key>RESOURCES</key>
<array/> <array/>
<key>ROOT_VOLUME_ONLY</key> <key>ROOT_VOLUME_ONLY</key>
<false/> <true/>
</dict> </dict>
<key>PROJECT_SETTINGS</key> <key>PROJECT_SETTINGS</key>
<dict> <dict>

View File

@ -13,16 +13,10 @@
5B27AD6B27CB1F9B000ED75B /* data-zhuyinwen.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5B27AD6927CB1F9B000ED75B /* data-zhuyinwen.txt */; }; 5B27AD6B27CB1F9B000ED75B /* data-zhuyinwen.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5B27AD6927CB1F9B000ED75B /* data-zhuyinwen.txt */; };
5B2DB16F27AF6891006D874E /* data-chs.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5B2DB16D27AF6891006D874E /* data-chs.txt */; }; 5B2DB16F27AF6891006D874E /* data-chs.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5B2DB16D27AF6891006D874E /* data-chs.txt */; };
5B2DB17027AF6891006D874E /* data-cht.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5B2DB16E27AF6891006D874E /* data-cht.txt */; }; 5B2DB17027AF6891006D874E /* data-cht.txt in Resources */ = {isa = PBXBuildFile; fileRef = 5B2DB16E27AF6891006D874E /* data-cht.txt */; };
5B62A31727AE73A700A19448 /* unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A30927AE73A700A19448 /* unzip.m */; };
5B62A31827AE73A700A19448 /* zip.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A30A27AE73A700A19448 /* zip.m */; };
5B62A31927AE73A700A19448 /* ioapi.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A30B27AE73A700A19448 /* ioapi.m */; };
5B62A31A27AE73A700A19448 /* mztools.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A30C27AE73A700A19448 /* mztools.m */; };
5B62A31B27AE73A700A19448 /* SSZipArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A31327AE73A700A19448 /* SSZipArchive.m */; };
5B62A31C27AE73A700A19448 /* AWFileHash.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A31627AE73A700A19448 /* AWFileHash.m */; };
5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A32827AE77D100A19448 /* FSEventStreamHelper.swift */; }; 5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A32827AE77D100A19448 /* FSEventStreamHelper.swift */; };
5B62A32F27AE78B000A19448 /* CoreLM.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A32D27AE78B000A19448 /* CoreLM.mm */; }; 5B62A32F27AE78B000A19448 /* CoreLM.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A32D27AE78B000A19448 /* CoreLM.mm */; };
5B62A33227AE792F00A19448 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */; }; 5B62A33227AE792F00A19448 /* InputSourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */; };
5B62A33627AE795800A19448 /* PreferencesModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33527AE795800A19448 /* PreferencesModule.swift */; }; 5B62A33627AE795800A19448 /* mgrPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33527AE795800A19448 /* mgrPrefs.swift */; };
5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */; }; 5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */; };
5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */; }; 5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */; };
5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */; }; 5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */; };
@ -168,19 +162,6 @@
5B2DB16E27AF6891006D874E /* data-cht.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "data-cht.txt"; path = "Data/data-cht.txt"; sourceTree = "<group>"; }; 5B2DB16E27AF6891006D874E /* data-cht.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "data-cht.txt"; path = "Data/data-cht.txt"; sourceTree = "<group>"; };
5B2DB17127AF8771006D874E /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = Data/Makefile; sourceTree = "<group>"; }; 5B2DB17127AF8771006D874E /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = Data/Makefile; sourceTree = "<group>"; };
5B30F11227BA568800484E24 /* vChewingKeyLayout.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = vChewingKeyLayout.bundle; sourceTree = "<group>"; }; 5B30F11227BA568800484E24 /* vChewingKeyLayout.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = vChewingKeyLayout.bundle; sourceTree = "<group>"; };
5B62A30927AE73A700A19448 /* unzip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = unzip.m; sourceTree = "<group>"; };
5B62A30A27AE73A700A19448 /* zip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = zip.m; sourceTree = "<group>"; };
5B62A30B27AE73A700A19448 /* ioapi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ioapi.m; sourceTree = "<group>"; };
5B62A30C27AE73A700A19448 /* mztools.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = mztools.m; sourceTree = "<group>"; };
5B62A30D27AE73A700A19448 /* crypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypt.h; sourceTree = "<group>"; };
5B62A30E27AE73A700A19448 /* zip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zip.h; sourceTree = "<group>"; };
5B62A30F27AE73A700A19448 /* unzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unzip.h; sourceTree = "<group>"; };
5B62A31027AE73A700A19448 /* mztools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mztools.h; sourceTree = "<group>"; };
5B62A31127AE73A700A19448 /* ioapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = "<group>"; };
5B62A31227AE73A700A19448 /* SSZipArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSZipArchive.h; sourceTree = "<group>"; };
5B62A31327AE73A700A19448 /* SSZipArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSZipArchive.m; sourceTree = "<group>"; };
5B62A31527AE73A700A19448 /* AWFileHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWFileHash.h; sourceTree = "<group>"; };
5B62A31627AE73A700A19448 /* AWFileHash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWFileHash.m; sourceTree = "<group>"; };
5B62A32627AE77BB00A19448 /* LMConsolidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LMConsolidator.h; sourceTree = "<group>"; }; 5B62A32627AE77BB00A19448 /* LMConsolidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LMConsolidator.h; sourceTree = "<group>"; };
5B62A32727AE77BB00A19448 /* LMConsolidator.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LMConsolidator.mm; sourceTree = "<group>"; }; 5B62A32727AE77BB00A19448 /* LMConsolidator.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LMConsolidator.mm; sourceTree = "<group>"; };
5B62A32827AE77D100A19448 /* FSEventStreamHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSEventStreamHelper.swift; sourceTree = "<group>"; }; 5B62A32827AE77D100A19448 /* FSEventStreamHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSEventStreamHelper.swift; sourceTree = "<group>"; };
@ -188,7 +169,7 @@
5B62A32C27AE78B000A19448 /* CoreLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreLM.h; sourceTree = "<group>"; }; 5B62A32C27AE78B000A19448 /* CoreLM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreLM.h; sourceTree = "<group>"; };
5B62A32D27AE78B000A19448 /* CoreLM.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreLM.mm; sourceTree = "<group>"; }; 5B62A32D27AE78B000A19448 /* CoreLM.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreLM.mm; sourceTree = "<group>"; };
5B62A33127AE792F00A19448 /* InputSourceHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceHelper.swift; sourceTree = "<group>"; }; 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceHelper.swift; sourceTree = "<group>"; };
5B62A33527AE795800A19448 /* PreferencesModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesModule.swift; sourceTree = "<group>"; }; 5B62A33527AE795800A19448 /* mgrPrefs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = mgrPrefs.swift; sourceTree = "<group>"; };
5B62A33727AE79CD00A19448 /* NSStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStringUtils.swift; sourceTree = "<group>"; }; 5B62A33727AE79CD00A19448 /* NSStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSStringUtils.swift; sourceTree = "<group>"; };
5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlAboutWindow.swift; sourceTree = "<group>"; }; 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlAboutWindow.swift; sourceTree = "<group>"; };
5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalCandidateController.swift; sourceTree = "<group>"; }; 5B62A33F27AE7CD900A19448 /* HorizontalCandidateController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorizontalCandidateController.swift; sourceTree = "<group>"; };
@ -363,8 +344,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
5B707CE627D9F43E0099EF99 /* OpenCCBridge */, 5B707CE627D9F43E0099EF99 /* OpenCCBridge */,
5B62A31427AE73A700A19448 /* AWFileHash */,
5B62A30727AE73A700A19448 /* SSZipArchive */,
5B62A30227AE733500A19448 /* OVMandarin */, 5B62A30227AE733500A19448 /* OVMandarin */,
); );
path = 3rdParty; path = 3rdParty;
@ -379,41 +358,6 @@
path = OVMandarin; path = OVMandarin;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
5B62A30727AE73A700A19448 /* SSZipArchive */ = {
isa = PBXGroup;
children = (
5B62A30827AE73A700A19448 /* minizip */,
5B62A31227AE73A700A19448 /* SSZipArchive.h */,
5B62A31327AE73A700A19448 /* SSZipArchive.m */,
);
path = SSZipArchive;
sourceTree = "<group>";
};
5B62A30827AE73A700A19448 /* minizip */ = {
isa = PBXGroup;
children = (
5B62A30927AE73A700A19448 /* unzip.m */,
5B62A30A27AE73A700A19448 /* zip.m */,
5B62A30B27AE73A700A19448 /* ioapi.m */,
5B62A30C27AE73A700A19448 /* mztools.m */,
5B62A30D27AE73A700A19448 /* crypt.h */,
5B62A30E27AE73A700A19448 /* zip.h */,
5B62A30F27AE73A700A19448 /* unzip.h */,
5B62A31027AE73A700A19448 /* mztools.h */,
5B62A31127AE73A700A19448 /* ioapi.h */,
);
path = minizip;
sourceTree = "<group>";
};
5B62A31427AE73A700A19448 /* AWFileHash */ = {
isa = PBXGroup;
children = (
5B62A31527AE73A700A19448 /* AWFileHash.h */,
5B62A31627AE73A700A19448 /* AWFileHash.m */,
);
path = AWFileHash;
sourceTree = "<group>";
};
5B62A31E27AE74E400A19448 /* SFX */ = { 5B62A31E27AE74E400A19448 /* SFX */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -462,7 +406,7 @@
children = ( children = (
D4A13D5927A59D5C003BE359 /* ctlInputMethod.swift */, D4A13D5927A59D5C003BE359 /* ctlInputMethod.swift */,
5B62A33127AE792F00A19448 /* InputSourceHelper.swift */, 5B62A33127AE792F00A19448 /* InputSourceHelper.swift */,
5B62A33527AE795800A19448 /* PreferencesModule.swift */, 5B62A33527AE795800A19448 /* mgrPrefs.swift */,
); );
path = IMEModules; path = IMEModules;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1007,8 +951,6 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
5B62A31927AE73A700A19448 /* ioapi.m in Sources */,
5B62A31C27AE73A700A19448 /* AWFileHash.m in Sources */,
5B707CE827D9F4590099EF99 /* OpenCCBridge.swift in Sources */, 5B707CE827D9F4590099EF99 /* OpenCCBridge.swift in Sources */,
D427F76C278CA2B0004A2160 /* AppDelegate.swift in Sources */, D427F76C278CA2B0004A2160 /* AppDelegate.swift in Sources */,
6ACC3D442793701600F1B140 /* ParselessPhraseDB.cpp in Sources */, 6ACC3D442793701600F1B140 /* ParselessPhraseDB.cpp in Sources */,
@ -1026,12 +968,10 @@
D47D73AC27A6CAE600255A50 /* AssociatedPhrases.mm in Sources */, D47D73AC27A6CAE600255A50 /* AssociatedPhrases.mm in Sources */,
5B62A34A27AE7CD900A19448 /* NotifierController.swift in Sources */, 5B62A34A27AE7CD900A19448 /* NotifierController.swift in Sources */,
5B11328927B94CFB00E58451 /* AppleKeyboardConverter.swift in Sources */, 5B11328927B94CFB00E58451 /* AppleKeyboardConverter.swift in Sources */,
5B62A31827AE73A700A19448 /* zip.m in Sources */,
D41355DB278E6D17005E5CBD /* LMInstantiator.mm in Sources */, D41355DB278E6D17005E5CBD /* LMInstantiator.mm in Sources */,
5B62A31A27AE73A700A19448 /* mztools.m in Sources */,
5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */, 5B62A32927AE77D100A19448 /* FSEventStreamHelper.swift in Sources */,
D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */, D47F7DD3278C1263002F9DD7 /* UserOverrideModel.cpp in Sources */,
5B62A33627AE795800A19448 /* PreferencesModule.swift in Sources */, 5B62A33627AE795800A19448 /* mgrPrefs.swift in Sources */,
5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */, 5B62A33827AE79CD00A19448 /* NSStringUtils.swift in Sources */,
5B62A33227AE792F00A19448 /* InputSourceHelper.swift in Sources */, 5B62A33227AE792F00A19448 /* InputSourceHelper.swift in Sources */,
5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */, 5B62A34927AE7CD900A19448 /* TooltipController.swift in Sources */,
@ -1039,11 +979,9 @@
5B62A34827AE7CD900A19448 /* VerticalCandidateController.swift in Sources */, 5B62A34827AE7CD900A19448 /* VerticalCandidateController.swift in Sources */,
6ACC3D452793701600F1B140 /* ParselessLM.cpp in Sources */, 6ACC3D452793701600F1B140 /* ParselessLM.cpp in Sources */,
5BBBB77A27AEDC690023B93A /* clsSFX.swift in Sources */, 5BBBB77A27AEDC690023B93A /* clsSFX.swift in Sources */,
5B62A31727AE73A700A19448 /* unzip.m in Sources */,
5BF8423127BAA942008E7E4C /* vChewingKanjiConverter.swift in Sources */, 5BF8423127BAA942008E7E4C /* vChewingKanjiConverter.swift in Sources */,
5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */, 5B62A34627AE7CD900A19448 /* HorizontalCandidateController.swift in Sources */,
5B62A34727AE7CD900A19448 /* CandidateController.swift in Sources */, 5B62A34727AE7CD900A19448 /* CandidateController.swift in Sources */,
5B62A31B27AE73A700A19448 /* SSZipArchive.m in Sources */,
D41355DE278EA3ED005E5CBD /* UserPhrasesLM.mm in Sources */, D41355DE278EA3ED005E5CBD /* UserPhrasesLM.mm in Sources */,
6ACC3D3F27914F2400F1B140 /* KeyValueBlobReader.cpp in Sources */, 6ACC3D3F27914F2400F1B140 /* KeyValueBlobReader.cpp in Sources */,
D41355D8278D74B5005E5CBD /* mgrLangModel.mm in Sources */, D41355D8278D74B5005E5CBD /* mgrLangModel.mm in Sources */,
@ -1241,7 +1179,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1931; CURRENT_PROJECT_VERSION = 1940;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
@ -1264,7 +1202,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.11.5; MACOSX_DEPLOYMENT_TARGET = 10.11.5;
MARKETING_VERSION = 1.3.9; MARKETING_VERSION = 1.4.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.vChewing.vChewingPhraseEditor; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.vChewing.vChewingPhraseEditor;
@ -1297,7 +1235,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1931; CURRENT_PROJECT_VERSION = 1940;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
@ -1316,7 +1254,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.11.5; MACOSX_DEPLOYMENT_TARGET = 10.11.5;
MARKETING_VERSION = 1.3.9; MARKETING_VERSION = 1.4.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.vChewing.vChewingPhraseEditor; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.vChewing.vChewingPhraseEditor;
@ -1431,7 +1369,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1931; CURRENT_PROJECT_VERSION = 1940;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -1466,7 +1404,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.11.5; MACOSX_DEPLOYMENT_TARGET = 10.11.5;
MARKETING_VERSION = 1.3.9; MARKETING_VERSION = 1.4.0;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.inputmethod.vChewing; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.inputmethod.vChewing;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@ -1499,7 +1437,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1931; CURRENT_PROJECT_VERSION = 1940;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
@ -1529,7 +1467,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.11.5; MACOSX_DEPLOYMENT_TARGET = 10.11.5;
MARKETING_VERSION = 1.3.9; MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.inputmethod.vChewing; PRODUCT_BUNDLE_IDENTIFIER = org.atelierInmu.inputmethod.vChewing;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -1613,7 +1551,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1931; CURRENT_PROJECT_VERSION = 1940;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
@ -1638,7 +1576,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.11.5; MACOSX_DEPLOYMENT_TARGET = 10.11.5;
MARKETING_VERSION = 1.3.9; MARKETING_VERSION = 1.4.0;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "org.atelierInmu.vChewing.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_BUNDLE_IDENTIFIER = "org.atelierInmu.vChewing.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@ -1666,7 +1604,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1931; CURRENT_PROJECT_VERSION = 1940;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -1686,7 +1624,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.11.5; MACOSX_DEPLOYMENT_TARGET = 10.11.5;
MARKETING_VERSION = 1.3.9; MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = "org.atelierInmu.vChewing.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_BUNDLE_IDENTIFIER = "org.atelierInmu.vChewing.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";