Skip to content

Commit

Permalink
Added: Updater class and a simple JSON parser
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 24, 2012
1 parent e6055a0 commit 70a8646
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doomsday/engine/engine.pro
Expand Up @@ -242,6 +242,7 @@ DENG_HEADERS += \
portable/include/hedge.h \
portable/include/image.h \
portable/include/joystick.h \
portable/include/json.h \
portable/include/kdtree.h \
portable/include/keycode.h \
portable/include/library.h \
Expand Down Expand Up @@ -358,6 +359,7 @@ DENG_HEADERS += \
portable/include/ui_main.h \
portable/include/ui_mpi.h \
portable/include/ui_panel.h \
portable/include/updater.h \
portable/include/vertex.h \
portable/include/wadfile.h \
portable/include/window.h \
Expand Down Expand Up @@ -519,6 +521,7 @@ SOURCES += \
portable/src/gridmap.c \
portable/src/hedge.cpp \
portable/src/image.c \
portable/src/json.cpp \
portable/src/kdtree.c \
portable/src/keycode.cpp \
portable/src/library.c \
Expand Down Expand Up @@ -636,6 +639,7 @@ SOURCES += \
portable/src/ui_main.c \
portable/src/ui_mpi.c \
portable/src/ui_panel.c \
portable/src/updater.cpp \
portable/src/uri.c \
portable/src/vertex.cpp \
portable/src/wadfile.c \
Expand Down Expand Up @@ -715,7 +719,7 @@ macx {
doPostLink("cp -fRp $$OUT_PWD/../libdeng2/libdeng2*dylib $$FW_DIR")

# Fix the dynamic linker paths so they point to ../Frameworks/ inside the bundle.
fixInstallName("Doomsday.app/Contents/MacOS/Doomsday", "libdeng2.2.dylib", "..")
fixInstallName(Doomsday.app/Contents/MacOS/Doomsday, libdeng2.2.dylib, ..)

# Clean up previous deployment.
doPostLink("rm -rf Doomsday.app/Contents/PlugIns/")
Expand Down
45 changes: 45 additions & 0 deletions doomsday/engine/portable/include/json.h
@@ -0,0 +1,45 @@
/**
* @file json.cpp
* JSON parser. @ingroup data
*
* Parses JSON and outputs a QVariant with the data.
*
* @todo Move this to libdeng2.
*
* @authors Copyright © 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_JSON_H
#define LIBDENG_JSON_H

#ifdef __cplusplus

#include <QVariant>
#include <de/String>

/**
* Parses text as JSON and returns the data structured in a QVariant.
*
* @param jsonText Text to parse.
*
* @return Parsed data, or an invalid variant if an error occurred.
*/
QVariant parseJSON(const de::String& jsonText);

#endif // __cplusplus

#endif // LIBDENG_JSON_H
71 changes: 71 additions & 0 deletions doomsday/engine/portable/include/updater.h
@@ -0,0 +1,71 @@
/**
* @file updater.h
* Automatic updater that works with dengine.net. @ingroup base
*
* @authors Copyright © 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2012 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_UPDATER_H
#define LIBDENG_UPDATER_H

#ifdef __cplusplus

#include <QObject>
#include <QNetworkReply>

/**
* Automatic updater. Communicates with dengine.net and coordinates the
* download and reinstall procedure.
*/
class Updater : public QObject
{
public:
explicit Updater(QObject* parent = 0);
~Updater();

public slots:
void gotReply(QNetworkReply*);

private:
struct Instance;
Instance* d;
};

#endif // __cplusplus

#ifdef __cplusplus
extern "C" {
#endif

/**
* Initializes the automatic updater. If it is time to check for an update,
* queries the latest version from http://dengine.net/ and determines the need
* to update.
*/
void Updater_Init(void);

/**
* Shuts down the automatic updater. Must be called at engine shutdown.
*/
void Updater_Shutdown(void);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // LIBDENG_UPDATER_H

0 comments on commit 70a8646

Please sign in to comment.