Commit a5b4fcb9e48bb7fb54d858b9792151da24d5affd

Authored by OpenWapp Developer

Merge branch 'get-server-properties' of /home/git/repositories/openwapp/coseme

Showing 6 changed files

dist/coseme.js View file @ a5b4fcb
... ... @@ -4114,7 +4114,7 @@
4114 4114 };
4115 4115  
4116 4116 Tree.prototype.getAllChildren = function(tag) {
4117   - var all = typeof tag !== 'undefined';
  4117 + var all = typeof tag === 'undefined';
4118 4118 var filteredChildren = this.children.filter(function(child) {
4119 4119 return all || child.tag === tag;
4120 4120 });
... ... @@ -5813,7 +5813,6 @@
5813 5813 var params = Object.create(null);
5814 5814 params['cc'] = countryCode;
5815 5815 params['in'] = phone;
5816   - params['to'] = countryCode + phone;
5817 5816 params['lc'] = 'US';
5818 5817 params['lg'] = 'en';
5819 5818 params['mcc'] = '000';
... ... @@ -6724,7 +6723,11 @@
6724 6723  
6725 6724 var processNode = {
6726 6725 result: function(iqType, idx, node) {
6727   - if (idx in _requests) {
  6726 + var props = node.getChild('props');
  6727 + if (props) {
  6728 + getProperties(props.getAllChildren());
  6729 + }
  6730 + else if (idx in _requests) {
6728 6731 _requests[idx](node);
6729 6732 delete _requests[idx];
6730 6733 }
... ... @@ -6774,6 +6777,21 @@
6774 6777 }
6775 6778 };
6776 6779  
  6780 + function getProperties(propertyNodes) {
  6781 + var properties = {};
  6782 + var stringProperties = {};
  6783 + propertyNodes.forEach(function (node) {
  6784 + var name = node.getAttributeValue('name');
  6785 + if (name) {
  6786 + properties[name] = node.getAttributeValue('value');
  6787 + if (!stringProperties[name]) {
  6788 + properties[name] = parseInt(properties[name], 10);
  6789 + }
  6790 + }
  6791 + });
  6792 + _signalInterface.send('got_properties', [properties]);
  6793 + }
  6794 +
6777 6795 function onError(evt) {
6778 6796 var reason = evt.data;
6779 6797 logger.error('Socket error due to:', evt, '!');
... ... @@ -7657,6 +7675,7 @@
7657 7675  
7658 7676 ping: [],
7659 7677 pong: [],
  7678 + got_properties: [],
7660 7679 disconnected: [],
7661 7680  
7662 7681 media_uploadRequestSuccess: [],
... ... @@ -8317,9 +8336,9 @@
8317 8336 innerNodeChildren.push(newProtocolTreeNode('user', {jid: aJid}));
8318 8337 });
8319 8338  
8320   - var queryNode = newProtocolTreeNode('list', {xmlns: 'w:profile:picture'},
8321   - innerNodeChildren);
8322   - var iqNode = newProtocolTreeNode('iq', {id: idx, type: 'get'}, [queryNode]);
  8339 + var queryNode = newProtocolTreeNode('list', {}, innerNodeChildren);
  8340 + var iqNode = newProtocolTreeNode('iq', {id: idx, type: 'get',
  8341 + xmlns: 'w:profile:picture'}, [queryNode]);
8323 8342  
8324 8343 self._writeNode(iqNode);
8325 8344 },
dist/coseme.min.js View file @ a5b4fcb

No preview for this file type

samples/ffosapp/index.html View file @ a5b4fcb
... ... @@ -91,6 +91,7 @@
91 91 <p data-test="contacts_sync">Contacts synchronized... <span></span></p>
92 92 <p data-test="contacts_gotStatus">Contacts status received... <span></span></p>
93 93 <p data-test="presence_updated">Contact's last seen received... <span></span></p>
  94 + <p data-test="got_properties">Recieving properties... <span></span></p>
94 95  
95 96 <h4>Group signals</h4>
96 97  
samples/ffosapp/js/testing.js View file @ a5b4fcb
... ... @@ -84,6 +84,9 @@
84 84  
85 85 ping: null,
86 86 pong: null,
  87 + got_properties: function (properties) {
  88 + ok('got_properties');
  89 + },
87 90 disconnected: null,
88 91  
89 92 media_uploadRequestSuccess: null,
src/protocol/tree.js View file @ a5b4fcb
... ... @@ -91,7 +91,7 @@
91 91 };
92 92  
93 93 Tree.prototype.getAllChildren = function(tag) {
94   - var all = typeof tag !== 'undefined';
  94 + var all = typeof tag === 'undefined';
95 95 var filteredChildren = this.children.filter(function(child) {
96 96 return all || child.tag === tag;
97 97 });
src/yowsup_if.js View file @ a5b4fcb
... ... @@ -76,7 +76,11 @@
76 76  
77 77 var processNode = {
78 78 result: function(iqType, idx, node) {
79   - if (idx in _requests) {
  79 + var props = node.getChild('props');
  80 + if (props) {
  81 + getProperties(props.getAllChildren());
  82 + }
  83 + else if (idx in _requests) {
80 84 _requests[idx](node);
81 85 delete _requests[idx];
82 86 }
... ... @@ -126,6 +130,21 @@
126 130 }
127 131 };
128 132  
  133 + function getProperties(propertyNodes) {
  134 + var properties = {};
  135 + var stringProperties = {};
  136 + propertyNodes.forEach(function (node) {
  137 + var name = node.getAttributeValue('name');
  138 + if (name) {
  139 + properties[name] = node.getAttributeValue('value');
  140 + if (!stringProperties[name]) {
  141 + properties[name] = parseInt(properties[name], 10);
  142 + }
  143 + }
  144 + });
  145 + _signalInterface.send('got_properties', [properties]);
  146 + }
  147 +
129 148 function onError(evt) {
130 149 var reason = evt.data;
131 150 logger.error('Socket error due to:', evt, '!');
... ... @@ -1009,6 +1028,7 @@
1009 1028  
1010 1029 ping: [],
1011 1030 pong: [],
  1031 + got_properties: [],
1012 1032 disconnected: [],
1013 1033  
1014 1034 media_uploadRequestSuccess: [],