Skip to content

Commit a3824b3

Browse files
committed
Code consistency with the rest of project
Replacing NSString by XMPPJID
1 parent 27568ec commit a3824b3

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

Extensions/XEP-0191/XMPPBlocking.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ typedef enum XMPPBlockingErrorCode
7575
/**
7676
* Block JID.
7777
*/
78-
- (void)blockJID:(NSString*)jid;
78+
- (void)blockJID:(XMPPJID*)xmppJID;
7979

8080
/**
8181
* Unblock JID.
8282
*/
83-
- (void)unblockJID:(NSString*)jid;
83+
- (void)unblockJID:(XMPPJID*)xmppJID;
8484

8585
/**
8686
* Return whether a jid is in blocking list or not.
8787
*/
88-
- (BOOL)containsJID:(NSString*)jid;
88+
- (BOOL)containsJID:(XMPPJID*)xmppJID;
8989

9090
/**
9191
* Unblock all.
@@ -120,11 +120,11 @@ typedef enum XMPPBlockingErrorCode
120120

121121
- (void)xmppBlocking:(XMPPBlocking *)sender didReceivePushWithBlockingList:(NSString *)name;
122122

123-
- (void)xmppBlocking:(XMPPBlocking *)sender didBlockJID:(NSString*)jid;
124-
- (void)xmppBlocking:(XMPPBlocking *)sender didNotBlockJID:(NSString*)jid error:(id)error;
123+
- (void)xmppBlocking:(XMPPBlocking *)sender didBlockJID:(XMPPJID*)xmppJID;
124+
- (void)xmppBlocking:(XMPPBlocking *)sender didNotBlockJID:(XMPPJID*)xmppJID error:(id)error;
125125

126-
- (void)xmppBlocking:(XMPPBlocking *)sender didUnblockJID:(NSString*)jid;
127-
- (void)xmppBlocking:(XMPPBlocking *)sender didNotUnblockJID:(NSString*)jid error:(id)error;
126+
- (void)xmppBlocking:(XMPPBlocking *)sender didUnblockJID:(XMPPJID*)xmppJID;
127+
- (void)xmppBlocking:(XMPPBlocking *)sender didNotUnblockJID:(XMPPJID*)xmppJID error:(id)error;
128128

129129
- (void)xmppBlocking:(XMPPBlocking *)sender didUnblockAllWithError:(id)error;
130130
- (void)xmppBlocking:(XMPPBlocking *)sender didNotUnblockAllDueToError:(id)error;

Extensions/XEP-0191/XMPPBlocking.m

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
@interface XMPPBlockingQueryInfo : NSObject
3131
{
3232
XMPPBlockingQueryInfoType type;
33-
NSString *blockingJID;
33+
XMPPJID *blockingXMPPJID;
3434
NSArray *blockingListItems;
3535

3636
dispatch_source_t timer;
@@ -39,14 +39,14 @@ @interface XMPPBlockingQueryInfo : NSObject
3939
@property (nonatomic, readonly) XMPPBlockingQueryInfoType type;
4040
@property (nonatomic, readonly) NSArray *blockingListItems;
4141

42-
@property (nonatomic, readwrite) NSString *blockingJID;
42+
@property (nonatomic, readwrite) XMPPJID *blockingXMPPJID;
4343
@property (nonatomic, readwrite) dispatch_source_t timer;
4444

4545
- (void)cancel;
4646

4747
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type;
48-
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type name:(NSString *)name;
49-
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type name:(NSString *)name items:(NSArray *)items;
48+
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type jid:(XMPPJID *)jid;
49+
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type jid:(XMPPJID *)jid items:(NSArray *)items;
5050

5151
@end
5252

@@ -232,14 +232,14 @@ - (NSArray*)blockingList
232232
}
233233
}
234234

235-
- (void)blockJID:(NSString*)jid
235+
- (void)blockJID:(XMPPJID*)xmppJID
236236
{
237237
XMPPLogTrace();
238238

239-
id value = [blockingDict objectForKey:jid];
239+
id value = [blockingDict objectForKey:[xmppJID full]];
240240
if (value == nil)
241241
{
242-
[blockingDict setObject:[NSNull null] forKey:jid];
242+
[blockingDict setObject:[NSNull null] forKey:[xmppJID full]];
243243
}
244244

245245
// <iq from='juliet@capulet.com/chamber' type='set' id='block1'>
@@ -250,7 +250,7 @@ - (void)blockJID:(NSString*)jid
250250

251251
NSXMLElement *block = [NSXMLElement elementWithName:@"block" xmlns:@"urn:xmpp:blocking"];
252252
NSXMLElement *item = [NSXMLElement elementWithName:@"item"];
253-
[item addAttributeWithName:@"jid" stringValue:jid];
253+
[item addAttributeWithName:@"jid" stringValue:[xmppJID full]];
254254
[block addChild:item];
255255

256256
NSString *uuid = [xmppStream generateUUID];
@@ -260,18 +260,18 @@ - (void)blockJID:(NSString*)jid
260260
[xmppStream sendElement:iq];
261261

262262
XMPPBlockingQueryInfo *qi = [XMPPBlockingQueryInfo queryInfoWithType:BlockUser];
263-
qi.blockingJID = jid;
263+
qi.blockingXMPPJID = xmppJID;
264264
[self addQueryInfo:qi withKey:uuid];
265265
}
266266

267-
- (void)unblockJID:(NSString*)jid
267+
- (void)unblockJID:(XMPPJID*)xmppJID
268268
{
269269
XMPPLogTrace();
270270

271-
id value = [blockingDict objectForKey:jid];
271+
id value = [blockingDict objectForKey:[xmppJID full]];
272272
if (value != nil)
273273
{
274-
[blockingDict removeObjectForKey:jid];
274+
[blockingDict removeObjectForKey:[xmppJID full]];
275275
}
276276

277277
// <iq type='set' id='unblock1'>
@@ -282,7 +282,7 @@ - (void)unblockJID:(NSString*)jid
282282

283283
NSXMLElement *block = [NSXMLElement elementWithName:@"unblock" xmlns:@"urn:xmpp:blocking"];
284284
NSXMLElement *item = [NSXMLElement elementWithName:@"item"];
285-
[item addAttributeWithName:@"jid" stringValue:jid];
285+
[item addAttributeWithName:@"jid" stringValue:[xmppJID full]];
286286
[block addChild:item];
287287

288288
NSString *uuid = [xmppStream generateUUID];
@@ -291,13 +291,13 @@ - (void)unblockJID:(NSString*)jid
291291
[xmppStream sendElement:iq];
292292

293293
XMPPBlockingQueryInfo *qi = [XMPPBlockingQueryInfo queryInfoWithType:UnblockUser];
294-
qi.blockingJID = jid;
294+
qi.blockingXMPPJID = xmppJID;
295295
[self addQueryInfo:qi withKey:uuid];
296296
}
297297

298-
- (BOOL)containsJID:(NSString*)jid
298+
- (BOOL)containsJID:(XMPPJID*)xmppJID
299299
{
300-
if ([blockingDict objectForKey:jid])
300+
if ([blockingDict objectForKey:[xmppJID full]])
301301
{
302302
return true;
303303
}
@@ -371,11 +371,11 @@ - (void)processQuery:(XMPPBlockingQueryInfo *)queryInfo withFailureCode:(XMPPBlo
371371
}
372372
else if (queryInfo.type == BlockUser)
373373
{
374-
[multicastDelegate xmppBlocking:self didNotBlockJID:queryInfo.blockingJID error:error];
374+
[multicastDelegate xmppBlocking:self didNotBlockJID:queryInfo.blockingXMPPJID error:error];
375375
}
376376
else if (queryInfo.type == UnblockUser)
377377
{
378-
[multicastDelegate xmppBlocking:self didNotUnblockJID:queryInfo.blockingJID error:error];
378+
[multicastDelegate xmppBlocking:self didNotUnblockJID:queryInfo.blockingXMPPJID error:error];
379379
}
380380
else if (queryInfo.type == UnblockAll)
381381
{
@@ -385,7 +385,7 @@ - (void)processQuery:(XMPPBlockingQueryInfo *)queryInfo withFailureCode:(XMPPBlo
385385

386386
- (void)queryTimeout:(NSString *)uuid
387387
{
388-
XMPPBlockingQueryInfo *queryInfo = [blockingDict objectForKey:uuid];
388+
XMPPBlockingQueryInfo *queryInfo = [pendingQueries objectForKey:uuid];
389389
if (queryInfo)
390390
{
391391
[self processQuery:queryInfo withFailureCode:XMPPBlockingQueryTimeout];
@@ -440,12 +440,12 @@ - (void)processQueryResponse:(XMPPIQ *)iq withInfo:(XMPPBlockingQueryInfo *)quer
440440
if ([[iq type] isEqualToString:@"result"])
441441
{
442442
[self removeQueryInfo:queryInfo withKey:[iq elementID]];
443-
[multicastDelegate xmppBlocking:self didBlockJID:queryInfo.blockingJID];
443+
[multicastDelegate xmppBlocking:self didBlockJID:queryInfo.blockingXMPPJID];
444444
}
445445
else
446446
{
447-
[blockingDict removeObjectForKey:[iq elementID]];
448-
[multicastDelegate xmppBlocking:self didNotBlockJID:queryInfo.blockingJID error:iq];
447+
[blockingDict removeObjectForKey:[queryInfo.blockingXMPPJID full]];
448+
[multicastDelegate xmppBlocking:self didNotBlockJID:queryInfo.blockingXMPPJID error:iq];
449449
}
450450
}
451451
else if (queryInfo.type == UnblockUser)
@@ -455,19 +455,19 @@ - (void)processQueryResponse:(XMPPIQ *)iq withInfo:(XMPPBlockingQueryInfo *)quer
455455
if ([[iq type] isEqualToString:@"result"])
456456
{
457457
[self removeQueryInfo:queryInfo withKey:[iq elementID]];
458-
[multicastDelegate xmppBlocking:self didUnblockJID:queryInfo.blockingJID];
458+
[multicastDelegate xmppBlocking:self didUnblockJID:queryInfo.blockingXMPPJID];
459459
}
460460
else
461461
{
462462
XMPPBlockingQueryInfo *queryInfo = [pendingQueries objectForKey:[iq elementID]];
463463

464-
id value = [blockingDict objectForKey:queryInfo.blockingJID];
464+
id value = [blockingDict objectForKey:[queryInfo.blockingXMPPJID full]];
465465
if (value == nil)
466466
{
467-
[blockingDict setObject:[NSNull null] forKey:queryInfo.blockingJID];
467+
[blockingDict setObject:[NSNull null] forKey:[queryInfo.blockingXMPPJID full]];
468468
}
469469

470-
[multicastDelegate xmppBlocking:self didNotBlockJID:queryInfo.blockingJID error:iq];
470+
[multicastDelegate xmppBlocking:self didNotBlockJID:queryInfo.blockingXMPPJID error:iq];
471471
}
472472
}
473473
else if (queryInfo.type == UnblockAll)
@@ -483,10 +483,10 @@ - (void)processQueryResponse:(XMPPIQ *)iq withInfo:(XMPPBlockingQueryInfo *)quer
483483
{
484484
XMPPBlockingQueryInfo *queryInfo = [pendingQueries objectForKey:[iq elementID]];
485485

486-
id value = [blockingDict objectForKey:queryInfo.blockingJID];
486+
id value = [blockingDict objectForKey:[queryInfo.blockingXMPPJID full]];
487487
if (value == nil)
488488
{
489-
[blockingDict setObject:[NSNull null] forKey:queryInfo.blockingJID];
489+
[blockingDict setObject:[NSNull null] forKey:queryInfo.blockingXMPPJID];
490490
}
491491

492492
[multicastDelegate xmppBlocking:self didNotUnblockAllDueToError:iq];
@@ -562,7 +562,7 @@ -(void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error
562562

563563
for (NSString *uuid in pendingQueries)
564564
{
565-
XMPPBlockingQueryInfo *queryInfo = [blockingDict objectForKey:uuid];
565+
XMPPBlockingQueryInfo *queryInfo = [pendingQueries objectForKey:uuid];
566566

567567
[self processQuery:queryInfo withFailureCode:XMPPBlockingDisconnect];
568568
}
@@ -588,16 +588,16 @@ -(void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error
588588
@implementation XMPPBlockingQueryInfo
589589

590590
@synthesize type;
591-
@synthesize blockingJID;
591+
@synthesize blockingXMPPJID;
592592
@synthesize blockingListItems;
593593
@synthesize timer;
594594

595-
- (id)initWithType:(XMPPBlockingQueryInfoType)aType name:(NSString *)name items:(NSArray *)items
595+
- (id)initWithType:(XMPPBlockingQueryInfoType)aType jid:(XMPPJID *)jid items:(NSArray *)items
596596
{
597597
if ((self = [super init]))
598598
{
599599
type = aType;
600-
blockingJID = [name copy];
600+
blockingXMPPJID = [jid copy];
601601
blockingListItems = [items copy];
602602
}
603603
return self;
@@ -622,17 +622,17 @@ - (void)dealloc
622622

623623
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type
624624
{
625-
return [self queryInfoWithType:type name:nil items:nil];
625+
return [self queryInfoWithType:type jid:nil items:nil];
626626
}
627627

628-
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type name:(NSString *)name
628+
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type jid:(XMPPJID *)jid
629629
{
630-
return [self queryInfoWithType:type name:name items:nil];
630+
return [self queryInfoWithType:type jid:jid items:nil];
631631
}
632632

633-
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type name:(NSString *)name items:(NSArray *)items
633+
+ (XMPPBlockingQueryInfo *)queryInfoWithType:(XMPPBlockingQueryInfoType)type jid:(XMPPJID *)jid items:(NSArray *)items
634634
{
635-
return [[XMPPBlockingQueryInfo alloc] initWithType:type name:name items:items];
635+
return [[XMPPBlockingQueryInfo alloc] initWithType:type jid:jid items:items];
636636
}
637637

638638
@end

0 commit comments

Comments
 (0)