Fixed file transfer upload with LIME
This commit is contained in:
parent
90abdcc38d
commit
760cf3a6e4
2 changed files with 13 additions and 14 deletions
|
@ -136,7 +136,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
private ChatMessageAdapter adapter;
|
private ChatMessageAdapter adapter;
|
||||||
|
|
||||||
private LinphoneCoreListenerBase mListener;
|
private LinphoneCoreListenerBase mListener;
|
||||||
private ByteArrayInputStream mUploadingImageStream;
|
|
||||||
private boolean newChatConversation = false;
|
private boolean newChatConversation = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -893,7 +892,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (progressDialog != null && progressDialog.isShowing()) {
|
if (progressDialog != null && progressDialog.isShowing()) {
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
}
|
}
|
||||||
mUploadingImageStream = new ByteArrayInputStream(result);
|
|
||||||
|
|
||||||
String fileName = path.substring(path.lastIndexOf("/") + 1);
|
String fileName = path.substring(path.lastIndexOf("/") + 1);
|
||||||
String extension = LinphoneUtils.getExtensionFromFileName(fileName);
|
String extension = LinphoneUtils.getExtensionFromFileName(fileName);
|
||||||
|
@ -905,7 +903,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.setAppData(path);
|
message.setAppData(path);
|
||||||
|
|
||||||
LinphoneManager.getInstance().setUploadPendingFileMessage(message);
|
LinphoneManager.getInstance().setUploadPendingFileMessage(message);
|
||||||
LinphoneManager.getInstance().setUploadingImageStream(mUploadingImageStream);
|
LinphoneManager.getInstance().setUploadingImage(result);
|
||||||
|
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
adapter.addMessage(message);
|
adapter.addMessage(message);
|
||||||
|
|
|
@ -153,7 +153,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
private static List<LinphoneChatMessage> mPendingChatFileMessage;
|
private static List<LinphoneChatMessage> mPendingChatFileMessage;
|
||||||
private static LinphoneChatMessage mUploadPendingFileMessage;
|
private static LinphoneChatMessage mUploadPendingFileMessage;
|
||||||
|
|
||||||
|
|
||||||
public String wizardLoginViewDomain = null;
|
public String wizardLoginViewDomain = null;
|
||||||
|
|
||||||
private static List<LinphoneChatMessage.LinphoneChatMessageListener> simpleListeners = new ArrayList<LinphoneChatMessage.LinphoneChatMessageListener>();
|
private static List<LinphoneChatMessage.LinphoneChatMessageListener> simpleListeners = new ArrayList<LinphoneChatMessage.LinphoneChatMessageListener>();
|
||||||
|
@ -214,7 +213,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
private final String mFriendsDatabaseFile;
|
private final String mFriendsDatabaseFile;
|
||||||
private final String mErrorToneFile;
|
private final String mErrorToneFile;
|
||||||
private final String mUserCertificatePath;
|
private final String mUserCertificatePath;
|
||||||
private ByteArrayInputStream mUploadingImageStream;
|
private byte[] mUploadingImage;
|
||||||
private Timer mTimer;
|
private Timer mTimer;
|
||||||
|
|
||||||
private void routeAudioToSpeakerHelper(boolean speakerOn) {
|
private void routeAudioToSpeakerHelper(boolean speakerOn) {
|
||||||
|
@ -371,16 +370,16 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
return mUploadPendingFileMessage;
|
return mUploadPendingFileMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploadingImageStream(ByteArrayInputStream array){
|
public void setUploadingImage(byte[] array){
|
||||||
this.mUploadingImageStream = array;
|
this.mUploadingImage = array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, LinphoneChatMessage.State state) {
|
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, LinphoneChatMessage.State state) {
|
||||||
if (state == LinphoneChatMessage.State.FileTransferDone) {
|
if (state == LinphoneChatMessage.State.FileTransferDone) {
|
||||||
if (msg.isOutgoing() && mUploadingImageStream != null) {
|
if (msg.isOutgoing() && mUploadingImage != null) {
|
||||||
mUploadPendingFileMessage = null;
|
mUploadPendingFileMessage = null;
|
||||||
mUploadingImageStream = null;
|
mUploadingImage = null;
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.storeImage(getContext(), msg);
|
LinphoneUtils.storeImage(getContext(), msg);
|
||||||
removePendingMessage(msg);
|
removePendingMessage(msg);
|
||||||
|
@ -402,14 +401,16 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLinphoneChatMessageFileTransferSent(LinphoneChatMessage msg, LinphoneContent content, int offset, int size, LinphoneBuffer bufferToFill) {
|
public void onLinphoneChatMessageFileTransferSent(LinphoneChatMessage msg, LinphoneContent content, int offset, int size, LinphoneBuffer bufferToFill) {
|
||||||
if (mUploadingImageStream != null && size > 0) {
|
if (mUploadingImage != null && size > 0) {
|
||||||
byte[] data = new byte[size];
|
byte[] data = new byte[size];
|
||||||
int read = mUploadingImageStream.read(data, 0, size);
|
if (offset + size <= mUploadingImage.length) {
|
||||||
if (read > 0) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
data[i] = mUploadingImage[i + offset];
|
||||||
|
}
|
||||||
bufferToFill.setContent(data);
|
bufferToFill.setContent(data);
|
||||||
bufferToFill.setSize(read);
|
bufferToFill.setSize(size);
|
||||||
} else {
|
} else {
|
||||||
Log.e("Error, upload task asking for more bytes(" + size + ") than available (" + mUploadingImageStream.available() + ")");
|
Log.e("Error, upload task asking for more bytes( " + (size+offset) + " ) than available (" + mUploadingImage.length + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue