@glympse-inc/com.glympse.enroute 2.108.260 → 2.108.266

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glympse-inc/com.glympse.enroute",
3
- "version": "2.108.260",
3
+ "version": "2.108.266",
4
4
  "description": "Glympse En Route Cordova Plugin",
5
5
  "cordova": {
6
6
  "id": "com.glympse.enroute",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" id="com.glympse.enroute" version="2.108.260">
2
+ <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" id="com.glympse.enroute" version="2.108.266">
3
3
 
4
4
  <name>Glympse En Route</name>
5
5
 
@@ -236,7 +236,7 @@
236
236
  <source url="https://github.com/CocoaPods/Specs.git"/>
237
237
  </config>
238
238
  <pods use-frameworks="true">
239
- <pod name="EnRouteApi" spec="~> 2.108.260"/>
239
+ <pod name="EnRouteApi" spec="~> 2.108.266"/>
240
240
  </pods>
241
241
  </podspec>
242
242
  <!-- RELEASE END -->
@@ -211,6 +211,26 @@ public class EnRoutePlugin extends CordovaPlugin implements GListener
211
211
  updateSessionTasks(args, callbackContext);
212
212
  return true;
213
213
  }
214
+ else if (action.equals("startSession"))
215
+ {
216
+ startSession(args, callbackContext);
217
+ return true;
218
+ }
219
+ else if (action.equals("arriveTaskForSession"))
220
+ {
221
+ arriveTaskForSession(args, callbackContext);
222
+ return true;
223
+ }
224
+ else if (action.equals("departTaskForSession"))
225
+ {
226
+ departTaskForSession(args, callbackContext);
227
+ return true;
228
+ }
229
+ else if (action.equals("completeSession"))
230
+ {
231
+ completeSession(args, callbackContext);
232
+ return true;
233
+ }
214
234
  else if (action.equals("startEtaPlannerQuery"))
