Skip to content

Commit

Permalink
Revert changes for contact import on Ubuntu Touch
Browse files Browse the repository at this point in the history
  • Loading branch information
sap-nocops committed Feb 18, 2017
1 parent 8a5bd9c commit 097e88b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 85 deletions.
3 changes: 0 additions & 3 deletions src/scripts/loqui/account.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,6 @@ var Account = {
var frag = f;
account = this;
this.contacts = {};
if(this.core.roster == undefined){
this.core.roster = [];

This comment has been minimized.

Copy link
@shamushivam

shamushivam Mar 2, 2017

Hh

}
this.core.roster.forEach(function (contact, i, roster) {
var name = contact.name || contact.jid;
var nameParts = name.toLowerCase().split(' ');
Expand Down
119 changes: 37 additions & 82 deletions src/scripts/loqui/connectors/coseme.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

1 comment on commit 097e88b

@shamushivam
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Download

Please sign in to comment.