Skip to content

Commit

Permalink
Creating a program to write out a JSON file which would be uploaded t…
Browse files Browse the repository at this point in the history
…o a server.

DREAM3D will retrieve this file to check for new versions. This replaces the old
version.txt file that was used for versions prior to this.
  • Loading branch information
imikejackson committed May 29, 2015
1 parent 22dde13 commit 1e28746
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Source/Applications/DREAM3D/DREAM3D_UI.cpp
Expand Up @@ -11,8 +11,8 @@
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its
* contributors may be used to endorse or promote products derived from this software
* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its
* contributors may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Expand Down Expand Up @@ -89,7 +89,7 @@ namespace Detail
static const QString VersionCheckGroupName("VersionCheck");
static const QString LastVersionCheck("LastVersionCheck");
static const QString WhenToCheck("WhenToCheck");
static const QString UpdateWebSite("http://dream3d.bluequartz.net/version.txt");
static const QString UpdateWebSite("http://dream3d.bluequartz.net/dream3d_version.json");
}

// -----------------------------------------------------------------------------
Expand Down
23 changes: 18 additions & 5 deletions Source/DREAM3DWidgetsLib/UpdateCheck.cpp
Expand Up @@ -11,8 +11,8 @@
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its
* contributors may be used to endorse or promote products derived from this software
* Neither the name of BlueQuartz Software, the US Air Force, nor the names of its
* contributors may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Expand All @@ -37,6 +37,10 @@

#include <QtCore/QDate>
#include <QtCore/QSettings>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>


#include <QtWidgets/QMessageBox>
#include <QtWidgets/QWidget>
Expand Down Expand Up @@ -128,9 +132,18 @@ void UpdateCheck::networkReplied(QNetworkReply* reply)
QString message;


QByteArray bytes = reply->readAll(); // bytes
QString serverVersionStr(bytes); // string
serverVersionStr = serverVersionStr.trimmed();
QByteArray byteArray = reply->readAll(); // bytes
// QString serverVersionStr(bytes); // string

QJsonParseError parseError;
QJsonDocument doc = QJsonDocument::fromJson(byteArray, &parseError);

QJsonObject root = doc.object();

QJsonObject d3dJson = root["DREAM3D"].toObject();
QString serverVersionStr = d3dJson["Version"].toString();

// serverVersionStr = serverVersionStr.trimmed();

QString appVersionStr = (DREAM3DLib::Version::Complete());

Expand Down
12 changes: 12 additions & 0 deletions Tools/CMakeLists.txt
Expand Up @@ -129,6 +129,18 @@ COMPILE_TOOL(
LINK_LIBRARIES Qt5::Gui Qt5::Widgets
)

# --------------------------------------------------------------------
COMPILE_TOOL(
TARGET CreateWebServerJson
SOURCES ${DREAM3DTools_SOURCE_DIR}/CreateWebServerJson.cpp
DEBUG_EXTENSION ${EXE_DEBUG_EXTENSION}
VERSION_MAJOR ${DREAM3D_VER_MAJOR}
VERSION_MINOR ${DREAM3D_VER_MINOR}
VERSION_PATCH ${DREAM3D_VER_PATCH}
BINARY_DIR ${${PROJECT_NAME}_BINARY_DIR}
LINK_LIBRARIES Qt5::Core
)

# Create a Command line tool for the DocsToPdf
if(0)
set(DREAM3D_DOCS_PDF_FILENAME ${DREAM3DProj_BINARY_DIR}/DREAM3D_Filter_Docs.pdf)
Expand Down
100 changes: 100 additions & 0 deletions Tools/CreateWebServerJson.cpp
@@ -0,0 +1,100 @@




#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
#include <QtCore/QDir>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonDocument>
#include <QtCore/QSet>
#include <QtCore/QDate>

#include "DREAM3DLib/DREAM3DLib.h"
#include "DREAM3DLib/Common/FilterManager.h"
#include "DREAM3DLib/Plugin/IDREAM3DPlugin.h"
#include "DREAM3DLib/Plugin/DREAM3DPluginLoader.h"


// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void WriteWebServerJSON(const QString& filePath)
{


// Register all the filters including trying to load those from Plugins
FilterManager* fm = FilterManager::Instance();
DREAM3DPluginLoader::LoadPluginFilters(fm);
PluginManager* pm = PluginManager::Instance();
QVector<IDREAM3DPlugin*> plugins = pm->getPluginsVector();

// Send progress messages from PipelineBuilder to this object for display
QMetaObjectUtilities::RegisterMetaTypes();


// Write our File Version and DREAM3D Version strings
QJsonObject meta;
meta[DREAM3D::Settings::Version] = DREAM3DLib::Version::Package();
meta["Release Date"] = QDate::currentDate().toString();
meta["Release Type"] = "Beta";

QJsonObject m_Root;
m_Root["DREAM3D"] = meta;


QJsonArray plugArray;

for(int i = 0; i < plugins.size(); i++)
{
IDREAM3DPlugin* plug = plugins[i];
QJsonObject jobj;
jobj["Plugin Name"] = plug->getPluginName();
jobj["Plugin Version"] = plug->getVersion();
jobj["Plugin Vendor"] = plug->getVendor();
plugArray.append(jobj);
}
m_Root["Plugins"] = plugArray;

QJsonDocument doc(m_Root);
QFile outputFile(filePath);
if (outputFile.open(QIODevice::WriteOnly))
{
outputFile.write(doc.toJson());
outputFile.close();
}

}




// -----------------------------------------------------------------------------
// Use test framework
// -----------------------------------------------------------------------------
int main(int argc, char** argv)
{
// Instantiate the QCoreApplication that we need to get the current path and load plugins.
QCoreApplication app(argc, argv);
QCoreApplication::setOrganizationName("BlueQuartz Software");
QCoreApplication::setOrganizationDomain("bluequartz.net");
QCoreApplication::setApplicationName("CreateWebServerJson");

QString filePath = "/tmp/Version.json";
if(argc == 2)
{
filePath = QString::fromLatin1(argv[1]);
}

WriteWebServerJSON(filePath);


int err = EXIT_SUCCESS;


return err;
}



4 changes: 2 additions & 2 deletions Tools/FilterParameterTool.cpp
Expand Up @@ -1006,7 +1006,7 @@ void GenerateFilterParametersCode()
// -----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
Q_ASSERT(true); // We don't want anyone to run this program.
Q_ASSERT(false); // We don't want anyone to run this program.
// Instantiate the QCoreApplication that we need to get the current path and load plugins.
QCoreApplication app(argc, argv);
QCoreApplication::setOrganizationName("BlueQuartz Software");
Expand All @@ -1024,7 +1024,7 @@ int main(int argc, char* argv[])
// Send progress messages from PipelineBuilder to this object for display
qRegisterMetaType<PipelineMessage>();

GenerateFilterParametersCode();
//GenerateFilterParametersCode();
//ReplaceLicenseCodeRecursively( QDir ( D3DTools::GetDREAM3DProjDir() ) );

return 0;
Expand Down

0 comments on commit 1e28746

Please sign in to comment.