215
235
  {
216
236
  startEtaPlannerQuery(args, callbackContext);
@@ -1060,20 +1080,23 @@ public class EnRoutePlugin extends CordovaPlugin implements GListener
1060
1080
  {
1061
1081
  GPrimitive sessionsPrimitive = CoreFactory.createPrimitive(CC.PRIMITIVE_TYPE_OBJECT);
1062
1082
 
1083
+ GPrimitive config = CoreFactory.createPrimitive(CC.PRIMITIVE_TYPE_OBJECT);
1084
+ config.put("truncate_locations", true);
1085
+ config.put("ticket_light", true);
1086
+
1063
1087
  for ( GSession session : sessions )
1064
1088
  {
1065
- GOperation operation = session.getOperation();
1066
- if ( null != operation )
1089
+ GTask activeTask = session.getActiveTask();
1090
+ if ( null != activeTask )
1067
1091
  {
1068
1092
  GPrimitive sessionData = CoreFactory.createPrimitive(CC.PRIMITIVE_TYPE_OBJECT);
1093
+ sessionData.put("phase", activeTask.getPhase());
1069
1094
 
1070
- GTicket ticket = operation.getTicket();
1095
+ GTicket ticket = activeTask.getOperation().getTicket();
1071
1096
  if ( null != ticket )
1072
1097
  {
1073
- sessionData.put("ticket", commonObjToPrimitive(operation.getTicket()));
1098
+ sessionData.put("ticket", commonObjToPrimitive(ticket, config));
1074
1099
  }
1075
-
1076
- sessionData.put("ticketVisible", operation.isTicketVisible());
1077
1100
 
1078
1101
  sessionsPrimitive.put("" + session.getId(), sessionData);
1079
1102
  }
@@ -1128,6 +1151,92 @@ public class EnRoutePlugin extends CordovaPlugin implements GListener
1128
1151
  sessionManager.updateSessionTasks(session, tasks);
1129
1152
  }
1130
1153
 
1154
+ private synchronized void startSession(final JSONArray args, final CallbackContext callbackContext)
1155
+ {
1156
+ GSessionManager sessionManager = ManagerWrapper.instance().manager().getSessionManager();
1157
+ if ( null == sessionManager )
1158
+ {
1159
+ return;
1160
+ }
1161
+
1162
+ long sessionId = args.optLong(0, -1);
1163
+ GSession session = sessionManager.findSessionById(sessionId);
1164
+ if ( null == session )
1165
+ {
1166
+ return;
1167
+ }
1168
+
1169
+ sessionManager.startSession(session);
1170
+ }
1171
+
1172
+ private synchronized void arriveTaskForSession(final JSONArray args, final CallbackContext callbackContext)
1173
+ {
1174
+ GSessionManager sessionManager = ManagerWrapper.instance().manager().getSessionManager();
1175
+ if ( null == sessionManager )
1176
+ {
1177
+ return;
1178
+ }
1179
+
1180
+ long sessionId = args.optLong(0, -1);
1181
+ long taskId = args.optLong(1, -1);
1182
+ GSession session = sessionManager.findSessionById(sessionId);
1183
+ if ( null == session )
1184
+ {
1185
+ return;
1186
+ }
1187
+
1188
+ GTask task = ManagerWrapper.instance().manager().getTaskManager().findTaskById(taskId);
1189
+ if ( null == task )
1190
+ {
1191
+ return;
1192
+ }
1193
+
1194
+ sessionManager.arriveTaskForSession(session, task);
1195
+ }
1196
+
1197
+ private synchronized void departTaskForSession(final JSONArray args, final CallbackContext callbackContext)
1198
+ {
1199
+ GSessionManager sessionManager = ManagerWrapper.instance().manager().getSessionManager();
1200
+ if ( null == sessionManager )
1201
+ {
1202
+ return;
1203
+ }
1204
+
1205
+ long sessionId = args.optLong(0, -1);
1206
+ long taskId = args.optLong(1, -1);
1207
+ GSession session = sessionManager.findSessionById(sessionId);
1208
+ if ( null == session )
1209
+ {
1210
+ return;
1211
+ }
1212
+
1213
+ GTask task = ManagerWrapper.instance().manager().getTaskManager().findTaskById(taskId);
1214
+ if ( null == task )
1215
+ {
1216
+ return;
1217
+ }
1218
+
1219
+ sessionManager.departTaskForSession(session, task);
1220
+ }
1221
+
1222
+ private synchronized void completeSession(final JSONArray args, final CallbackContext callbackContext)
1223
+ {
1224
+ GSessionManager sessionManager = ManagerWrapper.instance().manager().getSessionManager();
1225
+ if ( null == sessionManager )
1226
+ {
1227
+ return;
1228
+ }
1229
+
1230
+ long sessionId = args.optLong(0, -1);
1231
+ GSession session = sessionManager.findSessionById(sessionId);
1232
+ if ( null == session )
1233
+ {
1234
+ return;
1235
+ }
1236
+
1237
+ sessionManager.completeSession(session);
1238
+ }
1239
+
1131
1240
  private synchronized void startEtaPlannerQuery(final JSONArray args, final CallbackContext callbackContext)
1132
1241
  {
1133
1242
  GEnRouteManager manager = ManagerWrapper.instance().manager();
@@ -17,7 +17,7 @@ android {
17
17
  }
18
18
 
19
19
  dependencies {
20
- def GLYMPSE_VERSION = '2.108.260'
20
+ def GLYMPSE_VERSION = '2.108.266'
21
21
  implementation "com.glympse:enrouteapi:$GLYMPSE_VERSION"
22
22
  implementation "com.glympse:glympseapi:$GLYMPSE_VERSION"
23
23
  implementation "com.glympse:glympseapi-push:$GLYMPSE_VERSION"
@@ -84,6 +84,14 @@
84
84
 
85
85
  - (void) updateSessionTasks:(CDVInvokedUrlCommand *)command;
86
86
 
87
+ - (void) startSession:(CDVInvokedUrlCommand *)command;
88
+
89
+ - (void) arriveTaskForSession:(CDVInvokedUrlCommand *)command;
90
+
91
+ - (void) departTaskForSession:(CDVInvokedUrlCommand *)command;
92
+
93
+ - (void) completeSession:(CDVInvokedUrlCommand *)command;
94
+
87
95
  - (void) startEtaPlannerQuery:(CDVInvokedUrlCommand *)command;
88
96
 
89
97
  - (void) abortEtaPlannerQuery:(CDVInvokedUrlCommand *)command;
@@ -576,21 +576,24 @@
576
576
  {
577
577
  Glympse::GPrimitive sessionsPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
578
578
 
579
+ Glympse::GPrimitive config = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
580
+ config->put([GETHelpers toGString:@"truncate_locations"], true);
581
+ config->put([GETHelpers toGString:@"ticket_light"], true);
582
+
579
583
  for ( Glympse::EnRoute::GSession session : sessions )
580
584
  {
581
- Glympse::EnRoute::GOperation operation = session->getOperation();
585
+ Glympse::EnRoute::GTask activeTask = session->getActiveTask();
582
586
 
583
- if ( NULL != operation )
587
+ if ( NULL != activeTask )
584
588
  {
585
589
  Glympse::GPrimitive sessionData = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
590
+ sessionData->put([GETHelpers toGString:@"phase"], activeTask->getPhase());
586
591
 
587
- Glympse::GTicket ticket = operation->getTicket();
592
+ Glympse::GTicket ticket = activeTask->getOperation()->getTicket();
588
593
  if ( NULL != ticket )
589
594
  {
590
- sessionData->put([GETHelpers toGString:@"ticket"], [self commonObjToPrimitive:operation->getTicket()]);
595
+ sessionData->put([GETHelpers toGString:@"ticket"], [self commonObjToPrimitive:ticket withConfig:config]);
591
596
  }
592
-
593
- sessionData->put([GETHelpers toGString:@"ticketVisible"], operation->isTicketVisible());
594
597
 
595
598
  NSString *idString = [NSString stringWithFormat:@"%lld", session->getId()];
596
599
 
@@ -642,6 +645,68 @@
642
645
  [EnRouteWrapper instance].manager->getSessionManager()->updateSessionTasks(session, tasks);
643
646
  }
644
647
 
648
+ - (void) startSession:(CDVInvokedUrlCommand *)command
649
+ {
650
+ Glympse::int64 sessionId = [[command argumentAtIndex:0] longLongValue];
651
+ Glympse::EnRoute::GSession session = [EnRouteWrapper instance].manager->getSessionManager()->findSessionById(sessionId);
652
+ if ( NULL == session )
653
+ {
654
+ return;
655
+ }
656
+
657
+ [EnRouteWrapper instance].manager->getSessionManager()->startSession(session);
658
+ }
659
+
660
+ - (void) arriveTaskForSession:(CDVInvokedUrlCommand *)command
661
+ {
662
+ Glympse::int64 sessionId = [[command argumentAtIndex:0] longLongValue];
663
+ Glympse::int64 taskId = [[command argumentAtIndex:1] longLongValue];
664
+ Glympse::EnRoute::GSession session = [EnRouteWrapper instance].manager->getSessionManager()->findSessionById(sessionId);
665
+ if ( NULL == session )
666
+ {
667
+ return;
668
+ }
669
+
670
+ Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
671
+ if ( NULL == task )
672
+ {
673
+ return;
674
+ }
675
+
676
+ [EnRouteWrapper instance].manager->getSessionManager()->arriveTaskForSession(session, task);
677
+ }
678
+
679
+ - (void) departTaskForSession:(CDVInvokedUrlCommand *)command
680
+ {
681
+ Glympse::int64 sessionId = [[command argumentAtIndex:0] longLongValue];
682
+ Glympse::int64 taskId = [[command argumentAtIndex:1] longLongValue];
683
+ Glympse::EnRoute::GSession session = [EnRouteWrapper instance].manager->getSessionManager()->findSessionById(sessionId);
684
+ if ( NULL == session )
685
+ {
686
+ return;
687
+ }
688
+
689
+ Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
690
+ if ( NULL == task )
691
+ {
692
+ return;
693
+ }
694
+
695
+ [EnRouteWrapper instance].manager->getSessionManager()->departTaskForSession(session, task);
696
+ }
697
+
698
+ - (void) completeSession:(CDVInvokedUrlCommand *)command
699
+ {
700
+ Glympse::int64 sessionId = [[command argumentAtIndex:0] longLongValue];
701
+ Glympse::EnRoute::GSession session = [EnRouteWrapper instance].manager->getSessionManager()->findSessionById(sessionId);
702
+ if ( NULL == session )
703
+ {
704
+ return;
705
+ }
706
+
707
+ [EnRouteWrapper instance].manager->getSessionManager()->completeSession(session);
708
+ }
709
+
645
710
  - (void) startEtaPlannerQuery:(CDVInvokedUrlCommand *)command
646
711
  {
647
712
  NSDictionary *initial = [command argumentAtIndex:0 withDefault:NULL];
package/www/Native.js CHANGED
@@ -128,6 +128,22 @@ module.exports = {
128
128
  cordova.exec(successCallback, errorCallback, "EnRoutePlugin", "updateSessionTasks", [sessionId, taskIds]);
129
129
  },
130
130
 
131
+ startSession: function(sessionId, successCallback, errorCallback) {
132
+ cordova.exec(successCallback, errorCallback, "EnRoutePlugin", "startSession", [sessionId]);
133
+ },
134
+
135
+ arriveTaskForSession: function(sessionId, taskId, successCallback, errorCallback) {
136
+ cordova.exec(successCallback, errorCallback, "EnRoutePlugin", "arriveTaskForSession", [sessionId, taskId]);
137
+ },
138
+
139
+ departTaskForSession: function(sessionId, taskId, successCallback, errorCallback) {
140
+ cordova.exec(successCallback, errorCallback, "EnRoutePlugin", "departTaskForSession", [sessionId, taskId]);
141
+ },
142
+
143
+ completeSession: function(sessionId, successCallback, errorCallback) {
144
+ cordova.exec(successCallback, errorCallback, "EnRoutePlugin", "completeSession", [sessionId]);
145
+ },
146
+
131
147
  startEtaPlannerQuery: function (initial, places, stopoverTime, successCallback, errorCallback) {
132
148
  cordova.exec(successCallback, errorCallback, "EnRoutePlugin", "startEtaPlannerQuery", [initial, places, stopoverTime]);
133
149
  },
package/www/Session.js CHANGED
@@ -1,4 +1,3 @@
1
- var Operation = require('./Operation');
2
1
  var Task = require('./Task');
3
2
 
4
3
  function Session(data) {
@@ -19,17 +18,9 @@
19
18
  this._startTime = data.startTime;
20
19
  this._orgId = data.orgId;
21
20
  this._agentId = data.agentId;
22
- this._operationId = data.operationId;
21
+ this._completedTime = data.completedTime;
23
22
  this._completionReason = data.completionReason;
24
-
25
- var o = data.operation;
26
- if (o) {
27
- if (this._operation) {
28
- this._operation.update(o);
29
- } else {
30
- this._operation = new Operation(o);
31
- }
32
- }
23
+ this._etaToBase = data.etaToBase;
33
24
  };
34
25
 
35
26
  Session.prototype.getId = function () {
@@ -72,16 +63,16 @@
72
63
  return this._agentId;
73
64
  };
74
65
 
75
- Session.prototype.getOperationId = function () {
76
- return this._operationId;
77
- };
78
-
79
- Session.prototype.getOperation = function () {
80
- return this._operation;
66
+ Session.prototype.getCompletedTime = function () {
67
+ return this._completedTime;
81
68
  };
82
69
 
83
70
  Session.prototype.getCompletionReason = function () {
84
71
  return this._completionReason;
85
72
  };
86
73
 
74
+ Session.prototype.getEtaToBase = function () {
75
+ return this._etaToBase;
76
+ };
77
+
87
78
  module.exports = Session;
@@ -11,6 +11,8 @@
11
11
  var SESSIONS_SESSION_COMPLETION_FAILED = 0x000000010;
12
12
  var SESSIONS_SESSION_ACTIVE_TASK_CHANGED = 0x000000020;
13
13
  var SESSIONS_SESSION_ACTIVE_TASK_PHASE_CHANGED = 0x000000040;
14
+ var SESSIONS_SESSION_COMPLETION_DELAYED = 0x00000080;
15
+ var SESSIONS_SESSION_ACTIVE_TASK_ROUTE_UPDATED = 0x00000400;
14
16
 
15
17
  var SESSION_STATE_UNKNOWN = 0;
16
18
  var SESSION_STATE_CREATED = 1;
@@ -114,7 +116,7 @@
114
116
  }
115
117
  if ( 0 !== ( SESSIONS_SESSION_ACTIVE_TASK_PHASE_CHANGED & events ) ) {
116
118
  console.log("SessionManager SESSIONS_SESSION_ACTIVE_TASK_PHASE_CHANGED");
117
- refreshState(true, function() {
119
+ refreshState(false, function() {
118
120
  var session;
119
121
  if ( param1 && param1.id )
120
122
  {
@@ -128,6 +130,26 @@
128
130
  spreadSessionActiveTaskPhaseChanged(session, task);
129
131
  });
130
132
  }
133
+ if ( 0 !== ( SESSIONS_SESSION_COMPLETION_DELAYED & events ) ) {
134
+ console.log("SessionManager SESSIONS_SESSION_COMPLETION_DELAYED");
135
+ var session;
136
+ if ( param1 && param1.id )
137
+ {
138
+ session = _sessionMap[param1.id];
139
+ }
140
+ spreadSessionCompletionDelayed(session);
141
+ }
142
+ if ( 0 !== ( SESSIONS_SESSION_ACTIVE_TASK_ROUTE_UPDATED & events ) ) {
143
+ console.log("SessionManager SESSIONS_SESSION_ACTIVE_TASK_ROUTE_UPDATED");
144
+ refreshState(false, function() {
145
+ var session;
146
+ if ( param1 && param1.id )
147
+ {
148
+ session = _sessionMap[param1.id];
149
+ }
150
+ spreadSessionActiveTaskRouteUpdated(session);
151
+ });
152
+ }
131
153
  }
132
154
  };
133
155
 
@@ -159,6 +181,14 @@
159
181
  spreadEvent('sessionActiveTaskPhaseChanged', [session, task]);
160
182
  };
161
183
 
184
+ function spreadSessionCompletionDelayed(session) {
185
+ spreadEvent('sessionCompletionDelayed', [session]);
186
+ };
187
+
188
+ function spreadSessionActiveTaskRouteUpdated(session) {
189
+ spreadEvent('sessionActiveTaskRouteUpdated', [session]);
190
+ };
191
+
162
192
  function spreadEvent(event, params) {
163
193
  // console.log("spreadEvent");
164
194
  if (_listeners) {
@@ -220,12 +250,13 @@
220
250
  var sessionInfo = (session && sessionsData[session.getId().toString()]);
221
251
 
222
252
  if ( sessionInfo ) {
223
- var op = session.getOperation();
224
-
225
- if (op) {
226
- op._phase = sessionInfo.phase;
227
- op._ticketVisible = sessionInfo.ticketVisible;
228
- op._updateTicket(sessionInfo.ticket);
253
+ var activeTask = session._activeTask;
254
+ if (activeTask) {
255
+ activeTask._phase = sessionInfo.phase;
256
+ var op = activeTask._operation;
257
+ if (op) {
258
+ op._updateTicket(sessionInfo.ticket);
259
+ }
229
260
  }
230
261
  }
231
262
  }
@@ -427,5 +458,21 @@
427
458
  */
428
459
  findSessionById: function(sessionId){
429
460
  return _sessionMap[sessionId];
461
+ },
462
+
463
+ startSession: function(session) {
464
+ Native.startSession(session.getId(), _noop, _noop);
465
+ },
466
+
467
+ arriveTaskForSession: function(session, task) {
468
+ Native.arriveTaskForSession(session.getId(), task.getId(), _noop, _noop);
469
+ },
470
+
471
+ departTaskForSession: function(session, task) {
472
+ Native.departTaskForSession(session.getId(), task.getId(), _noop, _noop);
473
+ },
474
+
475
+ completeSession: function(session) {
476
+ Native.completeSession(session.getId(), _noop, _noop);
430
477
  }
431
478
  };
package/www/Task.js CHANGED
@@ -12,6 +12,7 @@
12
12
  this._id = data.id;
13
13
  this._description = data.description;
14
14
  this._dueTime = data.dueTime;
15
+ this._arrivedTime = data.arrivedTime
15
16
  this._completedTime = data.completedTime;
16
17
  this._phase = data.phase;
17
18
  this._foreignId = data.foreignId;
@@ -63,6 +64,10 @@
63
64
  return this._dueTime;
64
65
  };
65
66
 
67
+ Task.prototype.getArrivedTime = function() {
68
+ return this._arrivedTime;
69
+ };
70
+
66
71
  Task.prototype.getCompletedTime = function() {
67
72
  return this._completedTime;
68
73
  };