mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
Merge pull request #13876 from keymanapp/fix/mac/13718-sanskrit-unicode-crash
fix(mac): handle PackageInfo section in kmp.inf file
This commit is contained in:
commit
79d5347c80
4 changed files with 24 additions and 3 deletions
|
|
@ -130,8 +130,15 @@
|
|||
NSArray *pArray = (NSArray *)obj;
|
||||
NSString *packageFolder = [self packageFolderFromPath:[pArray objectAtIndex:0]];
|
||||
NSString *packageName = [self.AppDelegate packageNameFromPackageInfo:packageFolder];
|
||||
os_log_debug([KMLogs uiLog], "tableContents, packageFolder: %{public}@, packageName: %{public}@", packageFolder, packageName);
|
||||
[_tableContents addObject:[NSDictionary dictionaryWithObjectsAndKeys:packageName, @"HeaderTitle", nil]];
|
||||
|
||||
if (packageName) {
|
||||
os_log_debug([KMLogs testLog], "tableContents, packageFolder: %{public}@, packageName: %{public}@", packageFolder, packageName);
|
||||
[_tableContents addObject:[NSDictionary dictionaryWithObjectsAndKeys:packageName, @"HeaderTitle", nil]];
|
||||
} else {
|
||||
os_log_error([KMLogs testLog], "tableContents, no packageName for packageFolder: %{public}@", packageFolder);
|
||||
NSString *noPackageName = NSLocalizedString(@"unknown-package-name", nil);
|
||||
[_tableContents addObject:[NSDictionary dictionaryWithObjectsAndKeys:noPackageName, @"HeaderTitle", nil]];
|
||||
}
|
||||
for (NSString *path in pArray) {
|
||||
os_log_debug([KMLogs uiLog], "tableContents, path = '%{public}@'", path);
|
||||
NSDictionary *info = [KMXFile keyboardInfoFromKmxFile:path];
|
||||
|
|
|
|||
|
|
@ -17,10 +17,14 @@
|
|||
static NSString *const kPackageJsonFile = @"kmp.json";
|
||||
static NSString *const kPackageInfFile = @"kmp.inf";
|
||||
|
||||
// kmp.info section names
|
||||
static NSString *const kPackage = @"[Package]";
|
||||
static NSString *const kButtons = @"[Buttons]";
|
||||
static NSString *const kStartMenu = @"[StartMenu]";
|
||||
static NSString *const kStartMenuEntries = @"[StartMenuEntries]";
|
||||
// kmp.inf files version 5.0 includes a [PackageInfo] section
|
||||
static NSString *const kPackageInfo = @"[PackageInfo]";
|
||||
// kmp.inf files version 6.0 and later replace [PackageInfo] with [Info]
|
||||
static NSString *const kInfo = @"[Info]";
|
||||
static NSString *const kFiles = @"[Files]";
|
||||
|
||||
|
|
@ -211,10 +215,16 @@ typedef enum {
|
|||
contentType = ctStartMenuEntries;
|
||||
continue;
|
||||
}
|
||||
// as of version 6.0, kmp.inf files contain a section [Info]
|
||||
else if ([[line lowercaseString] hasPrefix:[kInfo lowercaseString]]) {
|
||||
contentType = ctInfo;
|
||||
continue;
|
||||
}
|
||||
// version 5.0 kmp.inf files contain a [PackageInfo] section instead
|
||||
else if ([[line lowercaseString] hasPrefix:[kPackageInfo lowercaseString]]) {
|
||||
contentType = ctInfo;
|
||||
continue;
|
||||
}
|
||||
else if ([[line lowercaseString] hasPrefix:[kFiles lowercaseString]]) {
|
||||
contentType = ctFiles;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
/* Message displayed in Configuration window when keyboard metadata cannot be loaded */
|
||||
"message-error-unknown-metadata" = "unknown";
|
||||
|
||||
/* Configuration window section heading when keyboard has no package name */
|
||||
"unknown-package-name" = "Unnamed Keyboard Package";
|
||||
|
||||
/* Button text to acknowledge that .kmp file could not be read */
|
||||
"button-keyboard-file-unreadable" = "OK";
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ NSString *const kKMVisualKeyboardKey = @"KMVisualKeyboardKey";
|
|||
+ (NSDictionary *)keyboardInfoFromKmxFile:(NSString *)path {
|
||||
os_log_info([KMELogs configLog], "keyboardInfoFromKmxFile, path: %{public}@", path);
|
||||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:path];
|
||||
|
||||
os_log_debug([KMELogs configLog], "keyboardInfoFromKmxFile, path: %{public}@", path);
|
||||
|
||||
if (file == nil) {
|
||||
os_log_error([KMELogs configLog], "Failed to open file");
|
||||
return nil;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue