Rework `Account.getJid()' to return full JIDs

Remove `Account.getFullJid()'
This commit is contained in:
Sam Whited 2014-11-09 10:57:22 -05:00
parent 377bd49ee8
commit 180a0e4408
27 changed files with 102 additions and 106 deletions

View File

@ -153,7 +153,7 @@ public class OtrEngine implements OtrEngineHost {
public void injectMessage(SessionID session, String body)
throws OtrException {
MessagePacket packet = new MessagePacket();
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
if (session.getUserID().isEmpty()) {
packet.setAttribute("to", session.getAccountID());
} else {

View File

@ -41,7 +41,7 @@ public class PgpEngine {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message
.getConversation().getAccount().getJid().toString());
.getConversation().getAccount().getJid().toBareJid().toString());
if (message.getType() == Message.TYPE_TEXT) {
InputStream is = new ByteArrayInputStream(message.getBody()
.getBytes());
@ -156,7 +156,7 @@ public class PgpEngine {
.getMucOptions().getPgpKeyIds());
}
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message
.getConversation().getAccount().getJid().toString());
.getConversation().getAccount().getJid().toBareJid().toString());
if (message.getType() == Message.TYPE_TEXT) {
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
@ -257,7 +257,7 @@ public class PgpEngine {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toString());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toBareJid().toString());
InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
@ -284,7 +284,7 @@ public class PgpEngine {
Intent params = new Intent();
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.setAction(OpenPgpApi.ACTION_SIGN);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toString());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toBareJid().toString());
InputStream is = new ByteArrayInputStream(status.getBytes());
final OutputStream os = new ByteArrayOutputStream();
api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
@ -336,7 +336,7 @@ public class PgpEngine {
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount()
.getJid().toString());
.getJid().toBareJid().toString());
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
@ -362,7 +362,7 @@ public class PgpEngine {
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount()
.getJid().toString());
.getJid().toBareJid().toString());
Intent result = api.executeApi(params, null, null);
return (PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
@ -372,7 +372,7 @@ public class PgpEngine {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyId);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toString());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toBareJid().toString());
Intent result = api.executeApi(params, null, null);
return (PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT);

View File

