diff --git a/src/scripts/loqui/account.js b/src/scripts/loqui/account.js old mode 100755 new mode 100644 index b6b1479d..f73f3b2d --- a/src/scripts/loqui/account.js +++ b/src/scripts/loqui/account.js @@ -445,9 +445,6 @@ var Account = { var frag = f; account = this; this.contacts = {}; - if(this.core.roster == undefined){ - this.core.roster = []; - } this.core.roster.forEach(function (contact, i, roster) { var name = contact.name || contact.jid; var nameParts = name.toLowerCase().split(' '); diff --git a/src/scripts/loqui/connectors/coseme.js b/src/scripts/loqui/connectors/coseme.js old mode 100755 new mode 100644 index 234d91e6..f07445cc --- a/src/scripts/loqui/connectors/coseme.js +++ b/src/scripts/loqui/connectors/coseme.js @@ -1221,88 +1221,43 @@ App.connectors.coseme = function (account) { var account = this.account; var contacts = this.contacts; contacts._pre = []; - console.log('------------aaaaaaaaaaaaaaaaaaa----------'); - if(typeof MozActivity != 'undefined') { - // FirefoxOS - var allContacts = navigator.mozContacts.getAll({sortBy: 'givenName', sortOrder: 'ascending'}); - allContacts.onsuccess = function (event) { - if (this.result) { - try { - var result = this.result; - var fullname = (result.givenName - ? result.givenName[0] + ' ' + (result.familyName - ? (result.familyName[0] || '') : - '' - ) - : (result.familyName ? - result.familyName[0] - : (result.tel - ? result.tel[0] - : '' - ) - )).trim(); - if (result.tel) { - for (var i = 0; i < result.tel.length; i++) { - contacts._pre[result.tel[i].value] = fullname; - } - } - } catch (e) { - Tools.log('CONTACT NORMALIZATION ERROR:', e); - } - this.continue(); - } else if (cb){ - Tools.log('CONTACT ACQUIRE ERROR'); - MI.call('contacts_sync', [Object.keys(contacts._pre)]); - contacts._cb = cb; - } - }; - allContacts.onerror = function (event) { - Tools.log('CONTACTS ERROR:', event); - Lungo.Notification.error(_('ContactsGetError'), _('ContactsGetErrorExp'), 'exclamation-sign', 5); - cb(); - }; - } else if(external && external.getUnityObject) { - // Ubuntu Touch - console.log('--------------------OK'); - if(!($.data( $('#contacts_input').get(0), 'events' ).change)) { - $('#contacts_input').change(function() { - console.log('-----------change'); - var contacts = document.getElementById('contacts_input').files; - var covertedContact = {}; - contacts._pre = {}; - for(var c in contacts) { - if(contacts[c].name && contacts[c].name.lastIndexOf('.vcf') > -1){ - console.log('-----------' + contacts[c].name); - covertedContact.givenName = [contacts[c].name.substring(0, contacts[c].name.lastIndexOf('.vcf'))]; - covertedContact.tel = ['+393394561221']; -// if (contacts already imported and is not a forced sync) { -// try { - var fullname = covertedContact.givenName[0].trim(); - console.log(fullname); - if(covertedContact.tel) { - for(var i = 0; i < covertedContact.tel.length; i++) { - contacts._pre[covertedContact.tel[i]] = fullname; - } - } -// } catch (e) { -// Tools.log('CONTACT NORMALIZATION ERROR:', e); -// } - covertedContact = {}; - } -// } else if (cb){ -// Tools.log('CONTACT ACQUIRE ERROR'); -// MI.call('contacts_sync', [Object.keys(contacts._pre)]); -// contacts._cb = cb; -// } - } - for(var cc in contacts._pre){ - console.log('------' + contacts._pre[cc]); - } - }); - } - console.log('-----------go'); - $('#contacts_input').trigger('click'); - } + var allContacts = navigator.mozContacts.getAll({sortBy: 'givenName', sortOrder: 'ascending'}); + allContacts.onsuccess = function (event) { + if (this.result) { + try { + var result = this.result; + var fullname = (result.givenName + ? result.givenName[0] + ' ' + (result.familyName + ? (result.familyName[0] || '') : + '' + ) + : (result.familyName ? + result.familyName[0] + : (result.tel + ? result.tel[0] + : '' + ) + )).trim(); + if (result.tel) { + for (var i = 0; i < result.tel.length; i++) { + contacts._pre[result.tel[i].value] = fullname; + } + } + } catch (e) { + Tools.log('CONTACT NORMALIZATION ERROR:', e); + } + this.continue(); + } else if (cb){ + Tools.log('CONTACT ACQUIRE ERROR'); + MI.call('contacts_sync', [Object.keys(contacts._pre)]); + contacts._cb = cb; + } + }; + allContacts.onerror = function (event) { + Tools.log('CONTACTS ERROR:', event); + Lungo.Notification.error(_('ContactsGetError'), _('ContactsGetErrorExp'), 'exclamation-sign', 5); + cb(); + }; } else { Lungo.Notification.error(_('ContactsGetError'), _('NoWhenOffline'), 'exclamation-sign', 5); }