Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80ada006 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "MAP: Support MMS pushMessage feature."

parents 3678944e 649bfc7d
Loading
Loading
Loading
Loading
+66 −67
Original line number Diff line number Diff line
@@ -753,10 +753,8 @@ public class BluetoothMapContentObserver {
                    {
                        /* Send message if folder is outbox */
                        /* to do, support MMS in the future */
                        /*String phone = recipient.getFirstPhoneNumber();
                        if (folder.equals("outbox")) {
                        String phone = recipient.getFirstPhoneNumber();
                        handle = sendMmsMessage(folder, phone, (BluetoothMapbMessageMmsEmail)msg);
                        }*/
                        break;
                    }
                    case SMS_GSM: //fall-through
@@ -823,7 +821,7 @@ public class BluetoothMapContentObserver {
         *else if folder !outbox:
         *1) push message to folder
         * */
        if (folder != null && (folder.equalsIgnoreCase("outbox")||  folder.equalsIgnoreCase("drafts"))) {
        if (folder != null && (folder.equalsIgnoreCase("outbox")||  folder.equalsIgnoreCase("drafts") || folder.equalsIgnoreCase("draft"))) {
            long handle = pushMmsToFolder(Mms.MESSAGE_BOX_DRAFTS, to_address, msg);
            /* if invalid handle (-1) then just return the handle - else continue sending (if folder is outbox) */
            if (BluetoothMapAppParams.INVALID_VALUE_PARAMETER != handle && folder.equalsIgnoreCase("outbox")) {
@@ -911,12 +909,12 @@ public class BluetoothMapContentObserver {
        }

        long handle = Long.parseLong(uri.getLastPathSegment());
        if (V){
        ArrayList<MimePart> parts = msg.getMimeParts();
        if (parts != null) {
            Log.v(TAG, " NEW URI " + uri.toString());
        }
            try {
            if(V) Log.v(TAG, "Adding " + msg.getMimeParts().size() + " parts to the data base.");
        for(MimePart part : msg.getMimeParts()) {
            //if(V) Log.v(TAG, "Adding " + msg.getMimeParts().size() + " parts to the data base.");
            for(MimePart part : parts) {
                int count = 0;
                count++;
                values.clear();
@@ -975,6 +973,7 @@ public class BluetoothMapContentObserver {
              Log.w(TAG, e);
           }

        }
        values.clear();
        values.put("contact_id", "null");
        values.put("address", "insert-address-token");
+25 −12
Original line number Diff line number Diff line
@@ -276,6 +276,10 @@ public class BluetoothMapbMessageMmsEmail extends BluetoothMapbMessage {
    }
    public int getSize() {
        int message_size = 0;
        if (parts == null) {
            Log.e(TAG, " parts is null. returning ");
            return message_size;
        }
        for(MimePart part : parts) {
            message_size += part.data.length;
        }
@@ -407,7 +411,6 @@ public class BluetoothMapbMessageMmsEmail extends BluetoothMapbMessage {
        }

        emailBody = sb.toString();
        if (V) Log.v(TAG, "emailBody is "+emailBody);

        if(emailBody != null) {
            String tmpBody = emailBody.replaceAll("END:MSG", "/END\\:MSG"); // Replace any occurrences of END:MSG with \END:MSG
@@ -576,14 +579,15 @@ public class BluetoothMapbMessageMmsEmail extends BluetoothMapbMessage {

    private void parseMmsMimePart(String partStr) {
        String[] parts = partStr.split("\r\n\r\n", 2); // Split the header from the body
        String body;
        String body=null;
        if(parts.length != 2) {
            body = partStr;
            //body = partStr;
            throw new IllegalArgumentException("Mime part not formatted correctly: No Header");
        } else {
            body = parts[1];
        }
        String[] headers = parts[0].split("\r\n");
        MimePart newPart = addMimePart();
        MimePart newPart = null;
        String partEncoding = encoding; /* Use the overall encoding as default */

        for(String header : headers) {
@@ -593,8 +597,13 @@ public class BluetoothMapbMessageMmsEmail extends BluetoothMapbMessage {
            if(header.trim() == "" || header.trim().equals("--")) // Skip empty lines(the \r\n after the boundary tag) and endBoundary tags
                continue;
            String[] headerParts = header.split(":",2);
            if(headerParts.length != 2)
                throw new IllegalArgumentException("part-Header not formatted correctly: " + header);
            if(headerParts.length != 2) {
                throw new IllegalArgumentException("part-Header not Formatted correctly: " + header);
            }
            if( newPart == null) {
                 if(V) Log.d(TAG,"Add new MimePart\n");
                 newPart = addMimePart();
            }
            String headerType = headerParts[0].toUpperCase();
            String headerValue = headerParts[1].trim();
            if(headerType.contains("CONTENT-TYPE")) {
@@ -808,7 +817,6 @@ public class BluetoothMapbMessageMmsEmail extends BluetoothMapbMessage {
                messageBody = messageParts[1];
            }
        }

        if(boundary == null)
        {
            // If the boundary is not set, handle as non-multi-part
@@ -820,11 +828,16 @@ public class BluetoothMapbMessageMmsEmail extends BluetoothMapbMessage {
        }
        else
        {
            mimeParts = messageBody.split("--" + boundary);
            mimeParts = messageBody.split("--" + boundary.replaceAll("\"",""));
            for(int i = 0; i < mimeParts.length -1; i++) {
                String part = mimeParts[i];
                if (part != null && (part.length() > 0))
                if (part != null && (part.length() > 0)){
                    try {
                        parseMmsMimePart(part);
                    } catch (IllegalArgumentException e) {
                       Log.d(TAG, " part-Header not formatted correctly: " + e);
                    }
                }
           }
        }
    }