@ -185,7 +185,7 @@ public class Account extends AbstractEntity {
}
public Jid getJid() {
return jid.toBareJid();
return jid;
}
public JSONObject getKeys() {
@ -246,10 +246,6 @@ public class Account extends AbstractEntity {
this.xmppConnection = connection;
}
public Jid getFullJid() {
return this.jid;
}
public String getOtrFingerprint() {
if (this.otrFingerprint == null) {
try {

View File

@ -38,7 +38,7 @@ public class MessageGenerator extends AbstractGenerator {
packet.setTo(message.getCounterpart().toBareJid());
packet.setType(MessagePacket.TYPE_GROUPCHAT);
}
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
packet.setId(message.getUuid());
if (addDelay) {
addDelay(packet, message.getTimeSent());
@ -124,7 +124,7 @@ public class MessageGenerator extends AbstractGenerator {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_NORMAL);
packet.setTo(to);
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
Element received = packet.addChild("displayed",
"urn:xmpp:chat-markers:0");
received.setAttribute("id", id);
@ -139,7 +139,7 @@ public class MessageGenerator extends AbstractGenerator {
Element subjectChild = new Element("subject");
subjectChild.setContent(subject);
packet.addChild(subjectChild);
packet.setFrom(conversation.getAccount().getJid());
packet.setFrom(conversation.getAccount().getJid().toBareJid());
return packet;
}
@ -147,7 +147,7 @@ public class MessageGenerator extends AbstractGenerator {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_NORMAL);
packet.setTo(contact);
packet.setFrom(conversation.getAccount().getFullJid());
packet.setFrom(conversation.getAccount().getJid());
Element x = packet.addChild("x", "jabber:x:conference");
x.setAttribute("jid", conversation.getContactJid().toBareJid().toString());
return packet;
@ -156,7 +156,7 @@ public class MessageGenerator extends AbstractGenerator {
public MessagePacket invite(Conversation conversation, String contact) {
MessagePacket packet = new MessagePacket();
packet.setTo(conversation.getContactJid().toBareJid());
packet.setFrom(conversation.getAccount().getFullJid());
packet.setFrom(conversation.getAccount().getJid());
Element x = new Element("x");
x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
Element invite = new Element("invite");
@ -171,7 +171,7 @@ public class MessageGenerator extends AbstractGenerator {
MessagePacket receivedPacket = new MessagePacket();
receivedPacket.setType(MessagePacket.TYPE_NORMAL);
receivedPacket.setTo(originalMessage.getFrom());
receivedPacket.setFrom(account.getFullJid());
receivedPacket.setFrom(account.getJid());
Element received = receivedPacket.addChild("received", namespace);
received.setAttribute("id", originalMessage.getId());
return receivedPacket;

View File

@ -16,7 +16,7 @@ public class PresenceGenerator extends AbstractGenerator {
PresencePacket packet = new PresencePacket();
packet.setAttribute("type", type);
packet.setTo(contact.getJid());
packet.setFrom(contact.getAccount().getJid());
packet.setFrom(contact.getAccount().getJid().toBareJid());
return packet;
}
@ -38,7 +38,7 @@ public class PresenceGenerator extends AbstractGenerator {
public PresencePacket sendPresence(Account account) {
PresencePacket packet = new PresencePacket();
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
String sig = account.getPgpSignature();
if (sig != null) {
packet.addChild("status").setContent("online");

View File

@ -68,7 +68,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.hasChild("query", "jabber:iq:roster")) {
final Jid from = packet.getFrom();
if ((from == null) || (from.equals(account.getJid()))) {
if ((from == null) || (from.equals(account.getJid().toBareJid()))) {
Element query = packet.findChild("query");
this.rosterItems(account, query);
}

View File

@ -347,7 +347,7 @@ public class MessageParser extends AbstractParser implements
avatar.owner = from;
if (mXmppConnectionService.getFileBackend().isAvatarCached(
avatar)) {
if (account.getJid().equals(from)) {
if (account.getJid().toBareJid().equals(from)) {
if (account.setAvatar(avatar.getFilename())) {
mXmppConnectionService.databaseBackend
.updateAccount(account);

View File

@ -55,7 +55,7 @@ public class PresenceParser extends AbstractParser implements
}
final Jid from = packet.getFrom();
String type = packet.getAttribute("type");
if (from.toBareJid().equals(account.getJid())) {
if (from.toBareJid().equals(account.getJid().toBareJid())) {
if (!from.getResourcepart().isEmpty()) {
if (type == null) {
account.updatePresence(from.getResourcepart(),

View File

@ -68,7 +68,7 @@ public class AvatarService {
this.sizes.add(size);
}
}
return PREFIX_CONTACT + "_" + contact.getAccount().getJid() + "_"
return PREFIX_CONTACT + "_" + contact.getAccount().getJid().toBareJid() + "_"
+ contact.getJid() + "_" + String.valueOf(size);
}
@ -173,7 +173,7 @@ public class AvatarService {
avatar = mXmppConnectionService.getFileBackend().getAvatar(
account.getAvatar(), size);
if (avatar == null) {
avatar = get(account.getJid().toString(), size);
avatar = get(account.getJid().toBareJid().toString(), size);
}
mXmppConnectionService.getBitmapCache().put(KEY, avatar);
return avatar;

View File

@ -190,11 +190,11 @@ public class XmppConnectionService extends Service {
}
if (connection != null && connection.getFeatures().csi()) {
if (checkListeners()) {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ " sending csi//inactive");
connection.sendInactive();
} else {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ " sending csi//active");
connection.sendActive();
}
@ -214,7 +214,7 @@ public class XmppConnectionService extends Service {
&& (account.getStatus() != Account.STATUS_NO_INTERNET)) {
if (connection != null) {
int next = connection.getTimeToNextAttempt();
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": error connecting account. try again in "
+ next + "s for the "
+ (connection.getAttempt() + 1) + " time");
@ -736,10 +736,10 @@ public class XmppConnectionService extends Service {
public void fetchRosterFromServer(Account account) {
IqPacket iqPacket = new IqPacket(IqPacket.TYPE_GET);
if (!"".equals(account.getRosterVersion())) {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": fetching roster version " + account.getRosterVersion());
} else {
Log.d(Config.LOGTAG, account.getJid() + ": fetching roster");
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching roster");
}
iqPacket.query("jabber:iq:roster").setAttribute("ver",
account.getRosterVersion());
@ -1276,7 +1276,7 @@ public class XmppConnectionService extends Service {
options.flagAboutToRename();
PresencePacket packet = new PresencePacket();
packet.setTo(options.getJoinJid());
packet.setFrom(conversation.getAccount().getFullJid());
packet.setFrom(conversation.getAccount().getJid());
String sig = account.getPgpSignature();
if (sig != null) {
@ -1305,12 +1305,12 @@ public class XmppConnectionService extends Service {
if (account.getStatus() == Account.STATUS_ONLINE) {
PresencePacket packet = new PresencePacket();
packet.setTo(conversation.getMucOptions().getJoinJid());
packet.setFrom(conversation.getAccount().getFullJid());
packet.setFrom(conversation.getAccount().getJid());
packet.setAttribute("type", "unavailable");
sendPresencePacket(conversation.getAccount(), packet);
conversation.getMucOptions().setOffline();
conversation.deregisterWithBookmark();
Log.d(Config.LOGTAG, conversation.getAccount().getJid()
Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid()
+ ": leaving muc " + conversation.getContactJid());
} else {
account.pendingConferenceLeaves.add(conversation);
@ -1328,7 +1328,7 @@ public class XmppConnectionService extends Service {
leaveMuc(conversation);
} else {
if (conversation.endOtrIfNeeded()) {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": ended otr session with "
+ conversation.getContactJid());
}
@ -1376,7 +1376,7 @@ public class XmppConnectionService extends Service {
List<Message> messages = conversation.getMessages();
Session otrSession = conversation.getOtrSession();
Log.d(Config.LOGTAG,
account.getJid() + " otr session established with "
account.getJid().toBareJid() + " otr session established with "
+ conversation.getContactJid() + "/"
+ otrSession.getSessionID().getUserID());
for (Message msg : messages) {
@ -1412,7 +1412,7 @@ public class XmppConnectionService extends Service {
if (otrSession != null) {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_CHAT);
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
packet.addChild("private", "urn:xmpp:carbons:2");
packet.addChild("no-copy", "urn:xmpp:hints");
packet.setAttribute("to", otrSession.getSessionID().getAccountID() + "/"
@ -1522,13 +1522,13 @@ public class XmppConnectionService extends Service {
@Override
public void onIqPacketReceived(Account account, IqPacket result) {
final String ERROR = account.getJid()
final String ERROR = account.getJid().toBareJid()
+ ": fetching avatar for " + avatar.owner + " failed ";
if (result.getType() == IqPacket.TYPE_RESULT) {
avatar.image = mIqParser.avatarData(result);
if (avatar.image != null) {
if (getFileBackend().save(avatar)) {
if (account.getJid().equals(avatar.owner)) {
if (account.getJid().toBareJid().equals(avatar.owner)) {
if (account.setAvatar(avatar.getFilename())) {
databaseBackend.updateAccount(account);
}
@ -1546,7 +1546,7 @@ public class XmppConnectionService extends Service {
if (callback != null) {
callback.success(avatar);
}
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": succesfully fetched avatar for "
+ avatar.owner);
return;
@ -1586,7 +1586,7 @@ public class XmppConnectionService extends Service {
if (items != null) {
Avatar avatar = Avatar.parseMetadata(items);
if (avatar != null) {
avatar.owner = account.getJid();
avatar.owner = account.getJid().toBareJid();
if (fileBackend.isAvatarCached(avatar)) {
if (account.setAvatar(avatar.getFilename())) {
databaseBackend.updateAccount(account);
@ -1750,7 +1750,7 @@ public class XmppConnectionService extends Service {
public Account findAccountByJid(final Jid accountJid) {
for (Account account : this.accounts) {
if (account.getJid().equals(accountJid)) {
if (account.getJid().toBareJid().equals(accountJid)) {
return account;
}
}
@ -1771,7 +1771,7 @@ public class XmppConnectionService extends Service {
String id = conversation.getLatestMarkableMessageId();
conversation.markRead();
if (confirmMessages() && id != null && calledByUi) {
Log.d(Config.LOGTAG, conversation.getAccount().getJid()
Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid()
+ ": sending read marker for " + conversation.getName());
Account account = conversation.getAccount();
final Jid to = conversation.getContactJid();

View File

@ -99,7 +99,7 @@ public class ChooseContactActivity extends XmppActivity {
data.putExtra("contact", mListItem.getJid().toString());
String account = request.getStringExtra("account");
if (account == null && mListItem instanceof Contact) {
account = ((Contact) mListItem).getAccount().getJid().toString();
account = ((Contact) mListItem).getAccount().getJid().toBareJid().toString();
}
data.putExtra("account", account);
data.putExtra("conversation",

View File

@ -207,7 +207,7 @@ public class ConferenceDetailsActivity extends XmppActivity {
private void populateView() {
mAccountJid.setText(getString(R.string.using_account, conversation
.getAccount().getJid()));
.getAccount().getJid().toBareJid()));
mYourPhoto.setImageBitmap(avatarService().get(
conversation.getAccount(), getPixel(48)));
setTitle(conversation.getName());

View File

@ -329,7 +329,7 @@ public class ContactDetailsActivity extends XmppActivity {
contactJidTv.setText(contact.getJid().toString());
}
accountJidTv.setText(getString(R.string.using_account, contact
.getAccount().getJid()));
.getAccount().getJid().toBareJid()));
prepareContactBadge(badge, contact);
if (contact.getSystemAccount() == null) {
badge.setOnClickListener(onBadgeClick);

View File

@ -106,7 +106,7 @@ public class ConversationActivity extends XmppActivity implements
protected String getShareableUri() {
Conversation conversation = getSelectedConversation();
if (conversation != null) {
return "xmpp:" + conversation.getAccount().getJid();
return "xmpp:" + conversation.getAccount().getJid().toBareJid();
} else {
return "";
}

View File

@ -298,7 +298,7 @@ public class ConversationFragment extends Fragment {
} else {
Account account = message.getConversation().getAccount();
Intent intent = new Intent(activity, EditAccountActivity.class);
intent.putExtra("jid", account.getJid().toString());
intent.putExtra("jid", account.getJid().toBareJid().toString());
startActivity(intent);
}
}

View File

@ -205,7 +205,7 @@ public class EditAccountActivity extends XmppActivity {
if (mAccount!=null) {
Intent intent = new Intent(getApplicationContext(),
PublishProfilePictureActivity.class);
intent.putExtra("account", mAccount.getJid().toString());
intent.putExtra("account", mAccount.getJid().toBareJid().toString());
startActivity(intent);
}
}
@ -223,7 +223,7 @@ public class EditAccountActivity extends XmppActivity {
} else {
intent = new Intent(getApplicationContext(),
PublishProfilePictureActivity.class);
intent.putExtra("account", mAccount.getJid().toString());
intent.putExtra("account", mAccount.getJid().toBareJid().toString());
intent.putExtra("setup", true);
}
startActivity(intent);
@ -264,7 +264,7 @@ public class EditAccountActivity extends XmppActivity {
}
protected boolean accountInfoEdited() {
return (!this.mAccount.getJid().equals(
return (!this.mAccount.getJid().toBareJid().equals(
this.mAccountJid.getText().toString()))
|| (!this.mAccount.getPassword().equals(
this.mPassword.getText().toString()));
@ -273,7 +273,7 @@ public class EditAccountActivity extends XmppActivity {
@Override
protected String getShareableUri() {
if (mAccount!=null) {
return "xmpp:"+mAccount.getJid();
return "xmpp:"+mAccount.getJid().toBareJid();
} else {
return "";
}
@ -378,7 +378,7 @@ public class EditAccountActivity extends XmppActivity {
}
private void updateAccountInformation() {
this.mAccountJid.setText(this.mAccount.getJid().toString());
this.mAccountJid.setText(this.mAccount.getJid().toBareJid().toString());
this.mPassword.setText(this.mAccount.getPassword());
if (this.jidToEdit != null) {
this.mAvatar.setVisibility(View.VISIBLE);

View File

@ -81,7 +81,7 @@ public class ManageAccountActivity extends XmppActivity {
} else {
menu.findItem(R.id.mgmt_account_enable).setVisible(false);
}
menu.setHeaderTitle(this.selectedAccount.getJid().toString());
menu.setHeaderTitle(this.selectedAccount.getJid().toBareJid().toString());
}
@Override

View File

@ -187,7 +187,7 @@ public class PublishProfilePictureActivity extends XmppActivity {
} else {
loadImageIntoPreview(avatarUri);
}
this.accountTextView.setText(this.account.getJid().toString());
this.accountTextView.setText(this.account.getJid().toBareJid().toString());
}
}

View File

@ -574,7 +574,7 @@ public class StartConversationActivity extends XmppActivity {
this.mActivatedAccounts.clear();
for (Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.STATUS_DISABLED) {
this.mActivatedAccounts.add(account.getJid().toString());
this.mActivatedAccounts.add(account.getJid().toBareJid().toString());
}
}
this.mKnownHosts = xmppConnectionService.getKnownHosts();

View File

@ -277,14 +277,14 @@ public abstract class XmppActivity extends Activity {
public void switchToContactDetails(Contact contact) {
Intent intent = new Intent(this, ContactDetailsActivity.class);
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
intent.putExtra("account", contact.getAccount().getJid().toString());
intent.putExtra("account", contact.getAccount().getJid().toBareJid().toString());
intent.putExtra("contact", contact.getJid().toString());
startActivity(intent);
}
public void switchToAccount(Account account) {
Intent intent = new Intent(this, EditAccountActivity.class);
intent.putExtra("jid", account.getJid().toString());
intent.putExtra("jid", account.getJid().toBareJid().toString());
startActivity(intent);
}

View File

@ -31,7 +31,7 @@ public class AccountAdapter extends ArrayAdapter<Account> {
view = inflater.inflate(R.layout.account_row, parent, false);
}
TextView jid = (TextView) view.findViewById(R.id.account_jid);
jid.setText(account.getJid().toString());
jid.setText(account.getJid().toBareJid().toString());
TextView statusView = (TextView) view.findViewById(R.id.account_status);
ImageView imageView = (ImageView) view.findViewById(R.id.account_image);
imageView.setImageBitmap(activity.avatarService().get(account,

View File

@ -90,7 +90,7 @@ public class ExceptionHelper {
public void onClick(DialogInterface dialog, int which) {
Log.d(Config.LOGTAG, "using account="
+ finalAccount.getJid()
+ finalAccount.getJid().toBareJid()
+ " to send in stack trace");
Conversation conversation = null;
try {

View File

@ -124,7 +124,7 @@ public class UIHelper {
} else if (accountsWproblems.size() == 1) {
mBuilder.setContentTitle(context
.getString(R.string.problem_connecting_to_account));
mBuilder.setContentText(accountsWproblems.get(0).getJid().toString());
mBuilder.setContentText(accountsWproblems.get(0).getJid().toBareJid().toString());
} else {
mBuilder.setContentTitle(context
.getString(R.string.problem_connecting_to_accounts));

View File

@ -107,7 +107,7 @@ public class XmppConnection implements Runnable {
public XmppConnection(Account account, XmppConnectionService service) {
this.account = account;
this.wakeLock = service.getPowerManager().newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, account.getJid().toString());
PowerManager.PARTIAL_WAKE_LOCK, account.getJid().toBareJid().toString());
tagWriter = new TagWriter();
mXmppConnectionService = service;
applicationContext = service.getApplicationContext();
@ -132,7 +132,7 @@ public class XmppConnection implements Runnable {
}
protected void connect() {
Log.d(Config.LOGTAG, account.getJid().toString() + ": connecting");
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting");
usingCompression = false;
usingEncryption = false;
lastConnect = SystemClock.elapsedRealtime();
@ -148,7 +148,7 @@ public class XmppConnection implements Runnable {
Bundle result = DNSHelper.getSRVRecord(account.getServer());
ArrayList<Parcelable> values = result.getParcelableArrayList("values");
if ("timeout".equals(result.getString("error"))) {
Log.d(Config.LOGTAG, account.getJid().toString() + ": dns timeout");
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": dns timeout");
this.changeStatus(Account.STATUS_OFFLINE);
return;
} else if (values != null) {
@ -169,12 +169,12 @@ public class XmppConnection implements Runnable {
InetSocketAddress addr;
if (srvIpServer != null) {
addr = new InetSocketAddress(srvIpServer, srvRecordPort);
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": using values from dns " + srvRecordServer
+ "[" + srvIpServer + "]:" + srvRecordPort);
} else {
addr = new InetSocketAddress(srvRecordServer, srvRecordPort);
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": using values from dns "
+ srvRecordServer + ":" + srvRecordPort);
}
@ -182,10 +182,10 @@ public class XmppConnection implements Runnable {
socket.connect(addr, 20000);
socketError = false;
} catch (UnknownHostException e) {
Log.d(Config.LOGTAG, account.getJid().toString() + ": " + e.getMessage());
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
i++;
} catch (IOException e) {
Log.d(Config.LOGTAG, account.getJid().toString() + ": " + e.getMessage());
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
i++;
}
}
@ -203,7 +203,7 @@ public class XmppConnection implements Runnable {
&& "nosrv".equals(result.getString("error", null))) {
socket = new Socket(account.getServer().getDomainpart(), 5222);
} else {
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": timeout in DNS resolution");
changeStatus(Account.STATUS_OFFLINE);
return;
@ -237,7 +237,7 @@ public class XmppConnection implements Runnable {
}
}
} catch (final IOException | XmlPullParserException e) {
Log.d(Config.LOGTAG, account.getJid().toString() + ": " + e.getMessage());
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
this.changeStatus(Account.STATUS_OFFLINE);
if (wakeLock.isHeld()) {
try {
@ -246,7 +246,7 @@ public class XmppConnection implements Runnable {
}
}
} catch (NoSuchAlgorithmException e) {
Log.d(Config.LOGTAG, account.getJid().toString() + ": " + e.getMessage());
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": " + e.getMessage());
this.changeStatus(Account.STATUS_OFFLINE);
Log.d(Config.LOGTAG, "compression exception " + e.getMessage());
if (wakeLock.isHeld()) {
@ -277,7 +277,7 @@ public class XmppConnection implements Runnable {
} else if (nextTag.isStart("compressed")) {
switchOverToZLib(nextTag);
} else if (nextTag.isStart("success")) {
Log.d(Config.LOGTAG, account.getJid().toString() + ": logged in");
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": logged in");
tagReader.readTag();
tagReader.reset();
sendStartStream();
@ -298,11 +298,11 @@ public class XmppConnection implements Runnable {
Element enabled = tagReader.readElement(nextTag);
if ("true".equals(enabled.getAttribute("resume"))) {
this.streamId = enabled.getAttribute("id");
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": stream managment(" + smVersion
+ ") enabled (resumable)");
} else {
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": stream managment(" + smVersion + ") enabled");
}
this.lastSessionStarted = SystemClock.elapsedRealtime();
@ -316,11 +316,11 @@ public class XmppConnection implements Runnable {
try {
int serverCount = Integer.parseInt(h);
if (serverCount != stanzasSent) {
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": session resumed with lost packages");
stanzasSent = serverCount;
} else {
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": session resumed");
}
if (acknowledgedListener != null) {
@ -355,7 +355,7 @@ public class XmppConnection implements Runnable {
}
} else if (nextTag.isStart("failed")) {
tagReader.readElement(nextTag);
Log.d(Config.LOGTAG, account.getJid().toString() + ": resumption failed");
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": resumption failed");
streamId = null;
if (account.getStatus() != Account.STATUS_ONLINE) {
sendBindRequest();
@ -378,15 +378,15 @@ public class XmppConnection implements Runnable {
}
private void sendInitialPing() {
Log.d(Config.LOGTAG, account.getJid().toString() + ": sending intial ping");
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": sending intial ping");
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
iq.setFrom(account.getFullJid());
iq.setFrom(account.getJid());
iq.addChild("ping", "urn:xmpp:ping");
this.sendIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
Log.d(Config.LOGTAG, account.getJid().toString()
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString()
+ ": online with resource " + account.getResource());
changeStatus(Account.STATUS_ONLINE);
}
@ -515,7 +515,7 @@ public class XmppConnection implements Runnable {
.setInputStream(new ZLibInputStream(tagReader.getInputStream()));
sendStartStream();
Log.d(Config.LOGTAG, account.getJid() + ": compression enabled");
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": compression enabled");
usingCompression = true;
processStream(tagReader.readTag());
}
@ -582,7 +582,7 @@ public class XmppConnection implements Runnable {
tagReader.setInputStream(sslSocket.getInputStream());
tagWriter.setOutputStream(sslSocket.getOutputStream());
sendStartStream();
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": TLS connection established");
usingEncryption = true;
processStream(tagReader.readTag());
@ -642,7 +642,7 @@ public class XmppConnection implements Runnable {
} else if (this.streamFeatures.hasChild("bind") && shouldBind) {
sendBindRequest();
} else {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": incompatible server. disconnecting");
disconnect(true);
}
@ -720,7 +720,7 @@ public class XmppConnection implements Runnable {
} else {
changeStatus(Account.STATUS_REGISTRATION_FAILED);
disconnect(true);
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": could not register. instructions are"
+ instructions.getContent());
}
@ -773,7 +773,7 @@ public class XmppConnection implements Runnable {
}
});
if (this.streamFeatures.hasChild("session")) {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": sending deprecated session");
IqPacket startSession = new IqPacket(IqPacket.TYPE_SET);
startSession.addChild("session",
@ -843,10 +843,10 @@ public class XmppConnection implements Runnable {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (!packet.hasChild("error")) {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": successfully enabled carbons");
} else {
Log.d(Config.LOGTAG, account.getJid()
Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ ": error enableing carbons " + packet.toString());
}
}
@ -860,14 +860,14 @@ public class XmppConnection implements Runnable {
final String resource = account.getResource().split("\\.")[0];
account.setResource(resource + "." + nextRandomId());
Log.d(Config.LOGTAG,
account.getJid() + ": switching resource due to conflict ("
account.getJid().toBareJid() + ": switching resource due to conflict ("
+ account.getResource() + ")");
}
}
private void sendStartStream() throws IOException {
Tag stream = Tag.start("stream:stream");
stream.setAttribute("from", account.getJid().toString());
stream.setAttribute("from", account.getJid().toBareJid().toString());
stream.setAttribute("to", account.getServer().toString());
stream.setAttribute("version", "1.0");
stream.setAttribute("xml:lang", "en");
@ -885,7 +885,7 @@ public class XmppConnection implements Runnable {
String id = nextRandomId();
packet.setAttribute("id", id);
}
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
this.sendPacket(packet, callback);
}
@ -932,7 +932,7 @@ public class XmppConnection implements Runnable {
tagWriter.writeStanzaAsync(new RequestPacket(smVersion));
} else {
IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
iq.setFrom(account.getFullJid());
iq.setFrom(account.getJid());
iq.addChild("ping", "urn:xmpp:ping");
this.sendIqPacket(iq, null);
}
@ -972,7 +972,7 @@ public class XmppConnection implements Runnable {
}
public void disconnect(boolean force) {
Log.d(Config.LOGTAG, account.getJid() + ": disconnecting");
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": disconnecting");
try {
if (force) {
socket.close();

View File

@ -83,7 +83,7 @@ public class JingleConnection implements Downloadable {
@Override
public void onFileTransmitted(DownloadableFile file) {
if (responder.equals(account.getFullJid())) {
if (responder.equals(account.getJid())) {
sendSuccess();
if (acceptedAutomatically) {
message.markUnread();
@ -122,7 +122,7 @@ public class JingleConnection implements Downloadable {
@Override
public void success() {
if (initiator.equals(account.getFullJid())) {
if (initiator.equals(account.getJid())) {
Log.d(Config.LOGTAG, "we were initiating. sending file");
transport.send(file, onFileTransmissionSatusChanged);
} else {
@ -204,7 +204,7 @@ public class JingleConnection implements Downloadable {
this.contentName = this.mJingleConnectionManager.nextRandomId();
this.message = message;
this.account = message.getConversation().getAccount();
this.initiator = this.account.getFullJid();
this.initiator = this.account.getJid();
this.responder = this.message.getCounterpart();
this.sessionId = this.mJingleConnectionManager.nextRandomId();
if (this.candidates.size() > 0) {
@ -265,7 +265,7 @@ public class JingleConnection implements Downloadable {
this.message.setCounterpart(from);
this.account = account;
this.initiator = packet.getFrom();
this.responder = this.account.getFullJid();
this.responder = this.account.getJid();
this.sessionId = packet.getSessionId();
Content content = packet.getJingleContent();
this.contentCreator = content.getAttribute("creator");
@ -444,7 +444,7 @@ public class JingleConnection implements Downloadable {
private JinglePacket bootstrapPacket(String action) {
JinglePacket packet = new JinglePacket();
packet.setAction(action);
packet.setFrom(account.getFullJid());
packet.setFrom(account.getJid());
packet.setTo(this.message.getCounterpart());
packet.setSessionId(this.sessionId);
packet.setInitiator(this.initiator);
@ -533,7 +533,7 @@ public class JingleConnection implements Downloadable {
if (connection == null) {
Log.d(Config.LOGTAG, "could not find suitable candidate");
this.disconnect();
if (this.initiator.equals(account.getFullJid())) {
if (this.initiator.equals(account.getJid())) {
this.sendFallbackToIbb();
}
} else {
@ -571,7 +571,7 @@ public class JingleConnection implements Downloadable {
+ " was a proxy. waiting for other party to activate");
}
} else {
if (initiator.equals(account.getFullJid())) {
if (initiator.equals(account.getJid())) {
Log.d(Config.LOGTAG, "we were initiating. sending file");
connection.send(file, onFileTransmissionSatusChanged);
} else {
@ -601,7 +601,7 @@ public class JingleConnection implements Downloadable {
} else if (connection.getCandidate().getPriority() == currentConnection
.getCandidate().getPriority()) {
// Log.d(Config.LOGTAG,"found two candidates with same priority");
if (initiator.equals(account.getFullJid())) {
if (initiator.equals(account.getJid())) {
if (currentConnection.getCandidate().isOurs()) {
connection = currentConnection;
}
@ -710,7 +710,7 @@ public class JingleConnection implements Downloadable {
this.mJingleStatus = JINGLE_STATUS_CANCELED;
this.disconnect();
if (this.message != null) {
if (this.responder.equals(account.getFullJid())) {
if (this.responder.equals(account.getJid())) {
this.mStatus = Downloadable.STATUS_FAILED;
this.mXmppConnectionService.updateConversationUi();
} else {

View File

@ -75,7 +75,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
public void getPrimaryCandidate(Account account,
final OnPrimaryCandidateFound listener) {
if (!this.primaryCandidates.containsKey(account.getJid())) {
if (!this.primaryCandidates.containsKey(account.getJid().toBareJid())) {
String xmlns = "http://jabber.org/protocol/bytestreams";
final String proxy = account.getXmppConnection()
.findDiscoItemByFeature(xmlns);
@ -109,7 +109,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
candidate.setJid(null);
}
candidate.setPriority(655360 + 65535);
primaryCandidates.put(account.getJid(),
primaryCandidates.put(account.getJid().toBareJid(),
candidate);
listener.onPrimaryCandidateFound(true,
candidate);
@ -125,7 +125,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
} else {
listener.onPrimaryCandidateFound(true,
this.primaryCandidates.get(account.getJid()));
this.primaryCandidates.get(account.getJid().toBareJid()));
}
}

View File

@ -30,11 +30,11 @@ public class JingleSocks5Transport extends JingleTransport {
StringBuilder destBuilder = new StringBuilder();
destBuilder.append(jingleConnection.getSessionId());
if (candidate.isOurs()) {
destBuilder.append(jingleConnection.getAccount().getFullJid());
destBuilder.append(jingleConnection.getAccount().getJid());
destBuilder.append(jingleConnection.getCounterPart());
} else {
destBuilder.append(jingleConnection.getCounterPart());
destBuilder.append(jingleConnection.getAccount().getFullJid());
destBuilder.append(jingleConnection.getAccount().getJid());
}
mDigest.reset();
this.destination = CryptoHelper.bytesToHex(mDigest