mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
bind and session request more compatible
This commit is contained in:
parent
e857cf979d
commit
590e2403ab
@ -9,5 +9,6 @@
|
|||||||
android:title="@string/attach_take_picture"/>
|
android:title="@string/attach_take_picture"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/attach_record_voice"
|
android:id="@+id/attach_record_voice"
|
||||||
android:title="@string/attach_record_voice" />
|
android:title="@string/attach_record_voice"
|
||||||
|
android:visible="false"/>
|
||||||
</menu>
|
</menu>
|
@ -29,6 +29,7 @@ public class Message extends AbstractEntity {
|
|||||||
|
|
||||||
public static final int TYPE_TEXT = 0;
|
public static final int TYPE_TEXT = 0;
|
||||||
public static final int TYPE_IMAGE = 1;
|
public static final int TYPE_IMAGE = 1;
|
||||||
|
public static final int TYPE_AUDIO = 2;
|
||||||
|
|
||||||
public static String CONVERSATION = "conversationUuid";
|
public static String CONVERSATION = "conversationUuid";
|
||||||
public static String COUNTERPART = "counterpart";
|
public static String COUNTERPART = "counterpart";
|
||||||
|
@ -722,12 +722,19 @@ public class ConversationActivity extends XmppActivity {
|
|||||||
encryptTextMessage();
|
encryptTextMessage();
|
||||||
} else if (requestCode == REQUEST_IMAGE_CAPTURE) {
|
} else if (requestCode == REQUEST_IMAGE_CAPTURE) {
|
||||||
attachImageToConversation(getSelectedConversation(), null);
|
attachImageToConversation(getSelectedConversation(), null);
|
||||||
|
} else if (requestCode == REQUEST_RECORD_AUDIO) {
|
||||||
|
Log.d("xmppService",data.getData().toString());
|
||||||
|
attachAudioToConversation(getSelectedConversation(),data.getData());
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOGTAG,"unknown result code:"+requestCode);
|
Log.d(LOGTAG,"unknown result code:"+requestCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void attachAudioToConversation(Conversation conversation, Uri uri) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void attachImageToConversation(Conversation conversation, Uri uri) {
|
private void attachImageToConversation(Conversation conversation, Uri uri) {
|
||||||
prepareImageToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
|
prepareImageToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
|
||||||
prepareImageToast.show();
|
prepareImageToast.show();
|
||||||
|
@ -617,7 +617,7 @@ public class XmppConnection implements Runnable {
|
|||||||
private void sendBindRequest() throws IOException {
|
private void sendBindRequest() throws IOException {
|
||||||
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
|
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
|
||||||
iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent(account.getResource());
|
iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent(account.getResource());
|
||||||
this.sendIqPacket(iq, new OnIqPacketReceived() {
|
this.sendUnboundIqPacket(iq, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
String resource = packet.findChild("bind").findChild("jid")
|
String resource = packet.findChild("bind").findChild("jid")
|
||||||
@ -644,9 +644,8 @@ public class XmppConnection implements Runnable {
|
|||||||
if (this.streamFeatures.hasChild("session")) {
|
if (this.streamFeatures.hasChild("session")) {
|
||||||
Log.d(LOGTAG,account.getJid()+": sending deprecated session");
|
Log.d(LOGTAG,account.getJid()+": sending deprecated session");
|
||||||
IqPacket startSession = new IqPacket(IqPacket.TYPE_SET);
|
IqPacket startSession = new IqPacket(IqPacket.TYPE_SET);
|
||||||
startSession.addChild("session","urn:ietf:params:xml:ns:xmpp-session"); //setContent("")
|
startSession.addChild("session","urn:ietf:params:xml:ns:xmpp-session");
|
||||||
startSession.setId(nextRandomId());
|
this.sendUnboundIqPacket(startSession, null);
|
||||||
this.sendPacket(startSession, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,6 +745,14 @@ public class XmppConnection implements Runnable {
|
|||||||
packet.setFrom(account.getFullJid());
|
packet.setFrom(account.getFullJid());
|
||||||
this.sendPacket(packet, callback);
|
this.sendPacket(packet, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendUnboundIqPacket(IqPacket packet, OnIqPacketReceived callback) {
|
||||||
|
if (packet.getId()==null) {
|
||||||
|
String id = nextRandomId();
|
||||||
|
packet.setAttribute("id", id);
|
||||||
|
}
|
||||||
|
this.sendPacket(packet, callback);
|
||||||
|
}
|
||||||
|
|
||||||
public void sendMessagePacket(MessagePacket packet) {
|
public void sendMessagePacket(MessagePacket packet) {
|
||||||
this.sendPacket(packet, null);
|
this.sendPacket(packet, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user