use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class XMPPAuthManager method addContactToRoster.
private void addContactToRoster(String apiJid, String clientJid) {
UserJid user;
AccountJid account;
try {
user = UserJid.from(apiJid);
account = AccountJid.from(clientJid);
RosterManager.getInstance().createContact(account, user, "xabber", Collections.EMPTY_LIST);
PresenceManager.getInstance().requestSubscription(account, user, false);
} catch (UserJid.UserJidCreateException | XmppStringprepException | InterruptedException | SmackException | NetworkException | XMPPException.XMPPErrorException e) {
LogManager.exception(this, e);
return;
}
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class ReceiptManager method onStanza.
@Override
public void onStanza(ConnectionItem connection, Stanza packet) {
if (!(connection instanceof AccountItem)) {
return;
}
final AccountJid account = ((AccountItem) connection).getAccount();
final Jid from = packet.getFrom();
if (from == null) {
return;
}
if (!(packet instanceof Message)) {
return;
}
final Message message = (Message) packet;
if (message.getType() == Message.Type.error) {
Application.getInstance().runInBackgroundUserRequest(new Runnable() {
@Override
public void run() {
markAsError(account, message);
}
});
} else {
// TODO setDefaultAutoReceiptMode should be used
for (ExtensionElement packetExtension : message.getExtensions()) {
if (packetExtension instanceof DeliveryReceiptRequest) {
String id = AbstractChat.getStanzaId(message);
if (id == null) {
continue;
}
Message receipt = new Message(from);
receipt.addExtension(new DeliveryReceipt(id));
// the key problem is Thread - smack does not keep it in auto reply
receipt.setThread(message.getThread());
receipt.setType(Message.Type.chat);
try {
StanzaSender.sendStanza(account, receipt);
} catch (NetworkException e) {
LogManager.exception(this, e);
}
}
}
}
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class QuestionViewer method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing()) {
return;
}
Intent intent = getIntent();
account = QuestionViewer.getAccount(intent);
user = QuestionViewer.getUser(intent);
if (AccountManager.getInstance().getAccount(account) == null || user == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish();
return;
}
if (intent.getBooleanExtra(EXTRA_FIELD_CANCEL, false)) {
try {
OTRManager.getInstance().abortSmp(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
finish();
return;
}
showQuestion = intent.getBooleanExtra(EXTRA_FIELD_SHOW_QUESTION, true);
answerRequest = intent.getBooleanExtra(EXTRA_FIELD_ANSWER_REQUEST, false);
if (showQuestion) {
setContentView(R.layout.question_viewer);
questionView = (EditText) findViewById(R.id.question);
questionView.setEnabled(!answerRequest);
if (answerRequest) {
questionView.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
} else {
findViewById(R.id.cancel).setVisibility(View.GONE);
}
} else {
setContentView(R.layout.secret_viewer);
}
findViewById(R.id.cancel).setOnClickListener(this);
findViewById(R.id.send).setOnClickListener(this);
contactTitleActionBarInflater = new ContactTitleActionBarInflater(this, (Toolbar) findViewById(R.id.toolbar_default));
contactTitleActionBarInflater.setUpActionBarView();
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class SSNManager method sendFeature.
private void sendFeature(String account, String user, String session, Feature feature) {
Message message = new Message(user, Message.Type.normal);
message.setThread(session);
message.addExtension(feature);
try {
ConnectionManager.getInstance().sendStanza(account, message);
} catch (NetworkException e) {
}
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class TimeManager method onPacket.
@Override
public void onPacket(ConnectionItem connection, final String bareAddress, Stanza packet) {
if (!(connection instanceof AccountItem))
return;
String account = ((AccountItem) connection).getAccount();
if (!(packet instanceof Time))
return;
Time time = (Time) packet;
if (time.getType() == Type.get) {
Time result = new Time();
result.setType(Type.result);
result.setPacketID(time.getPacketID());
result.setFrom(time.getTo());
result.setTo(time.getFrom());
Calendar calendar = Calendar.getInstance();
result.setTzo((calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / 60000);
result.setUtc(calendar.getTime());
try {
ConnectionManager.getInstance().sendStanza(account, result);
} catch (NetworkException e) {
}
}
}
Aggregations