#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>
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
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(
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 *