summaryrefslogtreecommitdiff
path: root/doc/enginio_overview.qdoc
blob: 8a26529e9d68ed03d94110b1b56aa2e89d6c7ad8 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of Enginio.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page enginio-index.html
\contentspage {enginio-index.html}{Contents}
\nextpage Enginio Installation Notes and Prerequisites

\title Enginio Manual

This manual shows how to use the Enginio library in a Qt application.
Both C++ and QML applications are covered. The manual is also used when
integrating Enginio into an existing Qt project.

Enginio is a \l {http://en.wikipedia.org/wiki/Backend_as_a_service}
{Backend-as-a-Service} solution for simplifying backend development
of connected and data-driven applications.

\section1 Getting Started

First read the installation notes and prerequisites, then follow one
of the short tutorials for using Enginio, either with QT Quick or with
C++.

\list
\li \l {Enginio Installation Notes and Prerequisites}
\li \l {Getting Started with Enginio using Qt Quick}
\li \l {Getting Started with Enginio using C++}
\endlist

\section1 Reference documentation and examples:
\list
\li \l {Enginio C++ Classes and Examples}
\li \l {Enginio QML Types and Examples}

Enginio documentation is also available at the
\l {https://developer.qtcloudservices.com} {Qt Cloud Services}
website \l{http://engin.io/documentation/} {here}.

\endlist

\section1 Enginio Overview

The Enginio APIs have a general pattern that is useful to understand.
This section gives a short overview of the API concepts used
throughout the library.

Enginio is a client-side library for communicating with the server
at \l {http://engin.io}. Multiple \e backends can exist in each
server account. When communicating with the server, the backend is
specified by a \b {backend id}. When multiple users load an Enginio
application, the all use the same \b {backend id}.

\section2 Objects

Enginio provides several types of objects. These include users, user
groups, files, custom objects, and more. All communications with the
backend use \l {http://json.org} {JSON}. When using the QML API, JSON
objects are simply written inline. When using the C++ API, the
\l QJsonObject and \l QJsonValue classes are used.

Each JSON object in Enginio has the reserved properties \c id,
\c objectType, \c createdAt, and \c updatedAt. For example,
a custom object with no user-defined properties will look like
this in JSON:

\code
{
    "id": "51cdbc08989e975ec300772a",
    "objectType": "objects.todos",
    "createdAt": "2013-06-28T16:38:32.369Z",
    "updatedAt": "2013-06-28T16:38:32.725Z"
}
\endcode

But custom object types are normally augmented with user-defined
properties that contain the application-specific data. A user-defined
property can also contain a JSON object. For a more detailed description of
Enginio objects, see the \l{http://engin.io/documentation/overview/objects}
{Enginio Object documentation}.

\section2 Operations

The basic operations on objects are shown in the table below.
For a complete list of operations see the
\l [CPP] {EnginioClient} {EnginioClient for C++} or the
\l [QML] {EnginioClient} {EnginioClient for QML}.

\table
\header
\li Operation
\li Description
\li C++
\li QML
\row
\li create
\li Insert a new object into the database
\li \l [CPP] {EnginioClient::create()}
\li \l [QML] {EnginioClient::create()}
\row
\li query
\li Query the database
\li \l [CPP] {EnginioClient::query()}
\li \l [QML] {EnginioClient::query()}
\row
\li update
\li Update an object in the database
\li \l [CPP] {EnginioClient::update()}
\li \l [QML] {EnginioClient::update()}
\row
\li remove
\li Remove an object from the database
\li \l [CPP] {EnginioClient::remove()}
\li \l [QML] {EnginioClient::remove()}
\endtable

\note User and access control list management are also performed using
these same functions.

\section2 File Management

For file management, these operations are slightly different in that
files are always attached to objects and can only be accessed through
their objects. The Qt library provides convenient functions to upload
and download files.

*/

/*!
\page enginio-getting-started.html
\nextpage Getting Started with Enginio using Qt Quick
\previouspage {enginio-index.html}{Enginio Manual}

\title Enginio Installation Notes and Prerequisites

\section1 Installation Notes

Enginio is packaged with Qt beginning with Qt 5.2. When starting the
Qt installation, ensure that the Enginio component in the \e {Qt Cloud
Services} category is selected.

Enginio requires OpenSSL to be installed, except for iOS, where the
native SSL framework is used instead.

\note For Qt 5.2.0, Enginio comes in the online installer only.

\section1 Prerequisites

A Qt Account is required to use the
\l{https://console.qtcloudservices.com} {Qt Cloud Services}.  A Qt
Account can be created at \l{Qt Account Sign-up}.

To run an Enginio Client application to use
\l{https://console.qtcloudservices.com} {Qt Cloud Services},
the \c{backend id} of an Engino Data Storage Instance is required.

Sign in to \l{https://console.qtcloudservices.com/login} {Qt Cloud
Services} using the Qt Account. Under \uicontrol {Enginio Data
Storage} (EDS), press the \uicontrol {Launch instance} button to create
a new cloud instance. Enter the name for the new instance and select
a data center. Then press \uicontrol {Create}.

A dialog of the new instance appears showing the \uicontrol {General}
tab. Here the instance \uicontrol {Name}, \uicontrol {ID}, and
\uicontrol {Address} are shown. Select the \uicontrol {Environment}
tab to show the \uicontrol {EDS_BACKEND_ID} and the
\uicontrol {EDS_INSTANCE ADDRESS}. These values can be cut and pasted
into the examples where required.

\note Some of the examples have built-in \uicontrol {EDS_BACKEND_ID}s.

Select the \uicontrol {Configure} tab and press the \uicontrol {Open}
button. This opens the dashboard for the new instance in a new browser
tab. The dashboard is used for instance management.

These instructions are also found in
\l{https://developer.qtcloudservices.com/qtc/getting-started}
{Getting Started With Qt Cloud Services}. Reading the documentation at
\l{https://developer.qtcloudservices.com/} {Qt Cloud Services Developers}
is also recommended.

*/

/*!
\page enginio-qml.html
\nextpage Getting Started with Enginio using C++
\previouspage Enginio Installation Notes and Prerequisites

\title Getting Started with Enginio using Qt Quick
\brief Introduction to using Enginio using Qt Quick

\section1 Setup a Qt Quick 2 application project

Create a new  \l [QtQuick] {Qt Quick} {Qt Quick 2} Application.

Qt Creator can be used to create a template.
\uicontrol {File ⇒ New File or Project ⇒ Applications ⇒ Qt Quick 2 Application}

\section1 Initialize Enginio Client

To use Enginio's QML API, the Enginio library must be imported.
\badcode
import Enginio 1.0
\endcode

Initialize the \l [QML] {EnginioClient} with the \b {backend id} value, which can be copied from the Dashboard.

Go to \uicontrol{Dashboard ⇒ The Backend home-view ⇒ See ’Keys box’ ⇒ Copy backend id value}.

\code
EnginioClient {
    id: enginio
    backendId: "YOUR_OWN_BACKEND_ID"
}
\endcode

\section1 Store the First Object

Now an \e object can be stored with Enginio. First, create an \e object in JSON format and fill it with data as needed.
Then call create on the client with the JSON object as a parameter.

\code
Component.onCompleted: {
    var city = {
        objectType: "objects.city",
        name: "Helsinki",
        population: 606000
    };
    enginio.create(city);
}
\endcode

\l{Checking stored objects in the Dashboard}{Check the Enginio dashboard} for the newly created object.
*/


/*!
\page enginio-cpp.html
\nextpage Checking stored objects in the Dashboard
\previouspage Getting Started with Enginio using Qt Quick

\title Getting Started with Enginio using C++
\brief Introduction to using Enginio using C++

\section1 Setup Qt Application Project

To link to Enginio in a qmake-based project, add the line shown below
to the \c .pro file.

\badcode
QT += enginio
\endcode

\section1 Initialize Enginio Client

To use the Enginio library, the required library headers must be included.
\code
 #include <Enginio/Enginio>
\endcode
Then an \l EnginioClient must be instantiated. The client requires
a \c{backend id}, which can be copied from the Dashboard. Go to the
\l{https://dashboard.engin.io/}{Enginio Dashboard} and select a backend.
Copy the \b {backend id} value.

\code
QByteArray backendId("YOUR_OWN_BACKEND_ID");
EnginioClient *client = new EnginioClient;
client->setBackendId(backendId);
\endcode
For testing purposes, it is easiest to hardcode the \b {backend id} directly into application code.
However, this might not be always the best choice, and sometimes it might be beneficial
to put the backend configuration in a separate configuration file.

\section1 Storing the First Object

Create an object in JSON format and fill in the data:
\code
    QJsonObject city;
    city.insert("objectType", QString("objects.city")); // an object type is required for all objects in Enginio
    city.insert("name", QString("Oslo")); // other properties can be chosen freely
    city.insert("population", 624000);
\endcode

Create the object in the Enginio database by calling \l {EnginioClient::create()}:
\code
    client->create(city);
    connect(client, SIGNAL(finished(EnginioReply*)), this, SLOT(uploadFinished(EnginioReply*)));
\endcode
Note that the \l {EnginioClient::create()} {create()} method performs the actual asynchronous network communication.
Wait for completion by connecting to the \l{EnginioClient::finished()}{finished} and \l{EnginioClient::error()}{error} signals.

\l{Checking stored objects in the Dashboard}{Check the Enginio dashboard} for the newly created object.
*/


/*!
\page enginio-dashboard.html
\title Checking Stored Objects in the Dashboard
\previouspage Getting Started with Enginio using C++

When objects have been stored in the database using either the C++ or
the QML code, go to the \l{https://dashboard.engin.io/}
{Enginio Dashboard} and check the status there.

\list
\li Select the Objects view from the top navigation bar.
\li Make sure that \gui objects.city is selected in the type drop-down.
\li The list should now show a row for the object which was just uploaded.
\endlist
\image object_browser_first_city_object.png

For more information on how to interact with Enginio, read the \l EnginioClient documentation.
To get convenient access to objects stored in Enginio, consider using \l EnginioModel.
*/

/*!
\page tutorials.html
\title Enginio Tutorials

\list
\li \l {Enginio Installation Notes and Prerequisites}
\li \l {Getting Started with Enginio using Qt Quick}
\li \l {Getting Started with Enginio using C++}
\endlist
*/