-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'delayed-delivery-module' of https://github.com/esl/XMPP…
…Framework into esl-one-to-one-chat-module
- Loading branch information
Showing
10 changed files
with
281 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
#import <Foundation/Foundation.h> | ||
@import KissXML; | ||
|
||
@class XMPPJID; | ||
|
||
@interface NSXMLElement (XEP_0203) | ||
|
||
@property (nonatomic, readonly) BOOL wasDelayed; | ||
@property (nonatomic, readonly, nullable) NSDate *delayedDeliveryDate; | ||
@property (nonatomic, readonly, nullable) XMPPJID *delayedDeliveryFrom; | ||
@property (nonatomic, readonly, nullable) NSString *delayedDeliveryReasonDescription; | ||
|
||
@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
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,25 @@ | ||
#import "XMPP.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/// A module for processing XEP-0203 Delayed Delivery information in incoming XMPP stanzas. | ||
@interface XMPPDelayedDelivery : XMPPModule | ||
|
||
@end | ||
|
||
/// A protocol defining @c XMPPDelayedDelivery module delegate API. | ||
@protocol XMPPDelayedDeliveryDelegate <NSObject> | ||
|
||
@optional | ||
|
||
/// Notifies the delegate that a delayed delivery message has been received in the stream. | ||
- (void)xmppDelayedDelivery:(XMPPDelayedDelivery *)xmppDelayedDelivery | ||
didReceiveDelayedMessage:(XMPPMessage *)delayedMessage; | ||
|
||
/// Notifies the delegate that a delayed delivery presence has been received in the stream. | ||
- (void)xmppDelayedDelivery:(XMPPDelayedDelivery *)xmppDelayedDelivery | ||
didReceiveDelayedPresence:(XMPPPresence *)delayedPresence; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_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 "XMPPDelayedDelivery.h" | ||
#import "XMPPLogging.h" | ||
#import "NSXMLElement+XEP_0203.h" | ||
|
||
// Log levels: off, error, warn, info, verbose | ||
// Log flags: trace | ||
#if DEBUG | ||
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; // | XMPP_LOG_FLAG_TRACE; | ||
#else | ||
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN; | ||
#endif | ||
|
||
@implementation XMPPDelayedDelivery | ||
|
||
- (void)didActivate | ||
{ | ||
XMPPLogTrace(); | ||
} | ||
|
||
- (void)willDeactivate | ||
{ | ||
XMPPLogTrace(); | ||
} | ||
|
||
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message | ||
{ | ||
XMPPLogTrace(); | ||
|
||
if (![message wasDelayed]) { | ||
return; | ||
} | ||
|
||
XMPPLogInfo(@"Received delayed delivery message with date: %@, origin: %@, reason description: %@", | ||
[message delayedDeliveryDate], | ||
[message delayedDeliveryFrom] ?: @"unspecified", | ||
[message delayedDeliveryReasonDescription] ?: @"unspecified"); | ||
|
||
[multicastDelegate xmppDelayedDelivery:self didReceiveDelayedMessage:message]; | ||
} | ||
|
||
- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence | ||
{ | ||
XMPPLogTrace(); | ||
|
||
if (![presence wasDelayed]) { | ||
return; | ||
} | ||
|
||
XMPPLogInfo(@"Received delayed delivery presence with date: %@, origin: %@, reason description: %@", | ||
[presence delayedDeliveryDate], | ||
[presence delayedDeliveryFrom] ?: @"unspecified", | ||
[presence delayedDeliveryReasonDescription] ?: @"unspecified"); | ||
|
||
[multicastDelegate xmppDelayedDelivery:self didReceiveDelayedPresence:presence]; | ||
} | ||
|
||
@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
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
Oops, something went wrong.