• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java EntityBareJid类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.jxmpp.jid.EntityBareJid的典型用法代码示例。如果您正苦于以下问题:Java EntityBareJid类的具体用法?Java EntityBareJid怎么用?Java EntityBareJid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

EntityBareJid类属于org.jxmpp.jid包,在下文中一共展示了EntityBareJid类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getFullThingJidOrNotify

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
EntityFullJid getFullThingJidOrNotify() {
	EntityBareJid thingJid = settings.getThingJid();
	IoTProvisioningManager ioTProvisioningManager = IoTProvisioningManager.getInstanceFor(xmppConnection);

	if (!ioTProvisioningManager.iAmFriendOf(thingJid)) {
		withMainActivity((ma) -> Toast.makeText(ma, "Can not perform action. Not befriended with thing", Toast.LENGTH_LONG).show());
		return null;
	}

	Presence presence = roster.getPresence(settings.getThingJid());
	if (presence == null || !presence.isAvailable()) {
		withMainActivity((ma) -> Toast.makeText(ma, "Can not perform action. Befriended with thing, but thing is not online/unavailable", Toast.LENGTH_LONG).show());
		return null;
	}

	EntityFullJid fullOtherJid = presence.getFrom().asEntityFullJidIfPossible();
	if (fullOtherJid == null) throw new IllegalStateException("Exepected full JID");
	return fullOtherJid;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:20,
代码来源:XmppManager.java

示例2: validateEntityBareJid

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
/**
 * Check if the given CharSequence is a valid entity bare JID. That
 * is, it must consists exactly of a local- and a domainpart
 * (<[email protected]>).
 * <p>
 * This is a convenience method meant to validate user entered bare JIDs. If
 * the given {@code jid} is not a valid bare JID, then this method will
 * throw either {@link NotAEntityBareJidStringException} or
 * {@link XmppStringprepException}. The NotABareJidStringException will
 * contain a meaningful message explaining why the given CharSequence is not a
 * valid bare JID (e.g. "does not contain a '@' character").
 * </p>
 * 
 * @param jidcs the JID CharSequence
 * @return a BareJid instance representing the given JID CharSequence
 * @throws NotAEntityBareJidStringException if the given CharSequence is not a bare JID.
 * @throws XmppStringprepException if an error happens.
 */
public static EntityBareJid validateEntityBareJid(CharSequence jidcs) throws NotAEntityBareJidStringException, XmppStringprepException {
	String jid = jidcs.toString();
	final int atIndex = jid.indexOf('@');
	if (atIndex == -1) {
		throw new NotAEntityBareJidStringException("'" + jid + "' does not contain a '@' character");
	} else if (jid.indexOf('@', atIndex + 1) != -1) {
		throw new NotAEntityBareJidStringException("'" + jid + "' contains multiple '@' characters");
	}
	final String localpart = XmppStringUtils.parseLocalpart(jid);
	if (localpart.length() == 0) {
		throw new NotAEntityBareJidStringException("'" + jid + "' has empty localpart");
	}
	final String domainpart = XmppStringUtils.parseDomain(jid);
	if (domainpart.length() == 0) {
		throw new NotAEntityBareJidStringException("'" + jid + "' has empty domainpart");
	}
	return JidCreate.entityBareFromUnescaped(jid);
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:37,
代码来源:JidUtil.java

示例3: entityBareJidsFrom

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
/**
 * Convert a collection of Strings to a Set of {@link EntityBareJid}'s.
 * <p>
 * If the optional argument <code>exceptions</code> is given, then all {@link XmppStringprepException} thrown while
 * converting will be added to the list. Otherwise, if an XmppStringprepExceptions is thrown, it will be wrapped in
 * a AssertionError Exception and throw.
 * </p>
 * 
 * @param jidStrings
 *            the strings that are going to get converted
 * @param output
 *            the collection where the BareJid's will be added to
 * @param exceptions the list of exceptions thrown while converting.
 */
public static void entityBareJidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super EntityBareJid> output,
		List<XmppStringprepException> exceptions) {
	for (CharSequence jid : jidStrings) {
		try {
			EntityBareJid bareJid = JidCreate.entityBareFrom(jid);
			output.add(bareJid);
		} catch (XmppStringprepException e) {
			if (exceptions != null) {
				exceptions.add(e);
			} else {
				throw new AssertionError(e);
			}
		}
	}
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:30,
代码来源:JidUtil.java

示例4: isParentOf

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public final boolean isParentOf(Jid jid) {
	EntityFullJid fullJid = jid.asEntityFullJidIfPossible();
	if (fullJid != null) {
		return isParentOf(fullJid);
	}
	EntityBareJid bareJid = jid.asEntityBareJidIfPossible();
	if (bareJid != null) {
		return isParentOf(bareJid);
	}
	DomainFullJid domainFullJid = jid.asDomainFullJidIfPossible();
	if (domainFullJid != null) {
		return isParentOf(domainFullJid);
	}

	return isParentOf(jid.asDomainBareJid());
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:18,
代码来源:AbstractJid.java

示例5: entityBareFrom

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
/**
 * Get a {@link EntityBareJid} representing the given String.
 *
 * @param jid the input String.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityBareJid entityBareFrom(String jid) throws XmppStringprepException {
	EntityBareJid bareJid = ENTITY_BAREJID_CACHE.lookup(jid);
	if (bareJid != null) {
		return bareJid;
	}

	String localpart = XmppStringUtils.parseLocalpart(jid);
	String domainpart = XmppStringUtils.parseDomain(jid);
	try {
		bareJid = new LocalAndDomainpartJid(localpart, domainpart);
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(jid, e);
	}
	ENTITY_BAREJID_CACHE.put(jid, bareJid);
	return bareJid;
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:24,
代码来源:JidCreate.java

示例6: entityBareFromUnescaped

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
/**
 * Get a {@link EntityBareJid} representing the given unescaped String.
 *
 * @param unescapedJidString the input String.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityBareJid entityBareFromUnescaped(String unescapedJidString) throws XmppStringprepException {
	EntityBareJid bareJid = ENTITY_BAREJID_CACHE.lookup(unescapedJidString);
	if (bareJid != null) {
		return bareJid;
	}

	String localpart = XmppStringUtils.parseLocalpart(unescapedJidString);
	// Some as from(String), but we escape the localpart
	localpart = XmppStringUtils.escapeLocalpart(localpart);

	String domainpart = XmppStringUtils.parseDomain(unescapedJidString);
	try {
		bareJid = new LocalAndDomainpartJid(localpart, domainpart);
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(unescapedJidString, e);
	}
	ENTITY_BAREJID_CACHE.put(unescapedJidString, bareJid);
	return bareJid;
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:27,
代码来源:JidCreate.java

示例7: newConnection

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public void newConnection(XMPPConnection connection) {
	mConnection = connection;
	mRoster = Roster.getInstanceFor(connection);
	mRoster.addRosterListener(this);

	mRoster.addSubscribeListener(new SubscribeListener() {
		@Override
		public SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest) {
			Set<EntityBareJid> masterJids = mSettings.getMasterJids();
			for (EntityBareJid masterJid : masterJids) {
				if (masterJid.equals(from)) {
					return SubscribeAnswer.Approve;
				}
			}
			return SubscribeAnswer.Deny;
		}
	});
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:20,
代码来源:XMPPRoster.java

示例8: notifyAboutNewMasterAddress

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public void notifyAboutNewMasterAddress(final EntityBareJid newMasterAddress) {
	final XMPPConnection connection = getConnection();
	if (connection == null || !connection.isAuthenticated()) {
		return;
	}

	final Roster roster = Roster.getInstanceFor(connection);

	Async.go(new ThrowingRunnable() {
		@Override
		public void runOrThrow() throws NotLoggedInException, NotConnectedException,
				FeatureNotSupportedException, InterruptedException {
			if (roster.isSubscriptionPreApprovalSupported()) {
				roster.preApprove(newMasterAddress);
			}
			RosterUtil.askForSubscriptionIfRequired(roster, newMasterAddress);
		}
	});
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:20,
代码来源:XMPPService.java

示例9: onCreate

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.infoandsettings);

	mSettings = Settings.getInstance(this);

	// Views
	mMasterAddresses = (LinearLayout) findViewById(R.id.masterAddresses);
	mJID = (TextView) findViewById(R.id.jid);

	// initialize the master jid linear layout if there are already some
	// configured
	Set<EntityBareJid> masterJids = mSettings.getMasterJids();
	for (EntityBareJid masterAddress : masterJids) {
		MasterAddressView.createNewAndAddUnderLayout(this, mMasterAddresses, masterAddress);
	}

	if (mSettings.getJid() != null) mJID.setText(mSettings.getJid());

	mPingServerButtonHandler = new PingServerButtonHandler(this);

	AndroidDozeUtil.requestWhitelistIfNecessary(this, mSettings.getSharedPreferences(),
			R.string.DozeAskForWhitelist, R.string.DozeDoNotWhitelist, R.string.AskAgain,
			R.string.DozeWhitelist);
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:27,
代码来源:InfoAndSettings.java

示例10: handleNewMasterAddressResult

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private final void handleNewMasterAddressResult(int resultCode, Intent data) {
	if (resultCode != RESULT_OK) {
		LOG.d("Non ok result code " + resultCode + " for NEW_MASTER_ADDRESS_REQUEST_CODE");
		return;
	}

	String newMasterAddressString = data.getStringExtra(GlobalConstants.EXTRA_ENTITY_BARE_JID);
	EntityBareJid newMasterAddress;
	try {
		newMasterAddress = JidCreate.entityBareFrom(newMasterAddressString);
	} catch (XmppStringprepException e) {
		throw new AssertionError(e);
	}
	mSettings.addMasterJid(newMasterAddress);
	MasterAddressView.createNewAndAddUnderLayout(this, mMasterAddresses, newMasterAddress);
	XMPPService xmppService = XMPPService.getInstance(this);
	xmppService.notifyAboutNewMasterAddress(newMasterAddress);
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:19,
代码来源:InfoAndSettings.java

示例11: MasterAddressView

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private MasterAddressView(Context context, LinearLayout parentLayout, EntityBareJid masterAddress) {
	super(context);

	LayoutInflater inflater = LayoutInflater.from(context);
	inflater.inflate(R.layout.master_address, this);

	mSettings = Settings.getInstance(context);
	mParentLayout = parentLayout;
	mDeleteMasterAddress = (ImageButton) findViewById(R.id.deleteMasterAddress);
	mMasterAddress = masterAddress;

	mMasterAddressTextView = (TextView) findViewById(R.id.masterAddress);
	mMasterAddressTextView.setText(masterAddress);

	mDeleteMasterAddress.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View view) {
			mParentLayout.removeView(MasterAddressView.this);
			boolean removed = mSettings.removeMasterJid(mMasterAddress);
			if (!removed) {
				LOG.w("Previous master JID " + mMasterAddress + " was not found in settings when removing it");
			}
		}
	});
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:26,
代码来源:MasterAddressView.java

示例12: getJid

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public EntityBareJid getJid() {
	if (mJidCache != null) {
		return mJidCache;
	}
	String jidString = mSharedPreferences.getString(JID, "");
	if (jidString.isEmpty()) {
		return null;
	}
	EntityBareJid bareJid;
	try {
		bareJid = JidCreate.entityBareFrom(jidString);
	} catch (XmppStringprepException e) {
		throw new AssertionError(e);
	}
	return bareJid;
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:17,
代码来源:Settings.java

示例13: getMasterJids

点赞 3

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
/**
 * Returns a set of master JID Strings or an empty set if no master JID was
 * ever set.
 * 
 * @return A set containing the master JIDs.
 */
public Set<EntityBareJid> getMasterJids() {
	if (mMasterJidCache != null) {
		return mMasterJidCache;
	}
	String s = mSharedPreferences.getString(MASTER_JIDS, "");
	Set<String> resString = SharedStringUtil.stringToSet(s);
	Set<EntityBareJid> res = new HashSet<>();
	for (String jidString : resString) {
		try {
			EntityBareJid bareJid = JidCreate.entityBareFrom(jidString);
			res.add(bareJid);
		} catch (XmppStringprepException e) {
			throw new AssertionError(e);
		}
	}
	return res;
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:24,
代码来源:Settings.java

示例14: claimButtonClicked

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private void claimButtonClicked(final Thing thing) {

		final XMPPTCPConnection connection = mXmppManger.getXmppConnection();
		if (connection == null) {
			showInGui("Not connection available");
			return;
		}

		if (!connection.isAuthenticated()) {
			showInGui("Connection not authenticated");
			return;
		}

		IoTDiscoveryManager ioTDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection);

		IoTClaimed iotClaimed;
		try {
			iotClaimed = ioTDiscoveryManager.claimThing(mRegistry, thing.getMetaTags(), true);
		} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
			showInGui("Could not claim because " + e);
			LOGGER.log(Level.WARNING, "Could not register", e);
			return;
		}

		EntityBareJid claimedJid = iotClaimed.getJid().asEntityBareJidIfPossible();
		if (claimedJid == null) {
			throw new IllegalStateException();
		}
		Settings settings = Settings.getInstance(this);
		settings.setClaimedJid(claimedJid);

		showInGui("Thing " + claimedJid + " claimed.");
		runOnUiThread(() -> {
			finish();
		});
	}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:37,
代码来源:ClaimThingActivity.java

示例15: saveBasics

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public void saveBasics(@NonNull EntityBareJid myJid, @NonNull CharSequence password, EntityBareJid thingJid) {
	SharedPreferences.Editor editor = preferences.edit()
			.putString(MY_JID_KEY, myJid.toString())
			.putString(PASSWORD_KEY, password.toString());
	if (thingJid != null) {
		editor.putString(THING_JID_KEY, thingJid.toString());
	}
	editor.apply();

	myJidCache = myJid;
	thingJidCache = thingJid;
	confBuilderCache = null;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:14,
代码来源:Settings.java

示例16: saveOwner

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public void saveOwner(EntityBareJid owner) {
	if (owner != null) {
		preferences.edit().putString(OWNER_JID_KEY, owner.toString()).apply();
	} else {
		preferences.edit().remove(OWNER_JID_KEY).apply();
	}
	ownerJidCache = owner;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:9,
代码来源:Settings.java

示例17: getOwner

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public EntityBareJid getOwner() {
	if (ownerJidCache == null) {
		String ownerJidString = preferences.getString(OWNER_JID_KEY, null);
		if (ownerJidString == null) return null;
		try {
			ownerJidCache = JidCreate.entityBareFrom(ownerJidString);
		} catch (XmppStringprepException e) {
			throw new IllegalStateException(e);
		}
	}
	return ownerJidCache;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:13,
代码来源:Settings.java

示例18: getMyJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public EntityBareJid getMyJid() {
	if (myJidCache == null) {
		String myJidString = preferences.getString(MY_JID_KEY, null);
		if (myJidString == null) return null;
		try {
			myJidCache = JidCreate.entityBareFrom(myJidString);
		} catch (XmppStringprepException e) {
			throw new IllegalStateException(e);
		}
	}
	return myJidCache;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:13,
代码来源:Settings.java

示例19: getThingJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public EntityBareJid getThingJid() {
	if (thingJidCache == null) {
		String otherJidString = preferences.getString(THING_JID_KEY, null);
		if (otherJidString == null) return null;
		try {
			thingJidCache = JidCreate.entityBareFrom(otherJidString);
		} catch (XmppStringprepException e) {
			throw new IllegalStateException(e);
		}
	}
	return thingJidCache;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:13,
代码来源:Settings.java

示例20: getClaimedJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public EntityBareJid getClaimedJid() {
	if (claimedJidCache == null) {
		String claimedJidString = preferences.getString(CLAIMED_JID_KEY, null);
		if (claimedJidString == null) return null;
		try {
			claimedJidCache = JidCreate.entityBareFrom(claimedJidString);
		} catch (XmppStringprepException e) {
			throw new IllegalStateException(e);
		}
	}
	return claimedJidCache;
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:13,
代码来源:Settings.java

示例21: inviteUserAsync

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public void inviteUserAsync(final ChatGroup group, final Contact invitee) {

    executeNow(new Runnable () {

        public void run() {
            String chatRoomJid = group.getAddress().getAddress();

            if (mMUCs.containsKey(chatRoomJid)) {
                MultiUserChat muc = mMUCs.get(chatRoomJid);

                String reason = group.getName(); //no reason for now
                try {
                    EntityBareJid inviteeJid = JidCreate.entityBareFrom(invitee.getAddress().getAddress());
                    muc.invite(inviteeJid, reason);
                    group.notifyMemberJoined(null, invitee);
                    group.notifyMemberRoleUpdate(invitee, "none", "member");
                    muc.grantMembership(inviteeJid);
                } catch (Exception nce) {
                    Log.e(ImApp.LOG_TAG, "not connected error trying to add invite", nce);

                }

            }
        }
    });

}
 

开发者ID:zom,
项目名称:Zom-Android,
代码行数:29,
代码来源:XmppConnection.java

示例22: filterEntityBareJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
/**
 * Filter all entity bare JIDs.
 *
 * @param in the input collection.
 * @param out the collection where the filtered JIDs are added to.
 */
public static void filterEntityBareJid(Collection<? extends Jid> in, Collection<? super EntityBareJid> out) {
	for (Jid jid : in) {
		EntityBareJid bareJid = jid.asEntityBareJidIfPossible();
		if (bareJid != null) {
			out.add(bareJid);
		}
	}
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:15,
代码来源:JidUtil.java

示例23: bareFromThrowTest

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Test
public void bareFromThrowTest() {
	final String notABareJid = "example.org/test";
	try {
		EntityBareJid jid = JidCreate.entityBareFrom(notABareJid);
		// Should throw
		fail(jid + " should never been created");
	} catch (XmppStringprepException e) {
		assertEquals(notABareJid, e.getCausingString());
	}
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:12,
代码来源:JidCreateTest.java

示例24: entityBareFromUnescapedTest

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Test
public void entityBareFromUnescapedTest() throws XmppStringprepException {
	EntityBareJid entityBareJid = JidCreate.entityBareFromUnescaped("[email protected]@example.org/baz");

	// Tricky question. Currently yields '[email protected]'. Domainparts are U-Labels, so this may be correct, even
	// if it is not a valid DNS label/name.
	Domainpart domainpart = entityBareJid.getDomain();
	assertEquals(Domainpart.from("[email protected]"), domainpart);

	Localpart localpart = entityBareJid.getLocalpart();
	assertEquals(Localpart.from("foo"), localpart);
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:13,
代码来源:JidCreateTest.java

示例25: connected

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public void connected(XMPPConnection connection) {
	Set<EntityBareJid> masterJids = mSettings.getMasterJids();
	for (EntityBareJid jid : masterJids)
		friendJid(jid);

	checkMasterJids();
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:9,
代码来源:XMPPRoster.java

示例26: setJidAndPassword

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public void setJidAndPassword(EntityBareJid jid, CharSequence password) {
	mSharedPreferences
		.edit()
		.putString(JID, jid.toString())
		.putString(PASSWORD, password.toString())
		.commit();
	mJidCache = jid;
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:9,
代码来源:Settings.java

示例27: addMasterJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public void addMasterJid(EntityBareJid jid) {
	if (jid == null) {
		throw new IllegalArgumentException();
	}
	Set<EntityBareJid> masterJids = getMasterJids();
	masterJids.add(jid);
	saveMasterJids(masterJids);
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:9,
代码来源:Settings.java

示例28: removeMasterJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public boolean removeMasterJid(EntityBareJid jid) {
	Set<EntityBareJid> masterJids = getMasterJids();
	if (masterJids.remove(jid)) {
		saveMasterJids(masterJids);
		return true;
	}
	return false;
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:9,
代码来源:Settings.java

示例29: isMasterJID

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public boolean isMasterJID(Jid jid) {
	EntityBareJid bareJid = jid.asEntityBareJidIfPossible();

	if (bareJid == null) {
		return false;
	}

	if (getMasterJids().contains(bareJid)) {
		return true;
	}

	return false;
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:14,
代码来源:Settings.java

示例30: saveMasterJids

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private void saveMasterJids(Set<EntityBareJid> newMasterJids) {
	SharedPreferences.Editor e = mSharedPreferences.edit();

	Set<String> jidStrings = new HashSet<String>();
	for (BareJid bareJid : newMasterJids) {
		jidStrings.add(bareJid.toString());
	}
	String masterJids = SharedStringUtil.setToString(jidStrings);
	e.putString(MASTER_JIDS, masterJids);
	e.commit();
	mMasterJidCache = newMasterJids;
}
 

开发者ID:ProjectMAXS,
项目名称:maxs,
代码行数:13,
代码来源:Settings.java

示例31: onResume

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public void onResume() {
	super.onResume();
	if (mSettings.isBasicConfigurationDone()) {
		mSetupLinearLayout.setVisibility(View.GONE);
		mMainLinearLayout.setVisibility(View.VISIBLE);
	} else {
		mSetupLinearLayout.setBackgroundColor(View.VISIBLE);
		mMainLinearLayout.setVisibility(View.GONE);
	}

	int appIdentityVisibility = mSettings.isIdentityModeApp() ? View.VISIBLE : View.GONE;
	mAppIdentityLinearLayout.setVisibility(appIdentityVisibility);
	mThingJidLinearLayout.setVisibility(appIdentityVisibility);

	int thingIdentityVisibility = mSettings.isIdentityModeThing() ? View.VISIBLE : View.GONE;
	mThingIdentityLinearLayout.setVisibility(thingIdentityVisibility);
	mOwnerJidLinearLayout.setVisibility(thingIdentityVisibility);

	if (mSettings.getThingJid() != null) {
		mThingJidTextView.setText(mSettings.getThingJid());
	}

	if (mSettings.getOwner() != null) {
		mOwnerJidTextView.setText(mSettings.getOwner());
	}

	if (mSettings.getMyJid() != null) {
		mMyJidTextView.setText(mSettings.getMyJid());
	}

	if (mSettings.showClaimGuiElements()) {
		EntityBareJid claimedJid = mSettings.getClaimedJid();
		if (claimedJid != null) {
			mClaimThingActivityButton.setVisibility(View.GONE);
			mClaimedJidTextView.setText(claimedJid);
		} else {
			mClaimThingActivityButton.setVisibility(View.VISIBLE);
		}
		mIotClaimedLinearLayout.setVisibility(View.VISIBLE);
	} else {
		mIotClaimedLinearLayout.setVisibility(View.GONE);
	}

	if (mSettings.isIdentityModeThing()) {
		if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED && !mAccessCoarseLocationPermissionDenied) {
			ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
		} else {
			BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
			BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
			if (bluetoothAdapter != null) {
				if (!bluetoothAdapter.isEnabled()) {
					Intent enableBluetoothIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
					startActivityForResult(enableBluetoothIntent, REQUEST_ENABLE_BLUETOOTH);
				} else {
					mXiotBluetoothLeManager.enableManager();
				}
			}
		}
	}
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:62,
代码来源:MainActivity.java

示例32: XmppIotDataControl

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private XmppIotDataControl(Context context) {
	mContext = context.getApplicationContext();
	mXmppManager = XmppManager.getInstance(mContext);
	mSettings = Settings.getInstance(mContext);
	mXmppManager.addXmppConnectionStatusListener((ma) -> {
		Roster roster = Roster.getInstanceFor(ma.getConnection());
		roster.addSubscribeListener((from, subRequest) -> {
			if (!mSettings.isIdentityModeApp()) return null;
			if (!mSettings.isMutualSubscriptionModeEnabled()) return null;

			if (from.equals(mSettings.getThingJid())) {
				return SubscribeListener.SubscribeAnswer.Approve;
			}
			return null;
		});

		ma.addListener(new AbstractManagedXmppConnectionListener() {
			@Override
			public void authenticated(XMPPConnection connection, boolean resumed) {
				withMainActivity((ma) -> setGuiElements(ma, true));

				if (resumed) return;

				if (!mSettings.isIdentityModeApp()) return;

				final EntityBareJid thingJid = mSettings.getThingJid();

				XmppManager.emptyRoster(connection, thingJid);

				if (thingJid == null) return;
				IoTProvisioningManager provisioningManager = IoTProvisioningManager.getInstanceFor(connection);
				if (!provisioningManager.iAmFriendOf(thingJid)) {
					withMainActivity((ma) -> Toast.makeText(ma, "Trying to befriend " + thingJid, Toast.LENGTH_SHORT).show());
					try {
						provisioningManager.sendFriendshipRequest(thingJid);
					} catch (SmackException.NotConnectedException | InterruptedException e) {
						LOGGER.log(Level.WARNING, "Could not befriend thing", e);
					}
				} else {
					LOGGER.info("We are already a friend of " + thingJid + ". Not sending friendship request.");
				}
				provisioningManager.addBecameFriendListener((friend, presence) -> {
					if (!mSettings.isIdentityModeApp()) return;
					withMainActivity((c) -> Toast.makeText(c, "We are now a friend of " + friend, Toast.LENGTH_SHORT).show());
				});
				provisioningManager.addWasUnfriendedListener((friend, presence) -> {
					if (!mSettings.isIdentityModeApp()) return;
					withMainActivity((c) -> Toast.makeText(c, "We are no longer a friend of " + friend, Toast.LENGTH_SHORT).show());
				});
			}
			@Override
			public void terminated() {
				withMainActivity((ma) -> setGuiElements(ma, false));
			}
		});
	});
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:58,
代码来源:XmppIotDataControl.java

示例33: setClaimedJid

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
void setClaimedJid(EntityBareJid claimedJid) {
	preferences.edit().putString(CLAIMED_JID_KEY, claimedJid.toString()).apply();
}
 

开发者ID:Flowdalic,
项目名称:android-xmpp-iot-demo,
代码行数:4,
代码来源:Settings.java

示例34: isAuthorizedXMPPUser

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private static boolean isAuthorizedXMPPUser(User user) {
    EntityBareJid userJid = XMPPSession.getInstance().getUser();
    String userName = user.getLogin();
    return userJid != null && userName != null && userName.equals(XMPPUtils.fromJIDToUserName(userJid.toString()));
}
 

开发者ID:esl,
项目名称:mangosta-android,
代码行数:6,
代码来源:UsersListAdapter.java

示例35: receiveBlogPosts

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private void receiveBlogPosts() {
    PEPManager pepManager = PEPManager.getInstanceFor(mXMPPConnection);
    pepManager.addPEPListener(new PEPListener() {
        @Override
        public void eventReceived(EntityBareJid entityBareJid, EventElement eventElement, Message message) {
            if (EventElementType.items == eventElement.getEventType()) {
                ItemsExtension itemsExtension = (ItemsExtension) eventElement.getExtensions().get(0);
                PayloadItem payloadItem = (PayloadItem) itemsExtension.getItems().get(0);
                PostEntryExtension postEntryExtension = (PostEntryExtension) payloadItem.getPayload();

                String id = postEntryExtension.getId();
                String jid = entityBareJid.toString();
                String title = postEntryExtension.getTitle();
                Date published = postEntryExtension.getPublished();
                Date updated = postEntryExtension.getUpdated();

                BlogPost blogPost = new BlogPost(id, jid, null, title, published, updated);
                RealmManager.getInstance().saveBlogPost(blogPost);

                String commentsNode = PublishCommentExtension.NODE + "/" + id;
                ServiceDiscoveryManager.getInstanceFor(mXMPPConnection).addFeature(commentsNode + "+notify");

                notifyNewBlogPost();
            }
        }

        private void notifyNewBlogPost() {
            MangostaApplication mangostaApplication = MangostaApplication.getInstance();
            if (mangostaApplication.isClosed()) {
                BlogPostNotifications.newBlogPostNotification();
            } else {
                mangostaApplication.getCurrentActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        new Event(Event.Type.BLOG_POST_CREATED).post();
                    }
                });
            }
        }
    });
}
 

开发者ID:esl,
项目名称:mangosta-android,
代码行数:42,
代码来源:XMPPSession.java

示例36: getPubSubManager

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public PubSubManager getPubSubManager() {
    EntityBareJid myJIDString = getUser();
    return PubSubManager.getInstance(mXMPPConnection, myJIDString);
}
 

开发者ID:esl,
项目名称:mangosta-android,
代码行数:5,
代码来源:XMPPSession.java

示例37: getUser

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
public EntityBareJid getUser() {
    return getXMPPConnection().getUser().asEntityBareJid();
}
 

开发者ID:esl,
项目名称:mangosta-android,
代码行数:4,
代码来源:XMPPSession.java

示例38: loadVCard

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
private boolean loadVCard (ContentResolver resolver, String jid)
{
    try {
            debug(TAG, "loading vcard for: " + jid);

            EntityBareJid bareJid = JidCreate.entityBareFrom(jid);

            VCardManager vCardManager = VCardManager.getInstanceFor(mConnection);
            VCard vCard = vCardManager.loadVCard(bareJid);

            Contact contact = mContactListManager.getContact(bareJid.toString());

            if (!TextUtils.isEmpty(vCard.getNickName()))
            {
                if (!vCard.getNickName().equals(contact.getName()))
                {
                    contact.setName(vCard.getNickName());
                    mContactListManager.doSetContactName(contact.getAddress().getBareAddress(), contact.getName());
                }

            }

            //check for a forwarding address
            if (vCard.getJabberId() != null && (!vCard.getJabberId().equals(bareJid.toString())))
            {
                contact.setForwardingAddress(vCard.getJabberId());

            }
            else
            {
                contact.setForwardingAddress(null);
            }

                // If VCard is loaded, then save the avatar to the personal folder.
            String avatarHash = vCard.getAvatarHash();

            if (avatarHash != null)
            {
                byte[] avatarBytes = vCard.getAvatar();

                if (avatarBytes != null)
                {

                    debug(TAG, "found avatar image in vcard for: " + bareJid.toString());
                    debug(TAG, "start avatar length: " + avatarBytes.length);

                    int rowsUpdated = DatabaseUtils.updateAvatarBlob(resolver, Imps.Avatars.CONTENT_URI, avatarBytes, bareJid.toString());

                    if (rowsUpdated <= 0)
                        DatabaseUtils.insertAvatarBlob(resolver, Imps.Avatars.CONTENT_URI, mProviderId, mAccountId, avatarBytes, avatarHash, bareJid.toString());

                    return true;
                }
            }



    } catch (Exception e) {

        debug(TAG, "err loading vcard: " + e.toString());

        if (e.getMessage() != null)
        {
            String streamErr = e.getMessage();

            if (streamErr != null && (streamErr.contains("404") || streamErr.contains("503")))
            {
                return false;
            }
        }

    }

    return false;
}
 

开发者ID:zom,
项目名称:Zom-Android,
代码行数:76,
代码来源:XmppConnection.java

示例39: asEntityBareJidIfPossible

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public EntityBareJid asEntityBareJidIfPossible() {
	return null;
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:5,
代码来源:DomainAndResourcepartJid.java

示例40: isParentOf

点赞 2

import org.jxmpp.jid.EntityBareJid; //导入依赖的package包/类
@Override
public boolean isParentOf(EntityBareJid bareJid) {
	return false;
}
 

开发者ID:igniterealtime,
项目名称:jxmpp,
代码行数:5,
代码来源:DomainAndResourcepartJid.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)