Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/net/rpc server #36

Merged
merged 20 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions binc.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ SOURCES += \
src/core/net/PortMapping.cpp \
src/core/IDataStream.cpp \
src/core/net/NetDataStreamException.cpp \
src/core/net/HTTPClient.cpp \
src/core/net/HTTPResponse.cpp \
src/core/net/IHTTPRequest.cpp \
src/core/net/HTTPgetRequest.cpp \
src/core/net/HTTPParsingException.cpp \
src/core/net/HTTPUdpClient.cpp \
src/core/net/http/HTTPClient.cpp \
src/core/net/http/HTTPResponse.cpp \
src/core/net/http/HTTPParsingException.cpp \
src/core/net/http/HTTPUdpClient.cpp \
src/core/net/SSDPRequest.cpp \
src/core/net/SSDPProvider.cpp \
src/database/Database.cpp \
Expand Down Expand Up @@ -57,7 +55,15 @@ SOURCES += \
tests/chat/Chat.cpp \
src/core/IBinarySerializable.cpp \
src/core/Settings.cpp \
src/core/ContextException.cpp
src/core/ContextException.cpp \
src/core/net/RPCServer.cpp \
src/core/net/RPCCommunicationThread.cpp \
src/core/StringUtils.cpp \
src/core/net/RPCRequest.cpp \
src/core/types/Version.cpp \
src/core/net/INetMessageWithHeaders.cpp \
src/core/net/http/IHTTPMessage.cpp \
src/core/net/http/HTTPRequest.cpp

HEADERS += \
src/core/IData.h \
Expand All @@ -67,12 +73,10 @@ HEADERS += \
src/core/net/PortMapping.h \
src/core/IDataStream.h \
src/core/net/NetDataStreamException.h \
src/core/net/HTTPClient.h \
src/core/net/HTTPResponse.h \
src/core/net/IHTTPRequest.h \
src/core/net/HTTPgetRequest.h \
src/core/net/HTTPParsingException.h \
src/core/net/HTTPUdpClient.h \
src/core/net/http/HTTPClient.h \
src/core/net/http/HTTPResponse.h \
src/core/net/http/HTTPParsingException.h \
src/core/net/http/HTTPUdpClient.h \
src/core/net/SSDPRequest.h \
src/core/net/SSDPProvider.h \
src/database/Database.h \
Expand Down Expand Up @@ -110,7 +114,15 @@ HEADERS += \
tests/chat/Chat.h \
src/core/IBinarySerializable.h \
src/core/Settings.h \
src/core/ContextException.h
src/core/ContextException.h \
src/core/net/RPCServer.h \
src/core/net/RPCCommunicationThread.h \
src/core/StringUtils.h \
src/core/net/RPCRequest.h \
src/core/types/Version.h \
src/core/net/INetMessageWithHeaders.h \
src/core/net/http/IHTTPMessage.h \
src/core/net/http/HTTPRequest.h


INCLUDEPATH += $$PWD/src
Expand Down
1 change: 1 addition & 0 deletions src/core/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Context
ConsoleInput * consoleInput() const { return _consoleInput; }
Settings *settings() { return &_sets; }


///
/// \brief load загружает среду выполнения приложения, настройки и пр.
/// \param settings Файл конфигурации
Expand Down
10 changes: 9 additions & 1 deletion src/core/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ void Settings::load(QString filename)
QFile file(filename);
if (!file.exists())
{
throw ContextException("Configuration file not found!");
//throw ContextException("Configuration file not found!");
// creating default configuration file
if (!file.open(QIODevice::WriteOnly))
{
throw ContextException("Configuration file access failed!");
}
_stream.setDevice(&file);
save();
file.close();
}
if (!file.open(QIODevice::ReadWrite))
{
Expand Down
29 changes: 29 additions & 0 deletions src/core/StringUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "StringUtils.h"
#include <QRegExp>

bool StringUtils::IsNullOrEmpty(QString value)
{
return value.isNull() || value.isEmpty();
}

bool StringUtils::IsVersion(QString value)
{
QRegExp validator("\\d+(\\.\\d+){0,2}[\\-\\s]*(pre-alpha|alpha|beta|rc|pre-a|a|b)?");
return validator.exactMatch(value);
}

QString StringUtils::TrimEx(QString value)
{
int st = value.indexOf(QRegExp("[^\\s\\t\\n\\r]")), en = value.lastIndexOf(QRegExp("[^\\s\\t\\n\\r]"));
return value.mid(st, en - st + 1);
}

QString StringUtils::EmptyString()
{
return QString();
}

StringUtils::StringUtils()
{

}
40 changes: 40 additions & 0 deletions src/core/StringUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef STRINGUTILS_H
#define STRINGUTILS_H

#include <QString>

///
/// \brief The StringUtils class Абстрактный класс для статических функций работы со строками
///
class StringUtils
{
public:
///
/// \brief IsNullOrEmpty Возвращает TRUE, если строка пустая или NULL
/// \param value проверяемая строка
/// \return
///
static bool IsNullOrEmpty(QString value);
///
/// \brief IsVersion Возвращает TRUE, если строка value может быть перобразована в тип Version
/// \param value
/// \return
///
static bool IsVersion(QString value);
///
/// \brief TrimEx Удаляет из начала и конца строки символы [\s,\r,\t,\n]
/// \param value
/// \return
///
static QString TrimEx(QString value);
///
/// \brief EmptyString Возвращает пустую строку
/// \return
///
static QString EmptyString();

private:
StringUtils();
};

#endif // STRINGUTILS_H
66 changes: 0 additions & 66 deletions src/core/net/HTTPResponse.cpp

This file was deleted.

65 changes: 0 additions & 65 deletions src/core/net/HTTPResponse.h

This file was deleted.

20 changes: 0 additions & 20 deletions src/core/net/HTTPgetRequest.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions src/core/net/HTTPgetRequest.h

This file was deleted.

33 changes: 0 additions & 33 deletions src/core/net/IHTTPRequest.cpp

This file was deleted.

Loading