From 6f8b9b6c4c088be036abbbcfeb37f139f08fa9d1 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Thu, 20 Nov 2014 01:12:47 +0100 Subject: [PATCH] Don't encode telephone numbers if a contact doesn't have any number --- midp/localmsg.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/midp/localmsg.js b/midp/localmsg.js index 2dab6022..3be2ab31 100644 --- a/midp/localmsg.js +++ b/midp/localmsg.js @@ -276,14 +276,16 @@ NokiaContactsLocalMsgConnection.prototype.encodeContact = function(encoder, cont encoder.put(DataType.WSTRING, "DisplayName", contact.name[0]); - encoder.putStart(DataType.ARRAY, "Numbers"); - contact.tel.forEach(function(tel) { - encoder.putStart(DataType.LIST, "NumbersList"); // The name of this field is unknown - // encoder.put(DataType.ULONG, "Kind", ???); // The meaning of this field is unknown - encoder.put(DataType.WSTRING, "Number", tel.value); - encoder.putEnd(DataType.LIST, "NumbersList"); - }); - encoder.putEnd(DataType.ARRAY, "Numbers"); + if (contact.tel) { + encoder.putStart(DataType.ARRAY, "Numbers"); + contact.tel.forEach(function(tel) { + encoder.putStart(DataType.LIST, "NumbersList"); // The name of this field is unknown + // encoder.put(DataType.ULONG, "Kind", ???); // The meaning of this field is unknown + encoder.put(DataType.WSTRING, "Number", tel.value); + encoder.putEnd(DataType.LIST, "NumbersList"); + }); + encoder.putEnd(DataType.ARRAY, "Numbers"); + } encoder.putEnd(DataType.LIST, "Contact"); }