-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for IoT Friend approvals
This adds supports for an experimental protocol flow where a pending friend request's decission is later on deliverd to the requestor after the owner made its decission.
- Loading branch information
Showing
11 changed files
with
404 additions
and
53 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...rimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/BecameFriendListener.java
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,26 @@ | ||
/** | ||
* | ||
* Copyright 2016 Florian Schmaus | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jivesoftware.smackx.iot.provisioning; | ||
|
||
import org.jivesoftware.smack.packet.Presence; | ||
import org.jxmpp.jid.BareJid; | ||
|
||
public interface BecameFriendListener { | ||
|
||
void becameFriend(BareJid jid, Presence presence); | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
...imental/src/main/java/org/jivesoftware/smackx/iot/provisioning/WasUnfriendedListener.java
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,26 @@ | ||
/** | ||
* | ||
* Copyright 2016 Florian Schmaus | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jivesoftware.smackx.iot.provisioning; | ||
|
||
import org.jivesoftware.smack.packet.Presence; | ||
import org.jxmpp.jid.BareJid; | ||
|
||
public interface WasUnfriendedListener { | ||
|
||
void wasUnfriendedListener(BareJid jid, Presence presence); | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
...k-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/element/Friend.java
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,61 @@ | ||
/** | ||
* | ||
* Copyright © 2016 Florian Schmaus | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jivesoftware.smackx.iot.provisioning.element; | ||
|
||
import org.jivesoftware.smack.packet.ExtensionElement; | ||
import org.jivesoftware.smack.packet.Message; | ||
import org.jivesoftware.smack.util.Objects; | ||
import org.jivesoftware.smack.util.XmlStringBuilder; | ||
import org.jxmpp.jid.BareJid; | ||
|
||
public class Friend implements ExtensionElement { | ||
|
||
public static final String ELEMENT = "friend"; | ||
public static final String NAMESPACE = Constants.IOT_PROVISIONING_NAMESPACE; | ||
|
||
private final BareJid friend; | ||
|
||
public Friend(BareJid friend) { | ||
this.friend = Objects.requireNonNull(friend, "Friend must not be null"); | ||
} | ||
|
||
@Override | ||
public String getElementName() { | ||
return ELEMENT; | ||
} | ||
|
||
@Override | ||
public String getNamespace() { | ||
return NAMESPACE; | ||
} | ||
|
||
@Override | ||
public XmlStringBuilder toXML() { | ||
XmlStringBuilder xml = new XmlStringBuilder(this); | ||
xml.attribute("jid", friend); | ||
xml.closeEmptyElement(); | ||
return xml; | ||
} | ||
|
||
public BareJid getFriend() { | ||
return friend; | ||
} | ||
|
||
public static Friend from(Message message) { | ||
return message.getExtension(ELEMENT, NAMESPACE); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ental/src/main/java/org/jivesoftware/smackx/iot/provisioning/provider/FriendProvider.java
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,34 @@ | ||
/** | ||
* | ||
* Copyright © 2016 Florian Schmaus | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jivesoftware.smackx.iot.provisioning.provider; | ||
|
||
import org.jivesoftware.smack.provider.ExtensionElementProvider; | ||
import org.jivesoftware.smack.util.ParserUtils; | ||
import org.jivesoftware.smackx.iot.provisioning.element.Friend; | ||
import org.jxmpp.jid.BareJid; | ||
import org.jxmpp.stringprep.XmppStringprepException; | ||
import org.xmlpull.v1.XmlPullParser; | ||
|
||
public class FriendProvider extends ExtensionElementProvider<Friend> { | ||
|
||
@Override | ||
public Friend parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException { | ||
BareJid jid = ParserUtils.getBareJidAttribute(parser); | ||
return new Friend(jid); | ||
} | ||
|
||
} |
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
Oops, something went wrong.