forked from smiley22/S22.Xmpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request smiley22#2 from ignacionr/master
XEP-0280 Message Carbons
- Loading branch information
Showing
4 changed files
with
180 additions
and
116 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,51 @@ | ||
using Sharp.Xmpp.Core; | ||
using Sharp.Xmpp.Im; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Sharp.Xmpp.Extensions | ||
{ | ||
internal class MessageCarbons: XmppExtension | ||
{ | ||
static readonly string[] _namespaces = { "urn:xmpp:carbons:2" }; | ||
private EntityCapabilities ecapa; | ||
|
||
public override IEnumerable<string> Namespaces | ||
{ | ||
get { return _namespaces; } | ||
} | ||
|
||
public override Extension Xep | ||
{ | ||
get { return Extension.MessageCarbons; } | ||
} | ||
|
||
public override void Initialize() | ||
{ | ||
ecapa = im.GetExtension<EntityCapabilities>(); | ||
} | ||
|
||
public void EnableCarbons(bool enable = true) | ||
{ | ||
if (!ecapa.Supports(im.Jid.Domain, Extension.MessageCarbons)) | ||
{ | ||
throw new NotSupportedException("The XMPP server does not support " + | ||
"the 'Message Carbons' extension."); | ||
} | ||
var iq = im.IqRequest(IqType.Set, null, im.Jid, | ||
Xml.Element(enable ? "enable" : "disable", _namespaces[0])); | ||
if (iq.Type == IqType.Error) | ||
throw Util.ExceptionFromError(iq, "Message Carbons could not " + | ||
"be enabled."); | ||
} | ||
|
||
public MessageCarbons(XmppIm im) : | ||
base(im) | ||
{ | ||
; | ||
} | ||
} | ||
} |
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