Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@
NSString *const DConnectServiceInformationProfileParamNFC = @"nfc";
NSString *const DConnectServiceInformationProfileParamBLE = @"ble";

static NSString *const KEY_PATHS = @"paths";
static NSString *const DConnectServiceInformationProfileKeyPaths = @"paths";

static NSString *const DConnectServiceInformationProfileKeyInfo = @"info";
static NSString *const DConnectServiceInformationProfileKeyDefinitions = @"definitions";
static NSString *const DConnectServiceInformationProfileKeyResponses = @"responses";
static NSString *const DConnectServiceInformationProfileKeyParameters = @"parameters";
static NSString *const DConnectServiceInformationProfileKeyXEvent = @"x-event";
static NSString *const DConnectServiceInformationProfileKeySummary = @"summary";
static NSString *const DConnectServiceInformationProfileKeyDescription = @"description";

@interface DConnectServiceInformationProfile()

Expand Down Expand Up @@ -115,6 +123,8 @@ + (BOOL) setSupportApis:(NSArray *)profiles target:(DConnectMessage *)message er
if (![DConnectServiceInformationProfile createSupportApisBundle: profileSpec profile: profile outBundle:&bundle error:error]) {
return NO;
}
// 送信しない情報はここで削除
[DConnectServiceInformationProfile reduceInformationForApi:bundle outApi:&bundle];
NSString *profileName = [profile profileName];
supportApis[profileName] = bundle;
}
Expand All @@ -135,7 +145,7 @@ + (BOOL) createSupportApisBundle: (DConnectProfileSpec *) profileSpec profile: (
NSMutableDictionary *tmpBundle = CFBridgingRelease(tmpBundle_);

// API定義(JSONファイルから読み取ったデータ)のうち、プロファイルにAPIが未実装のものは削除する
NSMutableDictionary *pathsObj = tmpBundle[KEY_PATHS];
NSMutableDictionary *pathsObj = tmpBundle[DConnectServiceInformationProfileKeyPaths];
if (!pathsObj) {
*outBundle = tmpBundle;
return YES;
Expand Down Expand Up @@ -169,6 +179,45 @@ + (BOOL) createSupportApisBundle: (DConnectProfileSpec *) profileSpec profile: (
return YES;
}

+ (void) reduceInformationForApi:(NSDictionary*)api outApi:(NSDictionary**)outApi {
CFPropertyListRef *tmpBundle_ = (CFPropertyListRef *)CFPropertyListCreateDeepCopy(kCFAllocatorDefault,
(CFDictionaryRef)api,
kCFPropertyListMutableContainersAndLeaves);
NSMutableDictionary *supportApi = CFBridgingRelease(tmpBundle_);
NSMutableDictionary* infoObj = supportApi[DConnectServiceInformationProfileKeyInfo];
if (infoObj != nil) {
[infoObj removeObjectForKey:DConnectServiceInformationProfileKeyDescription];
}
NSMutableDictionary *pathsObj = supportApi[DConnectServiceInformationProfileKeyPaths];
if (pathsObj != nil) {
for (NSString *pathName in [pathsObj keyEnumerator]) {
NSMutableDictionary *pathObj = pathsObj[pathName];
if (pathObj == nil) {
continue;
}
for (NSString *method in DConnectSpecMethods()) {
NSMutableDictionary *methodObj = pathObj[[method lowercaseString]];
if (methodObj == nil) {
continue;
}
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeyResponses];
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeyXEvent];
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeySummary];
[methodObj removeObjectForKey:DConnectServiceInformationProfileKeyDescription];

NSMutableArray *parameters = methodObj[DConnectServiceInformationProfileKeyParameters];
if (parameters != nil) {
for (NSMutableDictionary *parameter in parameters) {
[parameter removeObjectForKey:DConnectServiceInformationProfileKeyDescription];
}
}
}
}
}
[supportApi removeObjectForKey:DConnectServiceInformationProfileKeyDefinitions];

*outApi = supportApi;
}
// NSDictionaryをDConnectMessageに変換
+ (DConnectMessage *) convertToDConnectMessageFromNSDictionary: (NSDictionary *)dictionary {

Expand Down
8 changes: 4 additions & 4 deletions dConnectSDK/dConnectSDKForIOS/download-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

PROJECT_DIR=$(cd $(dirname $0) && pwd)
TEMP_DIR=${PROJECT_DIR}/temp-`date +%s`
REVISION=feature_plugin_sdk_2.0.0
REVISION=master
SPEC_ZIP_NAME=${REVISION}.zip
SPEC_ZIP_URL=https://github.com/TakayukiHoshi1984/DeviceConnect-Spec/archive/${SPEC_ZIP_NAME}
SPEC_ZIP_URL=https://github.com/DeviceConnect/DeviceConnect-Spec/archive/${SPEC_ZIP_NAME}
SPEC_DIR=${PROJECT_DIR}/DConnectSDK_resources/api

if [ -e ${SPEC_DIR} ]; then
Expand All @@ -18,8 +18,8 @@ cd ${TEMP_DIR}
echo "Download URL: ${SPEC_ZIP_URL}"
curl -L -O -k ${SPEC_ZIP_URL}

unzip -d . ${SPEC_ZIP_NAME}
cp ${TEMP_DIR}/DeviceConnect-Spec-${REVISION}/api/*.json ${SPEC_DIR}
unzip -d . ${SPEC_ZIP_NAME} "*.json"
cp -r ${TEMP_DIR}/DeviceConnect-Spec-${REVISION}/api/*.json ${SPEC_DIR}
rm -rf ${TEMP_DIR}

# ファイル名を小文字に統一
Expand Down