Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XEP-0084: User Avatar implementation #107

Closed
wants to merge 3 commits into from

Conversation

ramabit
Copy link
Contributor

@ramabit ramabit commented Feb 13, 2017

return getNode(METADATA_NAMESPACE);
}

private LeafNode getNode(String nodeName)
Copy link
Member

@Flowdalic Flowdalic Feb 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is why it's a good idea to have PubSubManager.getOrCreateNode(String): You are duplicating code that you already wrote for Geo Location here.

Copy link
Member

@Flowdalic Flowdalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code so that you can make as many member fields final. And make every member final that you can make final.

*/
public class MetadataInfo {

private String id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all be final.

*/
public class MetadataPointer {

private String namespace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all final

public static final String ELEMENT = "data";
public static final String NAMESPACE = UserAvatarManager.DATA_NAMESPACE;

private byte[] data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

*
* @return the data
*/
public byte[] getData() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return a copy of the data to keep DataExtension immutable.

public static final String ELEMENT = "metadata";
public static final String NAMESPACE = UserAvatarManager.METADATA_NAMESPACE;

private List<MetadataInfo> infos;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all final and unmodifiable.

Copy link

@mlkjhh mlkjhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

شماره نشان داده نمیشود

@ramabit
Copy link
Contributor Author

ramabit commented Apr 7, 2017

@Flowdalic please check the last fixes :)

Copy link
Member

@Flowdalic Flowdalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just finished the first round of reviews. The OMEMO PR will be merged soon, and after this happened, I'll hope that we can merge your PRs. :)

public class MetadataInfo {

private final String id;
private final String url;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be of type 'URL'

this.url = url;
this.bytes = bytes;
this.type = type;
this.height = pixelsHeight;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

height and width are xs:unsingedByte, thus the constructor should ensure that it's value is within the range of [1,254] and otherwise throw an IllegalArgumentException.

*/
public MetadataPointer(String namespace, HashMap<String, Object> fields) {
this.namespace = namespace;
this.fields = fields;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be wrap with Collections.umodifyableList()

*/
public boolean isSupportedByServer()
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return findNodeItem(DATA_NAMESPACE) && findNodeItem(METADATA_NAMESPACE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is how you determine if xep84 is supported by the server. You likely just need to check if PEP is supported.

*
* @return the data as String
*/
public String getDataAsString() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called getDataBase64Encoded(). To make it clear that the string representation of the data is base64 encoded.

outerloop: while (true) {
int eventType = parser.next();

if (eventType == XmlPullParser.START_TAG) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use switch/case on the eventType int.


if (eventType == XmlPullParser.START_TAG) {

if (parser.getName().equals("info")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use switch/case on the getName() string.

@vanitasvitae
Copy link
Member

I'll close this in favor of #332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants