Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Tropby/EBCpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Tropby committed Mar 6, 2024
2 parents 19ad32a + 93d957f commit e0e45ba
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 38 deletions.
25 changes: 0 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ project(EBCppExamples VERSION 0.1 LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)

# Configure and Include EBCpp
set(EBCPP_USE_GUI On) # On/Off - Using the windows gui functions (only for testing)
set(EBCPP_USE_SSL Off) # On/Off - Using openssl for ssl sockets and https
set(EBCPP_USE_SSL_STATIC Off) # On/Off - Activate static linking of openssl into your application (see openssl license)
set(EBCPP_USE_SQLITE Off) # On/Off - Using sqlite in your application (static linked)
Expand Down Expand Up @@ -94,30 +93,6 @@ if(WIN32)
else()
target_link_libraries(EBCppExampleSerialPort pthread)
endif()

# Compile EBCppExampleGui
add_executable(EBCppExampleGui examples/ExampleGui.cpp)
if(WIN32)
target_link_libraries(EBCppExampleGui gdiplus -Wl,-subsystem,windows)
else()
target_link_libraries(EBCppExampleGui pthread)
endif()

# Compile EBCppExampleImage
add_executable(EBCppExampleGuiImage examples/ExampleGuiImage.cpp)
if(WIN32)
target_link_libraries(EBCppExampleGuiImage gdiplus -Wl,-subsystem,windows)
else()
target_link_libraries(EBCppExampleGui pthread)
endif()

# Compile EBCppExampleGuiLayout
add_executable(EBCppExampleGuiLayout examples/ExampleGuiLayout.cpp)
if(WIN32)
target_link_libraries(EBCppExampleGuiLayout gdiplus -Wl,-subsystem,windows)
else()
target_link_libraries(EBCppExampleGuiLayout pthread)
endif()
endif()

find_package(OpenSSL)
Expand Down
5 changes: 5 additions & 0 deletions src/EBApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class EBApplication : public EBObject<EBApplication>
}
}

static bool containsArgument( const EBString& argument )
{
return arguments.contains(argument);
}

static EBString getArgument( int index )
{
return arguments.get(index);
Expand Down
57 changes: 46 additions & 11 deletions src/socket/raw/EBICMP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@
* Author: Carsten (Tropby)
*/

/**
* ATTENTION: You need to add the follwoing libs to the target:
* target_link_libraries(TARGET -lws2_32 -liphlpapi)
*
*/

#pragma once

#include <memory>
#include <thread>

#ifdef __WIN32__
#include <winsock2.h>
#endif

#ifdef __WIN32__
#include <icmpapi.h>
#include <ipexport.h>
#include <icmpapi.h>
#include <iphlpapi.h>
#else
#error NOT IMPLEMENTED FOR UNIX
Expand All @@ -65,6 +68,17 @@ class EBICMP : public EBObject<EBICMP>
{
}

~EBICMP()
{
if( thread )
{
if( thread->joinable() )
{
thread->join();
}
}
}

void setDestination(EBUrl destination)
{
this->destination = destination;
Expand Down Expand Up @@ -157,19 +171,40 @@ class EBICMP : public EBObject<EBICMP>
result.roundtrip = pEchoReply->RoundTripTime;
result.status = pEchoReply->Status;

WCHAR buffer[128];
char str[128];
long unsigned int size = 128;
GetIpErrorString(result.status, buffer, &size);
wcstombs(str, buffer, 128);
result.resultString = str;
if( result.status != IP_SUCCESS )
{
WCHAR buffer[128];
char str[128];
long unsigned int size = 128;
GetIpErrorString(result.status, buffer, &size);
wcstombs(str, buffer, 128);
result.resultString = str;
result.roundtrip = -1;
}
else
{
result.resultString = "Okay";
}

running = false;
EB_EMIT_WITH_ARGS(finished, result);
}
else
{
lastError = EBString() + "Timeout! [Code: " + EBUtils::intToStr(GetLastError()) + "]";
DWORD errorMessageID = ::GetLastError();
if(errorMessageID != 0)
{
LPSTR messageBuffer = nullptr;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);

lastError = EBString() + "Timeout! [Code: " + EBString(messageBuffer, size) + "]";
LocalFree(messageBuffer);
}
else
{
lastError = "NO ERROR? " + EBUtils::intToStr(dwRetVal);
}
running = false;
EB_EMIT(error);
}
Expand Down
14 changes: 12 additions & 2 deletions src/xml/EBXmlDocument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace EBCpp
class EBXmlDocument : public EBObject<EBXmlDocument>
{
public:
EBXmlDocument()
EBXmlDocument() : version("1.0")
{
root = nullptr;
}
Expand Down Expand Up @@ -132,7 +132,17 @@ class EBXmlDocument : public EBObject<EBXmlDocument>
const EBString getStandalone() const
{
return standalone;
}
}

void setRootElement(const EBPtr<EBXmlElement> element)
{
root = element;
}

const EBPtr<EBXmlElement> getRootElement() const
{
return root;
}

private:

Expand Down

0 comments on commit e0e45ba

Please sign in to comment.