use of org.jxmpp.stringprep.XmppStringprepException in project xabber-android by redsolution.
the class OTRManager method askForSecret.
@Override
public void askForSecret(SessionID sessionID, InstanceTag receiverTag, String question) {
try {
AccountJid accountJid = AccountJid.from(sessionID.getAccountID());
UserJid userJid = UserJid.from(sessionID.getUserID());
// set notify intent to chat
setNotifyIntentToChat(QuestionActivity.createIntent(Application.getInstance(), accountJid, userJid, question != null, true, question), accountJid, userJid);
// show android notification
SMRequest request = new SMRequest(AccountJid.from(sessionID.getAccountID()), UserJid.from(sessionID.getUserID()), question);
smRequestProvider.add(request, true);
// send event of adding auth request to fragment
EventBus.getDefault().post(new AuthAskEvent(accountJid, userJid));
} catch (UserJid.UserJidCreateException | XmppStringprepException e) {
LogManager.exception(this, e);
}
}
use of org.jxmpp.stringprep.XmppStringprepException in project xabber-android by redsolution.
the class AccountManager method getSelectedAccount.
/**
* @return Selected account to show contacts. <code>null</code> if
* <ul>
* <li>there is no selected account,</li>
* <li>selected account does not exists or disabled,</li>
* <li>Group by account is enabled.</li>
* </ul>
*/
public AccountJid getSelectedAccount() {
if (SettingsManager.contactsShowAccounts()) {
return null;
}
if (TextUtils.isEmpty(SettingsManager.contactsSelectedAccount())) {
return null;
}
AccountJid selected;
try {
selected = AccountJid.from(SettingsManager.contactsSelectedAccount());
} catch (XmppStringprepException e) {
LogManager.exception(this, e);
return null;
}
AccountItem selectedAccountItem = accountItems.get(selected);
if (selectedAccountItem != null && selectedAccountItem.isEnabled()) {
return selected;
}
return null;
}
use of org.jxmpp.stringprep.XmppStringprepException in project xabber-android by redsolution.
the class MessageDatabaseManager method copyDataFromSqliteToRealm.
void copyDataFromSqliteToRealm() {
Realm realm = getNewBackgroundRealm();
realm.beginTransaction();
LogManager.i("DatabaseManager", "copying from sqlite to Reaml");
long counter = 0;
Cursor cursor = MessageTable.getInstance().getAllMessages();
while (cursor.moveToNext()) {
try {
MessageItem messageItem = MessageTable.createMessageItem(cursor);
realm.copyToRealm(messageItem);
} catch (XmppStringprepException | UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
counter++;
}
cursor.close();
LogManager.i("DatabaseManager", counter + " messages copied to Realm");
LogManager.i("DatabaseManager", "onSuccess. removing messages from sqlite:");
int removedMessages = MessageTable.getInstance().removeAllMessages();
LogManager.i("DatabaseManager", removedMessages + " messages removed from sqlite");
realm.commitTransaction();
realm.close();
}
use of org.jxmpp.stringprep.XmppStringprepException in project xabber-android by redsolution.
the class XMPPAccountAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final XMPPAccountSettings account = items.get(position);
XMPPAccountVH viewHolder = (XMPPAccountVH) holder;
viewHolder.chkAccountSync.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
account.setSynchronization(isChecked);
}
});
// set colors
int colorId = ColorManager.getInstance().convertColorNameToId(account.getColor());
// set username
if (account.getUsername() != null && !account.getUsername().isEmpty())
viewHolder.username.setText(account.getUsername());
else
viewHolder.username.setText(account.getJid());
// set avatar
try {
AccountJid accountJid = AccountJid.from(account.getJid() + "/resource");
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatarForSync(accountJid, colorId));
} catch (XmppStringprepException e) {
e.printStackTrace();
}
if (account.isSynchronization() || isAllChecked) {
if (account.getStatus() != null) {
switch(account.getStatus()) {
case local:
viewHolder.jid.setText(R.string.sync_status_local);
break;
case remote:
viewHolder.jid.setText(R.string.sync_status_remote);
break;
case localNewer:
viewHolder.jid.setText(R.string.sync_status_local);
break;
case remoteNewer:
if (account.isDeleted()) {
viewHolder.jid.setText(R.string.sync_status_deleted);
} else {
viewHolder.jid.setText(R.string.sync_status_remote);
}
break;
case localEqualsRemote:
viewHolder.jid.setText(R.string.sync_status_ok);
break;
default:
break;
}
}
} else {
viewHolder.jid.setText(R.string.sync_status_no);
}
// set sync checkbox
if (account.isSyncNotAllowed()) {
viewHolder.jid.setText(R.string.sync_status_not_allowed);
viewHolder.chkAccountSync.setEnabled(false);
} else if (isAllChecked) {
viewHolder.chkAccountSync.setEnabled(false);
viewHolder.chkAccountSync.setChecked(true);
} else {
viewHolder.chkAccountSync.setEnabled(true);
viewHolder.chkAccountSync.setChecked(account.isSynchronization());
}
}
use of org.jxmpp.stringprep.XmppStringprepException in project Smack by igniterealtime.
the class FillableForm method setAnswer.
public void setAnswer(String fieldName, CharSequence answer) {
FormField blankField = getFieldOrThrow(fieldName);
FormField.Type type = blankField.getType();
FormField filledFormField;
switch(type) {
case list_multi:
case jid_multi:
throw new IllegalArgumentException("Can not answer fields of type '" + type + "' with a CharSequence");
case fixed:
throw new IllegalArgumentException("Fields of type 'fixed' are not answerable");
case list_single:
case text_private:
case text_single:
case hidden:
filledFormField = createSingleKindFieldBuilder(fieldName, type).setValue(answer).build();
break;
case bool:
filledFormField = FormField.booleanBuilder(fieldName).setValue(answer).build();
break;
case jid_single:
Jid jid;
try {
jid = JidCreate.from(answer);
} catch (XmppStringprepException e) {
throw new IllegalArgumentException(e);
}
filledFormField = FormField.jidSingleBuilder(fieldName).setValue(jid).build();
break;
case text_multi:
filledFormField = createMultiKindFieldbuilder(fieldName, type).addValue(answer).build();
break;
default:
throw new AssertionError();
}
write(filledFormField);
}
Aggregations