added very basic, very untested gui on the receiving side
This commit is contained in:
parent
18c3333271
commit
513f3c47b2
|
@ -209,7 +209,6 @@ public class ConversationFragment extends Fragment {
|
||||||
.findViewById(R.id.message_photo);
|
.findViewById(R.id.message_photo);
|
||||||
viewHolder.imageView.setImageBitmap(selfBitmap);
|
viewHolder.imageView.setImageBitmap(selfBitmap);
|
||||||
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
|
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
|
||||||
viewHolder.image = (ImageView) view.findViewById(R.id.message_image);
|
|
||||||
break;
|
break;
|
||||||
case RECIEVED:
|
case RECIEVED:
|
||||||
view = (View) inflater.inflate(
|
view = (View) inflater.inflate(
|
||||||
|
@ -231,6 +230,7 @@ public class ConversationFragment extends Fragment {
|
||||||
viewHolder = null;
|
viewHolder = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
viewHolder.image = (ImageView) view.findViewById(R.id.message_image);
|
||||||
viewHolder.messageBody = (TextView) view
|
viewHolder.messageBody = (TextView) view
|
||||||
.findViewById(R.id.message_body);
|
.findViewById(R.id.message_body);
|
||||||
viewHolder.time = (TextView) view
|
viewHolder.time = (TextView) view
|
||||||
|
@ -256,8 +256,13 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
if (item.getType() == Message.TYPE_IMAGE) {
|
if (item.getType() == Message.TYPE_IMAGE) {
|
||||||
viewHolder.image.setVisibility(View.VISIBLE);
|
viewHolder.image.setVisibility(View.VISIBLE);
|
||||||
viewHolder.image.setImageBitmap(activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288)));
|
if (item.getStatus() != Message.STATUS_RECIEVING) {
|
||||||
viewHolder.messageBody.setVisibility(View.GONE);
|
viewHolder.image.setImageBitmap(activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288)));
|
||||||
|
viewHolder.messageBody.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
viewHolder.messageBody.setText("receiving image file");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (viewHolder.image != null) viewHolder.image.setVisibility(View.GONE);
|
if (viewHolder.image != null) viewHolder.image.setVisibility(View.GONE);
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -133,6 +133,11 @@ public class JingleConnection {
|
||||||
Element fileSize = fileOffer.findChild("size");
|
Element fileSize = fileOffer.findChild("size");
|
||||||
Element fileName = fileOffer.findChild("name");
|
Element fileName = fileOffer.findChild("name");
|
||||||
this.file.setExpectedSize(Long.parseLong(fileSize.getContent()));
|
this.file.setExpectedSize(Long.parseLong(fileSize.getContent()));
|
||||||
|
conversation.getMessages().add(message);
|
||||||
|
this.mXmppConnectionService.databaseBackend.createMessage(message);
|
||||||
|
if (this.mXmppConnectionService.convChangedListener!=null) {
|
||||||
|
this.mXmppConnectionService.convChangedListener.onConversationListChanged();
|
||||||
|
}
|
||||||
if (this.file.getExpectedSize()>=this.mJingleConnectionManager.getAutoAcceptFileSize()) {
|
if (this.file.getExpectedSize()>=this.mJingleConnectionManager.getAutoAcceptFileSize()) {
|
||||||
Log.d("xmppService","auto accepting file from "+packet.getFrom());
|
Log.d("xmppService","auto accepting file from "+packet.getFrom());
|
||||||
this.sendAccept();
|
this.sendAccept();
|
||||||
|
@ -181,7 +186,7 @@ public class JingleConnection {
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.getType() != IqPacket.TYPE_ERROR) {
|
if (packet.getType() != IqPacket.TYPE_ERROR) {
|
||||||
status = STATUS_ACCEPTED;
|
status = STATUS_ACCEPTED;
|
||||||
connectWithCandidates();
|
connectNextCandidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -204,7 +209,7 @@ public class JingleConnection {
|
||||||
Content content = packet.getJingleContent();
|
Content content = packet.getJingleContent();
|
||||||
mergeCandidates(content.getCanditates());
|
mergeCandidates(content.getCanditates());
|
||||||
this.status = STATUS_ACCEPTED;
|
this.status = STATUS_ACCEPTED;
|
||||||
this.connectWithCandidates();
|
this.connectNextCandidate();
|
||||||
IqPacket response = packet.generateRespone(IqPacket.TYPE_RESULT);
|
IqPacket response = packet.generateRespone(IqPacket.TYPE_RESULT);
|
||||||
account.getXmppConnection().sendIqPacket(response, null);
|
account.getXmppConnection().sendIqPacket(response, null);
|
||||||
}
|
}
|
||||||
|
@ -240,6 +245,11 @@ public class JingleConnection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFileTransmitted(JingleFile file) {
|
public void onFileTransmitted(JingleFile file) {
|
||||||
|
if (initiator.equals(account.getFullJid())) {
|
||||||
|
mXmppConnectionService.markMessage(message, Message.STATUS_SEND);
|
||||||
|
} else {
|
||||||
|
mXmppConnectionService.markMessage(message, Message.STATUS_RECIEVED);
|
||||||
|
}
|
||||||
Log.d("xmppService","sucessfully transmitted file. sha1:"+file.getSha1Sum());
|
Log.d("xmppService","sucessfully transmitted file. sha1:"+file.getSha1Sum());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -286,33 +296,41 @@ public class JingleConnection {
|
||||||
this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_REJECTED);
|
this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_REJECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectWithCandidates() {
|
private void connectNextCandidate() {
|
||||||
for(Element candidate : this.candidates) {
|
for(Element candidate : this.candidates) {
|
||||||
final SocksConnection socksConnection = new SocksConnection(this,candidate);
|
String cid = candidate.getAttribute("cid");
|
||||||
connections.put(socksConnection.getCid(), socksConnection);
|
if (!connections.containsKey(cid)) {
|
||||||
socksConnection.connect(new OnSocksConnection() {
|
this.connectWithCandidate(candidate);
|
||||||
|
break;
|
||||||
@Override
|
}
|
||||||
public void failed() {
|
|
||||||
Log.d("xmppService","socks5 failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void established() {
|
|
||||||
if (candidatesUsedByCounterpart.contains(socksConnection.getCid())) {
|
|
||||||
if (status!=STATUS_TRANSMITTING) {
|
|
||||||
connect(socksConnection);
|
|
||||||
} else {
|
|
||||||
Log.d("xmppService","ignoring cuz already transmitting");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sendCandidateUsed(socksConnection.getCid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void connectWithCandidate(Element candidate) {
|
||||||
|
final SocksConnection socksConnection = new SocksConnection(this,candidate);
|
||||||
|
connections.put(socksConnection.getCid(), socksConnection);
|
||||||
|
socksConnection.connect(new OnSocksConnection() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed() {
|
||||||
|
connectNextCandidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void established() {
|
||||||
|
if (candidatesUsedByCounterpart.contains(socksConnection.getCid())) {
|
||||||
|
if (status!=STATUS_TRANSMITTING) {
|
||||||
|
connect(socksConnection);
|
||||||
|
} else {
|
||||||
|
Log.d("xmppService","ignoring cuz already transmitting");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sendCandidateUsed(socksConnection.getCid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void disconnect() {
|
private void disconnect() {
|
||||||
Iterator<Entry<String, SocksConnection>> it = this.connections.entrySet().iterator();
|
Iterator<Entry<String, SocksConnection>> it = this.connections.entrySet().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -378,4 +396,13 @@ public class JingleConnection {
|
||||||
mergeCandidate(c);
|
mergeCandidate(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Element getCandidate(String cid) {
|
||||||
|
for(Element c : this.candidates) {
|
||||||
|
if (c.getAttribute("cid").equals(cid)) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue