@glympse-inc/com.glympse.enroute 2.105.232
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 +34 -0
- package/plugin.xml +262 -0
- package/scripts/iosFixPCH.js +38 -0
- package/src/android/BootReceiver.java +13 -0
- package/src/android/EnRoutePlugin.java +1867 -0
- package/src/android/HealthCheckJobService.java +225 -0
- package/src/android/LocationAccuracyChecker.java +49 -0
- package/src/android/ManagerWrapper.java +205 -0
- package/src/android/NotificationService.java +81 -0
- package/src/android/PushReceiver.java +90 -0
- package/src/android/enroute/aars/enrouteapi-aar.gradle +17 -0
- package/src/android/enroute/aars/glympseapi-aar.gradle +17 -0
- package/src/android/enroute/aars/glympseapipush-aar.gradle +17 -0
- package/src/android/enroute/aars/glympseapitoolbox-aar.gradle +17 -0
- package/src/android/gradle/build.gradle +25 -0
- package/src/ios/EnRoutePlugin.h +128 -0
- package/src/ios/EnRoutePlugin.mm +1258 -0
- package/src/ios/EnRouteWrapper.h +30 -0
- package/src/ios/EnRouteWrapper.mm +176 -0
- package/www/Agent.js +48 -0
- package/www/AgentManager.js +422 -0
- package/www/CardMessage.js +49 -0
- package/www/ChatMessage.js +29 -0
- package/www/CustomerMessage.js +18 -0
- package/www/EnRouteManager.js +613 -0
- package/www/EtaPlanner.js +129 -0
- package/www/GlobalConfig.js +13 -0
- package/www/Invite.js +93 -0
- package/www/LatLng.js +28 -0
- package/www/Location.js +63 -0
- package/www/Native.js +215 -0
- package/www/Operation.js +67 -0
- package/www/OrderItem.js +43 -0
- package/www/OrgConfig.js +184 -0
- package/www/Organization.js +88 -0
- package/www/Pickup.js +119 -0
- package/www/PickupArrivalData.js +38 -0
- package/www/PickupManager.js +512 -0
- package/www/Place.js +33 -0
- package/www/Session.js +87 -0
- package/www/SessionManager.js +431 -0
- package/www/Task.js +106 -0
- package/www/TaskManager.js +443 -0
- package/www/Ticket.js +205 -0
- package/www/Track.js +75 -0
|
@@ -0,0 +1,1258 @@
|
|
|
1
|
+
//------------------------------------------------------------------------------
|
|
2
|
+
//
|
|
3
|
+
// Copyright (c) 2015 Glympse Inc. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
//------------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
#import "EnRoutePlugin.h"
|
|
8
|
+
#import <UIKit/UIApplication.h>
|
|
9
|
+
#import "EnRouteWrapper.h"
|
|
10
|
+
|
|
11
|
+
#define COMMAND_KEY_LOGIN @"LOGIN"
|
|
12
|
+
#define COMMAND_KEY_LOGOUT @"LOGOUT"
|
|
13
|
+
#define COMMAND_KEY_REFRESH @"REFRESH"
|
|
14
|
+
#define COMMAND_KEY_REFRESH_SESSIONS @"REFRESH_SESSIONS"
|
|
15
|
+
#define COMMAND_KEY_REFRESH_PICKUPS @"REFRESH_PICKUPS"
|
|
16
|
+
#define COMMAND_KEY_START_SHIFT @"START_SHIFT"
|
|
17
|
+
#define COMMAND_KEY_COMPLETE_SHIFT @"COMPLETE_SHIFT"
|
|
18
|
+
|
|
19
|
+
@implementation NSString (EnRoutePlugin)
|
|
20
|
+
|
|
21
|
+
+ (NSString *) stringWithGString:(const Glympse::GString &)gString
|
|
22
|
+
{
|
|
23
|
+
if ( gString == NULL )
|
|
24
|
+
{
|
|
25
|
+
return @"";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const char * str = gString->toCharArray();
|
|
29
|
+
if ( str != NULL )
|
|
30
|
+
{
|
|
31
|
+
return [NSString stringWithUTF8String:str];
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
{
|
|
35
|
+
return @"";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@end
|
|
40
|
+
|
|
41
|
+
@interface EnRoutePlugin () < GETListener >
|
|
42
|
+
|
|
43
|
+
@end
|
|
44
|
+
|
|
45
|
+
@implementation EnRoutePlugin
|
|
46
|
+
|
|
47
|
+
- (void) pluginInitialize
|
|
48
|
+
{
|
|
49
|
+
_cordovaCommands = [[NSMutableDictionary alloc] init];
|
|
50
|
+
_listenerCallbacks = [[NSMutableArray alloc] init];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#pragma mark - Cordova Plugin API
|
|
54
|
+
|
|
55
|
+
- (void) setActive:(CDVInvokedUrlCommand *)command
|
|
56
|
+
{
|
|
57
|
+
BOOL active = [[command argumentAtIndex:0] boolValue];
|
|
58
|
+
|
|
59
|
+
[EnRouteWrapper instance].manager->setActive(active);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void) setBaseUrl:(CDVInvokedUrlCommand *)command
|
|
63
|
+
{
|
|
64
|
+
NSString *baseUrl = [command argumentAtIndex:0 withDefault:NULL];
|
|
65
|
+
|
|
66
|
+
if ( NULL != baseUrl )
|
|
67
|
+
{
|
|
68
|
+
[EnRouteWrapper instance].manager->setBaseUrl([GETHelpers toGString:baseUrl]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (void) setAuthenticationMode:(CDVInvokedUrlCommand *)command
|
|
73
|
+
{
|
|
74
|
+
Glympse::int32 mode = [[command argumentAtIndex:0] integerValue];
|
|
75
|
+
|
|
76
|
+
[EnRouteWrapper instance].manager->setAuthenticationMode(mode);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void) registerDeviceToken:(CDVInvokedUrlCommand *)command
|
|
80
|
+
{
|
|
81
|
+
NSString *tokenType = [command argumentAtIndex:0 withDefault:NULL];
|
|
82
|
+
NSString *deviceToken = [command argumentAtIndex:1 withDefault:NULL];
|
|
83
|
+
|
|
84
|
+
if ( NULL != deviceToken && NULL != tokenType )
|
|
85
|
+
{
|
|
86
|
+
[EnRouteWrapper instance].manager->registerDeviceToken([GETHelpers toGString:tokenType], [GETHelpers toGString:deviceToken]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void) handleRemoteNotification:(CDVInvokedUrlCommand *)command
|
|
91
|
+
{
|
|
92
|
+
NSDictionary *payload = [command argumentAtIndex:0 withDefault:NULL];
|
|
93
|
+
if ( NULL != payload )
|
|
94
|
+
{
|
|
95
|
+
NSString *payloadString = [payload objectForKey:@"payload"];
|
|
96
|
+
[EnRouteWrapper instance].manager->handleRemoteNotification([GETHelpers toGString:payloadString]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void) registerListener:(CDVInvokedUrlCommand *)command
|
|
101
|
+
{
|
|
102
|
+
[_listenerCallbacks addObject:command.callbackId];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (void) syncAccountState:(CDVInvokedUrlCommand *)command
|
|
106
|
+
{
|
|
107
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
108
|
+
Glympse::EnRoute::GEnRouteManager manager = [EnRouteWrapper instance].manager;
|
|
109
|
+
|
|
110
|
+
result->put([GETHelpers toGString:@"loginNeeded"], manager->isLoginNeeded());
|
|
111
|
+
result->put([GETHelpers toGString:@"started"], manager->isStarted());
|
|
112
|
+
|
|
113
|
+
Glympse::EnRoute::GAgent agent = manager->getLoggedInAgent();
|
|
114
|
+
if ( NULL != agent )
|
|
115
|
+
{
|
|
116
|
+
Glympse::GPrimitive agentPrimitive = [self commonObjToPrimitive:agent];
|
|
117
|
+
result->put([GETHelpers toGString:@"loggedInAgent"], agentPrimitive);
|
|
118
|
+
result->put([GETHelpers toGString:@"onShiftModified"], (Glympse::int64)agent->getOnShiftModified());
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Glympse::EnRoute::GOrganization org = manager->getOrganization();
|
|
122
|
+
if ( NULL != org )
|
|
123
|
+
{
|
|
124
|
+
Glympse::GPrimitive orgPrimitive = [self commonObjToPrimitive:org];
|
|
125
|
+
result->put([GETHelpers toGString:@"loggedInOrg"], orgPrimitive);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
Glympse::GString authToken = manager->getEnRouteToken();
|
|
129
|
+
if ( NULL != authToken )
|
|
130
|
+
{
|
|
131
|
+
result->put([GETHelpers toGString:@"authToken"], authToken);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
Glympse::GString baseUrl = manager->getBaseUrl();
|
|
135
|
+
if ( NULL != baseUrl )
|
|
136
|
+
{
|
|
137
|
+
result->put([GETHelpers toGString:@"baseUrl"], baseUrl);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
Glympse::GGlympse glympse = manager->getGlympse();
|
|
141
|
+
if ( NULL != glympse )
|
|
142
|
+
{
|
|
143
|
+
Glympse::GLocationManager locationManager = glympse->getLocationManager();
|
|
144
|
+
Glympse::int32 accuracyAuth = locationManager->getLocationAccuracyAuthorization();
|
|
145
|
+
result->put([GETHelpers toGString:@"isLocationAccuracyAuthFull"], accuracyAuth == Glympse::CoreConstants::LOCATION_ACCURACY_AUTH_FULL);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
result->put([GETHelpers toGString:@"authenticationMode"], (Glympse::int64)manager->getAuthenticationMode());
|
|
149
|
+
result->put([GETHelpers toGString:@"isOnShift"], manager->isOnShift());
|
|
150
|
+
|
|
151
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
152
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
153
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
- (void) syncHealthReport:(CDVInvokedUrlCommand *)command
|
|
157
|
+
{
|
|
158
|
+
Glympse::EnRoute::GEnRouteManager manager = [EnRouteWrapper instance].manager;
|
|
159
|
+
Glympse::EnRoute::GEnRouteHealthCheck enRouteHealthCheck = manager->getEnRouteHealthCheck();
|
|
160
|
+
Glympse::GCoreHealthCheck coreHealthCheck = manager->getGlympse()->getCoreHealthCheck();
|
|
161
|
+
|
|
162
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
163
|
+
|
|
164
|
+
// En Route checks
|
|
165
|
+
Glympse::GHealthReport healthReport = enRouteHealthCheck->checkLoggedInState();
|
|
166
|
+
Glympse::GPrimitive value = healthReport->getValue();
|
|
167
|
+
result->put([GETHelpers toGString:@"isLoginNeeded"], value->getBool());
|
|
168
|
+
|
|
169
|
+
healthReport = enRouteHealthCheck->checkSharingCompliance();
|
|
170
|
+
value = healthReport->getValue();
|
|
171
|
+
result->put([GETHelpers toGString:@"sharingCompliance"], value->getBool());
|
|
172
|
+
|
|
173
|
+
// Core checks
|
|
174
|
+
healthReport = coreHealthCheck->checkLocationAuth();
|
|
175
|
+
value = healthReport->getValue();
|
|
176
|
+
result->put([GETHelpers toGString:@"locationAuth"], value->getLong());
|
|
177
|
+
|
|
178
|
+
healthReport = coreHealthCheck->checkNotificationAuth();
|
|
179
|
+
value = healthReport->getValue();
|
|
180
|
+
result->put([GETHelpers toGString:@"notificationAuth"], value->getLong());
|
|
181
|
+
|
|
182
|
+
healthReport = coreHealthCheck->checkBatteryOptimization();
|
|
183
|
+
value = healthReport->getValue();
|
|
184
|
+
result->put([GETHelpers toGString:@"batteryOptimization"], value->getBool());
|
|
185
|
+
|
|
186
|
+
healthReport = coreHealthCheck->checkLocationAccuracyAuth();
|
|
187
|
+
value = healthReport->getValue();
|
|
188
|
+
result->put([GETHelpers toGString:@"locationAccuracy"], value->getLong());
|
|
189
|
+
|
|
190
|
+
healthReport = coreHealthCheck->checkMobileDataAvailability();
|
|
191
|
+
value = healthReport->getValue();
|
|
192
|
+
result->put([GETHelpers toGString:@"mobileData"], value->getLong());
|
|
193
|
+
|
|
194
|
+
healthReport = coreHealthCheck->checkRestrictBackgroundStatus();
|
|
195
|
+
value = healthReport->getValue();
|
|
196
|
+
result->put([GETHelpers toGString:@"restrictBackground"], value->getLong());
|
|
197
|
+
|
|
198
|
+
healthReport = coreHealthCheck->checkIsWifiScanningEnabled();
|
|
199
|
+
value = healthReport->getValue();
|
|
200
|
+
result->put([GETHelpers toGString:@"wifiScanning"], value->getBool());
|
|
201
|
+
|
|
202
|
+
healthReport = coreHealthCheck->checkIsBluetoothScanningEnabled();
|
|
203
|
+
value = healthReport->getValue();
|
|
204
|
+
result->put([GETHelpers toGString:@"btScanning"], value->getBool());
|
|
205
|
+
|
|
206
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
207
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
208
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
- (void) start:(CDVInvokedUrlCommand *)command
|
|
212
|
+
{
|
|
213
|
+
[self subscribeToListeners];
|
|
214
|
+
|
|
215
|
+
[EnRouteWrapper instance].manager->start();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
- (void) loginWithCredentials:(CDVInvokedUrlCommand *)command
|
|
219
|
+
{
|
|
220
|
+
NSString *username = [command argumentAtIndex:0 withDefault:NULL];
|
|
221
|
+
NSString *password = [command argumentAtIndex:1 withDefault:NULL];
|
|
222
|
+
|
|
223
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_LOGIN];
|
|
224
|
+
|
|
225
|
+
[EnRouteWrapper instance].manager->loginWithCredentials([GETHelpers toGString:username], [GETHelpers toGString:password]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
- (void) loginWithToken:(CDVInvokedUrlCommand *)command
|
|
229
|
+
{
|
|
230
|
+
NSString *token = [command argumentAtIndex:0 withDefault:NULL];
|
|
231
|
+
Glympse::int64 expireTime = [[command argumentAtIndex:1] longLongValue];
|
|
232
|
+
|
|
233
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_LOGIN];
|
|
234
|
+
|
|
235
|
+
[EnRouteWrapper instance].manager->loginWithToken([GETHelpers toGString:token], expireTime);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
- (void) logout:(CDVInvokedUrlCommand *)command
|
|
239
|
+
{
|
|
240
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_LOGOUT];
|
|
241
|
+
|
|
242
|
+
[EnRouteWrapper instance].manager->logout(Glympse::EnRoute::EnRouteConstants::LOGOUT_REASON_USER_ACTION);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
- (void) logoutWithReason:(CDVInvokedUrlCommand *)command
|
|
246
|
+
{
|
|
247
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_LOGOUT];
|
|
248
|
+
|
|
249
|
+
id reasonArgument = [command argumentAtIndex:0];
|
|
250
|
+
Glympse::int32 reason = Glympse::EnRoute::EnRouteConstants::LOGOUT_REASON_UNKNOWN;
|
|
251
|
+
if ( nil != reasonArgument )
|
|
252
|
+
{
|
|
253
|
+
reason = [reasonArgument integerValue];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
[EnRouteWrapper instance].manager->logout(reason);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
- (void) stop:(CDVInvokedUrlCommand *)command
|
|
260
|
+
{
|
|
261
|
+
[EnRouteWrapper instance].manager->stop();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
- (void) syncTasksState:(CDVInvokedUrlCommand *)command
|
|
265
|
+
{
|
|
266
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
267
|
+
|
|
268
|
+
if ( [EnRouteWrapper instance].manager->isStarted() )
|
|
269
|
+
{
|
|
270
|
+
Glympse::GArray<Glympse::EnRoute::GTask>::ptr tasks = [EnRouteWrapper instance].manager->getTaskManager()->getTasks();
|
|
271
|
+
if ( NULL != tasks )
|
|
272
|
+
{
|
|
273
|
+
Glympse::GPrimitive tasksPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
274
|
+
|
|
275
|
+
Glympse::GPrimitive config = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
276
|
+
config->put([GETHelpers toGString:@"truncate_locations"], true);
|
|
277
|
+
|
|
278
|
+
Glympse::GChatManager chatManager = [EnRouteWrapper instance].manager->getGlympse()->getChatManager();
|
|
279
|
+
|
|
280
|
+
for ( Glympse::EnRoute::GTask task : tasks )
|
|
281
|
+
{
|
|
282
|
+
Glympse::GPrimitive taskPrimitive = [self commonObjToPrimitive:task withConfig:config];
|
|
283
|
+
|
|
284
|
+
Glympse::GString chatRoomId = task->getChatRoomId();
|
|
285
|
+
if ( NULL != chatRoomId )
|
|
286
|
+
{
|
|
287
|
+
Glympse::GChatRoom chatRoom = chatManager->getChatRoom(chatRoomId);
|
|
288
|
+
if ( NULL != chatRoom )
|
|
289
|
+
{
|
|
290
|
+
Glympse::GArray<Glympse::GChatMessage>::ptr messages = chatRoom->getChatMessages();
|
|
291
|
+
|
|
292
|
+
Glympse::GPrimitive chatMessagesPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
293
|
+
for ( Glympse::GChatMessage chatMessage : messages )
|
|
294
|
+
{
|
|
295
|
+
Glympse::GPrimitive chatMessagePrimitive = [self commonObjToPrimitive:chatMessage];
|
|
296
|
+
chatMessagesPrimitive->put(chatMessagePrimitive);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
taskPrimitive->put([GETHelpers toGString:@"chatMessages"], chatMessagesPrimitive);
|
|
300
|
+
taskPrimitive->put([GETHelpers toGString:@"lastReadSequenceNumber"], chatRoom->getLastReadSequenceNumber());
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
Glympse::GString travelMode = [EnRouteWrapper instance].manager->getTaskManager()->getTravelModeForTask(task);
|
|
305
|
+
taskPrimitive->put([GETHelpers toGString:@"travelMode"], travelMode);
|
|
306
|
+
|
|
307
|
+
tasksPrimitive->put(taskPrimitive);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
result->put([GETHelpers toGString:@"tasks"], tasksPrimitive);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
315
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
316
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
- (void) syncTasksStateLight:(CDVInvokedUrlCommand *)command
|
|
320
|
+
{
|
|
321
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
322
|
+
|
|
323
|
+
if ( [EnRouteWrapper instance].manager->isStarted() )
|
|
324
|
+
{
|
|
325
|
+
Glympse::GArray<Glympse::EnRoute::GTask>::ptr tasks = [EnRouteWrapper instance].manager->getTaskManager()->getTasks();
|
|
326
|
+
if ( NULL != tasks )
|
|
327
|
+
{
|
|
328
|
+
Glympse::GPrimitive tasksPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
329
|
+
|
|
330
|
+
Glympse::GPrimitive config = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
331
|
+
config->put([GETHelpers toGString:@"truncate_locations"], true);
|
|
332
|
+
config->put([GETHelpers toGString:@"ticket_light"], true);
|
|
333
|
+
|
|
334
|
+
for ( Glympse::EnRoute::GTask task : tasks )
|
|
335
|
+
{
|
|
336
|
+
Glympse::EnRoute::GOperation operation = task->getOperation();
|
|
337
|
+
if ( NULL != operation )
|
|
338
|
+
{
|
|
339
|
+
Glympse::GPrimitive taskData = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
340
|
+
taskData->put([GETHelpers toGString:@"phase"], task->getPhase());
|
|
341
|
+
|
|
342
|
+
Glympse::GTicket ticket = operation->getTicket();
|
|
343
|
+
if ( NULL != ticket )
|
|
344
|
+
{
|
|
345
|
+
taskData->put([GETHelpers toGString:@"ticket"], [self commonObjToPrimitive:operation->getTicket() withConfig:config]);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
taskData->put([GETHelpers toGString:@"ticketVisible"], operation->isTicketVisible());
|
|
349
|
+
|
|
350
|
+
NSString *idString = [NSString stringWithFormat:@"%lld", task->getId()];
|
|
351
|
+
|
|
352
|
+
tasksPrimitive->put([GETHelpers toGString:idString], taskData);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
result->put([GETHelpers toGString:@"tasks_data"], tasksPrimitive);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
361
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
362
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
- (void) refreshTasks:(CDVInvokedUrlCommand *)command
|
|
366
|
+
{
|
|
367
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_REFRESH];
|
|
368
|
+
|
|
369
|
+
[EnRouteWrapper instance].manager->refresh();
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
- (void) startTask:(CDVInvokedUrlCommand *)command
|
|
373
|
+
{
|
|
374
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
375
|
+
Glympse::int32 duration = [[command argumentAtIndex:1] integerValue];
|
|
376
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
377
|
+
if ( NULL == task )
|
|
378
|
+
{
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
[EnRouteWrapper instance].manager->getTaskManager()->startTask(task, duration);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
- (void) createTask:(CDVInvokedUrlCommand *)command
|
|
386
|
+
{
|
|
387
|
+
NSString *value = (NSString *)[command argumentAtIndex:0];
|
|
388
|
+
Glympse::GString valueString = [GETHelpers toGString:value];
|
|
389
|
+
Glympse::GPrimitive taskData = Glympse::CoreTools::stringToPrimitive(valueString);
|
|
390
|
+
|
|
391
|
+
if ( NULL == taskData )
|
|
392
|
+
{
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
[EnRouteWrapper instance].manager->getTaskManager()->createTask(taskData, true);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
- (void) setTaskPhase:(CDVInvokedUrlCommand *)command
|
|
400
|
+
{
|
|
401
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
402
|
+
NSString *phaseString = (NSString *)[command argumentAtIndex:1];
|
|
403
|
+
|
|
404
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
405
|
+
if ( NULL == task )
|
|
406
|
+
{
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
[EnRouteWrapper instance].manager->getTaskManager()->setTaskPhase(task, [GETHelpers toGString:phaseString]);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
- (void) setTaskVisibility:(CDVInvokedUrlCommand *)command
|
|
414
|
+
{
|
|
415
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
416
|
+
NSString *nsVisible = [command argumentAtIndex:1];
|
|
417
|
+
Glympse::GString visible = [GETHelpers toGString:nsVisible];
|
|
418
|
+
|
|
419
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
420
|
+
if ( NULL == task )
|
|
421
|
+
{
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
Glympse::EnRoute::GOperation operation = task->getOperation();
|
|
426
|
+
if ( NULL == operation )
|
|
427
|
+
{
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
operation->setTicketVisible(visible);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
- (void) completeTask:(CDVInvokedUrlCommand *)command
|
|
435
|
+
{
|
|
436
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
437
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
438
|
+
if ( NULL == task )
|
|
439
|
+
{
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
Glympse::EnRoute::GOperation operation = task->getOperation();
|
|
444
|
+
if ( NULL == operation )
|
|
445
|
+
{
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
[EnRouteWrapper instance].manager->getTaskManager()->completeOperation(operation);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
- (void) addOrUpdateMetadataItem:(CDVInvokedUrlCommand *)command
|
|
453
|
+
{
|
|
454
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
455
|
+
NSString *key = (NSString *)[command argumentAtIndex:1];
|
|
456
|
+
Glympse::GString keyString = [GETHelpers toGString:key];
|
|
457
|
+
|
|
458
|
+
NSString *value = (NSString *)[command argumentAtIndex:2];
|
|
459
|
+
Glympse::GString valueString = [GETHelpers toGString:value];
|
|
460
|
+
Glympse::GPrimitive valuePrim = Glympse::CoreFactory::createPrimitive(valueString);
|
|
461
|
+
|
|
462
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
463
|
+
if ( NULL == task )
|
|
464
|
+
{
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
[EnRouteWrapper instance].manager->getTaskManager()->addOrUpdateMetadataItem(task, keyString, valuePrim);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
- (void) setTravelModeForTask:(CDVInvokedUrlCommand *)command
|
|
472
|
+
{
|
|
473
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
474
|
+
NSString *travelMode = (NSString *)[command argumentAtIndex:1];
|
|
475
|
+
Glympse::GString travelModeString = [GETHelpers toGString:travelMode];
|
|
476
|
+
|
|
477
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
478
|
+
if ( NULL == task )
|
|
479
|
+
{
|
|
480
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
481
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
[EnRouteWrapper instance].manager->getTaskManager()->setTravelModeForTask(task, travelModeString);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
- (void) sendMessageToTask:(CDVInvokedUrlCommand *)command
|
|
489
|
+
{
|
|
490
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
491
|
+
NSString *message = (NSString *)[command argumentAtIndex:1];
|
|
492
|
+
Glympse::GString messageString = [GETHelpers toGString:message];
|
|
493
|
+
Glympse::int64 predefinedMessageId = [[command argumentAtIndex:2] longLongValue];
|
|
494
|
+
|
|
495
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
496
|
+
if ( NULL == task )
|
|
497
|
+
{
|
|
498
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
499
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
bool result = [EnRouteWrapper instance].manager->getTaskManager()->sendMessage(task, messageString, predefinedMessageId);
|
|
504
|
+
if ( !result )
|
|
505
|
+
{
|
|
506
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
507
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
512
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
- (void) markTaskMessagesAsRead:(CDVInvokedUrlCommand *)command
|
|
516
|
+
{
|
|
517
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
518
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
519
|
+
if ( NULL == task )
|
|
520
|
+
{
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
Glympse::GString chatRoomId = task->getChatRoomId();
|
|
525
|
+
if ( NULL == chatRoomId )
|
|
526
|
+
{
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
Glympse::GChatManager chatManager = [EnRouteWrapper instance].manager->getGlympse()->getChatManager();
|
|
531
|
+
chatManager->setRoomAsRead(chatRoomId);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Deprecated
|
|
535
|
+
- (void) confirmMessageRead:(CDVInvokedUrlCommand *)command
|
|
536
|
+
{
|
|
537
|
+
Glympse::int64 taskId = [[command argumentAtIndex:0] longLongValue];
|
|
538
|
+
NSString *messageId = (NSString *)[command argumentAtIndex:1];
|
|
539
|
+
Glympse::GString messageIdString = [GETHelpers toGString:messageId];
|
|
540
|
+
|
|
541
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById(taskId);
|
|
542
|
+
if ( NULL == task )
|
|
543
|
+
{
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
Glympse::GCardMessages cardMessages = [EnRouteWrapper instance].manager->getTaskManager()->getCardMessagesForTask(task);
|
|
548
|
+
if ( NULL == cardMessages )
|
|
549
|
+
{
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
cardMessages->confirmRead(messageIdString);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
- (void) syncSessionsState:(CDVInvokedUrlCommand *)command
|
|
557
|
+
{
|
|
558
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
559
|
+
|
|
560
|
+
if ( [EnRouteWrapper instance].manager->isStarted() )
|
|
561
|
+
{
|
|
562
|
+
Glympse::EnRoute::GSessionManager sessionManager = [EnRouteWrapper instance].manager->getSessionManager();
|
|
563
|
+
if ( NULL != sessionManager )
|
|
564
|
+
{
|
|
565
|
+
Glympse::GArray<Glympse::EnRoute::GSession>::ptr sessions = sessionManager->getSessions();
|
|
566
|
+
if ( NULL != sessions )
|
|
567
|
+
{
|
|
568
|
+
Glympse::GPrimitive sessionsPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
569
|
+
|
|
570
|
+
for ( Glympse::EnRoute::GSession session : sessions )
|
|
571
|
+
{
|
|
572
|
+
Glympse::GPrimitive sessionPrimitive = [self commonObjToPrimitive:session];
|
|
573
|
+
|
|
574
|
+
sessionsPrimitive->put(sessionPrimitive);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
result->put([GETHelpers toGString:@"sessions"], sessionsPrimitive);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
583
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
584
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
- (void) syncSessionsStateLight:(CDVInvokedUrlCommand *)command
|
|
588
|
+
{
|
|
589
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
590
|
+
|
|
591
|
+
if ( [EnRouteWrapper instance].manager->isStarted() )
|
|
592
|
+
{
|
|
593
|
+
Glympse::EnRoute::GSessionManager sessionManager = [EnRouteWrapper instance].manager->getSessionManager();
|
|
594
|
+
if ( NULL != sessionManager )
|
|
595
|
+
{
|
|
596
|
+
Glympse::GArray<Glympse::EnRoute::GSession>::ptr sessions = sessionManager->getSessions();
|
|
597
|
+
if ( NULL != sessions )
|
|
598
|
+
{
|
|
599
|
+
Glympse::GPrimitive sessionsPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
600
|
+
|
|
601
|
+
for ( Glympse::EnRoute::GSession session : sessions )
|
|
602
|
+
{
|
|
603
|
+
Glympse::EnRoute::GOperation operation = session->getOperation();
|
|
604
|
+
|
|
605
|
+
if ( NULL != operation )
|
|
606
|
+
{
|
|
607
|
+
Glympse::GPrimitive sessionData = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
608
|
+
|
|
609
|
+
Glympse::GTicket ticket = operation->getTicket();
|
|
610
|
+
if ( NULL != ticket )
|
|
611
|
+
{
|
|
612
|
+
sessionData->put([GETHelpers toGString:@"ticket"], [self commonObjToPrimitive:operation->getTicket()]);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
sessionData->put([GETHelpers toGString:@"ticketVisible"], operation->isTicketVisible());
|
|
616
|
+
|
|
617
|
+
NSString *idString = [NSString stringWithFormat:@"%lld", session->getId()];
|
|
618
|
+
|
|
619
|
+
sessionsPrimitive->put([GETHelpers toGString:idString], sessionData);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
result->put([GETHelpers toGString:@"sessions_data"], sessionsPrimitive);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
629
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
630
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
- (void) refreshSessions:(CDVInvokedUrlCommand *)command
|
|
634
|
+
{
|
|
635
|
+
// TODO: Should we be refreshing just the session manager, or should we refresh EnRouteManager and let it decide to refresh tasks or sessions?
|
|
636
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_REFRESH_SESSIONS];
|
|
637
|
+
|
|
638
|
+
[EnRouteWrapper instance].manager->getSessionManager()->refresh();
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
- (void) updateSessionTasks:(CDVInvokedUrlCommand *)command
|
|
642
|
+
{
|
|
643
|
+
Glympse::int64 sessionId = [[command argumentAtIndex:0] longLongValue];
|
|
644
|
+
NSArray *taskIds = [command argumentAtIndex:1 withDefault:NULL];
|
|
645
|
+
if ( NULL == taskIds )
|
|
646
|
+
{
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
Glympse::EnRoute::GSession session = [EnRouteWrapper instance].manager->getSessionManager()->findSessionById(sessionId);
|
|
651
|
+
if ( NULL == session )
|
|
652
|
+
{
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
Glympse::GVector<Glympse::GCommonObj>::ptr tasks = Glympse::CoreFactory::createVector();
|
|
657
|
+
for ( id taskIdObj in taskIds )
|
|
658
|
+
{
|
|
659
|
+
NSNumber *taskIdNumber = (NSNumber*)taskIdObj;
|
|
660
|
+
Glympse::EnRoute::GTask task = [EnRouteWrapper instance].manager->getTaskManager()->findTaskById([taskIdNumber longLongValue]);
|
|
661
|
+
tasks->addElement(task);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
[EnRouteWrapper instance].manager->getSessionManager()->updateSessionTasks(session, tasks);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
- (void) startEtaPlannerQuery:(CDVInvokedUrlCommand *)command
|
|
668
|
+
{
|
|
669
|
+
NSDictionary *initial = [command argumentAtIndex:0 withDefault:NULL];
|
|
670
|
+
NSArray *places = [command argumentAtIndex:1 withDefault:NULL];
|
|
671
|
+
Glympse::int64 stopoverTime = [[command argumentAtIndex:2] longLongValue];
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
Glympse::EnRoute::GEtaPlanner etaPlanner = [EnRouteWrapper instance].manager->getEtaPlanner();
|
|
675
|
+
[GETHelpers subscribe:self onManager:etaPlanner];
|
|
676
|
+
|
|
677
|
+
double lat = [[initial objectForKey:@"latitude"] doubleValue];
|
|
678
|
+
double lng = [[initial objectForKey:@"longitude"] doubleValue];
|
|
679
|
+
Glympse::GLatLng start = Glympse::CoreFactory::createLocation(lat, lng);
|
|
680
|
+
|
|
681
|
+
Glympse::GVector<Glympse::GCommonObj>::ptr stops = Glympse::CoreFactory::createVector();
|
|
682
|
+
for ( id placeObj in places )
|
|
683
|
+
{
|
|
684
|
+
NSDictionary *placeDict = (NSDictionary*)placeObj;
|
|
685
|
+
lat = [[placeDict objectForKey:@"latitude"] doubleValue];
|
|
686
|
+
lng = [[placeDict objectForKey:@"longitude"] doubleValue];
|
|
687
|
+
Glympse::GLatLng place = Glympse::CoreFactory::createLocation(lat, lng);
|
|
688
|
+
stops->addElement(place);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
etaPlanner->query(start, stops, stopoverTime);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
- (void) abortEtaPlannerQuery:(CDVInvokedUrlCommand *)command
|
|
695
|
+
{
|
|
696
|
+
|
|
697
|
+
Glympse::EnRoute::GEtaPlanner etaPlanner = [EnRouteWrapper instance].manager->getEtaPlanner();
|
|
698
|
+
[GETHelpers unsubscribe:self onManager:etaPlanner];
|
|
699
|
+
|
|
700
|
+
etaPlanner->abort();
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
- (void) overrideLoggingLevels:(CDVInvokedUrlCommand *)command
|
|
704
|
+
{
|
|
705
|
+
Glympse::int32 fileLogLevel = [[command argumentAtIndex:0] integerValue];
|
|
706
|
+
Glympse::int32 debugLogLevel = [[command argumentAtIndex:1] integerValue];
|
|
707
|
+
|
|
708
|
+
[EnRouteWrapper instance].manager->overrideLoggingLevels(fileLogLevel, debugLogLevel);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
- (void) setRemoteLoggingEnabled:(CDVInvokedUrlCommand *)command
|
|
712
|
+
{
|
|
713
|
+
BOOL enabled = [[command argumentAtIndex:0] boolValue];
|
|
714
|
+
[EnRouteWrapper instance].manager->setRemoteLoggingEnabled(enabled);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
- (void) setFetchCompletedTasks:(CDVInvokedUrlCommand *)command
|
|
718
|
+
{
|
|
719
|
+
BOOL enabled = [[command argumentAtIndex:0] boolValue];
|
|
720
|
+
[EnRouteWrapper instance].manager->getTaskManager()->setFetchCompletedTasks(enabled);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
- (void) refreshPickups:(CDVInvokedUrlCommand *)command
|
|
724
|
+
{
|
|
725
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_REFRESH_PICKUPS];
|
|
726
|
+
|
|
727
|
+
[EnRouteWrapper instance].manager->getPickupManager()->refresh();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
- (void) setPickupPhase:(CDVInvokedUrlCommand *)command
|
|
731
|
+
{
|
|
732
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
733
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
734
|
+
NSString *phaseString = (NSString *)[command argumentAtIndex:1];
|
|
735
|
+
|
|
736
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
737
|
+
if ( NULL == pickup )
|
|
738
|
+
{
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
[EnRouteWrapper instance].manager->getPickupManager()->setPickupPhase(pickup, [GETHelpers toGString:phaseString]);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
- (void) completePickup:(CDVInvokedUrlCommand *)command
|
|
746
|
+
{
|
|
747
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
748
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
749
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
750
|
+
if ( NULL == pickup )
|
|
751
|
+
{
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
[EnRouteWrapper instance].manager->getPickupManager()->completePickup(pickup);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
- (void) claimPickup:(CDVInvokedUrlCommand *)command
|
|
759
|
+
{
|
|
760
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
761
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
762
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
763
|
+
if ( NULL == pickup )
|
|
764
|
+
{
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
[EnRouteWrapper instance].manager->getPickupManager()->claimPickup(pickup);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
- (void) unclaimPickup:(CDVInvokedUrlCommand *)command
|
|
772
|
+
{
|
|
773
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
774
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
775
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
776
|
+
if ( NULL == pickup )
|
|
777
|
+
{
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
[EnRouteWrapper instance].manager->getPickupManager()->unclaimPickup(pickup);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
- (void) sendMessageToPickup:(CDVInvokedUrlCommand *)command
|
|
785
|
+
{
|
|
786
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
787
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
788
|
+
NSString *message = (NSString *)[command argumentAtIndex:1];
|
|
789
|
+
Glympse::GString messageString = [GETHelpers toGString:message];
|
|
790
|
+
Glympse::int64 predefinedMessageId = [[command argumentAtIndex:2] longLongValue];
|
|
791
|
+
|
|
792
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
793
|
+
if ( NULL == pickup )
|
|
794
|
+
{
|
|
795
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
796
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
bool result = [EnRouteWrapper instance].manager->getPickupManager()->sendMessage(pickup, messageString, predefinedMessageId);
|
|
801
|
+
if ( !result )
|
|
802
|
+
{
|
|
803
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
804
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Next: We might need to do something like task messaging where we generate a unique id and save the callback for later
|
|
809
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
810
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
- (void) markMessagesAsRead:(CDVInvokedUrlCommand *)command
|
|
814
|
+
{
|
|
815
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
816
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
817
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
818
|
+
if ( NULL == pickup )
|
|
819
|
+
{
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
Glympse::GString chatRoomId = pickup->getChatRoomId();
|
|
824
|
+
if ( NULL == chatRoomId )
|
|
825
|
+
{
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
Glympse::GChatManager chatManager = [EnRouteWrapper instance].manager->getGlympse()->getChatManager();
|
|
830
|
+
chatManager->setRoomAsRead(chatRoomId);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
- (void) syncPickupsState:(CDVInvokedUrlCommand *)command
|
|
834
|
+
{
|
|
835
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
836
|
+
|
|
837
|
+
if ( [EnRouteWrapper instance].manager->isStarted() )
|
|
838
|
+
{
|
|
839
|
+
Glympse::GArray<Glympse::EnRoute::GPickup>::ptr pickups = [EnRouteWrapper instance].manager->getPickupManager()->getPickups();
|
|
840
|
+
if ( NULL != pickups )
|
|
841
|
+
{
|
|
842
|
+
Glympse::GPrimitive pickupsPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
843
|
+
|
|
844
|
+
Glympse::GPrimitive config = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
845
|
+
config->put([GETHelpers toGString:@"with_items"], true);
|
|
846
|
+
|
|
847
|
+
Glympse::GChatManager chatManager = [EnRouteWrapper instance].manager->getGlympse()->getChatManager();
|
|
848
|
+
|
|
849
|
+
for ( Glympse::EnRoute::GPickup pickup : pickups )
|
|
850
|
+
{
|
|
851
|
+
Glympse::GPrimitive pickupPrimitive = [self commonObjToPrimitive:pickup withConfig:config];
|
|
852
|
+
|
|
853
|
+
Glympse::GString chatRoomId = pickup->getChatRoomId();
|
|
854
|
+
if ( NULL != chatRoomId )
|
|
855
|
+
{
|
|
856
|
+
Glympse::GChatRoom chatRoom = chatManager->getChatRoom(chatRoomId);
|
|
857
|
+
if ( NULL != chatRoom )
|
|
858
|
+
{
|
|
859
|
+
Glympse::GArray<Glympse::GChatMessage>::ptr messages = chatRoom->getChatMessages();
|
|
860
|
+
|
|
861
|
+
Glympse::GPrimitive chatMessagesPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
862
|
+
for ( Glympse::GChatMessage chatMessage : messages )
|
|
863
|
+
{
|
|
864
|
+
Glympse::GPrimitive chatMessagePrimitive = [self commonObjToPrimitive:chatMessage];
|
|
865
|
+
chatMessagesPrimitive->put(chatMessagePrimitive);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
pickupPrimitive->put([GETHelpers toGString:@"chatMessages"], chatMessagesPrimitive);
|
|
869
|
+
pickupPrimitive->put([GETHelpers toGString:@"lastReadSequenceNumber"], chatRoom->getLastReadSequenceNumber());
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
pickupsPrimitive->put(pickupPrimitive);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
result->put([GETHelpers toGString:@"pickups"], pickupsPrimitive);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
881
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
882
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
- (void) syncPickupsStateLight:(CDVInvokedUrlCommand *)command
|
|
886
|
+
{
|
|
887
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
888
|
+
|
|
889
|
+
if ( [EnRouteWrapper instance].manager->isStarted() )
|
|
890
|
+
{
|
|
891
|
+
Glympse::GArray<Glympse::EnRoute::GPickup>::ptr pickups = [EnRouteWrapper instance].manager->getPickupManager()->getPickups();
|
|
892
|
+
if ( NULL != pickups )
|
|
893
|
+
{
|
|
894
|
+
Glympse::GPrimitive pickupsPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
895
|
+
|
|
896
|
+
Glympse::GPrimitive config = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
897
|
+
config->put([GETHelpers toGString:@"truncate_locations"], true);
|
|
898
|
+
config->put([GETHelpers toGString:@"ticket_light"], true);
|
|
899
|
+
|
|
900
|
+
for ( Glympse::EnRoute::GPickup pickup : pickups )
|
|
901
|
+
{
|
|
902
|
+
Glympse::GPrimitive pickupData = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
903
|
+
pickupData->put([GETHelpers toGString:@"phase"], pickup->getPhase());
|
|
904
|
+
pickupData->put([GETHelpers toGString:@"agentId"], pickup->getAgentId());
|
|
905
|
+
|
|
906
|
+
Glympse::GTicket ticket = pickup->getCustomerTicket();
|
|
907
|
+
if ( NULL != ticket )
|
|
908
|
+
{
|
|
909
|
+
pickupData->put([GETHelpers toGString:@"customerTicket"], [self commonObjToPrimitive:ticket withConfig:config]);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
NSString *idString = [NSString stringWithFormat:@"%s", pickup->getId()->getBytes()];
|
|
913
|
+
|
|
914
|
+
pickupsPrimitive->put([GETHelpers toGString:idString], pickupData);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
result->put([GETHelpers toGString:@"pickups_data"], pickupsPrimitive);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
922
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
923
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
- (void) syncPickup:(CDVInvokedUrlCommand *)command
|
|
927
|
+
{
|
|
928
|
+
NSString *pickupId = (NSString *)[command argumentAtIndex:0];
|
|
929
|
+
Glympse::GString pickupIdString = [GETHelpers toGString:pickupId];
|
|
930
|
+
|
|
931
|
+
Glympse::EnRoute::GPickup pickup = [EnRouteWrapper instance].manager->getPickupManager()->findPickupById(pickupIdString);
|
|
932
|
+
if ( NULL == pickup )
|
|
933
|
+
{
|
|
934
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
935
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
940
|
+
Glympse::GPrimitive config = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
941
|
+
config->put([GETHelpers toGString:@"with_items"], true);
|
|
942
|
+
|
|
943
|
+
Glympse::GPrimitive pickupPrimitive = [self commonObjToPrimitive:pickup withConfig:config];
|
|
944
|
+
|
|
945
|
+
// Add message data
|
|
946
|
+
Glympse::GString chatRoomId = pickup->getChatRoomId();
|
|
947
|
+
if ( NULL != chatRoomId )
|
|
948
|
+
{
|
|
949
|
+
Glympse::GChatManager chatManager = [EnRouteWrapper instance].manager->getGlympse()->getChatManager();
|
|
950
|
+
Glympse::GChatRoom chatRoom = chatManager->getChatRoom(chatRoomId);
|
|
951
|
+
if ( NULL != chatRoom )
|
|
952
|
+
{
|
|
953
|
+
Glympse::GArray<Glympse::GChatMessage>::ptr messages = chatRoom->getChatMessages();
|
|
954
|
+
|
|
955
|
+
Glympse::GPrimitive chatMessagesPrimitive = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
956
|
+
for ( Glympse::GChatMessage chatMessage : messages )
|
|
957
|
+
{
|
|
958
|
+
Glympse::GPrimitive chatMessagePrimitive = [self commonObjToPrimitive:chatMessage];
|
|
959
|
+
chatMessagesPrimitive->put(chatMessagePrimitive);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
pickupPrimitive->put([GETHelpers toGString:@"chatMessages"], chatMessagesPrimitive);
|
|
963
|
+
pickupPrimitive->put([GETHelpers toGString:@"lastReadSequenceNumber"], chatRoom->getLastReadSequenceNumber());
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
result->put([GETHelpers toGString:@"pickup_data"], pickupPrimitive);
|
|
968
|
+
|
|
969
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
970
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
971
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
- (void) startShift:(CDVInvokedUrlCommand *)command
|
|
975
|
+
{
|
|
976
|
+
bool result = [EnRouteWrapper instance].manager->toggleOnShift(true);
|
|
977
|
+
|
|
978
|
+
if ( !result )
|
|
979
|
+
{
|
|
980
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
981
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// Save callback for when server responds
|
|
986
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_START_SHIFT];
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
- (void) completeShift:(CDVInvokedUrlCommand *)command
|
|
990
|
+
{
|
|
991
|
+
bool result = [EnRouteWrapper instance].manager->toggleOnShift(false);
|
|
992
|
+
|
|
993
|
+
if ( !result )
|
|
994
|
+
{
|
|
995
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
996
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// Save callback for when server responds
|
|
1001
|
+
[_cordovaCommands setObject:command forKey:COMMAND_KEY_COMPLETE_SHIFT];
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
- (void) checkGoogleLocationAccuracy:(CDVInvokedUrlCommand *)command
|
|
1005
|
+
{
|
|
1006
|
+
// Not available on iOS
|
|
1007
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
1008
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
- (void) checkIsNetworkConstrained:(CDVInvokedUrlCommand *)command
|
|
1012
|
+
{
|
|
1013
|
+
bool isConstrained = [EnRouteWrapper instance].isNetworkConstrained;
|
|
1014
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:isConstrained];
|
|
1015
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
- (void) checkCellularDataAvailable:(CDVInvokedUrlCommand *)command
|
|
1019
|
+
{
|
|
1020
|
+
bool isCellularDataAvailable = [EnRouteWrapper instance].isCellularDataAvailable;
|
|
1021
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:isCellularDataAvailable];
|
|
1022
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
- (void)eventsOccurred:(const Glympse::GSource&)source listener:(Glympse::int32)listener events:(Glympse::int32)events param1:(const Glympse::GCommonObj&)param1 param2:(const Glympse::GCommonObj&)param2
|
|
1026
|
+
{
|
|
1027
|
+
Glympse::GPrimitive result = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_OBJECT);
|
|
1028
|
+
result->put([GETHelpers toGString:@"listener"], (Glympse::int64)listener);
|
|
1029
|
+
result->put([GETHelpers toGString:@"events"], (Glympse::int64)events);
|
|
1030
|
+
|
|
1031
|
+
if ( NULL != param1 )
|
|
1032
|
+
{
|
|
1033
|
+
Glympse::GPrimitive primitive1 = [self commonObjToPrimitive:param1];
|
|
1034
|
+
if ( NULL != primitive1 )
|
|
1035
|
+
{
|
|
1036
|
+
result->put([GETHelpers toGString:@"param1"], primitive1);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
if ( NULL != param2 )
|
|
1041
|
+
{
|
|
1042
|
+
Glympse::GPrimitive primitive2 = [self commonObjToPrimitive:param2];
|
|
1043
|
+
if ( NULL != primitive2 )
|
|
1044
|
+
{
|
|
1045
|
+
result->put([GETHelpers toGString:@"param2"], primitive2);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
NSString *jsonString = [NSString stringWithUTF8String:Glympse::CoreTools::primitiveToString(result)->getBytes()];
|
|
1050
|
+
|
|
1051
|
+
for ( NSString *callbackId : _listenerCallbacks )
|
|
1052
|
+
{
|
|
1053
|
+
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString];
|
|
1054
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
|
1055
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if ( Glympse::EnRoute::EE::LISTENER_ENROUTE_MANAGER == listener )
|
|
1059
|
+
{
|
|
1060
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_LOGIN_COMPLETED ) )
|
|
1061
|
+
{
|
|
1062
|
+
bool success = ( param1 == NULL );
|
|
1063
|
+
[self loginCompleted:success error:(Glympse::GString)param1];
|
|
1064
|
+
}
|
|
1065
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_SYNCED ) )
|
|
1066
|
+
{
|
|
1067
|
+
[self synced];
|
|
1068
|
+
}
|
|
1069
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_STOPPED ) )
|
|
1070
|
+
{
|
|
1071
|
+
[self stopped];
|
|
1072
|
+
}
|
|
1073
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_SHIFT_STARTED ) )
|
|
1074
|
+
{
|
|
1075
|
+
[self shiftToggleCompletedWithOnShift:true success:true];
|
|
1076
|
+
}
|
|
1077
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_SHIFT_COMPLETED ) )
|
|
1078
|
+
{
|
|
1079
|
+
[self shiftToggleCompletedWithOnShift:false success:true];
|
|
1080
|
+
}
|
|
1081
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_SHIFT_START_FAILED ) )
|
|
1082
|
+
{
|
|
1083
|
+
[self shiftToggleCompletedWithOnShift:true success:false];
|
|
1084
|
+
}
|
|
1085
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::ENROUTE_MANAGER_SHIFT_COMPLETE_FAILED ) )
|
|
1086
|
+
{
|
|
1087
|
+
[self shiftToggleCompletedWithOnShift:false success:false];
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
else if ( Glympse::EnRoute::EE::LISTENER_TASKS == listener )
|
|
1091
|
+
{
|
|
1092
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::TASKS_TASK_LIST_CHANGED ) )
|
|
1093
|
+
{
|
|
1094
|
+
bool success = ( param1 == NULL );
|
|
1095
|
+
[self tasksChanged:success];
|
|
1096
|
+
}
|
|
1097
|
+
if ( 0 != ( events & Glympse::EnRoute::EE::TASKS_TASK_CARD_MESSAGE_STATUS ) )
|
|
1098
|
+
{
|
|
1099
|
+
Glympse::GString eventId = (Glympse::GString) param1;
|
|
1100
|
+
Glympse::GString uniqueId = (Glympse::GString) param2;
|
|
1101
|
+
if ( NULL != uniqueId )
|
|
1102
|
+
{
|
|
1103
|
+
CDVInvokedUrlCommand* command = [_cordovaCommands objectForKey:[NSString stringWithGString:uniqueId]];
|
|
1104
|
+
if ( NULL != command )
|
|
1105
|
+
{
|
|
1106
|
+
CDVPluginResult* pluginResult = nil;
|
|
1107
|
+
if ( NULL != eventId )
|
|
1108
|
+
{
|
|
1109
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[NSString stringWithGString:eventId]];
|
|
1110
|
+
}
|
|
1111
|
+
else
|
|
1112
|
+
{
|
|
1113
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
[pluginResult setKeepCallback:[NSNumber numberWithBool:NO]];
|
|
1117
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1118
|
+
|
|
1119
|
+
[_cordovaCommands removeObjectForKey:[NSString stringWithGString:uniqueId]];
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
else if ( Glympse::EnRoute::EE::LISTENER_SESSIONS == listener )
|
|
1125
|
+
{
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
-(Glympse::GPrimitive)commonObjToPrimitive:(const Glympse::GCommonObj&)obj
|
|
1130
|
+
{
|
|
1131
|
+
return [self commonObjToPrimitive:obj withConfig:NULL];
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
-(Glympse::GPrimitive)commonObjToPrimitive:(const Glympse::GCommonObj&)obj withConfig:(const Glympse::GPrimitive&)config
|
|
1135
|
+
{
|
|
1136
|
+
Glympse::GVector<Glympse::GLong>::ptr longVector = (Glympse::GVector<Glympse::GLong>::ptr)obj;
|
|
1137
|
+
if ( NULL != longVector)
|
|
1138
|
+
{
|
|
1139
|
+
Glympse::GPrimitive longArray = Glympse::CoreFactory::createPrimitive(Glympse::CC::PRIMITIVE_TYPE_ARRAY);
|
|
1140
|
+
|
|
1141
|
+
for ( int i = 0; i < longVector->length(); i++ )
|
|
1142
|
+
{
|
|
1143
|
+
Glympse::GLong longObject = longVector->elementAt(i);
|
|
1144
|
+
longArray->put(longObject->longValue());
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
return longArray;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
return Glympse::EnRoute::ObjectEncoder::valueToPrimitive(obj, config);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
- (void)subscribeToListeners
|
|
1154
|
+
{
|
|
1155
|
+
[GETHelpers subscribe:self onManager:[EnRouteWrapper instance].manager];
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
- (void)unsubscribeFromListeners
|
|
1159
|
+
{
|
|
1160
|
+
[GETHelpers unsubscribe:self onManager:[EnRouteWrapper instance].manager];
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
- (void)loginCompleted:(bool)success error:(const Glympse::GString&)error
|
|
1164
|
+
{
|
|
1165
|
+
CDVInvokedUrlCommand* command = [_cordovaCommands objectForKey:COMMAND_KEY_LOGIN];
|
|
1166
|
+
if ( NULL == command )
|
|
1167
|
+
{
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
CDVPluginResult* pluginResult = nil;
|
|
1172
|
+
if ( success )
|
|
1173
|
+
{
|
|
1174
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1175
|
+
}
|
|
1176
|
+
else
|
|
1177
|
+
{
|
|
1178
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[NSString stringWithGString:error]];
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
- (void)tasksChanged:(bool)success
|
|
1185
|
+
{
|
|
1186
|
+
CDVInvokedUrlCommand* command = [_cordovaCommands objectForKey:COMMAND_KEY_REFRESH];
|
|
1187
|
+
if ( NULL == command )
|
|
1188
|
+
{
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
CDVPluginResult* pluginResult = nil;
|
|
1193
|
+
if ( success )
|
|
1194
|
+
{
|
|
1195
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1196
|
+
}
|
|
1197
|
+
else
|
|
1198
|
+
{
|
|
1199
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
- (void)started
|
|
1206
|
+
{
|
|
1207
|
+
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
- (void)stopped
|
|
1211
|
+
{
|
|
1212
|
+
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
- (void)synced
|
|
1216
|
+
{
|
|
1217
|
+
Glympse::EnRoute::GTaskManager taskManager = [EnRouteWrapper instance].manager->getTaskManager();
|
|
1218
|
+
if ( NULL != taskManager )
|
|
1219
|
+
{
|
|
1220
|
+
[GETHelpers subscribe:self onManager:taskManager];
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
Glympse::EnRoute::GSessionManager sessionManager = [EnRouteWrapper instance].manager->getSessionManager();
|
|
1224
|
+
if ( NULL != sessionManager )
|
|
1225
|
+
{
|
|
1226
|
+
[GETHelpers subscribe:self onManager:sessionManager];
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
Glympse::EnRoute::GPickupManager pickupManager = [EnRouteWrapper instance].manager->getPickupManager();
|
|
1230
|
+
if ( NULL != pickupManager )
|
|
1231
|
+
{
|
|
1232
|
+
[GETHelpers subscribe:self onManager:pickupManager];
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
- (void)shiftToggleCompletedWithOnShift:(bool)onShift success:(bool)success
|
|
1237
|
+
{
|
|
1238
|
+
NSString* key = onShift ? COMMAND_KEY_START_SHIFT : COMMAND_KEY_COMPLETE_SHIFT;
|
|
1239
|
+
CDVInvokedUrlCommand* command = [_cordovaCommands objectForKey:key];
|
|
1240
|
+
if ( NULL == command )
|
|
1241
|
+
{
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
[_cordovaCommands removeObjectForKey:key];
|
|
1245
|
+
|
|
1246
|
+
CDVPluginResult* pluginResult = nil;
|
|
1247
|
+
if ( success )
|
|
1248
|
+
{
|
|
1249
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1250
|
+
}
|
|
1251
|
+
else
|
|
1252
|
+
{
|
|
1253
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"failed"];
|
|
1254
|
+
}
|
|
1255
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
@end
|