This repository was archived by the owner on Sep 13, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathparse_impl.c
More file actions
76 lines (63 loc) · 3.17 KB
/
parse_impl.c
File metadata and controls
76 lines (63 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) 2015, Parse, LLC. All rights reserved.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
* copy, modify, and distribute this software in source code or binary form for use
* in connection with the web services and APIs provided by Parse.
*
* As with any software that integrates with the Parse platform, your use of
* this software is subject to the Parse Terms of Service
* [https://www.parse.com/about/terms]. This copyright notice shall be
* included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <parse_impl.h>
ParseClient parseInitialize(const char *applicationId, const char *clientKey) {
#ifdef CLIENT_DEBUG
DEBUG_PRINT("[Parse] Initializing new client.\r\n");
#endif /* CLIENT_DEBUG */
// Do any one-time intialization of the new client
ParseClientInternal *parseClient = (ParseClientInternal *)malloc(sizeof(ParseClientInternal));
if (parseClient != NULL) {
memset(parseClient->applicationId, 0, sizeof(parseClient->applicationId));
memset(parseClient->clientKey, 0, sizeof(parseClient->clientKey));
memset(parseClient->installationObjectId, 0, sizeof(parseClient->installationObjectId));
memset(parseClient->installationId, 0, sizeof(parseClient->installationId));
memset(parseClient->sessionToken, 0, sizeof(parseClient->sessionToken));
// Copy the application id and the client key to the client
strncpy(parseClient->applicationId, applicationId, APPLICATION_ID_MAX_LEN);
strncpy(parseClient->clientKey, clientKey, CLIENT_KEY_MAX_LEN);
#ifdef CLIENT_DEBUG
DEBUG_PRINT("[Parse] Application id: %s.\r\n", parseClient->applicationId);
DEBUG_PRINT("[Parse] Client key: %s.\r\n", parseClient->clientKey);
#endif /* CLIENT_DEBUG */
// initialize the push service data
parseClient->socketHandle = -1;
parseClient->callback = NULL;
parseClient->nFailedPing = 0;
memset(parseClient->lastPushTime, 0, sizeof(parseClient->lastPushTime));
memset(parseClient->osVersion, 0, sizeof(parseClient->osVersion));
memset(parseClient->deviceClientVersion, 0, sizeof(parseClient->deviceClientVersion));
fetchDeviceOSVersion(parseClient->osVersion, sizeof(parseClient->osVersion)-1);
strncpy(parseClient->deviceClientVersion, CLIENT_VERSION, CLIENT_VERSION_MAX_LEN);
loadClientState(parseClient);
#ifdef CLIENT_DEBUG
} else {
DEBUG_PRINT("[Parse] Failed to allocate client handle.\r\n");
#endif /* CLIENT_DEBUG */
}
return (ParseClient)parseClient;
}
ParseClientInternal *getInternalClient(ParseClient client) {
return (ParseClientInternal *)(client);
}