当前位置: 首页>>代码示例>>Java>>正文


Java Session.getSessionStatus方法代码示例

本文整理汇总了Java中net.java.otr4j.session.Session.getSessionStatus方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getSessionStatus方法的具体用法?Java Session.getSessionStatus怎么用?Java Session.getSessionStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.java.otr4j.session.Session的用法示例。


在下文中一共展示了Session.getSessionStatus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseOtrChat

import net.java.otr4j.session.Session; //导入方法依赖的package包/类
private Message parseOtrChat(String body, Jid from, String id, Conversation conversation) {
	String presence;
	if (from.isBareJid()) {
		presence = "";
	} else {
		presence = from.getResourcepart();
	}
	if (body.matches("^\\?OTRv\\d{1,2}\\?.*")) {
		conversation.endOtrIfNeeded();
	}
	if (!conversation.hasValidOtrSession()) {
		conversation.startOtrSession(presence,false);
	} else {
		String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
		if (!foreignPresence.equals(presence)) {
			conversation.endOtrIfNeeded();
			conversation.startOtrSession(presence, false);
		}
	}
	try {
		conversation.setLastReceivedOtrMessageId(id);
		Session otrSession = conversation.getOtrSession();
		body = otrSession.transformReceiving(body);
		SessionStatus status = otrSession.getSessionStatus();
		if (body == null && status == SessionStatus.ENCRYPTED) {
			mXmppConnectionService.onOtrSessionEstablished(conversation);
			return null;
		} else if (body == null && status == SessionStatus.FINISHED) {
			conversation.resetOtrSession();
			mXmppConnectionService.updateConversationUi();
			return null;
		} else if (body == null || (body.isEmpty())) {
			return null;
		}
		if (body.startsWith(CryptoHelper.FILETRANSFER)) {
			String key = body.substring(CryptoHelper.FILETRANSFER.length());
			conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
			return null;
		}
		if (clientMightSendHtml(conversation.getAccount(), from)) {
			Log.d(Config.LOGTAG,conversation.getAccount().getJid().toBareJid()+": received OTR message from bad behaving client. escaping HTML…");
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
				body = Html.fromHtml(body,Html.FROM_HTML_MODE_LEGACY).toString();
			} else {
				body = Html.fromHtml(body).toString();
			}
		}

		final OtrService otrService = conversation.getAccount().getOtrService();
		Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
		finishedMessage.setFingerprint(otrService.getFingerprint(otrSession.getRemotePublicKey()));
		conversation.setLastReceivedOtrMessageId(null);

		return finishedMessage;
	} catch (Exception e) {
		conversation.resetOtrSession();
		return null;
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:60,代码来源:MessageParser.java

示例2: parseOtrChat

import net.java.otr4j.session.Session; //导入方法依赖的package包/类
private Message parseOtrChat(String body, Jid from, String id, Conversation conversation) {
	String presence;
	if (from.isBareJid()) {
		presence = "";
	} else {
		presence = from.getResourcepart();
	}
	if (body.matches("^\\?OTRv\\d{1,2}\\?.*")) {
		conversation.endOtrIfNeeded();
	}
	if (!conversation.hasValidOtrSession()) {
		conversation.startOtrSession(presence,false);
	} else {
		String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
		if (!foreignPresence.equals(presence)) {
			conversation.endOtrIfNeeded();
			conversation.startOtrSession(presence, false);
		}
	}
	try {
		conversation.setLastReceivedOtrMessageId(id);
		Session otrSession = conversation.getOtrSession();
		body = otrSession.transformReceiving(body);
		SessionStatus status = otrSession.getSessionStatus();
		if (body == null && status == SessionStatus.ENCRYPTED) {
			mXmppConnectionService.onOtrSessionEstablished(conversation);
			return null;
		} else if (body == null && status == SessionStatus.FINISHED) {
			conversation.resetOtrSession();
			mXmppConnectionService.updateConversationUi();
			return null;
		} else if (body == null || (body.isEmpty())) {
			return null;
		}
		if (body.startsWith(CryptoHelper.FILETRANSFER)) {
			String key = body.substring(CryptoHelper.FILETRANSFER.length());
			conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
			return null;
		}
		Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
		conversation.setLastReceivedOtrMessageId(null);
		return finishedMessage;
	} catch (Exception e) {
		conversation.resetOtrSession();
		return null;
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:48,代码来源:MessageParser.java

示例3: parseOtrChat

import net.java.otr4j.session.Session; //导入方法依赖的package包/类
private Message parseOtrChat(String body, Jid from, String id, Conversation conversation) {
    String presence;
    if (from.isBareJid()) {
        presence = "";
    } else {
        presence = from.getResourcepart();
    }
    if (body.matches("^\\?OTRv\\d{1,2}\\?.*")) {
        conversation.endOtrIfNeeded();
    }
    if (!conversation.hasValidOtrSession()) {
        conversation.startOtrSession(presence, false);
    } else {
        String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
        if (!foreignPresence.equals(presence)) {
            conversation.endOtrIfNeeded();
            conversation.startOtrSession(presence, false);
        }
    }
    try {
        conversation.setLastReceivedOtrMessageId(id);
        Session otrSession = conversation.getOtrSession();
        body = otrSession.transformReceiving(body);
        SessionStatus status = otrSession.getSessionStatus();
        if (body == null && status == SessionStatus.ENCRYPTED) {
            mXmppConnectionService.onOtrSessionEstablished(conversation);
            return null;
        } else if (body == null && status == SessionStatus.FINISHED) {
            conversation.resetOtrSession();
            mXmppConnectionService.updateConversationUi();
            return null;
        } else if (body == null || (body.isEmpty())) {
            return null;
        }
        if (body.startsWith(CryptoHelper.FILETRANSFER)) {
            String key = body.substring(CryptoHelper.FILETRANSFER.length());
            conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
            return null;
        }
        if (clientMightSendHtml(conversation.getAccount(), from)) {
            Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": received OTR message from bad behaving client. escaping HTML…");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                body = Html.fromHtml(body, Html.FROM_HTML_MODE_LEGACY).toString();
            } else {
                body = Html.fromHtml(body).toString();
            }
        }

        final OtrService otrService = conversation.getAccount().getOtrService();
        Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
        finishedMessage.setFingerprint(otrService.getFingerprint(otrSession.getRemotePublicKey()));
        conversation.setLastReceivedOtrMessageId(null);

        return finishedMessage;
    } catch (Exception e) {
        conversation.resetOtrSession();
        return null;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:60,代码来源:MessageParser.java

示例4: parseOtrChat

import net.java.otr4j.session.Session; //导入方法依赖的package包/类
private Message parseOtrChat(String body, Jid from, String id, Conversation conversation) {
	String presence;
	if (from.isBareJid()) {
		presence = "";
	} else {
		presence = from.getResourcepart();
	}
	if (body.matches("^\\?OTRv\\d{1,2}\\?.*")) {
		conversation.endOtrIfNeeded();
	}
	if (!conversation.hasValidOtrSession()) {
		conversation.startOtrSession(presence, false);
	} else {
		String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
		if (!foreignPresence.equals(presence)) {
			conversation.endOtrIfNeeded();
			conversation.startOtrSession(presence, false);
		}
	}
	try {
		conversation.setLastReceivedOtrMessageId(id);
		Session otrSession = conversation.getOtrSession();
		body = otrSession.transformReceiving(body);
		SessionStatus status = otrSession.getSessionStatus();
		if (body == null && status == SessionStatus.ENCRYPTED) {
			mXmppConnectionService.onOtrSessionEstablished(conversation);
			return null;
		} else if (body == null && status == SessionStatus.FINISHED) {
			conversation.resetOtrSession();
			mXmppConnectionService.updateConversationUi();
			return null;
		} else if (body == null || (body.isEmpty())) {
			return null;
		}
		if (body.startsWith(CryptoHelper.FILETRANSFER)) {
			String key = body.substring(CryptoHelper.FILETRANSFER.length());
			conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
			return null;
		}
		if (clientMightSendHtml(conversation.getAccount(), from)) {
			Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": received OTR message from bad behaving client. escaping HTML…");
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
				body = Html.fromHtml(body, Html.FROM_HTML_MODE_LEGACY).toString();
			} else {
				body = Html.fromHtml(body).toString();
			}
		}

		final OtrService otrService = conversation.getAccount().getOtrService();
		Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR, Message.STATUS_RECEIVED);
		finishedMessage.setFingerprint(otrService.getFingerprint(otrSession.getRemotePublicKey()));
		conversation.setLastReceivedOtrMessageId(null);

		return finishedMessage;
	} catch (Exception e) {
		conversation.resetOtrSession();
		return null;
	}
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:60,代码来源:MessageParser.java

示例5: parseOtrChat

import net.java.otr4j.session.Session; //导入方法依赖的package包/类
private Message parseOtrChat(MessagePacket packet, Account account) {
	final Jid to = packet.getTo();
	final Jid from = packet.getFrom();
	if (to == null || from == null) {
		return null;
	}
	boolean properlyAddressed = !to.isBareJid() || account.countPresences() == 1;
	Conversation conversation = mXmppConnectionService
			.findOrCreateConversation(account, from.toBareJid(), false);
	String presence;
	if (from.isBareJid()) {
           presence = "";
	} else {
		presence = from.getResourcepart();
	}
	updateLastseen(packet, account, true);
	String body = packet.getBody();
	if (body.matches("^\\?OTRv\\d*\\?")) {
		conversation.endOtrIfNeeded();
	}
	if (!conversation.hasValidOtrSession()) {
		if (properlyAddressed) {
			conversation.startOtrSession(presence,false);
		} else {
			return null;
		}
	} else {
		String foreignPresence = conversation.getOtrSession()
				.getSessionID().getUserID();
		if (!foreignPresence.equals(presence)) {
			conversation.endOtrIfNeeded();
			if (properlyAddressed) {
				conversation.startOtrSession(presence, false);
			} else {
				return null;
			}
		}
	}
	try {
		Session otrSession = conversation.getOtrSession();
		SessionStatus before = otrSession.getSessionStatus();
		body = otrSession.transformReceiving(body);
		SessionStatus after = otrSession.getSessionStatus();
		if ((before != after) && (after == SessionStatus.ENCRYPTED)) {
			mXmppConnectionService.onOtrSessionEstablished(conversation);
		} else if ((before != after) && (after == SessionStatus.FINISHED)) {
			conversation.resetOtrSession();
			mXmppConnectionService.updateConversationUi();
		}
		if ((body == null) || (body.isEmpty())) {
			return null;
		}
		if (body.startsWith(CryptoHelper.FILETRANSFER)) {
			String key = body.substring(CryptoHelper.FILETRANSFER.length());
			conversation.setSymmetricKey(CryptoHelper.hexToBytes(key));
			return null;
		}
		Message finishedMessage = new Message(conversation, body, Message.ENCRYPTION_OTR,
				Message.STATUS_RECEIVED);
		finishedMessage.setTime(getTimestamp(packet));
		finishedMessage.setRemoteMsgId(packet.getId());
		finishedMessage.markable = isMarkable(packet);
		finishedMessage.setCounterpart(from);
		return finishedMessage;
	} catch (Exception e) {
		conversation.resetOtrSession();
		return null;
	}
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:70,代码来源:MessageParser.java

示例6: parseOtrChat

import net.java.otr4j.session.Session; //导入方法依赖的package包/类
public Message parseOtrChat(MessagePacket packet, Account account) {
	boolean properlyAddressed = (packet.getTo().split("/").length == 2)
			|| (account.countPresences() == 1);
	String[] fromParts = packet.getFrom().split("/");
	Conversation conversation = mXmppConnectionService
			.findOrCreateConversation(account, fromParts[0], false);
	updateLastseen(packet, account,true);
	String body = packet.getBody();
	if (!conversation.hasValidOtrSession()) {
		if (properlyAddressed) {
			conversation.startOtrSession(
					mXmppConnectionService.getApplicationContext(),
					fromParts[1], false);
		} else {
			return null;
		}
	} else {
		String foreignPresence = conversation.getOtrSession()
				.getSessionID().getUserID();
		if (!foreignPresence.equals(fromParts[1])) {
			conversation.resetOtrSession();
			if (properlyAddressed) {
				conversation.startOtrSession(
						mXmppConnectionService.getApplicationContext(),
						fromParts[1], false);
			} else {
				return null;
			}
		}
	}
	try {
		Session otrSession = conversation.getOtrSession();
		SessionStatus before = otrSession.getSessionStatus();
		body = otrSession.transformReceiving(body);
		SessionStatus after = otrSession.getSessionStatus();
		if ((before != after) && (after == SessionStatus.ENCRYPTED)) {
			mXmppConnectionService.onOtrSessionEstablished(conversation);
		} else if ((before != after) && (after == SessionStatus.FINISHED)) {
			conversation.resetOtrSession();
		}
		// isEmpty is a work around for some weird clients which send emtpty
		// strings over otr
		if ((body == null) || (body.isEmpty())) {
			return null;
		}
		conversation.setLatestMarkableMessageId(getMarkableMessageId(packet));
		Message finishedMessage = new Message(conversation, packet.getFrom(), body,
				Message.ENCRYPTION_OTR, Message.STATUS_RECIEVED);
		finishedMessage.setTime(getTimestamp(packet));
		return finishedMessage;
	} catch (Exception e) {
		conversation.resetOtrSession();
		return null;
	}
}
 
开发者ID:GitESS,项目名称:SyncChatAndroid,代码行数:56,代码来源:MessageParser.java


注:本文中的net.java.otr4j.session.Session.getSessionStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。