summaryrefslogtreecommitdiffstats
blob: 515df8237930e2a53238442412f9f4224472a945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * Copyright (c) 2010-2015, Isode Limited, London, England.
 * All rights reserved.
 */
package com.isode.stroke.roster;

import com.isode.stroke.elements.ErrorPayload;
import com.isode.stroke.elements.RosterPayload;
import com.isode.stroke.jid.JID;
import com.isode.stroke.queries.IQRouter;
import com.isode.stroke.queries.SetResponder;
import com.isode.stroke.signals.Signal1;

public class RosterPushResponder extends SetResponder<RosterPayload> {

	public final Signal1<RosterPayload> onRosterReceived = new Signal1<RosterPayload>();

	public RosterPushResponder(IQRouter router) {
		super(new RosterPayload(), router);
	}

	@Override
	protected boolean handleSetRequest(JID from, JID to, String id, RosterPayload payload) {
			if (getIQRouter().isAccountJID(from)) {
				onRosterReceived.emit(payload);
				sendResponse(from, id, new RosterPayload());
			} else {
				sendError(from, id, ErrorPayload.Condition.NotAuthorized, ErrorPayload.Type.Cancel);
			}
			return true;
	}


}