mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Send m-notifyresp-ind after retrieving MMS
This commit is contained in:
parent
a057b628eb
commit
81107a98eb
@ -174,7 +174,7 @@ public class MmsCommunication {
|
||||
|
||||
protected static byte[] parseResponse(HttpEntity entity) throws IOException {
|
||||
if (entity == null || entity.getContentLength() == 0)
|
||||
throw new IOException("Null response");
|
||||
return null;
|
||||
|
||||
if (entity.getContentLength() < 0)
|
||||
throw new IOException("Unknown content length!");
|
||||
|
@ -36,7 +36,7 @@ import java.net.URISyntaxException;
|
||||
public class MmsDownloadHelper extends MmsCommunication {
|
||||
|
||||
private static byte[] makeRequest(Context context, MmsConnectionParameters connectionParameters, String url)
|
||||
throws ClientProtocolException, IOException
|
||||
throws IOException
|
||||
{
|
||||
AndroidHttpClient client = null;
|
||||
|
||||
@ -82,6 +82,10 @@ public class MmsDownloadHelper extends MmsCommunication {
|
||||
|
||||
byte[] pdu = makeRequest(context, connectionParameters, url);
|
||||
|
||||
if (pdu == null) {
|
||||
throw new IOException("Retrieved null PDU!");
|
||||
}
|
||||
|
||||
RetrieveConf retrieved = (RetrieveConf)new PduParser(pdu).parse();
|
||||
|
||||
if (retrieved == null) {
|
||||
|
@ -54,7 +54,6 @@ public class MmsSendHelper extends MmsCommunication {
|
||||
request.setEntity(entity);
|
||||
request.setParams(client.getParams());
|
||||
request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
|
||||
// request.addHeader("x-wap-profile", "http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml");
|
||||
request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
|
||||
HttpResponse response = client.execute(target, request);
|
||||
StatusLine status = response.getStatusLine();
|
||||
@ -72,16 +71,35 @@ public class MmsSendHelper extends MmsCommunication {
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendNotificationReceived(Context context, byte[] mms, String apn,
|
||||
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
||||
throws IOException
|
||||
{
|
||||
sendBytes(context, mms, apn, usingMmsRadio, useProxyIfAvailable);
|
||||
}
|
||||
|
||||
public static SendConf sendMms(Context context, byte[] mms, String apn,
|
||||
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
||||
throws IOException
|
||||
{
|
||||
byte[] response = sendBytes(context, mms, apn, usingMmsRadio, useProxyIfAvailable);
|
||||
|
||||
if (response == null) {
|
||||
throw new IOException("Got null response!");
|
||||
}
|
||||
|
||||
return (SendConf) new PduParser(response).parse();
|
||||
}
|
||||
|
||||
private static byte[] sendBytes(Context context, byte[] mms, String apn,
|
||||
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
||||
throws IOException
|
||||
{
|
||||
Log.w("MmsSender", "Sending MMS of length: " + mms.length);
|
||||
try {
|
||||
MmsConnectionParameters parameters = getMmsConnectionParameters(context, apn, useProxyIfAvailable);
|
||||
checkRouteToHost(context, parameters, parameters.getMmsc(), usingMmsRadio);
|
||||
byte[] response = makePost(context, parameters, mms);
|
||||
return (SendConf) new PduParser(response).parse();
|
||||
return makePost(context, parameters, mms);
|
||||
} catch (ApnUnavailableException aue) {
|
||||
Log.w("MmsSender", aue);
|
||||
throw new IOException("Failed to get MMSC information...");
|
||||
|
@ -28,10 +28,15 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
import org.thoughtcrime.securesms.mms.MmsDownloadHelper;
|
||||
import org.thoughtcrime.securesms.mms.MmsSendHelper;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
||||
|
||||
import ws.com.google.android.mms.InvalidHeaderValueException;
|
||||
import ws.com.google.android.mms.MmsException;
|
||||
import ws.com.google.android.mms.pdu.NotifyRespInd;
|
||||
import ws.com.google.android.mms.pdu.PduComposer;
|
||||
import ws.com.google.android.mms.pdu.PduHeaders;
|
||||
import ws.com.google.android.mms.pdu.RetrieveConf;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -100,9 +105,7 @@ public class MmsDownloader extends MmscProcessor {
|
||||
}
|
||||
|
||||
storeRetrievedMms(mmsDatabase, item, retrieved);
|
||||
|
||||
// NotifyRespInd notifyResponse = new NotifyRespInd(PduHeaders.CURRENT_MMS_VERSION, item.getTransactionId(), PduHeaders.STATUS_RETRIEVED);
|
||||
// MmsSendHelper.sendMms(context, new PduComposer(context, notifyResponse).make());
|
||||
sendRetrievedAcknowledgement(item);
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.w("MmsDownloader", e);
|
||||
@ -147,6 +150,22 @@ public class MmsDownloader extends MmscProcessor {
|
||||
MessageNotifier.updateNotification(context, item.getMasterSecret(), messageAndThreadId.second);
|
||||
}
|
||||
|
||||
private void sendRetrievedAcknowledgement(DownloadItem item) {
|
||||
try {
|
||||
NotifyRespInd notifyResponse = new NotifyRespInd(PduHeaders.CURRENT_MMS_VERSION,
|
||||
item.getTransactionId(),
|
||||
PduHeaders.STATUS_RETRIEVED);
|
||||
|
||||
MmsSendHelper.sendNotificationReceived(context, new PduComposer(context, notifyResponse).make(),
|
||||
getApnInformation(), item.useMmsRadioMode(),
|
||||
item.proxyRequestIfPossible());
|
||||
} catch (InvalidHeaderValueException e) {
|
||||
Log.w("MmsDownloader", e);
|
||||
} catch (IOException e) {
|
||||
Log.w("MmsDownloader", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleConnectivityChange() {
|
||||
LinkedList<DownloadItem> downloadItems = (LinkedList<DownloadItem>)pendingMessages.clone();
|
||||
|
||||
|
@ -110,8 +110,6 @@ public class SmsListener extends BroadcastReceiver {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String messageBody = getSmsMessageBodyFromIntent(intent);
|
||||
|
||||
Log.w("SmsListener", "Checking challenge: " + messageBody);
|
||||
|
||||
if (messageBody == null)
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user