Recognize another magic token sent in the LaunchInfo's EventData.
<rdar://problem/32505028> llvm-svn: 318496
This commit is contained in:
parent
9347b68629
commit
e28a93deff
|
@ -45,6 +45,26 @@
|
|||
#include "CFBundle.h"
|
||||
#include "CFString.h"
|
||||
|
||||
static void SplitEventData(const char *data, std::vector<std::string> &elements)
|
||||
{
|
||||
elements.clear();
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
const char *start = data;
|
||||
|
||||
while (*start != '\0') {
|
||||
const char *token = strchr(start, ':');
|
||||
if (!token) {
|
||||
elements.push_back(std::string(start));
|
||||
return;
|
||||
}
|
||||
if (token != start)
|
||||
elements.push_back(std::string(start, token - start));
|
||||
start = ++token;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_SPRINGBOARD
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
@ -112,7 +132,9 @@ static bool CallBoardSystemServiceOpenApplication(NSString *bundleIDNSStr,
|
|||
if (!cstr)
|
||||
cstr = "<Unknown Bundle ID>";
|
||||
|
||||
DNBLog("About to launch process for bundle ID: %s", cstr);
|
||||
NSString *description = [options description];
|
||||
DNBLog("About to launch process for bundle ID: %s - options:\n%s", cstr,
|
||||
[description UTF8String]);
|
||||
[system_service
|
||||
openApplication:bundleIDNSStr
|
||||
options:options
|
||||
|
@ -222,21 +244,31 @@ static void SetBKSError(NSInteger error_code, DNBError &error) {
|
|||
static bool BKSAddEventDataToOptions(NSMutableDictionary *options,
|
||||
const char *event_data,
|
||||
DNBError &option_error) {
|
||||
if (strcmp(event_data, "BackgroundContentFetching") == 0) {
|
||||
DNBLog("Setting ActivateForEvent key in options dictionary.");
|
||||
NSDictionary *event_details = [NSDictionary dictionary];
|
||||
NSDictionary *event_dictionary = [NSDictionary
|
||||
dictionaryWithObject:event_details
|
||||
forKey:
|
||||
BKSActivateForEventOptionTypeBackgroundContentFetching];
|
||||
[options setObject:event_dictionary
|
||||
forKey:BKSOpenApplicationOptionKeyActivateForEvent];
|
||||
return true;
|
||||
} else {
|
||||
DNBLogError("Unrecognized event type: %s. Ignoring.", event_data);
|
||||
option_error.SetErrorString("Unrecognized event data.");
|
||||
return false;
|
||||
std::vector<std::string> values;
|
||||
SplitEventData(event_data, values);
|
||||
bool found_one = false;
|
||||
for (std::string value : values)
|
||||
{
|
||||
if (value.compare("BackgroundContentFetching") == 0) {
|
||||
DNBLog("Setting ActivateForEvent key in options dictionary.");
|
||||
NSDictionary *event_details = [NSDictionary dictionary];
|
||||
NSDictionary *event_dictionary = [NSDictionary
|
||||
dictionaryWithObject:event_details
|
||||
forKey:
|
||||
BKSActivateForEventOptionTypeBackgroundContentFetching];
|
||||
[options setObject:event_dictionary
|
||||
forKey:BKSOpenApplicationOptionKeyActivateForEvent];
|
||||
found_one = true;
|
||||
} else if (value.compare("ActivateSuspended") == 0) {
|
||||
DNBLog("Setting ActivateSuspended key in options dictionary.");
|
||||
[options setObject:@YES forKey: BKSOpenApplicationOptionKeyActivateSuspended];
|
||||
found_one = true;
|
||||
} else {
|
||||
DNBLogError("Unrecognized event type: %s. Ignoring.", value.c_str());
|
||||
option_error.SetErrorString("Unrecognized event data");
|
||||
}
|
||||
}
|
||||
return found_one;
|
||||
}
|
||||
|
||||
static NSMutableDictionary *BKSCreateOptionsDictionary(
|
||||
|
@ -322,21 +354,31 @@ static void SetFBSError(NSInteger error_code, DNBError &error) {
|
|||
static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
|
||||
const char *event_data,
|
||||
DNBError &option_error) {
|
||||
if (strcmp(event_data, "BackgroundContentFetching") == 0) {
|
||||
DNBLog("Setting ActivateForEvent key in options dictionary.");
|
||||
NSDictionary *event_details = [NSDictionary dictionary];
|
||||
NSDictionary *event_dictionary = [NSDictionary
|
||||
dictionaryWithObject:event_details
|
||||
forKey:
|
||||
FBSActivateForEventOptionTypeBackgroundContentFetching];
|
||||
[options setObject:event_dictionary
|
||||
forKey:FBSOpenApplicationOptionKeyActivateForEvent];
|
||||
return true;
|
||||
} else {
|
||||
DNBLogError("Unrecognized event type: %s. Ignoring.", event_data);
|
||||
option_error.SetErrorString("Unrecognized event data.");
|
||||
return false;
|
||||
std::vector<std::string> values;
|
||||
SplitEventData(event_data, values);
|
||||
bool found_one = false;
|
||||
for (std::string value : values)
|
||||
{
|
||||
if (value.compare("BackgroundContentFetching") == 0) {
|
||||
DNBLog("Setting ActivateForEvent key in options dictionary.");
|
||||
NSDictionary *event_details = [NSDictionary dictionary];
|
||||
NSDictionary *event_dictionary = [NSDictionary
|
||||
dictionaryWithObject:event_details
|
||||
forKey:
|
||||
FBSActivateForEventOptionTypeBackgroundContentFetching];
|
||||
[options setObject:event_dictionary
|
||||
forKey:FBSOpenApplicationOptionKeyActivateForEvent];
|
||||
found_one = true;
|
||||
} else if (value.compare("ActivateSuspended") == 0) {
|
||||
DNBLog("Setting ActivateSuspended key in options dictionary.");
|
||||
[options setObject:@YES forKey: FBSOpenApplicationOptionKeyActivateSuspended];
|
||||
found_one = true;
|
||||
} else {
|
||||
DNBLogError("Unrecognized event type: %s. Ignoring.", value.c_str());
|
||||
option_error.SetErrorString("Unrecognized event data.");
|
||||
}
|
||||
}
|
||||
return found_one;
|
||||
}
|
||||
|
||||
static NSMutableDictionary *
|
||||
|
|
Loading…
Reference in New Issue