MAP: EMAIL GetMessage support multiple VCARD for multiple recipients.

Compose multiple VCARD in GetMessage Response BENV for multiple
recipients instead of composing all recipient address(es) within
one single VCARD.

Change-Id: Id5eba997bd4a121fd6639160c8b1bcefc4990e85
CRs-fixed: 521718
diff --git a/src/org/codeaurora/bluetooth/map/MapUtils/EmailUtils.java b/src/org/codeaurora/bluetooth/map/MapUtils/EmailUtils.java
index 62da953..92f1a43 100755
--- a/src/org/codeaurora/bluetooth/map/MapUtils/EmailUtils.java
+++ b/src/org/codeaurora/bluetooth/map/MapUtils/EmailUtils.java
@@ -611,6 +611,16 @@
                         bmsg.setRecipientVcard_email(multiRecepients.trim());
                     }
                 }
+                else if(recipientName.contains(",")){
+                    multiRecepients = recipientName.replace(',', ';');
+                    if(multiRecepients != null){
+                        if (V){
+                            Log.v(TAG, " ::Recepient name :: " + multiRecepients);
+                        }
+                        bmsg.setRecipientVcard_name(multiRecepients.trim());
+                        bmsg.setRecipientVcard_email(multiRecepients.trim());
+                    }
+                }
                 else{
                     bmsg.setRecipientVcard_name(recipientName.trim());
                     bmsg.setRecipientVcard_email(recipientName.trim());
diff --git a/src/org/codeaurora/bluetooth/map/MapUtils/MapUtils.java b/src/org/codeaurora/bluetooth/map/MapUtils/MapUtils.java
old mode 100644
new mode 100755
index f2f6f31..a6b89e9
--- a/src/org/codeaurora/bluetooth/map/MapUtils/MapUtils.java
+++ b/src/org/codeaurora/bluetooth/map/MapUtils/MapUtils.java
@@ -835,36 +835,73 @@
             // End Originator
 
             sb.append("BEGIN:BENV").append("\r\n");
+            if ((bmsg.recipient_vcard_email != null) &&
+                            (bmsg.recipient_vcard_email.contains(";"))) {
+                if (V) Log.v (TAG, "recipient_vcard_name:" + bmsg.recipient_vcard_name);
+                if (V) Log.v (TAG, "recipient_vcard_phone_number:" + bmsg.recipient_vcard_email);
+                String emailTokens[] = bmsg.recipient_vcard_email.split(";");
+                String nameTokens[] = bmsg.recipient_vcard_name.split(";");
+                if (V) Log.v (TAG, "Length:name:" + nameTokens.length + "number:" + emailTokens.length);
+                for (int i=0; i < emailTokens.length; i++) {
+                    // Recipient
+                    sb.append("BEGIN:VCARD").append("\r\n");
 
-            // Recipient
-            sb.append("BEGIN:VCARD").append("\r\n");
+                    if (bmsg.vcard_version != null) {
+                        sb.append("VERSION:").append(bmsg.vcard_version).append("\r\n");
+                    } else {
 
-            if (bmsg.vcard_version != null) {
-                sb.append("VERSION:").append(bmsg.vcard_version).append("\r\n");
+                    }
+
+                    if (nameTokens[i] != null) {
+                        sb.append("N:").append(nameTokens[i])
+                            .append("\r\n");
+                        sb.append("FN:").append(nameTokens[i])
+                           .append("\r\n");
+                    } else {
+
+                    }
+                    sb.append("TEL:").append("\r\n");
+
+                    if (emailTokens[i] != null) {
+                        sb.append("EMAIL:").append(emailTokens[i])
+                            .append("\r\n");
+                    } else {
+
+                    }
+
+                    sb.append("END:VCARD").append("\r\n");
+                    // End Recipient
+                }
             } else {
+                // Recipient
+                sb.append("BEGIN:VCARD").append("\r\n");
+                if (bmsg.vcard_version != null) {
+                   sb.append("VERSION:").append(bmsg.vcard_version).append("\r\n");
+                } else {
 
-            }
-            if (bmsg.recipient_vcard_name != null) {
-                sb.append("N:").append(bmsg.recipient_vcard_name)
+                }
+                if (bmsg.recipient_vcard_name != null) {
+                   sb.append("N:").append(bmsg.recipient_vcard_name)
                         .append("\r\n");
-            } else {
+                } else {
 
-            }
-            if (bmsg.recipient_vcard_name != null) {
-                sb.append("FN:").append(bmsg.recipient_vcard_name)
+                }
+                if (bmsg.recipient_vcard_name != null) {
+                   sb.append("FN:").append(bmsg.recipient_vcard_name)
                         .append("\r\n");
-            } else {
+                } else {
 
-            }
-            sb.append("TEL:").append("\r\n");
-            if (bmsg.recipient_vcard_email != null) {
-                sb.append("EMAIL:").append(bmsg.recipient_vcard_email)
+                }
+                sb.append("TEL:").append("\r\n");
+                if (bmsg.recipient_vcard_email != null) {
+                   sb.append("EMAIL:").append(bmsg.recipient_vcard_email)
                         .append("\r\n");
-            } else {
+                } else {
 
+                }
+                sb.append("END:VCARD").append("\r\n");
+                // End Recipient
             }
-            sb.append("END:VCARD").append("\r\n");
-            // End Recipient
 
             sb.append("BEGIN:BBODY").append("\r\n");