aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/services/XmppConnectionService.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-18 11:25:04 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-18 11:25:04 +0200
commit0cdd74417fe98afbb184d83c8ff0a4fc248006de (patch)
treef59f392b11b638eddee6b505b750c8dafd6cc40a /src/eu/siacs/conversations/services/XmppConnectionService.java
parent66aacf7e3edae1e4a6ec6cab72df82ae38daa096 (diff)
fixed #53 aka server not found bug
Diffstat (limited to 'src/eu/siacs/conversations/services/XmppConnectionService.java')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 624dd219..e5ed6a55 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -242,10 +242,17 @@ public class XmppConnectionService extends Service {
} else if (account.getStatus() == Account.STATUS_REGISTRATION_SUCCESSFULL) {
databaseBackend.updateAccount(account);
reconnectAccount(account, true);
- } else {
- UIHelper.showErrorNotification(getApplicationContext(),
- getAccounts());
+ } else if (account.getStatus() != Account.STATUS_CONNECTING) {
+ int next = account.getXmppConnection().getTimeToNextAttempt();
+ Log.d(LOGTAG, account.getJid()
+ + ": error connecting account. try again in " + next
+ + "s for the "
+ + (account.getXmppConnection().getAttempt() + 1)
+ + " time");
+ scheduleWakeupCall(next, false);
}
+ UIHelper.showErrorNotification(getApplicationContext(),
+ getAccounts());
}
};
@@ -576,8 +583,6 @@ public class XmppConnectionService extends Service {
statusListener.onStatusChanged(account);
}
}
-
- // TODO 3 remaining cases
if (account.getStatus() == Account.STATUS_ONLINE) {
long lastReceived = account.getXmppConnection().lastPaketReceived;
long lastSent = account.getXmppConnection().lastPingSent;
@@ -605,15 +610,9 @@ public class XmppConnectionService extends Service {
+ ": time out during connect reconnecting");
reconnectAccount(account, true);
} else {
- Log.d(LOGTAG,
- "seconds since last connect:"
- + ((SystemClock.elapsedRealtime() - account
- .getXmppConnection().lastConnect) / 1000));
- Log.d(LOGTAG,
- account.getJid() + ": status="
- + account.getStatus());
- // TODO notify user of ssl cert problem or auth problem
- // or what ever
+ if (account.getXmppConnection().getTimeToNextAttempt() <= 0) {
+ reconnectAccount(account, true);
+ }
}
// in any case. reschedule wakup call
this.scheduleWakeupCall(PING_MAX_INTERVAL, true);
@@ -676,7 +675,6 @@ public class XmppConnectionService extends Service {
this.pingIntent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
timeToWake, pendingPingIntent);
- // Log.d(LOGTAG,"schedule ping in "+seconds+" seconds");
} else {
long scheduledTime = this.pingIntent.getLongExtra("time", 0);
if (scheduledTime < SystemClock.elapsedRealtime()
@@ -687,7 +685,6 @@ public class XmppConnectionService extends Service {
context, 0, this.pingIntent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
timeToWake, pendingPingIntent);
- // Log.d(LOGTAG,"reschedule old ping to ping in "+seconds+" seconds");
}
}
} else {
@@ -829,16 +826,16 @@ public class XmppConnectionService extends Service {
}
}
}
-
+
private void resendMessage(Message message) {
Account account = message.getConversation().getAccount();
MessagePacket packet = null;
if (message.getEncryption() == Message.ENCRYPTION_NONE) {
- packet = prepareMessagePacket(account, message,null);
+ packet = prepareMessagePacket(account, message, null);
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
packet = prepareMessagePacket(account, message, null);
packet.setBody("This is an XEP-0027 encryted message");
- if (message.getEncryptedBody()==null) {
+ if (message.getEncryptedBody() == null) {
markMessage(message, Message.STATUS_SEND_FAILED);
return;
}
@@ -850,7 +847,7 @@ public class XmppConnectionService extends Service {
packet.addChild("x", "jabber:x:encrypted").setContent(
message.getBody());
}
- if (packet!=null) {
+ if (packet != null) {
account.getXmppConnection().sendMessagePacket(packet);
markMessage(message, Message.STATUS_SEND);
}
@@ -1159,8 +1156,7 @@ public class XmppConnectionService extends Service {
if (accountChangedListener != null) {
accountChangedListener.onAccountListChangedListener();
}
- UIHelper.showErrorNotification(getApplicationContext(),
- getAccounts());
+ UIHelper.showErrorNotification(getApplicationContext(), getAccounts());
}
public void deleteAccount(Account account) {
@@ -1172,8 +1168,7 @@ public class XmppConnectionService extends Service {
if (accountChangedListener != null) {
accountChangedListener.onAccountListChangedListener();
}
- UIHelper.showErrorNotification(getApplicationContext(),
- getAccounts());
+ UIHelper.showErrorNotification(getApplicationContext(), getAccounts());
}
public void setOnConversationListChangedListener(
@@ -1492,8 +1487,9 @@ public class XmppConnectionService extends Service {
}
return false;
}
-
- public boolean markMessage(Conversation conversation, String uuid, int status) {
+
+ public boolean markMessage(Conversation conversation, String uuid,
+ int status) {
for (Message message : conversation.getMessages()) {
if (message.getUuid().equals(uuid)) {
markMessage(message, status);