comparison mac/dw.m @ 2070:370baf78abdc

Mac: Added dw_app_id_set() and updates to generate the APP ID automatically.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 15 May 2020 01:19:55 +0000
parents 3ccd0da07514
children c2f13c5eefac
comparison
equal deleted inserted replaced
2069:b4b49d29b940 2070:370baf78abdc
441 #endif 441 #endif
442 pthread_key_t _dw_fg_color_key; 442 pthread_key_t _dw_fg_color_key;
443 pthread_key_t _dw_bg_color_key; 443 pthread_key_t _dw_bg_color_key;
444 int DWOSMajor, DWOSMinor, DWOSBuild; 444 int DWOSMajor, DWOSMinor, DWOSBuild;
445 static char _dw_bundle_path[PATH_MAX+1] = { 0 }; 445 static char _dw_bundle_path[PATH_MAX+1] = { 0 };
446 static char _dw_app_id[101]= {0};
446 447
447 /* Create a default colors for a thread */ 448 /* Create a default colors for a thread */
448 void _init_colors(void) 449 void _init_colors(void)
449 { 450 {
450 NSColor *fgcolor = [[NSColor grayColor] retain]; 451 NSColor *fgcolor = [[NSColor grayColor] retain];
3938 { 3939 {
3939 return _dw_bundle_path; 3940 return _dw_bundle_path;
3940 } 3941 }
3941 3942
3942 /* 3943 /*
3944 * Sets the application ID used by this Dynamic Windows application instance.
3945 * Parameters:
3946 * appid: A string typically in the form: com.company.division.application
3947 * appguid: A globally unique identifier required on Windows or NULL.
3948 * Returns:
3949 * DW_ERROR_NONE after successfully setting the application ID.
3950 * DW_ERROR_UNKNOWN if unsupported on this system.
3951 * DW_ERROR_GENERAL if the application ID is not allowed.
3952 * Remarks:
3953 * This must be called before dw_init(). If dw_init() is called first
3954 * it will create a unique ID in the form: org.dbsoft.dwindows.application
3955 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.#
3956 * The GUID is only required on Windows, NULL can be passed on other platforms.
3957 */
3958 int dw_app_id_set(const char *appid, const char *appguid)
3959 {
3960 strncpy(_dw_app_id, appid, 100);
3961 return DW_ERROR_NONE;
3962 }
3963
3964 /*
3943 * Displays a debug message on the console... 3965 * Displays a debug message on the console...
3944 * Parameters: 3966 * Parameters:
3945 * format: printf style format string. 3967 * format: printf style format string.
3946 * ...: Additional variables for use in the format. 3968 * ...: Additional variables for use in the format.
3947 */ 3969 */
11992 /* Correct the startup path if run from a bundle */ 12014 /* Correct the startup path if run from a bundle */
11993 if(argc > 0 && argv[0]) 12015 if(argc > 0 && argv[0])
11994 { 12016 {
11995 char *pathcopy = strdup(argv[0]); 12017 char *pathcopy = strdup(argv[0]);
11996 char *app = strstr(pathcopy, ".app/"); 12018 char *app = strstr(pathcopy, ".app/");
11997 12019 char *binname = strrchr(pathcopy, '/');
12020
12021 if(binname && (binname++) && _dw_app_id[0])
12022 {
12023 /* If we have a binary name, use that for the Application ID instead. */
12024 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname);
12025 }
11998 if(app) 12026 if(app)
11999 { 12027 {
12000 char pathbuf[PATH_MAX+1] = { 0 }; 12028 char pathbuf[PATH_MAX+1] = { 0 };
12001 size_t len = (size_t)(app - pathcopy); 12029 size_t len = (size_t)(app - pathcopy);
12002 12030
12075 /* Use NSThread to start a dummy thread to initialize the threading subsystem */ 12103 /* Use NSThread to start a dummy thread to initialize the threading subsystem */
12076 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil]; 12104 NSThread *thread = [[ NSThread alloc] initWithTarget:DWObj selector:@selector(uselessThread:) object:nil];
12077 [thread start]; 12105 [thread start];
12078 [thread release]; 12106 [thread release];
12079 [NSTextField setCellClass:[DWTextFieldCell class]]; 12107 [NSTextField setCellClass:[DWTextFieldCell class]];
12108 if(!_dw_app_id[0])
12109 {
12110 /* Generate an Application ID based on the PID if all else fails. */
12111 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid());
12112 }
12080 return 0; 12113 return 0;
12081 } 12114 }
12082 12115
12083 /* 12116 /*
12084 * Allocates a shared memory region with a name. 12117 * Allocates a shared memory region with a name.