/PlayphoneExample/PlayPhoneMultiNet/providers/MNWSProvider.m

https://github.com/PPUA/PlayPhoneSDKDemoIOS · Objective C · 1136 lines · 763 code · 367 blank · 6 comment · 63 complexity · 247e0d2878a82457950f414578fd4fc3 MD5 · raw file

  1. //
  2. // MNWSProvider.m
  3. // MultiNet client
  4. //
  5. // Copyright 2012 PlayPhone. All rights reserved.
  6. //
  7. #import "MNWSRequest.h"
  8. #import "MNWSProvider.h"
  9. @interface MNWSRequestContent()
  10. -(NSString*) addCurrUserSubscriptionStatusForSnId:(NSInteger) snId;
  11. @end
  12. @interface MNWSInfoRequest()
  13. -(void) handleRequestCompleted:(MNWSResponse*) response;
  14. -(void) handleRequestError:(MNWSRequestError*) error;
  15. -(void) addContent:(MNWSRequestContent*) content;
  16. @end
  17. @interface MNWSInfoRequestResult()
  18. -(void) setError:(NSString*) errorMessage;
  19. @end
  20. @interface MNWSProviderRequestDelegate : NSObject<MNWSRequestDelegate> {
  21. @private
  22. NSArray* _requests;
  23. }
  24. -(id) initWithMNWSInfoRequests:(NSArray*) requests;
  25. @end
  26. @implementation MNWSInfoRequest
  27. -(void) handleRequestCompleted:(MNWSResponse*) response {
  28. }
  29. -(void) handleRequestError:(MNWSRequestError*) error {
  30. }
  31. -(void) addContent:(MNWSRequestContent*) content {
  32. }
  33. @end
  34. @implementation MNWSInfoRequestResult
  35. -(id) init {
  36. self = [super init];
  37. if (self != nil) {
  38. _failed = false;
  39. _errorMessage = nil;
  40. }
  41. return self;
  42. }
  43. -(void) dealloc {
  44. [_errorMessage release];
  45. [super dealloc];
  46. }
  47. -(void) setError:(NSString*) errorMessage {
  48. _failed = YES;
  49. [_errorMessage release];
  50. _errorMessage = [errorMessage retain];
  51. }
  52. -(BOOL) hadError {
  53. return _failed;
  54. }
  55. -(NSString*) getErrorMessage {
  56. return _errorMessage;
  57. }
  58. @end
  59. @implementation MNWSProviderRequestDelegate
  60. -(id) initWithMNWSInfoRequests:(NSArray *)requests {
  61. self = [super init];
  62. if (self != nil) {
  63. _requests = [requests retain];
  64. }
  65. return self;
  66. }
  67. -(void) dealloc {
  68. [_requests release];
  69. [super dealloc];
  70. }
  71. -(void) wsRequestDidSucceed:(MNWSResponse*) response {
  72. for (MNWSInfoRequest* request in _requests) {
  73. [request handleRequestCompleted: response];
  74. }
  75. [self autorelease];
  76. }
  77. -(void) wsRequestDidFailWithError:(MNWSRequestError*) error {
  78. for (MNWSInfoRequest* request in _requests) {
  79. [request handleRequestError: error];
  80. }
  81. [self autorelease];
  82. }
  83. @end
  84. @implementation MNWSLoader
  85. -(id) initWithMNWSRequest:(MNWSRequest*) request {
  86. self = [super init];
  87. if (self != nil) {
  88. _request = request;
  89. }
  90. return self;
  91. }
  92. -(void) cancel {
  93. [_request cancel];
  94. }
  95. @end
  96. @implementation MNWSProvider
  97. -(id) initWithSession: (MNSession*) session {
  98. self = [super init];
  99. if (self != nil) {
  100. _session = session;
  101. }
  102. return self;
  103. }
  104. -(MNWSLoader*) send:(MNWSInfoRequest*) request {
  105. return [self sendBatch: [NSArray arrayWithObject: request]];
  106. }
  107. -(MNWSLoader*) sendBatch:(NSArray*) requests {
  108. MNWSRequestSender* sender = [[MNWSRequestSender alloc] initWithSession: _session];
  109. MNWSRequestContent* content = [[MNWSRequestContent alloc] init];
  110. MNWSProviderRequestDelegate* delegate = [[MNWSProviderRequestDelegate alloc] initWithMNWSInfoRequests: requests];
  111. for (MNWSInfoRequest* request in requests) {
  112. [request addContent: content];
  113. }
  114. MNWSLoader* loader = [[[MNWSLoader alloc] initWithMNWSRequest: [sender sendWSRequestSmartAuth: content withDelegate: delegate]] autorelease];
  115. [sender release];
  116. [content release];
  117. return loader;
  118. }
  119. @end
  120. @implementation MNWSInfoRequestResultAnyGame
  121. -(id) initWithMNWSAnyGameItem:(MNWSAnyGameItem*) data {
  122. self = [super init];
  123. if (self != nil) {
  124. _data = [data retain];
  125. }
  126. return self;
  127. }
  128. -(void) dealloc {
  129. [_data release];
  130. [super dealloc];
  131. }
  132. -(MNWSAnyGameItem*) getDataEntry {
  133. return _data;
  134. }
  135. @end
  136. @implementation MNWSInfoRequestAnyGame
  137. +(id) mnWSInfoRequestAnyGameWithGameId:(NSInteger) gameId andDelegate:(id<MNWSInfoRequestAnyGameDelegate>) delegate {
  138. return [[[MNWSInfoRequestAnyGame alloc] initWSInfoRequestAnyGameWithGameId: gameId andDelegate: delegate] autorelease];
  139. }
  140. -(id) initWSInfoRequestAnyGameWithGameId:(NSInteger) gameId andDelegate:(id<MNWSInfoRequestAnyGameDelegate>) delegate {
  141. self = [super init];
  142. if (self != nil) {
  143. _gameId = gameId;
  144. _delegate = [delegate retain];
  145. _blockName = nil;
  146. }
  147. return self;
  148. }
  149. -(void) dealloc {
  150. [_delegate release];
  151. [_blockName release];
  152. [super dealloc];
  153. }
  154. -(void) handleRequestCompleted:(MNWSResponse*) response {
  155. MNWSInfoRequestResultAnyGame* result = [[MNWSInfoRequestResultAnyGame alloc] initWithMNWSAnyGameItem: [response getDataForBlock: _blockName]];
  156. [_delegate mnWSInfoRequestAnyGameCompleted: result];
  157. [result release];
  158. }
  159. -(void) handleRequestError:(MNWSRequestError*) error {
  160. MNWSInfoRequestResultAnyGame* result = [[MNWSInfoRequestResultAnyGame alloc] init];
  161. [result setError: error.message];
  162. [_delegate mnWSInfoRequestAnyGameCompleted: result];
  163. [result release];
  164. }
  165. -(void) addContent:(MNWSRequestContent*) content {
  166. [_blockName release];
  167. _blockName = [[content addAnyGame: _gameId] retain];
  168. }
  169. @end
  170. @implementation MNWSInfoRequestResultAnyUser
  171. -(id) initWithMNWSAnyUserItem:(MNWSAnyUserItem*) data {
  172. self = [super init];
  173. if (self != nil) {
  174. _data = [data retain];
  175. }
  176. return self;
  177. }
  178. -(void) dealloc {
  179. [_data release];
  180. [super dealloc];
  181. }
  182. -(MNWSAnyUserItem*) getDataEntry {
  183. return _data;
  184. }
  185. @end
  186. @implementation MNWSInfoRequestAnyUser
  187. +(id) mnWSInfoRequestAnyUserWithUserId:(MNUserId) userId andDelegate:(id<MNWSInfoRequestAnyUserDelegate>) delegate {
  188. return [[[MNWSInfoRequestAnyUser alloc] initWSInfoRequestAnyUserWithUserId: userId andDelegate: delegate] autorelease];
  189. }
  190. -(id) initWSInfoRequestAnyUserWithUserId:(MNUserId) userId andDelegate:(id<MNWSInfoRequestAnyUserDelegate>) delegate {
  191. self = [super init];
  192. if (self != nil) {
  193. _userId = userId;
  194. _delegate = [delegate retain];
  195. _blockName = nil;
  196. }
  197. return self;
  198. }
  199. -(void) dealloc {
  200. [_delegate release];
  201. [_blockName release];
  202. [super dealloc];
  203. }
  204. -(void) handleRequestCompleted:(MNWSResponse*) response {
  205. MNWSInfoRequestResultAnyUser* result = [[MNWSInfoRequestResultAnyUser alloc] initWithMNWSAnyUserItem: [response getDataForBlock: _blockName]];
  206. [_delegate mnWSInfoRequestAnyUserCompleted: result];
  207. [result release];
  208. }
  209. -(void) handleRequestError:(MNWSRequestError*) error {
  210. MNWSInfoRequestResultAnyUser* result = [[MNWSInfoRequestResultAnyUser alloc] init];
  211. [result setError: error.message];
  212. [_delegate mnWSInfoRequestAnyUserCompleted: result];
  213. [result release];
  214. }
  215. -(void) addContent:(MNWSRequestContent*) content {
  216. [_blockName release];
  217. _blockName = [[content addAnyUser: _userId] retain];
  218. }
  219. @end
  220. @implementation MNWSInfoRequestResultAnyUserGameCookies
  221. -(id) initWithMNWSUserGameCookieList:(NSArray*) data {
  222. self = [super init];
  223. if (self != nil) {
  224. _data = [data retain];
  225. }
  226. return self;
  227. }
  228. -(void) dealloc {
  229. [_data release];
  230. [super dealloc];
  231. }
  232. -(NSArray*) getDataEntry {
  233. return _data;
  234. }
  235. @end
  236. @implementation MNWSInfoRequestAnyUserGameCookies
  237. +(id) mnWSInfoRequestAnyUserGameCookiesWithUserIdList:(NSArray*) userIdList
  238. cookieKeyList:(NSArray*) cookieKeyList
  239. andDelegate:(id<MNWSInfoRequestAnyUserGameCookiesDelegate>) delegate {
  240. return [[[MNWSInfoRequestAnyUserGameCookies alloc] initWSInfoRequestAnyUserGameCookiesWithUserIdList: userIdList
  241. cookieKeyList: cookieKeyList
  242. andDelegate: delegate] autorelease];
  243. }
  244. -(id) initWSInfoRequestAnyUserGameCookiesWithUserIdList:(NSArray*) userIdList
  245. cookieKeyList:(NSArray*) cookieKeyList
  246. andDelegate:(id<MNWSInfoRequestAnyUserGameCookiesDelegate>) delegate {
  247. self = [super init];
  248. if (self != nil) {
  249. _userIdList = [userIdList retain];
  250. _cookieKeyList = [cookieKeyList retain];
  251. _delegate = [delegate retain];
  252. _blockName = nil;
  253. }
  254. return self;
  255. }
  256. -(void) dealloc {
  257. [_userIdList release];
  258. [_cookieKeyList release];
  259. [_delegate release];
  260. [_blockName release];
  261. [super dealloc];
  262. }
  263. -(void) handleRequestCompleted:(MNWSResponse*) response {
  264. MNWSInfoRequestResultAnyUserGameCookies* result = [[MNWSInfoRequestResultAnyUserGameCookies alloc] initWithMNWSUserGameCookieList: [response getDataForBlock: _blockName]];
  265. [_delegate mnWSInfoRequestAnyUserGameCookiesCompleted: result];
  266. [result release];
  267. }
  268. -(void) handleRequestError:(MNWSRequestError*) error {
  269. MNWSInfoRequestResultAnyUserGameCookies* result = [[MNWSInfoRequestResultAnyUserGameCookies alloc] init];
  270. [result setError: error.message];
  271. [_delegate mnWSInfoRequestAnyUserGameCookiesCompleted: result];
  272. [result release];
  273. }
  274. -(void) addContent:(MNWSRequestContent*) content {
  275. [_blockName release];
  276. _blockName = [[content addAnyUserGameCookies: _userIdList withKeys: _cookieKeyList] retain];
  277. }
  278. @end
  279. @implementation MNWSInfoRequestResultCurrGameRoomList
  280. -(id) initWithMNWSRoomList:(NSArray*) data {
  281. self = [super init];
  282. if (self != nil) {
  283. _data = [data retain];
  284. }
  285. return self;
  286. }
  287. -(void) dealloc {
  288. [_data release];
  289. [super dealloc];
  290. }
  291. -(NSArray*) getDataEntry {
  292. return _data;
  293. }
  294. @end
  295. @implementation MNWSInfoRequestCurrGameRoomList
  296. +(id) mnWSInfoRequestCurrGameRoomListWithDelegate:(id<MNWSInfoRequestCurrGameRoomListDelegate>) delegate {
  297. return [[[MNWSInfoRequestCurrGameRoomList alloc] initWSInfoRequestCurrGameRoomListWithDelegate: delegate] autorelease];
  298. }
  299. -(id) initWSInfoRequestCurrGameRoomListWithDelegate:(id<MNWSInfoRequestCurrGameRoomListDelegate>) delegate {
  300. self = [super init];
  301. if (self != nil) {
  302. _delegate = [delegate retain];
  303. _blockName = nil;
  304. }
  305. return self;
  306. }
  307. -(void) dealloc {
  308. [_delegate release];
  309. [_blockName release];
  310. [super dealloc];
  311. }
  312. -(void) handleRequestCompleted:(MNWSResponse*) response {
  313. MNWSInfoRequestResultCurrGameRoomList* result = [[MNWSInfoRequestResultCurrGameRoomList alloc] initWithMNWSRoomList: [response getDataForBlock: _blockName]];
  314. [_delegate mnWSInfoRequestCurrGameRoomListCompleted: result];
  315. [result release];
  316. }
  317. -(void) handleRequestError:(MNWSRequestError*) error {
  318. MNWSInfoRequestResultCurrGameRoomList* result = [[MNWSInfoRequestResultCurrGameRoomList alloc] init];
  319. [result setError: error.message];
  320. [_delegate mnWSInfoRequestCurrGameRoomListCompleted: result];
  321. [result release];
  322. }
  323. -(void) addContent:(MNWSRequestContent*) content {
  324. [_blockName release];
  325. _blockName = [[content addCurrGameRoomList] retain];
  326. }
  327. @end
  328. @implementation MNWSInfoRequestResultCurrGameRoomUserList
  329. -(id) initWithMNWSRoomUserInfoList:(NSArray*) data {
  330. self = [super init];
  331. if (self != nil) {
  332. _data = [data retain];
  333. }
  334. return self;
  335. }
  336. -(void) dealloc {
  337. [_data release];
  338. [super dealloc];
  339. }
  340. -(NSArray*) getDataEntry {
  341. return _data;
  342. }
  343. @end
  344. @implementation MNWSInfoRequestCurrGameRoomUserList
  345. +(id) mnWSInfoRequestCurrGameRoomUserListWithRoomSFId:(NSInteger) roomSFId
  346. andDelegate:(id<MNWSInfoRequestCurrGameRoomUserListDelegate>) delegate {
  347. return [[[MNWSInfoRequestCurrGameRoomUserList alloc] initWSInfoRequestCurrGameRoomUserListWithRoomSFId: roomSFId
  348. andDelegate: delegate] autorelease];
  349. }
  350. -(id) initWSInfoRequestCurrGameRoomUserListWithRoomSFId:(NSInteger) roomSFId
  351. andDelegate:(id<MNWSInfoRequestCurrGameRoomUserListDelegate>)delegate {
  352. self = [super init];
  353. if (self != nil) {
  354. _roomSFId = roomSFId;
  355. _delegate = [delegate retain];
  356. _blockName = nil;
  357. }
  358. return self;
  359. }
  360. -(void) dealloc {
  361. [_delegate release];
  362. [_blockName release];
  363. [super dealloc];
  364. }
  365. -(void) handleRequestCompleted:(MNWSResponse*) response {
  366. MNWSInfoRequestResultCurrGameRoomUserList* result = [[MNWSInfoRequestResultCurrGameRoomUserList alloc] initWithMNWSRoomUserInfoList: [response getDataForBlock: _blockName]];
  367. [_delegate mnWSInfoRequestCurrGameRoomUserListCompleted: result];
  368. [result release];
  369. }
  370. -(void) handleRequestError:(MNWSRequestError*) error {
  371. MNWSInfoRequestResultCurrGameRoomUserList* result = [[MNWSInfoRequestResultCurrGameRoomUserList alloc] init];
  372. [result setError: error.message];
  373. [_delegate mnWSInfoRequestCurrGameRoomUserListCompleted: result];
  374. [result release];
  375. }
  376. -(void) addContent:(MNWSRequestContent*) content {
  377. [_blockName release];
  378. _blockName = [[content addCurrGameRoomUserList: _roomSFId] retain];
  379. }
  380. @end
  381. @implementation MNWSInfoRequestResultCurrUserBuddyList
  382. -(id) initWithMNWSBuddyList:(NSArray*) data {
  383. self = [super init];
  384. if (self != nil) {
  385. _data = [data retain];
  386. }
  387. return self;
  388. }
  389. -(void) dealloc {
  390. [_data release];
  391. [super dealloc];
  392. }
  393. -(NSArray*) getDataEntry {
  394. return _data;
  395. }
  396. @end
  397. @implementation MNWSInfoRequestCurrUserBuddyList
  398. +(id) mnWSInfoRequestCurrUserBuddyListWithDelegate:(id<MNWSInfoRequestCurrUserBuddyListDelegate>) delegate {
  399. return [[[MNWSInfoRequestCurrUserBuddyList alloc] initWSInfoRequestCurrUserBuddyListWithDelegate: delegate] autorelease];
  400. }
  401. -(id) initWSInfoRequestCurrUserBuddyListWithDelegate:(id<MNWSInfoRequestCurrUserBuddyListDelegate>)delegate {
  402. self = [super init];
  403. if (self != nil) {
  404. _delegate = [delegate retain];
  405. _blockName = nil;
  406. }
  407. return self;
  408. }
  409. -(void) dealloc {
  410. [_delegate release];
  411. [_blockName release];
  412. [super dealloc];
  413. }
  414. -(void) handleRequestCompleted:(MNWSResponse*) response {
  415. MNWSInfoRequestResultCurrUserBuddyList* result = [[MNWSInfoRequestResultCurrUserBuddyList alloc] initWithMNWSBuddyList: [response getDataForBlock: _blockName]];
  416. [_delegate mnWSInfoRequestCurrUserBuddyListCompleted: result];
  417. [result release];
  418. }
  419. -(void) handleRequestError:(MNWSRequestError*) error {
  420. MNWSInfoRequestResultCurrUserBuddyList* result = [[MNWSInfoRequestResultCurrUserBuddyList alloc] init];
  421. [result setError: error.message];
  422. [_delegate mnWSInfoRequestCurrUserBuddyListCompleted: result];
  423. [result release];
  424. }
  425. -(void) addContent:(MNWSRequestContent*) content {
  426. [_blockName release];
  427. _blockName = [[content addCurrUserBuddyList] retain];
  428. }
  429. @end
  430. @implementation MNWSInfoRequestResultCurrUserSubscriptionStatus
  431. -(id) initWithMNWSSubscriptionStatus:(MNWSCurrUserSubscriptionStatus*) data {
  432. self = [super init];
  433. if (self != nil) {
  434. _data = [data retain];
  435. }
  436. return self;
  437. }
  438. -(void) dealloc {
  439. [_data release];
  440. [super dealloc];
  441. }
  442. -(MNWSCurrUserSubscriptionStatus*) getDataEntry {
  443. return _data;
  444. }
  445. @end
  446. @implementation MNWSInfoRequestCurrUserSubscriptionStatus
  447. +(id) mnWSInfoRequestCurrUserSubscriptionStatusWithDelegate:(id<MNWSInfoRequestCurrUserSubscriptionStatusDelegate>) delegate {
  448. return [[[MNWSInfoRequestCurrUserSubscriptionStatus alloc] initWSInfoRequestCurrUserSubscriptionStatusWithDelegate: delegate] autorelease];
  449. }
  450. -(id) initWSInfoRequestCurrUserSubscriptionStatusWithDelegate:(id<MNWSInfoRequestCurrUserSubscriptionStatusDelegate>)delegate {
  451. self = [super init];
  452. if (self != nil) {
  453. _socNetId = MNWSSNIdPlayPhone;
  454. _delegate = [delegate retain];
  455. _blockName = nil;
  456. }
  457. return self;
  458. }
  459. -(void) dealloc {
  460. [_delegate release];
  461. [_blockName release];
  462. [super dealloc];
  463. }
  464. -(void) handleRequestCompleted:(MNWSResponse*) response {
  465. MNWSInfoRequestResultCurrUserSubscriptionStatus* result = [[MNWSInfoRequestResultCurrUserSubscriptionStatus alloc] initWithMNWSSubscriptionStatus: [response getDataForBlock: _blockName]];
  466. [_delegate mnWSInfoRequestCurrUserSubscriptionStatusCompleted: result];
  467. [result release];
  468. }
  469. -(void) handleRequestError:(MNWSRequestError*) error {
  470. MNWSInfoRequestResultCurrUserSubscriptionStatus* result = [[MNWSInfoRequestResultCurrUserSubscriptionStatus alloc] init];
  471. [result setError: error.message];
  472. [_delegate mnWSInfoRequestCurrUserSubscriptionStatusCompleted: result];
  473. [result release];
  474. }
  475. -(void) addContent:(MNWSRequestContent*) content {
  476. [_blockName release];
  477. _blockName = [[content addCurrUserSubscriptionStatusForSnId: _socNetId] retain];
  478. }
  479. @end
  480. @implementation MNWSInfoRequestResultCurrentUserInfo
  481. -(id) initWithMNWSCurrentUserInfo:(MNWSCurrentUserInfo*) data {
  482. self = [super init];
  483. if (self != nil) {
  484. _data = [data retain];
  485. }
  486. return self;
  487. }
  488. -(void) dealloc {
  489. [_data release];
  490. [super dealloc];
  491. }
  492. -(MNWSCurrentUserInfo*) getDataEntry {
  493. return _data;
  494. }
  495. @end
  496. @implementation MNWSInfoRequestCurrentUserInfo
  497. +(id) mnWSInfoRequestCurrentUserInfoWithDelegate:(id<MNWSInfoRequestCurrentUserInfoDelegate>) delegate {
  498. return [[[MNWSInfoRequestCurrentUserInfo alloc] initWSInfoRequestCurrentUserInfoWithDelegate: delegate] autorelease];
  499. }
  500. -(id) initWSInfoRequestCurrentUserInfoWithDelegate:(id<MNWSInfoRequestCurrentUserInfoDelegate>)delegate {
  501. self = [super init];
  502. if (self != nil) {
  503. _delegate = [delegate retain];
  504. _blockName = nil;
  505. }
  506. return self;
  507. }
  508. -(void) dealloc {
  509. [_delegate release];
  510. [_blockName release];
  511. [super dealloc];
  512. }
  513. -(void) handleRequestCompleted:(MNWSResponse*) response {
  514. MNWSInfoRequestResultCurrentUserInfo* result = [[MNWSInfoRequestResultCurrentUserInfo alloc] initWithMNWSCurrentUserInfo: [response getDataForBlock: _blockName]];
  515. [_delegate mnWSInfoRequestCurrentUserInfoCompleted: result];
  516. [result release];
  517. }
  518. -(void) handleRequestError:(MNWSRequestError*) error {
  519. MNWSInfoRequestResultCurrentUserInfo* result = [[MNWSInfoRequestResultCurrentUserInfo alloc] init];
  520. [result setError: error.message];
  521. [_delegate mnWSInfoRequestCurrentUserInfoCompleted: result];
  522. [result release];
  523. }
  524. -(void) addContent:(MNWSRequestContent*) content {
  525. [_blockName release];
  526. _blockName = [[content addCurrentUserInfo] retain];
  527. }
  528. @end
  529. @implementation MNWSInfoRequestResultSessionSignedClientToken
  530. -(id) initWithMNWSSessionSignedClientToken:(MNWSSessionSignedClientToken*) data {
  531. self = [super init];
  532. if (self != nil) {
  533. _data = [data retain];
  534. }
  535. return self;
  536. }
  537. -(void) dealloc {
  538. [_data release];
  539. [super dealloc];
  540. }
  541. -(MNWSSessionSignedClientToken*) getDataEntry {
  542. return _data;
  543. }
  544. @end
  545. @implementation MNWSInfoRequestSessionSignedClientToken
  546. +(id) mnWSInfoRequestSessionSignedClientTokenWithPayload:(NSString*) payload
  547. andDelegate:(id<MNWSInfoRequestSessionSignedClientTokenDelegate>) delegate {
  548. return [[[MNWSInfoRequestSessionSignedClientToken alloc] initWSInfoRequestSessionSignedClientTokenWithPayload: payload andDelegate: delegate] autorelease];
  549. }
  550. -(id) initWSInfoRequestSessionSignedClientTokenWithPayload:(NSString*) payload
  551. andDelegate:(id<MNWSInfoRequestSessionSignedClientTokenDelegate>) delegate {
  552. self = [super init];
  553. if (self != nil) {
  554. _payload = [payload retain];
  555. _delegate = [delegate retain];
  556. _blockName = nil;
  557. }
  558. return self;
  559. }
  560. -(void) dealloc {
  561. [_payload release];
  562. [_delegate release];
  563. [_blockName release];
  564. [super dealloc];
  565. }
  566. -(void) handleRequestCompleted:(MNWSResponse*) response {
  567. MNWSInfoRequestResultSessionSignedClientToken* result = [[MNWSInfoRequestResultSessionSignedClientToken alloc] initWithMNWSSessionSignedClientToken: [response getDataForBlock: _blockName]];
  568. [_delegate mnWSInfoRequestSessionSignedClientTokenCompleted: result];
  569. [result release];
  570. }
  571. -(void) handleRequestError:(MNWSRequestError*) error {
  572. MNWSInfoRequestResultSessionSignedClientToken* result = [[MNWSInfoRequestResultSessionSignedClientToken alloc] init];
  573. [result setError: error.message];
  574. [_delegate mnWSInfoRequestSessionSignedClientTokenCompleted: result];
  575. [result release];
  576. }
  577. -(void) addContent:(MNWSRequestContent*) content {
  578. [_blockName release];
  579. _blockName = [[content addGetSessionSignedClientToken: _payload] retain];
  580. }
  581. @end
  582. @implementation MNWSInfoRequestResultSystemGameNetStats
  583. -(id) initWithMNWSSystemGameNetStats:(MNWSSystemGameNetStats*) data {
  584. self = [super init];
  585. if (self != nil) {
  586. _data = [data retain];
  587. }
  588. return self;
  589. }
  590. -(void) dealloc {
  591. [_data release];
  592. [super dealloc];
  593. }
  594. -(MNWSSystemGameNetStats*) getDataEntry {
  595. return _data;
  596. }
  597. @end
  598. @implementation MNWSInfoRequestSystemGameNetStats
  599. +(id) mnWSInfoRequestSystemGameNetStatsWithDelegate:(id<MNWSInfoRequestSystemGameNetStatsDelegate>) delegate {
  600. return [[[MNWSInfoRequestSystemGameNetStats alloc] initWSInfoRequestSystemGameNetStatsWithDelegate: delegate] autorelease];
  601. }
  602. -(id) initWSInfoRequestSystemGameNetStatsWithDelegate:(id<MNWSInfoRequestSystemGameNetStatsDelegate>) delegate {
  603. self = [super init];
  604. if (self != nil) {
  605. _delegate = [delegate retain];
  606. _blockName = nil;
  607. }
  608. return self;
  609. }
  610. -(void) dealloc {
  611. [_delegate release];
  612. [_blockName release];
  613. [super dealloc];
  614. }
  615. -(void) handleRequestCompleted:(MNWSResponse*) response {
  616. MNWSInfoRequestResultSystemGameNetStats* result = [[MNWSInfoRequestResultSystemGameNetStats alloc] initWithMNWSSystemGameNetStats: [response getDataForBlock: _blockName]];
  617. [_delegate mnWSInfoRequestSystemGameNetStatsCompleted: result];
  618. [result release];
  619. }
  620. -(void) handleRequestError:(MNWSRequestError*) error {
  621. MNWSInfoRequestResultSystemGameNetStats* result = [[MNWSInfoRequestResultSystemGameNetStats alloc] init];
  622. [result setError: error.message];
  623. [_delegate mnWSInfoRequestSystemGameNetStatsCompleted: result];
  624. [result release];
  625. }
  626. -(void) addContent:(MNWSRequestContent*) content {
  627. [_blockName release];
  628. _blockName = [[content addSystemGameNetStats] retain];
  629. }
  630. @end
  631. @implementation MNWSInfoRequestLeaderboardMode
  632. -(NSString*) addContent:(MNWSRequestContent*) content {
  633. return nil;
  634. }
  635. @end
  636. @implementation MNWSInfoRequestLeaderboardModeCurrentUser
  637. +(id) mnWSInfoRequestLeaderboardModeCurrentUserWithScope:(NSInteger) scope andPeriod:(NSInteger) period {
  638. return [[[MNWSInfoRequestLeaderboardModeCurrentUser alloc] initWSInfoRequestLeaderboardModeCurrentUserWithScope:scope andPeriod: period] autorelease];
  639. }
  640. -(id) initWSInfoRequestLeaderboardModeCurrentUserWithScope:(NSInteger) scope andPeriod:(NSInteger) period {
  641. self = [super init];
  642. if (self != nil) {
  643. _scope = scope;
  644. _period = period;
  645. }
  646. return self;
  647. }
  648. -(NSString*) addContent:(MNWSRequestContent*) content {
  649. return [content addCurrUserLeaderboard: _scope period: _period];
  650. }
  651. @end
  652. @implementation MNWSInfoRequestLeaderboardModeAnyGameGlobal
  653. +(id) mnWSInfoRequestLeaderboardModeAnyGameGlobalWithGameId:(NSInteger) gameId
  654. gameSetId:(NSInteger) gameSetId
  655. andPeriod:(NSInteger) period {
  656. return [[[MNWSInfoRequestLeaderboardModeAnyGameGlobal alloc] initWSInfoRequestLeaderboardModeAnyGameGlobalWithGameId:gameId gameSetId: gameSetId andPeriod: period] autorelease];
  657. }
  658. -(id) initWSInfoRequestLeaderboardModeAnyGameGlobalWithGameId:(NSInteger) gameId
  659. gameSetId:(NSInteger) gameSetId
  660. andPeriod:(NSInteger) period {
  661. self = [super init];
  662. if (self != nil) {
  663. _gameId = gameId;
  664. _gameSetId = gameSetId;
  665. _period = period;
  666. }
  667. return self;
  668. }
  669. -(NSString*) addContent:(MNWSRequestContent*) content {
  670. return [content addAnyGameLeaderboardGlobal: _gameId gameSetId: _gameSetId period: _period];
  671. }
  672. @end
  673. @implementation MNWSInfoRequestLeaderboardModeAnyUserAnyGameGlobal
  674. +(id) mnWSInfoRequestLeaderboardModeAnyUserAnyGameGlobalWithUserId:(MNUserId) userId
  675. gameId:(NSInteger) gameId
  676. gameSetId:(NSInteger) gameSetId
  677. andPeriod:(NSInteger) period {
  678. return [[[MNWSInfoRequestLeaderboardModeAnyUserAnyGameGlobal alloc] initWSInfoRequestLeaderboardModeAnyUserAnyGameGlobalWithUserId:userId gameId:gameId gameSetId:gameSetId andPeriod: period] autorelease];
  679. }
  680. -(id) initWSInfoRequestLeaderboardModeAnyUserAnyGameGlobalWithUserId:(MNUserId) userId
  681. gameId:(NSInteger) gameId
  682. gameSetId:(NSInteger) gameSetId
  683. andPeriod:(NSInteger) period {
  684. self = [super init];
  685. if (self != nil) {
  686. _userId = userId;
  687. _gameId = gameId;
  688. _gameSetId = gameSetId;
  689. _period = period;
  690. }
  691. return self;
  692. }
  693. -(NSString*) addContent:(MNWSRequestContent*) content {
  694. return [content addAnyUserAnyGameLeaderboardGlobal: _userId gameId: _gameId gameSetId: _gameSetId period: _period];
  695. }
  696. @end
  697. @implementation MNWSInfoRequestLeaderboardModeCurrUserAnyGameLocal
  698. +(id) mnWSInfoRequestLeaderboardModeCurrUserAnyGameLocalWithGameId:(NSInteger) gameId
  699. gameSetId:(NSInteger) gameSetId
  700. andPeriod:(NSInteger) period {
  701. return [[[MNWSInfoRequestLeaderboardModeCurrUserAnyGameLocal alloc] initWSInfoRequestLeaderboardModeCurrUserAnyGameLocalWithGameId: gameId gameSetId: gameSetId andPeriod: period] autorelease];
  702. }
  703. -(id) initWSInfoRequestLeaderboardModeCurrUserAnyGameLocalWithGameId:(NSInteger) gameId
  704. gameSetId:(NSInteger) gameSetId
  705. andPeriod:(NSInteger) period {
  706. self = [super init];
  707. if (self != nil) {
  708. _gameId = gameId;
  709. _gameSetId = gameSetId;
  710. _period = period;
  711. }
  712. return self;
  713. }
  714. -(NSString*) addContent:(MNWSRequestContent*) content {
  715. return [content addCurrUserAnyGameLeaderboardLocal: _gameId gameSetId: _gameSetId period: _period];
  716. }
  717. @end
  718. @implementation MNWSInfoRequestResultLeaderboard
  719. -(id) initWithMNWSLeaderboardItemList:(NSArray*) data {
  720. self = [super init];
  721. if (self != nil) {
  722. _data = [data retain];
  723. }
  724. return self;
  725. }
  726. -(void) dealloc {
  727. [_data release];
  728. [super dealloc];
  729. }
  730. -(NSArray*) getDataEntry {
  731. return _data;
  732. }
  733. @end
  734. @implementation MNWSInfoRequestLeaderboard
  735. +(id) mnWSInfoRequestLeaderboardWithMode:(MNWSInfoRequestLeaderboardMode*) mode
  736. andDelegate:(id<MNWSInfoRequestLeaderboardDelegate>) delegate {
  737. return [[[MNWSInfoRequestLeaderboard alloc] initWSInfoRequestLeaderboardWithMode: mode andDelegate: delegate] autorelease];
  738. }
  739. -(id) initWSInfoRequestLeaderboardWithMode:(MNWSInfoRequestLeaderboardMode*) mode andDelegate:(id<MNWSInfoRequestLeaderboardDelegate>) delegate {
  740. self = [super init];
  741. if (self != nil) {
  742. _mode = [mode retain];
  743. _delegate = [delegate retain];
  744. _blockName = nil;
  745. }
  746. return self;
  747. }
  748. -(void) dealloc {
  749. [_mode release];
  750. [_delegate release];
  751. [_blockName release];
  752. [super dealloc];
  753. }
  754. -(void) handleRequestCompleted:(MNWSResponse*) response {
  755. MNWSInfoRequestResultLeaderboard* result = [[MNWSInfoRequestResultLeaderboard alloc] initWithMNWSLeaderboardItemList: [response getDataForBlock: _blockName]];
  756. [_delegate mnWSInfoRequestLeaderboardCompleted: result];
  757. [result release];
  758. }
  759. -(void) handleRequestError:(MNWSRequestError*) error {
  760. MNWSInfoRequestResultLeaderboard* result = [[MNWSInfoRequestResultLeaderboard alloc] init];
  761. [result setError: error.message];
  762. [_delegate mnWSInfoRequestLeaderboardCompleted: result];
  763. [result release];
  764. }
  765. -(void) addContent:(MNWSRequestContent*) content {
  766. [_blockName release];
  767. _blockName = [[_mode addContent: content] retain];
  768. }
  769. @end