1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3
/* The contents of this file are subject to the Mozilla Public License
4
* Version 1.0 (the "License"); you may not use this file except in
5
* compliance with the License. You may obtain a copy of the License at
6
* http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS IS"
9
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10
* License for the specific language governing rights and limitations
13
* The Original Code is Mobile Application Link.
15
* The Initial Developer of the Original Code is AvantGo, Inc.
16
* Portions created by AvantGo, Inc. are Copyright (C) 1997-1999
17
* AvantGo, Inc. All Rights Reserved.
22
#include <MAL31ServerConfig.h>
23
#include <AGBufferReader.h>
24
#include <AGBufferWriter.h>
29
#include <MAL31DBConfig.h>
31
/* Version 0 - original creation */
32
#define RECORD_VERSION_0 (0)
34
/* Version 1 - added allowSecureConnection */
35
#define RECORD_VERSION_1 (1)
37
/* This is the version number that is written to new records */
38
#define CURRENT_RECORD_VERSION (RECORD_VERSION_1)
40
/*--------------------------------------------------------------------------*/
42
MAL31ServerConfigReadData(AGServerConfig *config, AGReader *r)
48
recordVersion = AGReadInt16(r);
49
config->uid = AGReadInt32(r);
50
config->status = (AGRecordStatus)AGReadInt16(r);
51
config->serverName = AGReadCString(r);
52
config->serverPort = AGReadInt16(r);
54
config->userName = AGReadCString(r);
55
config->cleartextPassword = AGReadCString(r);
57
AGReadBytes(r, config->password, 16);
61
AGReadBytes(r, config->nonce, 16);
64
config->disabled = TRUE;
66
config->disabled = FALSE;
68
config->friendlyName = AGReadCString(r);
69
config->userUrl = AGReadCString(r);
70
config->description = AGReadCString(r);
71
config->serverUri = AGReadCString(r);
73
config->sequenceCookieLength = AGReadInt32(r);
74
if (config->sequenceCookieLength > 0) {
75
config->sequenceCookie =
76
(uint8*)malloc(config->sequenceCookieLength);
77
AGReadBytes(r, config->sequenceCookie, config->sequenceCookieLength);
80
count = AGReadInt32(r);
81
config->dbconfigs = AGArrayNew(AGUnownedPointerElements, count);
82
for (i = 0; i < count; i++) {
83
dbconfig = AGDBConfigNew(NULL, AG_SENDALL_CFG, FALSE, 0, NULL, NULL);
84
MAL31DBConfigReadData(dbconfig, r);
85
AGArrayAppend(config->dbconfigs, dbconfig);
88
config->sendDeviceInfo = TRUE;
90
config->sendDeviceInfo = FALSE;
92
config->hashPassword = AGReadBoolean(r);
93
/* pending(miket): leave in until cleartext password support is in. */
94
config->hashPassword = TRUE;
95
config->connectTimeout = AGReadCompactInt(r);
96
config->writeTimeout = AGReadCompactInt(r);
97
config->readTimeout = AGReadCompactInt(r);
99
config->connectSecurely = AGReadBoolean(r);
101
if (recordVersion >= RECORD_VERSION_1) {
102
/* Record version 1: added allowSecureConnection. */
103
config->allowSecureConnection = AGReadBoolean(r);
105
config->allowSecureConnection = FALSE;
109
/*---------------------------------------------------------------------------*/
111
digestIsNull(uint8 a[16])
119
/*---------------------------------------------------------------------------*/
121
MAL31ServerConfigWriteData(AGServerConfig *config, AGWriter *w)
124
AGDBConfig *dbconfig;
126
AGWriteInt16(w, CURRENT_RECORD_VERSION);
127
AGWriteInt32(w, config->uid);
128
AGWriteInt16(w, (uint16)config->status);
129
AGWriteCString(w, config->serverName);
130
AGWriteInt16(w, config->serverPort);
132
AGWriteCString(w, config->userName);
133
AGWriteCString(w, config->cleartextPassword);
135
if (digestIsNull(config->password))
139
AGWriteBytes(w, config->password, 16);
142
if (digestIsNull(config->nonce))
146
AGWriteBytes(w, config->nonce, 16);
149
if (config->disabled)
154
AGWriteCString(w, config->friendlyName);
155
AGWriteCString(w, config->userUrl);
156
AGWriteCString(w, config->description);
157
AGWriteCString(w, config->serverUri);
159
AGWriteInt32(w, config->sequenceCookieLength);
160
if (config->sequenceCookieLength > 0) {
161
AGWriteBytes(w, config->sequenceCookie,
162
config->sequenceCookieLength);
165
count = AGArrayCount(config->dbconfigs);
166
AGWriteInt32(w, count);
167
for (i = 0; i < count; i++) {
168
dbconfig = (AGDBConfig*)AGArrayElementAt(config->dbconfigs, i);
169
MAL31DBConfigWriteData(dbconfig, w);
171
if (config->sendDeviceInfo)
176
AGWriteBoolean(w, config->hashPassword);
177
AGWriteCompactInt(w, config->connectTimeout);
178
AGWriteCompactInt(w, config->writeTimeout);
179
AGWriteCompactInt(w, config->readTimeout);
181
AGWriteBoolean(w, config->connectSecurely);
182
AGWriteBoolean(w, config->allowSecureConnection);