mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
handle conference invites differently to deal with killed activities. fixes #1188
This commit is contained in:
parent
93e444ac3a
commit
d3a6aa9f7a
@ -2108,6 +2108,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||
}
|
||||
|
||||
public void invite(Conversation conversation, Jid contact) {
|
||||
Log.d(Config.LOGTAG,conversation.getAccount().getJid().toBareJid()+": inviting "+contact+" to "+conversation.getJid().toBareJid());
|
||||
MessagePacket packet = mMessageGenerator.invite(conversation, contact);
|
||||
sendMessagePacket(conversation.getAccount(), packet);
|
||||
}
|
||||
|
@ -385,6 +385,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||
|
||||
@Override
|
||||
void onBackendConnected() {
|
||||
if (mPendingConferenceInvite != null) {
|
||||
mPendingConferenceInvite.execute(this);
|
||||
mPendingConferenceInvite = null;
|
||||
}
|
||||
if (getIntent().getAction().equals(ACTION_VIEW_MUC)) {
|
||||
this.uuid = getIntent().getExtras().getString("uuid");
|
||||
}
|
||||
|
@ -901,6 +901,12 @@ public class ConversationActivity extends XmppActivity
|
||||
void onBackendConnected() {
|
||||
this.xmppConnectionService.getNotificationService().setIsInForeground(true);
|
||||
updateConversationList();
|
||||
|
||||
if (mPendingConferenceInvite != null) {
|
||||
mPendingConferenceInvite.execute(this);
|
||||
mPendingConferenceInvite = null;
|
||||
}
|
||||
|
||||
if (xmppConnectionService.getAccounts().size() == 0) {
|
||||
if (!mRedirected) {
|
||||
this.mRedirected = true;
|
||||
|
@ -113,6 +113,8 @@ public abstract class XmppActivity extends Activity {
|
||||
}
|
||||
};
|
||||
|
||||
protected ConferenceInvite mPendingConferenceInvite = null;
|
||||
|
||||
|
||||
protected void refreshUi() {
|
||||
final long diff = SystemClock.elapsedRealtime() - mLastUiRefresh;
|
||||
@ -367,7 +369,7 @@ public abstract class XmppActivity extends Activity {
|
||||
}
|
||||
|
||||
public void highlightInMuc(Conversation conversation, String nick) {
|
||||
switchToConversation(conversation,null,nick,false);
|
||||
switchToConversation(conversation, null, nick, false);
|
||||
}
|
||||
|
||||
private void switchToConversation(Conversation conversation, String text, String nick, boolean newTask) {
|
||||
@ -435,7 +437,7 @@ public abstract class XmppActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void userInputRequried(PendingIntent pi,
|
||||
Account account) {
|
||||
Account account) {
|
||||
try {
|
||||
startIntentSenderForResult(pi.getIntentSender(),
|
||||
REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
|
||||
@ -446,13 +448,13 @@ public abstract class XmppActivity extends Activity {
|
||||
@Override
|
||||
public void success(Account account) {
|
||||
xmppConnectionService.databaseBackend
|
||||
.updateAccount(account);
|
||||
.updateAccount(account);
|
||||
xmppConnectionService.sendPresence(account);
|
||||
if (conversation != null) {
|
||||
conversation
|
||||
.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||
.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||
xmppConnectionService.databaseBackend
|
||||
.updateConversation(conversation);
|
||||
.updateConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,32 +667,13 @@ public abstract class XmppActivity extends Activity {
|
||||
protected void onActivityResult(int requestCode, int resultCode,
|
||||
final Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == REQUEST_INVITE_TO_CONVERSATION
|
||||
&& resultCode == RESULT_OK) {
|
||||
try {
|
||||
String conversationUuid = data.getStringExtra("conversation");
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findConversationByUuid(conversationUuid);
|
||||
List<Jid> jids = new ArrayList<Jid>();
|
||||
if (data.getBooleanExtra("multiple", false)) {
|
||||
String[] toAdd = data.getStringArrayExtra("contacts");
|
||||
for (String item : toAdd) {
|
||||
jids.add(Jid.fromString(item));
|
||||
}
|
||||
} else {
|
||||
jids.add(Jid.fromString(data.getStringExtra("contact")));
|
||||
}
|
||||
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
for (Jid jid : jids) {
|
||||
xmppConnectionService.invite(conversation, jid);
|
||||
}
|
||||
} else {
|
||||
jids.add(conversation.getJid().toBareJid());
|
||||
xmppConnectionService.createAdhocConference(conversation.getAccount(), jids, adhocCallback);
|
||||
}
|
||||
} catch (final InvalidJidException ignored) {
|
||||
|
||||
if (requestCode == REQUEST_INVITE_TO_CONVERSATION && resultCode == RESULT_OK) {
|
||||
mPendingConferenceInvite = ConferenceInvite.parse(data);
|
||||
if (xmppConnectionServiceBound && mPendingConferenceInvite != null) {
|
||||
mPendingConferenceInvite.execute(this);
|
||||
mPendingConferenceInvite = null;
|
||||
} else {
|
||||
Log.d(Config.LOGTAG,"putting invite on pending");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -855,6 +838,48 @@ public abstract class XmppActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConferenceInvite {
|
||||
private String uuid;
|
||||
private List<Jid> jids = new ArrayList<>();
|
||||
|
||||
public static ConferenceInvite parse(Intent data) {
|
||||
ConferenceInvite invite = new ConferenceInvite();
|
||||
invite.uuid = data.getStringExtra("conversation");
|
||||
if (invite.uuid == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (data.getBooleanExtra("multiple", false)) {
|
||||
String[] toAdd = data.getStringArrayExtra("contacts");
|
||||
for (String item : toAdd) {
|
||||
invite.jids.add(Jid.fromString(item));
|
||||
}
|
||||
} else {
|
||||
invite.jids.add(Jid.fromString(data.getStringExtra("contact")));
|
||||
}
|
||||
} catch (final InvalidJidException ignored) {
|
||||
return null;
|
||||
}
|
||||
return invite;
|
||||
}
|
||||
|
||||
public void execute(XmppActivity activity) {
|
||||
XmppConnectionService service = activity.xmppConnectionService;
|
||||
Conversation conversation = service.findConversationByUuid(this.uuid);
|
||||
if (conversation == null) {
|
||||
return;
|
||||
}
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
for (Jid jid : jids) {
|
||||
service.invite(conversation, jid);
|
||||
}
|
||||
} else {
|
||||
jids.add(conversation.getJid().toBareJid());
|
||||
service.createAdhocConference(conversation.getAccount(), jids, activity.adhocCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AvatarService avatarService() {
|
||||
return xmppConnectionService.getAvatarService();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user