2424NSString *const DConnectServiceInformationProfileParamNFC = @" nfc" ;
2525NSString *const DConnectServiceInformationProfileParamBLE = @" ble" ;
2626
27- static NSString *const KEY_PATHS = @" paths" ;
27+ static NSString *const DConnectServiceInformationProfileKeyPaths = @" paths" ;
28+
29+ static NSString *const DConnectServiceInformationProfileKeyInfo = @" info" ;
30+ static NSString *const DConnectServiceInformationProfileKeyDefinitions = @" definitions" ;
31+ static NSString *const DConnectServiceInformationProfileKeyResponses = @" responses" ;
32+ static NSString *const DConnectServiceInformationProfileKeyParameters = @" parameters" ;
33+ static NSString *const DConnectServiceInformationProfileKeyXEvent = @" x-event" ;
34+ static NSString *const DConnectServiceInformationProfileKeySummary = @" summary" ;
35+ static NSString *const DConnectServiceInformationProfileKeyDescription = @" description" ;
2836
2937@interface DConnectServiceInformationProfile ()
3038
@@ -115,6 +123,8 @@ + (BOOL) setSupportApis:(NSArray *)profiles target:(DConnectMessage *)message er
115123 if (![DConnectServiceInformationProfile createSupportApisBundle: profileSpec profile: profile outBundle: &bundle error: error]) {
116124 return NO ;
117125 }
126+ // 送信しない情報はここで削除
127+ [DConnectServiceInformationProfile reduceInformationForApi: bundle outApi: &bundle];
118128 NSString *profileName = [profile profileName ];
119129 supportApis[profileName] = bundle;
120130 }
@@ -135,7 +145,7 @@ + (BOOL) createSupportApisBundle: (DConnectProfileSpec *) profileSpec profile: (
135145 NSMutableDictionary *tmpBundle = CFBridgingRelease (tmpBundle_);
136146
137147 // API定義(JSONファイルから読み取ったデータ)のうち、プロファイルにAPIが未実装のものは削除する
138- NSMutableDictionary *pathsObj = tmpBundle[KEY_PATHS ];
148+ NSMutableDictionary *pathsObj = tmpBundle[DConnectServiceInformationProfileKeyPaths ];
139149 if (!pathsObj) {
140150 *outBundle = tmpBundle;
141151 return YES ;
@@ -169,6 +179,45 @@ + (BOOL) createSupportApisBundle: (DConnectProfileSpec *) profileSpec profile: (
169179 return YES ;
170180}
171181
182+ + (void ) reduceInformationForApi : (NSDictionary *)api outApi : (NSDictionary **)outApi {
183+ CFPropertyListRef *tmpBundle_ = (CFPropertyListRef *)CFPropertyListCreateDeepCopy (kCFAllocatorDefault ,
184+ (CFDictionaryRef)api,
185+ kCFPropertyListMutableContainersAndLeaves );
186+ NSMutableDictionary *supportApi = CFBridgingRelease (tmpBundle_);
187+ NSMutableDictionary * infoObj = supportApi[DConnectServiceInformationProfileKeyInfo];
188+ if (infoObj != nil ) {
189+ [infoObj removeObjectForKey: DConnectServiceInformationProfileKeyDescription];
190+ }
191+ NSMutableDictionary *pathsObj = supportApi[DConnectServiceInformationProfileKeyPaths];
192+ if (pathsObj != nil ) {
193+ for (NSString *pathName in [pathsObj keyEnumerator ]) {
194+ NSMutableDictionary *pathObj = pathsObj[pathName];
195+ if (pathObj == nil ) {
196+ continue ;
197+ }
198+ for (NSString *method in DConnectSpecMethods ()) {
199+ NSMutableDictionary *methodObj = pathObj[[method lowercaseString ]];
200+ if (methodObj == nil ) {
201+ continue ;
202+ }
203+ [methodObj removeObjectForKey: DConnectServiceInformationProfileKeyResponses];
204+ [methodObj removeObjectForKey: DConnectServiceInformationProfileKeyXEvent];
205+ [methodObj removeObjectForKey: DConnectServiceInformationProfileKeySummary];
206+ [methodObj removeObjectForKey: DConnectServiceInformationProfileKeyDescription];
207+
208+ NSMutableArray *parameters = methodObj[DConnectServiceInformationProfileKeyParameters];
209+ if (parameters != nil ) {
210+ for (NSMutableDictionary *parameter in parameters) {
211+ [parameter removeObjectForKey: DConnectServiceInformationProfileKeyDescription];
212+ }
213+ }
214+ }
215+ }
216+ }
217+ [supportApi removeObjectForKey: DConnectServiceInformationProfileKeyDefinitions];
218+
219+ *outApi = supportApi;
220+ }
172221// NSDictionaryをDConnectMessageに変換
173222+ (DConnectMessage *) convertToDConnectMessageFromNSDictionary : (NSDictionary *)dictionary {
174223
0 commit comments