本文整理汇总了Java中net.java.otr4j.session.SessionStatus类的典型用法代码示例。如果您正苦于以下问题:Java SessionStatus类的具体用法?Java SessionStatus怎么用?Java SessionStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionStatus类属于net.java.otr4j.session包,在下文中一共展示了SessionStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: endOtrIfNeeded
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public boolean endOtrIfNeeded() {
if (this.otrSession != null) {
if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
this.otrSession.endSession();
this.resetOtrSession();
return true;
} catch (OtrException e) {
this.resetOtrSession();
return false;
}
} else {
this.resetOtrSession();
return false;
}
} else {
return false;
}
}
示例2: endOtrIfNeeded
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public boolean endOtrIfNeeded() {
if (this.otrSession != null) {
if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
this.otrSession.endSession();
this.resetOtrSession();
return true;
} catch (OtrException e) {
this.resetOtrSession();
return false;
}
} else {
this.resetOtrSession();
return false;
}
} else {
return false;
}
}
示例3: sendDataAsync
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
private void sendDataAsync (OtrChatManager cm, Message message, boolean isResponse, byte[] data)
{
SessionID sId = cm.getSessionId(message.getFrom().getAddress(), message.getTo().getAddress());
SessionStatus otrStatus = cm.getSessionStatus(sId);
//can't send if not encrypted session
if (otrStatus == SessionStatus.ENCRYPTED) {
boolean verified = cm.getKeyManager().isVerified(sId);
if (verified) {
message.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED);
} else {
message.setType(Imps.MessageType.OUTGOING_ENCRYPTED);
}
boolean canSend = cm.transformSending(message, isResponse, data);
if (canSend)
mManager.sendMessageAsync(this, message);
}
}
示例4: toggleInputMode
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
private void toggleInputMode ()
{
if (mButtonTalk.getVisibility() == View.GONE) {
if (mComposeMessage.getText().length() > 0 && mSendButton.getVisibility() == View.GONE) {
mMicButton.setVisibility(View.GONE);
mSendButton.setVisibility(View.VISIBLE);
mSendButton.setImageResource(R.drawable.ic_send_holo_light);
if (mLastSessionStatus == SessionStatus.ENCRYPTED)
mSendButton.setImageResource(R.drawable.ic_send_secure);
} else if (mComposeMessage.getText().length() == 0) {
mMicButton.setVisibility(View.VISIBLE);
mSendButton.setVisibility(View.GONE);
}
}
}
示例5: makeFingerprintWarning
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
protected void makeFingerprintWarning() {
if (conversation.smpRequested()) {
showSnackbar(R.string.smp_requested, R.string.verify, new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString());
intent.putExtra("account", conversation.getAccount().getJid().toBareJid().toString());
intent.putExtra("mode",VerifyOTRActivity.MODE_ANSWER_QUESTION);
startActivity(intent);
}
});
} else if (conversation.hasValidOtrSession() && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED)
&& (!conversation.isOtrFingerprintVerified())) {
showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, clickToVerify);
}
}
示例6: sessionStatusChanged
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
@Override
public void sessionStatusChanged(final SessionID sessionID) {
Log.d(TAG, "OTR Status changed for " + sessionID + " : " + mOtrEngine.getSessionStatus(sessionID));
if (mOtrKeyManager.loadRemotePublicKey(sessionID) == null) {
mOtrKeyManager.savePublicKey(sessionID, mOtrEngine.getRemotePublicKey(sessionID));
}
SessionStatus status = mOtrEngine.getSessionStatus(sessionID);
if (status.equals(SessionStatus.ENCRYPTED) && mOtrKeyManager.isVerified(sessionID)) {
mChats.get(sessionID).otrStateChanged("AUTHENTICATED");
} else {
if (status.equals(SessionStatus.FINISHED)) {
try {
mChats.get(sessionID).localEndOtrSession();
} catch (OtrException e) {
Log.w(TAG, "error when closing local otr session", e);
}
}
else {
mChats.get(sessionID).otrStateChanged(status.toString());
}
}
}
示例7: startOtrIfNeeded
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public boolean startOtrIfNeeded() {
if (this.otrSession != null && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try {
this.otrSession.startSession();
return true;
} catch (OtrException e) {
this.resetOtrSession();
return false;
}
} else {
return true;
}
}
示例8: getOtrFingerprint
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public synchronized String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (getOtrSession() == null || getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
return null;
}
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey).toLowerCase(Locale.US);
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
return null;
}
}
return this.otrFingerprint;
}
示例9: verifyOtrSessionDialog
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public void verifyOtrSessionDialog(final Conversation conversation, View view) {
if (!conversation.hasValidOtrSession() || conversation.getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
Toast.makeText(this, R.string.otr_session_not_started, Toast.LENGTH_LONG).show();
return;
}
if (view == null) {
return;
}
PopupMenu popup = new PopupMenu(this, view);
popup.inflate(R.menu.verification_choices);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent intent = new Intent(ConversationActivity.this, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString());
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString());
switch (menuItem.getItemId()) {
case R.id.scan_fingerprint:
intent.putExtra("mode", VerifyOTRActivity.MODE_SCAN_FINGERPRINT);
break;
case R.id.ask_question:
intent.putExtra("mode", VerifyOTRActivity.MODE_ASK_QUESTION);
break;
case R.id.manual_verification:
intent.putExtra("mode", VerifyOTRActivity.MODE_MANUAL_VERIFICATION);
break;
}
startActivity(intent);
return true;
}
});
popup.show();
}
示例10: startOtrIfNeeded
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public void startOtrIfNeeded() {
if (this.otrSession != null
&& this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try {
this.otrSession.startSession();
} catch (OtrException e) {
this.resetOtrSession();
}
}
}
示例11: getOtrFingerprint
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public synchronized String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (getOtrSession() == null || getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
return null;
}
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey);
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
return null;
}
}
return this.otrFingerprint;
}
示例12: verifyOtrSessionDialog
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public void verifyOtrSessionDialog(final Conversation conversation, View view) {
if (!conversation.hasValidOtrSession() || conversation.getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
Toast.makeText(this, R.string.otr_session_not_started, Toast.LENGTH_LONG).show();
return;
}
if (view == null) {
return;
}
PopupMenu popup = new PopupMenu(this, view);
popup.inflate(R.menu.verification_choices);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent intent = new Intent(ConversationActivity.this, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString());
intent.putExtra("account", conversation.getAccount().getJid().toBareJid().toString());
switch (menuItem.getItemId()) {
case R.id.scan_fingerprint:
intent.putExtra("mode", VerifyOTRActivity.MODE_SCAN_FINGERPRINT);
break;
case R.id.ask_question:
intent.putExtra("mode", VerifyOTRActivity.MODE_ASK_QUESTION);
break;
case R.id.manual_verification:
intent.putExtra("mode", VerifyOTRActivity.MODE_MANUAL_VERIFICATION);
break;
}
startActivity(intent);
return true;
}
});
popup.show();
}
示例13: startOtrIfNeeded
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public boolean startOtrIfNeeded() {
if (this.otrSession != null && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try {
this.otrSession.startSession();
return true;
} catch (OtrException e) {
this.resetOtrSession();
return false;
}
} else {
return true;
}
}
示例14: getOtrFingerprint
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public synchronized String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {
if (getOtrSession() == null || getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
return null;
}
DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey();
this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey).toLowerCase(Locale.US);
} catch (final OtrCryptoException | UnsupportedOperationException ignored) {
return null;
}
}
return this.otrFingerprint;
}
示例15: verifyOtrSessionDialog
import net.java.otr4j.session.SessionStatus; //导入依赖的package包/类
public void verifyOtrSessionDialog(final Conversation conversation, View view) {
if (!conversation.hasValidOtrSession() || conversation.getOtrSession().getSessionStatus() != SessionStatus.ENCRYPTED) {
Toast.makeText(this, R.string.otr_session_not_started, Toast.LENGTH_LONG).show();
return;
}
if (view == null) {
return;
}
PopupMenu popup = new PopupMenu(this, view);
popup.inflate(R.menu.verification_choices);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
Intent intent = new Intent(ConversationActivity.this, VerifyOTRActivity.class);
intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT);
intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString());
intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString());
switch (menuItem.getItemId()) {
case R.id.scan_fingerprint:
intent.putExtra("mode", VerifyOTRActivity.MODE_SCAN_FINGERPRINT);
break;
case R.id.ask_question:
intent.putExtra("mode", VerifyOTRActivity.MODE_ASK_QUESTION);
break;
case R.id.manual_verification:
intent.putExtra("mode", VerifyOTRActivity.MODE_MANUAL_VERIFICATION);
break;
}
startActivity(intent);
return true;
}
});
popup.show();
}