this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

LaunchServices: Build a database of URL scheme handlers

+60
+35
src/frameworks/CoreServices/src/LaunchServices/launchservicesd/LSBundle.m
··· 269 269 } 270 270 } 271 271 272 + -(void)processURLTypes 273 + { 274 + NSDictionary* infoDict = (NSDictionary*) CFBundleGetInfoDictionary(_bundle); 275 + NSArray<NSDictionary*>* urlTypes = (NSArray*) infoDict[@"CFBundleURLTypes"]; 276 + NSNumber* myId = [NSNumber numberWithInt: _bundleId]; 277 + 278 + [g_database executeUpdate:@"delete from bundle_url_type where bundle = ?", myId]; 279 + if (urlTypes != nil) 280 + { 281 + for (NSDictionary<NSString*, id>* type in urlTypes) 282 + { 283 + NSString* role = type[@"CFBundleTypeRole"]; 284 + NSString* iconFile = type[@"CFBundleURLTypes"]; 285 + NSString* name = type[@"CFBundleURLName"]; 286 + 287 + if (role == nil) 288 + role = @"None"; 289 + 290 + NSArray<NSString*>* schemes = type[@"CFBundleURLSchemes"]; 291 + 292 + [g_database executeUpdate:@"insert into bundle_url_type (bundle, role, name, icon) values (?,?,?,?)", 293 + myId, role, name, iconFile]; 294 + 295 + if (schemes) 296 + { 297 + NSNumber* typeId = [NSNumber numberWithInt:[g_database lastInsertRowId]]; 298 + 299 + for (NSString* scheme in schemes) 300 + [g_database executeUpdate:@"insert into bundle_url_type_scheme (type, scheme) values (?,?)", typeId, scheme]; 301 + } 302 + } 303 + } 304 + } 305 + 272 306 -(BOOL)setupBundleID 273 307 { 274 308 NSURL* url = (NSURL*) CFBundleCopyBundleURL(_bundle); ··· 353 387 } 354 388 355 389 [self processFileAssociations]; 390 + [self processURLTypes]; 356 391 [g_database commit]; 357 392 } 358 393
+25
src/frameworks/CoreServices/src/LaunchServices/launchservicesd/schema.sql
··· 70 70 FOREIGN KEY(`bundle`) REFERENCES `bundle`(`id`) ON DELETE CASCADE 71 71 ); 72 72 CREATE INDEX `app_doc_bundle_index` ON `app_doc`(`bundle`); 73 + CREATE INDEX `app_doc_role_index` ON `app_doc`(`role`); 74 + CREATE INDEX `app_doc_rank_index` ON `app_doc`(`rank`); 73 75 74 76 -- LSItemContentTypes 75 77 CREATE TABLE `app_doc_uti` ( ··· 100 102 ); 101 103 CREATE INDEX `app_doc_extension_doc_index` ON `app_doc_extension`(`doc`); 102 104 CREATE INDEX `app_doc_extension_index` ON `app_doc_extension`(`extension`); 105 + 106 + -- CFBundleURLTypes 107 + CREATE TABLE `bundle_url_type` ( 108 + `id` INTEGER PRIMARY KEY AUTOINCREMENT, 109 + `bundle` INTEGER, 110 + `role` TEXT NOT NULL, 111 + `name` TEXT, 112 + `icon` TEXT, 113 + FOREIGN KEY(`bundle`) REFERENCES `bundle`(`id`) ON DELETE CASCADE 114 + ); 115 + CREATE INDEX `bundle_url_type_bundle` ON `bundle_url_type`(`bundle`); 116 + CREATE INDEX `bundle_url_type_role_index` ON `bundle_url_type`(`role`); 117 + 118 + -- CFBundleURLSchemes 119 + 120 + CREATE TABLE `bundle_url_type_scheme` ( 121 + `id` INTEGER PRIMARY KEY AUTOINCREMENT, 122 + `type` INTEGER, 123 + `scheme` TEXT NOT NULL COLLATE NOCASE, 124 + FOREIGN KEY(`type`) REFERENCES `bundle_url_type`(`id`) ON DELETE CASCADE 125 + ); 126 + CREATE INDEX `bundle_url_type_scheme_type_index` ON `bundle_url_type_scheme`(`type`); 127 + CREATE INDEX `bundle_url_type_scheme_scheme_index` ON `bundle_url_type_scheme`(`scheme`);