Permalink
Browse files

Moving XEP-0184 support into it's own category.

  • Loading branch information...
1 parent 42d3b87 commit 9383ab460042deca9c2ff2ecef1f6f2a71b9e7bb @robbiehanson committed Mar 15, 2012
Showing with 69 additions and 59 deletions.
  1. +0 −5 Core/XMPPMessage.h
  2. +0 −54 Core/XMPPMessage.m
  3. +12 −0 Extensions/XEP-0184/XMPPMessage+XEP_0184.h
  4. +57 −0 Extensions/XEP-0184/XMPPMessage+XEP_0184.m
View
@@ -29,11 +29,6 @@
- (BOOL)isErrorMessage;
- (BOOL)isMessageWithBody;
-- (BOOL)hasReceiptRequest;
-- (BOOL)hasReceiptResponse;
-- (NSString *)extractReceiptResponseID;
-- (XMPPMessage *)generateReceiptResponse;
-
- (NSError *)errorMessage;
@end
View
@@ -117,58 +117,4 @@ - (BOOL)isMessageWithBody
return ([body length] > 0);
}
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#pragma mark XEP-0184: Message Receipts
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-- (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
@@ -0,0 +1,12 @@
+#import <Foundation/Foundation.h>
+#import "XMPPMessage.h"
+
+
+@interface XMPPMessage (XEP_0184)
+
+- (BOOL)hasReceiptRequest;
+- (BOOL)hasReceiptResponse;
+- (NSString *)extractReceiptResponseID;
+- (XMPPMessage *)generateReceiptResponse;
+
+@end
@@ -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

0 comments on commit 9383ab4

Please sign in to comment.