Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving XEP-0184 support into it's own category.
- Loading branch information
1 parent
42d3b87
commit 9383ab4
Showing
4 changed files
with
69 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "XMPPMessage.h" | ||
|
||
|
||
@interface XMPPMessage (XEP_0184) | ||
|
||
- (BOOL)hasReceiptRequest; | ||
- (BOOL)hasReceiptResponse; | ||
- (NSString *)extractReceiptResponseID; | ||
- (XMPPMessage *)generateReceiptResponse; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#import "XMPPMessage+XEP_0184.h" | ||
#import "NSXMLElement+XMPP.h" | ||
|
||
|
||
@implementation XMPPMessage (XEP_0184) | ||
|
||
- (BOOL)hasReceiptRequest | ||
{ | ||
NSXMLElement *receiptRequest = [self elementForName:@"request" xmlns:@"urn:xmpp:receipts"]; | ||
|
||
return (receiptRequest != nil); | ||
} | ||
|
||
- (BOOL)hasReceiptResponse | ||
{ | ||
NSXMLElement *receiptResponse = [self elementForName:@"received" xmlns:@"urn:xmpp:receipts"]; | ||
|
||
return (receiptResponse != nil); | ||
} | ||
|
||
- (NSString *)extractReceiptResponseID | ||
{ | ||
NSXMLElement *receiptResponse = [self elementForName:@"received" xmlns:@"urn:xmpp:receipts"]; | ||
|
||
return [receiptResponse attributeStringValueForName:@"id"]; | ||
} | ||
|
||
- (XMPPMessage *)generateReceiptResponse | ||
{ | ||
// Example: | ||
// | ||
// <message to="juliet"> | ||
// <received xmlns="urn:xmpp:receipts" id="ABC-123"/> | ||
// </message> | ||
|
||
NSXMLElement *received = [NSXMLElement elementWithName:@"received" xmlns:@"urn:xmpp:receipts"]; | ||
|
||
NSXMLElement *message = [NSXMLElement elementWithName:@"message"]; | ||
|
||
NSString *to = [self fromStr]; | ||
if (to) | ||
{ | ||
[message addAttributeWithName:@"to" stringValue:to]; | ||
} | ||
|
||
NSString *msgid = [self elementID]; | ||
if (msgid) | ||
{ | ||
[received addAttributeWithName:@"id" stringValue:msgid]; | ||
} | ||
|
||
[message addChild:received]; | ||
|
||
return [[self class] messageFromElement:message]; | ||
} | ||
|
||
@end |