Remove graphics add email
This commit is contained in:
@ -13,6 +13,7 @@ src/Http/HttpUtils.cpp
|
|||||||
src/Http/HttpClient.cpp
|
src/Http/HttpClient.cpp
|
||||||
src/Http/HttpStream.cpp
|
src/Http/HttpStream.cpp
|
||||||
src/Http/ContentDisposition.cpp
|
src/Http/ContentDisposition.cpp
|
||||||
|
src/Mail/Smtp.cpp
|
||||||
src/Streams/FileStream.cpp
|
src/Streams/FileStream.cpp
|
||||||
src/Streams/MemoryStream.cpp
|
src/Streams/MemoryStream.cpp
|
||||||
src/Streams/NetworkStream.cpp
|
src/Streams/NetworkStream.cpp
|
||||||
@ -34,12 +35,6 @@ src/Filesystem/NullFilesystem.cpp
|
|||||||
src/Filesystem/MountableFilesystem.cpp
|
src/Filesystem/MountableFilesystem.cpp
|
||||||
src/Crypto/ClientTLSStream.cpp
|
src/Crypto/ClientTLSStream.cpp
|
||||||
src/Crypto/MbedHelpers.cpp
|
src/Crypto/MbedHelpers.cpp
|
||||||
src/Graphics/ImageFormats/Bitmap.cpp
|
|
||||||
src/Graphics/ImageFormats/ImageFormat.cpp
|
|
||||||
src/Graphics/Renderers/ImageRenderer.cpp
|
|
||||||
src/Graphics/Renderers/Renderer.cpp
|
|
||||||
src/Graphics/Color.cpp
|
|
||||||
src/Graphics/Image.cpp
|
|
||||||
src/TF_Init.cpp
|
src/TF_Init.cpp
|
||||||
src/wrapper.cpp
|
src/wrapper.cpp
|
||||||
src/HiddenField.cpp
|
src/HiddenField.cpp
|
||||||
@ -48,7 +43,6 @@ src/HiddenField.cpp
|
|||||||
set(TESSESFRAMEWORK_CERT_BUNDLE_FILE "/etc/ssl/certs/ca-certificates.crt" CACHE FILEPATH "Path to ca-chain")
|
set(TESSESFRAMEWORK_CERT_BUNDLE_FILE "/etc/ssl/certs/ca-certificates.crt" CACHE FILEPATH "Path to ca-chain")
|
||||||
option(TESSESFRAMEWORK_EMBED_CERT_BUNDLE "Embed the certificate chain bundle" ON)
|
option(TESSESFRAMEWORK_EMBED_CERT_BUNDLE "Embed the certificate chain bundle" ON)
|
||||||
option(TESSESFRAMEWORK_ENABLE_MBED "Enable Tesses Framework mbedtls" ON)
|
option(TESSESFRAMEWORK_ENABLE_MBED "Enable Tesses Framework mbedtls" ON)
|
||||||
option(TESSESFRAMEWORK_ENABLE_LIBWEBCAM "Enable LibWebCam" OFF)
|
|
||||||
option(TESSESFRAMEWORK_ENABLE_NETWORKING "Enable Networking" ON)
|
option(TESSESFRAMEWORK_ENABLE_NETWORKING "Enable Networking" ON)
|
||||||
option(TESSESFRAMEWORK_ENABLE_THREADING "Enable Threading" ON)
|
option(TESSESFRAMEWORK_ENABLE_THREADING "Enable Threading" ON)
|
||||||
|
|
||||||
@ -74,18 +68,13 @@ endif()
|
|||||||
endif()
|
endif()
|
||||||
set(MBEDTLS_DIR "" CACHE PATH "Mbed tls directory")
|
set(MBEDTLS_DIR "" CACHE PATH "Mbed tls directory")
|
||||||
|
|
||||||
function(link_deps TessesFramework_TARGET)
|
function(TESSESFRAMEWORK_LINKDEPS TessesFramework_TARGET)
|
||||||
if(TESSESFRAMEWORK_ENABLE_THREADING)
|
if(TESSESFRAMEWORK_ENABLE_THREADING)
|
||||||
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_THREADING)
|
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_THREADING)
|
||||||
endif()
|
endif()
|
||||||
if(TESSESFRAMEWORK_ENABLE_NETWORKING)
|
if(TESSESFRAMEWORK_ENABLE_NETWORKING)
|
||||||
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_NETWORKING)
|
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_NETWORKING)
|
||||||
endif()
|
endif()
|
||||||
if(TESSESFRAMEWORK_ENABLE_LIBWEBCAM)
|
|
||||||
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_LIBWEBCAM)
|
|
||||||
find_package(libwebcam REQUIRED)
|
|
||||||
target_link_libraries(${TessesFramework_TARGET} PUBLIC libwebcam)
|
|
||||||
endif()
|
|
||||||
if(TESSESFRAMEWORK_ENABLE_MBED)
|
if(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_MBED)
|
target_compile_definitions(${TessesFramework_TARGET} PUBLIC TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
if(TESSESFRAMEWORK_EMBED_CERT_BUNDLE)
|
if(TESSESFRAMEWORK_EMBED_CERT_BUNDLE)
|
||||||
@ -131,7 +120,7 @@ include(GNUInstallDirs)
|
|||||||
if(TESSESFRAMEWORK_ENABLE_STATIC)
|
if(TESSESFRAMEWORK_ENABLE_STATIC)
|
||||||
|
|
||||||
add_library(tessesframework STATIC ${TESSESFRAMEWORK_SOURCE})
|
add_library(tessesframework STATIC ${TESSESFRAMEWORK_SOURCE})
|
||||||
link_deps(tessesframework)
|
TESSESFRAMEWORK_LINKDEPS(tessesframework)
|
||||||
list(APPEND TessesFrameworkLibs tessesframework)
|
list(APPEND TessesFrameworkLibs tessesframework)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -139,7 +128,7 @@ endif()
|
|||||||
if(TESSESFRAMEWORK_ENABLE_SHARED)
|
if(TESSESFRAMEWORK_ENABLE_SHARED)
|
||||||
|
|
||||||
add_library(tessesframework_shared SHARED ${TESSESFRAMEWORK_SOURCE})
|
add_library(tessesframework_shared SHARED ${TESSESFRAMEWORK_SOURCE})
|
||||||
link_deps(tessesframework_shared)
|
TESSESFRAMEWORK_LINKDEPS(tessesframework_shared)
|
||||||
list(APPEND TessesFrameworkLibs tessesframework_shared)
|
list(APPEND TessesFrameworkLibs tessesframework_shared)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -189,14 +178,6 @@ if(TESSESFRAMEWORK_ENABLE_EXAMPLES)
|
|||||||
add_executable(mountabletest examples/mountabletest.cpp)
|
add_executable(mountabletest examples/mountabletest.cpp)
|
||||||
target_link_libraries(mountabletest PUBLIC tessesframework)
|
target_link_libraries(mountabletest PUBLIC tessesframework)
|
||||||
|
|
||||||
add_executable(bmp examples/bmp.cpp)
|
|
||||||
target_link_libraries(bmp PUBLIC tessesframework)
|
|
||||||
add_executable(bmp2 examples/bmp2.cpp)
|
|
||||||
target_link_libraries(bmp2 PUBLIC tessesframework)
|
|
||||||
add_executable(bmp3 examples/bmp3.cpp)
|
|
||||||
target_link_libraries(bmp3 PUBLIC tessesframework)
|
|
||||||
add_executable(bmp4 examples/bmp4.cpp)
|
|
||||||
target_link_libraries(bmp4 PUBLIC tessesframework)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TESSESFRAMEWORK_ENABLE_APPS)
|
if(TESSESFRAMEWORK_ENABLE_APPS)
|
||||||
|
|||||||
@ -1,47 +0,0 @@
|
|||||||
#include "TessesFramework/TessesFramework.hpp"
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
using namespace Tesses::Framework::Graphics;
|
|
||||||
using namespace Tesses::Framework::Graphics::ImageFormats;
|
|
||||||
using namespace Tesses::Framework::Streams;
|
|
||||||
|
|
||||||
void doIt(const char* n)
|
|
||||||
{
|
|
||||||
std::string p = n;
|
|
||||||
srand(std::stoi(p));
|
|
||||||
p.append(".bmp");
|
|
||||||
FileStream* strm = new FileStream(p,"wb");
|
|
||||||
Image image(320,240);
|
|
||||||
|
|
||||||
std::vector<Color> colors = {
|
|
||||||
Colors::Crimson,
|
|
||||||
Colors::Chartreuse,
|
|
||||||
Colors::FireBrick,
|
|
||||||
Colors::Turquoise,
|
|
||||||
Colors::DarkOrange,
|
|
||||||
Colors::Orange
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(uint32_t y = 0; y < image.Height(); y++)
|
|
||||||
{
|
|
||||||
for(uint32_t x = 0; x < image.Width(); x++)
|
|
||||||
{
|
|
||||||
image.SetPixel(x,y,colors[rand() % (int)colors.size()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageFormats::Bitmap bmp;
|
|
||||||
bmp.Save(strm,&image);
|
|
||||||
delete strm;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
for(int i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
doIt(argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
#include "TessesFramework/TessesFramework.hpp"
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
using namespace Tesses::Framework::Graphics;
|
|
||||||
using namespace Tesses::Framework::Graphics::ImageFormats;
|
|
||||||
using namespace Tesses::Framework::Streams;
|
|
||||||
|
|
||||||
#define WIDTH 19
|
|
||||||
#define HEIGHT 12
|
|
||||||
#define A 0x0A
|
|
||||||
#define B 0x0B
|
|
||||||
#define C 0x0C
|
|
||||||
char house[] = {
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //1
|
|
||||||
0,0,0,0,0,0,0,0,9,9,0,0,0,7,0,0,B,B,0, //2
|
|
||||||
0,0,0,8,8,0,0,0,9,9,0,0,7,6,7,0,A,0,B, //3
|
|
||||||
0,0,0,8,8,0,0,0,0,0,0,7,C,C,C,7,A,0,0, //4
|
|
||||||
0,8,8,8,8,8,8,0,0,0,7,C,C,C,C,C,7,0,0, //5
|
|
||||||
0,8,8,8,8,8,8,0,0,7,7,7,7,7,7,7,7,7,0, //6
|
|
||||||
0,0,0,8,8,0,0,0,0,1,5,5,5,5,5,5,5,1,0, //7
|
|
||||||
0,0,0,8,8,0,0,0,0,1,6,5,3,3,3,5,6,1,0, //8
|
|
||||||
4,4,4,8,8,4,4,4,4,1,6,5,3,2,3,5,6,1,4, //9
|
|
||||||
4,4,4,8,8,4,4,4,4,1,5,5,3,2,3,5,5,1,4, //10
|
|
||||||
4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,4, //11
|
|
||||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 //12
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
Color pallete[] = {
|
|
||||||
Colors::SkyBlue,
|
|
||||||
Colors::Grey,
|
|
||||||
Colors::Crimson,
|
|
||||||
Colors::Lime,
|
|
||||||
Colors::LawnGreen,
|
|
||||||
Colors::DarkOliveGreen,
|
|
||||||
Colors::DimGrey,
|
|
||||||
Colors::BurlyWood,
|
|
||||||
Colors::White,
|
|
||||||
Colors::Yellow,
|
|
||||||
Colors::FireBrick,
|
|
||||||
Colors::WhiteSmoke,
|
|
||||||
Colors::DarkGoldenRod
|
|
||||||
};
|
|
||||||
|
|
||||||
Image img(WIDTH*32,HEIGHT*32);
|
|
||||||
|
|
||||||
for(uint32_t y = 0; y < HEIGHT; y++)
|
|
||||||
{
|
|
||||||
for(uint32_t x = 0; x < WIDTH; x++)
|
|
||||||
{
|
|
||||||
char c = house[y * WIDTH + x];
|
|
||||||
for(uint32_t y0 = 0; y0 < 32; y0++)
|
|
||||||
{
|
|
||||||
uint32_t y1 = y * 32 + y0;
|
|
||||||
for(uint32_t x0 = 0; x0 < 32;x0++)
|
|
||||||
{
|
|
||||||
uint32_t x1 = x * 32 + x0;
|
|
||||||
|
|
||||||
img.SetPixel(x1,y1, pallete[c]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileStream* strm = new FileStream("house.bmp","wb");
|
|
||||||
ImageFormats::Bitmap bmp;
|
|
||||||
bmp.Save(strm,&img);
|
|
||||||
delete strm;
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
#include "TessesFramework/TessesFramework.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
using namespace Tesses::Framework::Graphics;
|
|
||||||
using namespace Tesses::Framework::Graphics::ImageFormats;
|
|
||||||
using namespace Tesses::Framework::Streams;
|
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
|
||||||
{
|
|
||||||
if(argc < 3) {
|
|
||||||
std::cout << "INBMP OUTBMP" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
FileStream* src = new FileStream(argv[1],"rb");
|
|
||||||
|
|
||||||
Image img;
|
|
||||||
Bitmap bmp;
|
|
||||||
bmp.Load(src,&img);
|
|
||||||
delete src;
|
|
||||||
FileStream* dest = new FileStream(argv[2],"wb");
|
|
||||||
bmp.Save(dest,&img);
|
|
||||||
delete dest;
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
#include "TessesFramework/TessesFramework.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
using namespace Tesses::Framework;
|
|
||||||
using namespace Tesses::Framework::Graphics;
|
|
||||||
using namespace Tesses::Framework::Graphics::ImageFormats;
|
|
||||||
using namespace Tesses::Framework::Streams;
|
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
|
||||||
{
|
|
||||||
if(argc < 3) {
|
|
||||||
std::cout << "INBMP OUTBMP" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
FileStream* src = new FileStream(argv[1],"rb");
|
|
||||||
|
|
||||||
Image img;
|
|
||||||
Bitmap bmp;
|
|
||||||
bmp.Load(src,&img);
|
|
||||||
|
|
||||||
delete src;
|
|
||||||
|
|
||||||
Image img2(img.Width()+64,img.Height()+64);
|
|
||||||
Renderers::ImageRenderer irdr(&img2);
|
|
||||||
irdr.DrawRectangle(Rectangle(0,0,(int32_t)img2.Width(),(int32_t)img2.Height()),Colors::Crimson,false);
|
|
||||||
irdr.DrawRectangle(Rectangle(1,1,(int32_t)img2.Width()-2,(int32_t)img2.Height()-2),Colors::Chartreuse,true);
|
|
||||||
irdr.DrawImage(Point(32,32),&img);
|
|
||||||
|
|
||||||
FileStream* dest = new FileStream(argv[2],"wb");
|
|
||||||
bmp.Save(dest,&img2);
|
|
||||||
delete dest;
|
|
||||||
}
|
|
||||||
@ -1,176 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "../Common.hpp"
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
|
|
||||||
struct Color {
|
|
||||||
uint8_t Red=0;
|
|
||||||
uint8_t Green=0;
|
|
||||||
uint8_t Blue=0;
|
|
||||||
uint8_t Alpha=255;
|
|
||||||
Color();
|
|
||||||
Color(uint8_t r, uint8_t g, uint8_t b);
|
|
||||||
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
|
||||||
Color(Color c, uint8_t a);
|
|
||||||
Color(uint8_t* color_data);
|
|
||||||
|
|
||||||
std::string ToString(bool alphaIf255=false);
|
|
||||||
|
|
||||||
void ToArray(uint8_t* color_data);
|
|
||||||
|
|
||||||
static bool TryParse(std::string color, Color& col);
|
|
||||||
|
|
||||||
static Color Parse(std::string color);
|
|
||||||
bool operator!=(Color other);
|
|
||||||
bool operator==(Color other);
|
|
||||||
};
|
|
||||||
namespace Colors {
|
|
||||||
extern const Color AliceBlue;
|
|
||||||
extern const Color AntiqueWhite;
|
|
||||||
extern const Color Aqua;
|
|
||||||
extern const Color Aquamarine;
|
|
||||||
extern const Color Azure;
|
|
||||||
extern const Color Beige;
|
|
||||||
extern const Color Bisque;
|
|
||||||
extern const Color Black;
|
|
||||||
extern const Color BlanchedAlmond;
|
|
||||||
extern const Color Blue;
|
|
||||||
extern const Color BlueViolet;
|
|
||||||
extern const Color Brown;
|
|
||||||
extern const Color BurlyWood;
|
|
||||||
extern const Color CadetBlue;
|
|
||||||
extern const Color Chartreuse;
|
|
||||||
extern const Color Chocolate;
|
|
||||||
extern const Color Coral;
|
|
||||||
extern const Color CornflowerBlue;
|
|
||||||
extern const Color Cornsilk;
|
|
||||||
extern const Color Crimson;
|
|
||||||
extern const Color Cyan;
|
|
||||||
extern const Color DarkBlue;
|
|
||||||
extern const Color DarkCyan;
|
|
||||||
extern const Color DarkGoldenRod;
|
|
||||||
extern const Color DarkGray;
|
|
||||||
extern const Color DarkGrey;
|
|
||||||
extern const Color DarkGreen;
|
|
||||||
extern const Color DarkKhaki;
|
|
||||||
extern const Color DarkMagenta;
|
|
||||||
extern const Color DarkOliveGreen;
|
|
||||||
extern const Color DarkOrange;
|
|
||||||
extern const Color DarkOrchid;
|
|
||||||
extern const Color DarkRed;
|
|
||||||
extern const Color DarkSalmon;
|
|
||||||
extern const Color DarkSeaGreen;
|
|
||||||
extern const Color DarkSlateBlue;
|
|
||||||
extern const Color DarkSlateGray;
|
|
||||||
extern const Color DarkSlateGrey;
|
|
||||||
extern const Color DarkTurquoise;
|
|
||||||
extern const Color DarkViolet;
|
|
||||||
extern const Color DeepPink;
|
|
||||||
extern const Color DeepSkyBlue;
|
|
||||||
extern const Color DimGray;
|
|
||||||
extern const Color DimGrey;
|
|
||||||
extern const Color DodgerBlue;
|
|
||||||
extern const Color FireBrick;
|
|
||||||
extern const Color FloralWhite;
|
|
||||||
extern const Color ForestGreen;
|
|
||||||
extern const Color Fuchsia;
|
|
||||||
extern const Color Gainsboro;
|
|
||||||
extern const Color GhostWhite;
|
|
||||||
extern const Color Gold;
|
|
||||||
extern const Color GoldenRod;
|
|
||||||
extern const Color Gray;
|
|
||||||
extern const Color Grey;
|
|
||||||
extern const Color Green;
|
|
||||||
extern const Color GreenYellow;
|
|
||||||
extern const Color HoneyDew;
|
|
||||||
extern const Color HotPink;
|
|
||||||
extern const Color IndianRed;
|
|
||||||
extern const Color Indigo;
|
|
||||||
extern const Color Ivory;
|
|
||||||
extern const Color Khaki;
|
|
||||||
extern const Color Lavender;
|
|
||||||
extern const Color LavenderBlush;
|
|
||||||
extern const Color LawnGreen;
|
|
||||||
extern const Color LemonChiffon;
|
|
||||||
extern const Color LightBlue;
|
|
||||||
extern const Color LightCoral;
|
|
||||||
extern const Color LightCyan;
|
|
||||||
extern const Color LightGoldenRodYellow;
|
|
||||||
extern const Color LightGray;
|
|
||||||
extern const Color LightGrey;
|
|
||||||
extern const Color LightGreen;
|
|
||||||
extern const Color LightPink;
|
|
||||||
extern const Color LightSalmon;
|
|
||||||
extern const Color LightSeaGreen;
|
|
||||||
extern const Color LightSkyBlue;
|
|
||||||
extern const Color LightSlateGray;
|
|
||||||
extern const Color LightSlateGrey;
|
|
||||||
extern const Color LightSteelBlue;
|
|
||||||
extern const Color LightYellow;
|
|
||||||
extern const Color Lime;
|
|
||||||
extern const Color LimeGreen;
|
|
||||||
extern const Color Linen;
|
|
||||||
extern const Color Magenta;
|
|
||||||
extern const Color Maroon;
|
|
||||||
extern const Color MediumAquaMarine;
|
|
||||||
extern const Color MediumBlue;
|
|
||||||
extern const Color MediumOrchid;
|
|
||||||
extern const Color MediumPurple;
|
|
||||||
extern const Color MediumSeaGreen;
|
|
||||||
extern const Color MediumSlateBlue;
|
|
||||||
extern const Color MediumSpringGreen;
|
|
||||||
extern const Color MediumTurquoise;
|
|
||||||
extern const Color MediumVioletRed;
|
|
||||||
extern const Color MidnightBlue;
|
|
||||||
extern const Color MintCream;
|
|
||||||
extern const Color MistyRose;
|
|
||||||
extern const Color Moccasin;
|
|
||||||
extern const Color NavajoWhite;
|
|
||||||
extern const Color Navy;
|
|
||||||
extern const Color OldLace;
|
|
||||||
extern const Color Olive;
|
|
||||||
extern const Color OliveDrab;
|
|
||||||
extern const Color Orange;
|
|
||||||
extern const Color OrangeRed;
|
|
||||||
extern const Color Orchid;
|
|
||||||
extern const Color PaleGoldenRod;
|
|
||||||
extern const Color PaleGreen;
|
|
||||||
extern const Color PaleTurquoise;
|
|
||||||
extern const Color PaleVioletRed;
|
|
||||||
extern const Color PapayaWhip;
|
|
||||||
extern const Color PeachPuff;
|
|
||||||
extern const Color Peru;
|
|
||||||
extern const Color Pink;
|
|
||||||
extern const Color Plum;
|
|
||||||
extern const Color PowderBlue;
|
|
||||||
extern const Color Purple;
|
|
||||||
extern const Color RebeccaPurple;
|
|
||||||
extern const Color Red;
|
|
||||||
extern const Color RosyBrown;
|
|
||||||
extern const Color SaddleBrown;
|
|
||||||
extern const Color Salmon;
|
|
||||||
extern const Color SandyBrown;
|
|
||||||
extern const Color SeaGreen;
|
|
||||||
extern const Color SeaShell;
|
|
||||||
extern const Color Sienna;
|
|
||||||
extern const Color Silver;
|
|
||||||
extern const Color SkyBlue;
|
|
||||||
extern const Color SlateBlue;
|
|
||||||
extern const Color SlateGray;
|
|
||||||
extern const Color SlateGrey;
|
|
||||||
extern const Color Snow;
|
|
||||||
extern const Color SpringGreen;
|
|
||||||
extern const Color SteelBlue;
|
|
||||||
extern const Color Tan;
|
|
||||||
extern const Color Teal;
|
|
||||||
extern const Color Thistle;
|
|
||||||
extern const Color Tomato;
|
|
||||||
extern const Color Turquoise;
|
|
||||||
extern const Color Violet;
|
|
||||||
extern const Color Wheat;
|
|
||||||
extern const Color White;
|
|
||||||
extern const Color WhiteSmoke;
|
|
||||||
extern const Color Yellow;
|
|
||||||
extern const Color YellowGreen;
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Color.hpp"
|
|
||||||
#include <vector>
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
class Image {
|
|
||||||
uint32_t w=0;
|
|
||||||
uint32_t h=0;
|
|
||||||
std::vector<Color> data={};
|
|
||||||
public:
|
|
||||||
Image();
|
|
||||||
Image(uint32_t w, uint32_t h);
|
|
||||||
Image(uint32_t w,uint32_t h,std::vector<Color> data);
|
|
||||||
uint32_t Width();
|
|
||||||
uint32_t Height();
|
|
||||||
void SetSize(uint32_t w, uint32_t h);
|
|
||||||
void SetSize(uint32_t w, uint32_t h, Color c);
|
|
||||||
void SetPixel(uint32_t x, uint32_t y, Color c);
|
|
||||||
Color GetPixel(uint32_t x, uint32_t y);
|
|
||||||
|
|
||||||
std::vector<Color>& Data();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "ImageFormat.hpp"
|
|
||||||
namespace Tesses::Framework::Graphics::ImageFormats {
|
|
||||||
class Bitmap : public ImageFormat {
|
|
||||||
public:
|
|
||||||
Bitmap();
|
|
||||||
void Load(Tesses::Framework::Streams::Stream* strm, Image* image);
|
|
||||||
void Save(Tesses::Framework::Streams::Stream* strm, Image* image,std::string flags="");
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "../../Streams/Stream.hpp"
|
|
||||||
#include "../Image.hpp"
|
|
||||||
|
|
||||||
namespace Tesses::Framework::Graphics::ImageFormats {
|
|
||||||
class ImageFormat {
|
|
||||||
public:
|
|
||||||
virtual void Load(Tesses::Framework::Streams::Stream* strm, Image* image)=0;
|
|
||||||
virtual void Save(Tesses::Framework::Streams::Stream* strm, Image* image,std::string flags="")=0;
|
|
||||||
|
|
||||||
virtual ~ImageFormat();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
class Point {
|
|
||||||
public:
|
|
||||||
Point()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Point(int32_t x, int32_t y)
|
|
||||||
{
|
|
||||||
this->X = x;
|
|
||||||
this->Y = y;
|
|
||||||
}
|
|
||||||
int32_t X=0;
|
|
||||||
int32_t Y=0;
|
|
||||||
std::string ToString()
|
|
||||||
{
|
|
||||||
return std::to_string(X) + ", " + std::to_string(Y);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Point.hpp"
|
|
||||||
#include "Size.hpp"
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
class Rectangle {
|
|
||||||
public:
|
|
||||||
Rectangle()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Rectangle(Point pt, int32_t square) : Rectangle(pt, Graphics::Size(square))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Rectangle(int32_t x, int32_t y, int32_t square) : Rectangle(Point(x,y),square)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Rectangle(int32_t x, int32_t y, int32_t width, int32_t height) : Rectangle(Point(x,y),Graphics::Size(width,height))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Rectangle(Point pt, Size sz)
|
|
||||||
{
|
|
||||||
this->Location = pt;
|
|
||||||
this->Size = sz;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphics::Point Location;
|
|
||||||
Graphics::Size Size;
|
|
||||||
|
|
||||||
std::string ToString()
|
|
||||||
{
|
|
||||||
return std::to_string(Location.X) + ", " + std::to_string(Location.Y) + ", " + std::to_string(Size.Width) + ", " + std::to_string(Size.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Intersects(Point pt)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Renderer.hpp"
|
|
||||||
|
|
||||||
namespace Tesses::Framework::Graphics::Renderers {
|
|
||||||
|
|
||||||
|
|
||||||
class ImageRenderer : public Renderer {
|
|
||||||
Image* image;
|
|
||||||
public:
|
|
||||||
ImageRenderer(Image* image);
|
|
||||||
uint32_t Width();
|
|
||||||
uint32_t Height();
|
|
||||||
void SetPixel(Point pt,Color c);
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../Image.hpp"
|
|
||||||
#include "../Rectangle.hpp"
|
|
||||||
namespace Tesses::Framework::Graphics::Renderers {
|
|
||||||
|
|
||||||
|
|
||||||
class Renderer {
|
|
||||||
public:
|
|
||||||
virtual uint32_t Width()=0;
|
|
||||||
virtual uint32_t Height()=0;
|
|
||||||
virtual void SetPixel(Point pt,Color c) = 0;
|
|
||||||
virtual void DrawRectangle(Rectangle rect,Color c,bool fill);
|
|
||||||
virtual void DrawImage(Point pt, Image* image);
|
|
||||||
virtual ~Renderer();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
class Size {
|
|
||||||
public:
|
|
||||||
Size()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Size(int32_t square)
|
|
||||||
{
|
|
||||||
this->Width = square;
|
|
||||||
this->Height = square;
|
|
||||||
}
|
|
||||||
Size(int32_t width, int32_t height)
|
|
||||||
{
|
|
||||||
this->Width = width;
|
|
||||||
this->Height = height;
|
|
||||||
}
|
|
||||||
int32_t Width=0;
|
|
||||||
int32_t Height=0;
|
|
||||||
bool IsSquare()
|
|
||||||
{
|
|
||||||
return Width == Height;
|
|
||||||
}
|
|
||||||
std::string ToString()
|
|
||||||
{
|
|
||||||
return std::to_string(Width) + "x" + std::to_string(Height);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -23,7 +23,15 @@ namespace Tesses::Framework::Http
|
|||||||
~StreamHttpRequestBody();
|
~StreamHttpRequestBody();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TextHttpRequestBody : public HttpRequestBody {
|
||||||
|
std::string text;
|
||||||
|
std::string mimeType;
|
||||||
|
public:
|
||||||
|
TextHttpRequestBody(std::string text, std::string mimeType);
|
||||||
|
void HandleHeaders(HttpDictionary& dict);
|
||||||
|
void Write(Tesses::Framework::Streams::Stream* strm);
|
||||||
|
~TextHttpRequestBody();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class HttpRequest {
|
class HttpRequest {
|
||||||
|
|||||||
53
include/TessesFramework/Mail/Smtp.hpp
Normal file
53
include/TessesFramework/Mail/Smtp.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../Streams/Stream.hpp"
|
||||||
|
namespace Tesses::Framework::Mail
|
||||||
|
{
|
||||||
|
class SMTPBody
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string mimeType;
|
||||||
|
virtual void Write(Tesses::Framework::Streams::Stream* strm)=0;
|
||||||
|
virtual ~SMTPBody();
|
||||||
|
};
|
||||||
|
|
||||||
|
class SMTPStringBody : public SMTPBody
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SMTPStringBody();
|
||||||
|
SMTPStringBody(std::string text, std::string mimeType);
|
||||||
|
std::string text;
|
||||||
|
void Write(Tesses::Framework::Streams::Stream* strm);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SMTPStreamBody : public SMTPBody
|
||||||
|
{
|
||||||
|
Tesses::Framework::Streams::Stream* stream;
|
||||||
|
bool owns;
|
||||||
|
public:
|
||||||
|
SMTPStreamBody(std::string mimeType,Tesses::Framework::Streams::Stream& stream);
|
||||||
|
SMTPStreamBody(std::string mimeType,Tesses::Framework::Streams::Stream* stream, bool owns);
|
||||||
|
void Write(Tesses::Framework::Streams::Stream* strm);
|
||||||
|
~SMTPStreamBody();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SMTPClient {
|
||||||
|
Tesses::Framework::Streams::Stream* strm;
|
||||||
|
bool owns;
|
||||||
|
public:
|
||||||
|
SMTPClient(Tesses::Framework::Streams::Stream* stream,bool owns=true);
|
||||||
|
SMTPClient(Tesses::Framework::Streams::Stream& strm);
|
||||||
|
std::string domain;
|
||||||
|
std::string username;
|
||||||
|
std::string password;
|
||||||
|
std::string from;
|
||||||
|
std::string from_name;
|
||||||
|
std::string to;
|
||||||
|
std::string subject;
|
||||||
|
SMTPBody* body;
|
||||||
|
std::vector<std::pair<std::string,SMTPBody*>> attachments;
|
||||||
|
void Send();
|
||||||
|
~SMTPClient();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@ -24,10 +24,5 @@
|
|||||||
#include "Crypto/ClientTLSStream.hpp"
|
#include "Crypto/ClientTLSStream.hpp"
|
||||||
#include "Crypto/MbedHelpers.hpp"
|
#include "Crypto/MbedHelpers.hpp"
|
||||||
#include "Lazy.hpp"
|
#include "Lazy.hpp"
|
||||||
#include "Graphics/ImageFormats/ImageFormat.hpp"
|
#include "Mail/Smtp.hpp"
|
||||||
#include "Graphics/ImageFormats/Bitmap.hpp"
|
|
||||||
#include "Graphics/Renderers/ImageRenderer.hpp"
|
|
||||||
#include "Graphics/Renderers/Renderer.hpp"
|
|
||||||
#include "Graphics/Image.hpp"
|
|
||||||
#include "Graphics/Color.hpp"
|
|
||||||
#include "HiddenField.hpp"
|
#include "HiddenField.hpp"
|
||||||
@ -65,7 +65,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
{
|
{
|
||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
auto ctx = static_cast<mbedtls_sha1_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha1_context*>(this->inner);
|
||||||
if(mbedtls_sha1_starts_ret(ctx) != 0) return false;
|
mbedtls_sha1_starts(ctx);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -74,7 +74,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
{
|
{
|
||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
auto ctx = static_cast<mbedtls_sha1_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha1_context*>(this->inner);
|
||||||
if(mbedtls_sha1_update_ret(ctx,buffer,sz) != 0) return false;
|
mbedtls_sha1_update(ctx,buffer,sz);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -103,7 +103,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
auto ctx = static_cast<mbedtls_sha1_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha1_context*>(this->inner);
|
||||||
std::vector<uint8_t> hash;
|
std::vector<uint8_t> hash;
|
||||||
hash.resize(20);
|
hash.resize(20);
|
||||||
if(mbedtls_sha1_finish_ret(ctx,hash.data()) != 0) return {};
|
mbedtls_sha1_finish(ctx,hash.data());
|
||||||
return hash;
|
return hash;
|
||||||
#endif
|
#endif
|
||||||
return {};
|
return {};
|
||||||
@ -152,7 +152,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
auto ctx = static_cast<mbedtls_sha256_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha256_context*>(this->inner);
|
||||||
this->is224=is224;
|
this->is224=is224;
|
||||||
if(mbedtls_sha256_starts_ret(ctx,is224) != 0) return false;
|
mbedtls_sha256_starts(ctx,is224);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -166,7 +166,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
|
|
||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
auto ctx = static_cast<mbedtls_sha256_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha256_context*>(this->inner);
|
||||||
if(mbedtls_sha256_update_ret(ctx,buffer,sz) != 0) return false;
|
mbedtls_sha256_update(ctx,buffer,sz);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -195,7 +195,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
auto ctx = static_cast<mbedtls_sha256_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha256_context*>(this->inner);
|
||||||
std::vector<uint8_t> hash;
|
std::vector<uint8_t> hash;
|
||||||
hash.resize(32);
|
hash.resize(32);
|
||||||
if(mbedtls_sha256_finish_ret(ctx,hash.data()) != 0) return {};
|
mbedtls_sha256_finish(ctx,hash.data());
|
||||||
return hash;
|
return hash;
|
||||||
#endif
|
#endif
|
||||||
return {};
|
return {};
|
||||||
@ -243,7 +243,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
auto ctx = static_cast<mbedtls_sha512_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha512_context*>(this->inner);
|
||||||
this->is384=is384;
|
this->is384=is384;
|
||||||
if(mbedtls_sha512_starts_ret(ctx,is384) != 0) return false;
|
mbedtls_sha512_starts(ctx,is384);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -256,7 +256,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
{
|
{
|
||||||
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
#if defined(TESSESFRAMEWORK_ENABLE_MBED)
|
||||||
auto ctx = static_cast<mbedtls_sha512_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha512_context*>(this->inner);
|
||||||
if(mbedtls_sha512_update_ret(ctx,buffer,sz) != 0) return false;
|
mbedtls_sha512_update(ctx,buffer,sz);
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
@ -285,7 +285,7 @@ namespace Tesses::Framework::Crypto
|
|||||||
auto ctx = static_cast<mbedtls_sha512_context*>(this->inner);
|
auto ctx = static_cast<mbedtls_sha512_context*>(this->inner);
|
||||||
std::vector<uint8_t> hash;
|
std::vector<uint8_t> hash;
|
||||||
hash.resize(64);
|
hash.resize(64);
|
||||||
if(mbedtls_sha512_finish_ret(ctx,hash.data()) != 0) return {};
|
mbedtls_sha512_finish(ctx,hash.data());
|
||||||
return hash;
|
return hash;
|
||||||
#endif
|
#endif
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@ -1,432 +0,0 @@
|
|||||||
#include "TessesFramework/Graphics/Color.hpp"
|
|
||||||
#include "TessesFramework/Http/HttpUtils.hpp"
|
|
||||||
using HttpUtils = Tesses::Framework::Http::HttpUtils;
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
namespace Colors {
|
|
||||||
const Color AliceBlue(240,248,255);
|
|
||||||
const Color AntiqueWhite(250,235,215);
|
|
||||||
const Color Aqua(0,255,255);
|
|
||||||
const Color Aquamarine(127,255,212);
|
|
||||||
const Color Azure(240,255,255);
|
|
||||||
const Color Beige(245,245,220);
|
|
||||||
const Color Bisque(255,228,196);
|
|
||||||
const Color Black(0,0,0);
|
|
||||||
const Color BlanchedAlmond(255,235,205);
|
|
||||||
const Color Blue(0,0,255);
|
|
||||||
const Color BlueViolet(138,43,226);
|
|
||||||
const Color Brown(165,42,42);
|
|
||||||
const Color BurlyWood(222,184,135);
|
|
||||||
const Color CadetBlue(95,158,160);
|
|
||||||
const Color Chartreuse(127,255,0);
|
|
||||||
const Color Chocolate(210,105,30);
|
|
||||||
const Color Coral(255,127,80);
|
|
||||||
const Color CornflowerBlue(100,149,237);
|
|
||||||
const Color Cornsilk(255,248,220);
|
|
||||||
const Color Crimson(220,20,60);
|
|
||||||
const Color Cyan(0,255,255);
|
|
||||||
const Color DarkBlue(0,0,139);
|
|
||||||
const Color DarkCyan(0,139,139);
|
|
||||||
const Color DarkGoldenRod(184,134,11);
|
|
||||||
const Color DarkGray(169,169,169);
|
|
||||||
const Color DarkGrey(169,169,169);
|
|
||||||
const Color DarkGreen(0,100,0);
|
|
||||||
const Color DarkKhaki(189,183,107);
|
|
||||||
const Color DarkMagenta(139,0,139);
|
|
||||||
const Color DarkOliveGreen(85,107,47);
|
|
||||||
const Color DarkOrange(255,140,0);
|
|
||||||
const Color DarkOrchid(153,50,204);
|
|
||||||
const Color DarkRed(139,0,0);
|
|
||||||
const Color DarkSalmon(233,150,122);
|
|
||||||
const Color DarkSeaGreen(143,188,143);
|
|
||||||
const Color DarkSlateBlue(72,61,139);
|
|
||||||
const Color DarkSlateGray(47,79,79);
|
|
||||||
const Color DarkSlateGrey(47,79,79);
|
|
||||||
const Color DarkTurquoise(0,206,209);
|
|
||||||
const Color DarkViolet(148,0,211);
|
|
||||||
const Color DeepPink(255,20,147);
|
|
||||||
const Color DeepSkyBlue(0,191,255);
|
|
||||||
const Color DimGray(105,105,105);
|
|
||||||
const Color DimGrey(105,105,105);
|
|
||||||
const Color DodgerBlue(30,144,255);
|
|
||||||
const Color FireBrick(178,34,34);
|
|
||||||
const Color FloralWhite(255,250,240);
|
|
||||||
const Color ForestGreen(34,139,34);
|
|
||||||
const Color Fuchsia(255,0,255);
|
|
||||||
const Color Gainsboro(220,220,220);
|
|
||||||
const Color GhostWhite(248,248,255);
|
|
||||||
const Color Gold(255,215,0);
|
|
||||||
const Color GoldenRod(218,165,32);
|
|
||||||
const Color Gray(128,128,128);
|
|
||||||
const Color Grey(128,128,128);
|
|
||||||
const Color Green(0,128,0);
|
|
||||||
const Color GreenYellow(173,255,47);
|
|
||||||
const Color HoneyDew(240,255,240);
|
|
||||||
const Color HotPink(255,105,180);
|
|
||||||
const Color IndianRed(205,92,92);
|
|
||||||
const Color Indigo(75,0,130);
|
|
||||||
const Color Ivory(255,255,240);
|
|
||||||
const Color Khaki(240,230,140);
|
|
||||||
const Color Lavender(230,230,250);
|
|
||||||
const Color LavenderBlush(255,240,245);
|
|
||||||
const Color LawnGreen(124,252,0);
|
|
||||||
const Color LemonChiffon(255,250,205);
|
|
||||||
const Color LightBlue(173,216,230);
|
|
||||||
const Color LightCoral(240,128,128);
|
|
||||||
const Color LightCyan(224,255,255);
|
|
||||||
const Color LightGoldenRodYellow(250,250,210);
|
|
||||||
const Color LightGray(211,211,211);
|
|
||||||
const Color LightGrey(211,211,211);
|
|
||||||
const Color LightGreen(144,238,144);
|
|
||||||
const Color LightPink(255,182,193);
|
|
||||||
const Color LightSalmon(255,160,122);
|
|
||||||
const Color LightSeaGreen(32,178,170);
|
|
||||||
const Color LightSkyBlue(135,206,250);
|
|
||||||
const Color LightSlateGray(119,136,153);
|
|
||||||
const Color LightSlateGrey(119,136,153);
|
|
||||||
const Color LightSteelBlue(176,196,222);
|
|
||||||
const Color LightYellow(255,255,224);
|
|
||||||
const Color Lime(0,255,0);
|
|
||||||
const Color LimeGreen(50,205,50);
|
|
||||||
const Color Linen(250,240,230);
|
|
||||||
const Color Magenta(255,0,255);
|
|
||||||
const Color Maroon(128,0,0);
|
|
||||||
const Color MediumAquaMarine(102,205,170);
|
|
||||||
const Color MediumBlue(0,0,205);
|
|
||||||
const Color MediumOrchid(186,85,211);
|
|
||||||
const Color MediumPurple(147,112,219);
|
|
||||||
const Color MediumSeaGreen(60,179,113);
|
|
||||||
const Color MediumSlateBlue(123,104,238);
|
|
||||||
const Color MediumSpringGreen(0,250,154);
|
|
||||||
const Color MediumTurquoise(72,209,204);
|
|
||||||
const Color MediumVioletRed(199,21,133);
|
|
||||||
const Color MidnightBlue(25,25,112);
|
|
||||||
const Color MintCream(245,255,250);
|
|
||||||
const Color MistyRose(255,228,225);
|
|
||||||
const Color Moccasin(255,228,181);
|
|
||||||
const Color NavajoWhite(255,222,173);
|
|
||||||
const Color Navy(0,0,128);
|
|
||||||
const Color OldLace(253,245,230);
|
|
||||||
const Color Olive(128,128,0);
|
|
||||||
const Color OliveDrab(107,142,35);
|
|
||||||
const Color Orange(255,165,0);
|
|
||||||
const Color OrangeRed(255,69,0);
|
|
||||||
const Color Orchid(218,112,214);
|
|
||||||
const Color PaleGoldenRod(238,232,170);
|
|
||||||
const Color PaleGreen(152,251,152);
|
|
||||||
const Color PaleTurquoise(175,238,238);
|
|
||||||
const Color PaleVioletRed(219,112,147);
|
|
||||||
const Color PapayaWhip(255,239,213);
|
|
||||||
const Color PeachPuff(255,218,185);
|
|
||||||
const Color Peru(205,133,63);
|
|
||||||
const Color Pink(255,192,203);
|
|
||||||
const Color Plum(221,160,221);
|
|
||||||
const Color PowderBlue(176,224,230);
|
|
||||||
const Color Purple(128,0,128);
|
|
||||||
const Color RebeccaPurple(102,51,153);
|
|
||||||
const Color Red(255,0,0);
|
|
||||||
const Color RosyBrown(188,143,143);
|
|
||||||
const Color SaddleBrown(139,69,19);
|
|
||||||
const Color Salmon(250,128,114);
|
|
||||||
const Color SandyBrown(244,164,96);
|
|
||||||
const Color SeaGreen(46,139,87);
|
|
||||||
const Color SeaShell(255,245,238);
|
|
||||||
const Color Sienna(160,82,45);
|
|
||||||
const Color Silver(192,192,192);
|
|
||||||
const Color SkyBlue(135,206,235);
|
|
||||||
const Color SlateBlue(106,90,205);
|
|
||||||
const Color SlateGray(112,128,144);
|
|
||||||
const Color SlateGrey(112,128,144);
|
|
||||||
const Color Snow(255,250,250);
|
|
||||||
const Color SpringGreen(0,255,127);
|
|
||||||
const Color SteelBlue(70,130,180);
|
|
||||||
const Color Tan(210,180,140);
|
|
||||||
const Color Teal(0,128,128);
|
|
||||||
const Color Thistle(216,191,216);
|
|
||||||
const Color Tomato(255,99,71);
|
|
||||||
const Color Turquoise(64,224,208);
|
|
||||||
const Color Violet(238,130,238);
|
|
||||||
const Color Wheat(245,222,179);
|
|
||||||
const Color White(255,255,255);
|
|
||||||
const Color WhiteSmoke(245,245,245);
|
|
||||||
const Color Yellow(255,255,0);
|
|
||||||
const Color YellowGreen(154,205,50);
|
|
||||||
}
|
|
||||||
Color::Color()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Color::Color(uint8_t r, uint8_t g, uint8_t b) : Color(r,g,b,255)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
|
||||||
{
|
|
||||||
this->Red = r;
|
|
||||||
this->Green = g;
|
|
||||||
this->Blue = b;
|
|
||||||
this->Alpha = a;
|
|
||||||
}
|
|
||||||
Color::Color(Color c, uint8_t a) : Color(c.Red,c.Green,c.Blue,a)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Color::Color(uint8_t* color_data) : Color(color_data[0],color_data[1],color_data[2],color_data[3])
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Color::ToString(bool alphaIf255)
|
|
||||||
{
|
|
||||||
std::string str={
|
|
||||||
'#',
|
|
||||||
HttpUtils::NibbleToHex((Red >> 4) & 0x0F),
|
|
||||||
HttpUtils::NibbleToHex(Red & 0x0F),
|
|
||||||
HttpUtils::NibbleToHex((Green >> 4) & 0x0F),
|
|
||||||
HttpUtils::NibbleToHex(Green & 0x0F),
|
|
||||||
HttpUtils::NibbleToHex((Blue >> 4) & 0x0F),
|
|
||||||
HttpUtils::NibbleToHex(Blue & 0x0F)
|
|
||||||
};
|
|
||||||
if(alphaIf255 || this->Alpha < 255)
|
|
||||||
{
|
|
||||||
str.push_back(HttpUtils::NibbleToHex((Blue >> 4) & 0x0F));
|
|
||||||
str.push_back(HttpUtils::NibbleToHex(Blue & 0x0F));
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Color::ToArray(uint8_t* color_data)
|
|
||||||
{
|
|
||||||
color_data[0] = Red;
|
|
||||||
color_data[1] = Green;
|
|
||||||
color_data[2] = Blue;
|
|
||||||
color_data[3] = Alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Color::TryParse(std::string color, Color& col)
|
|
||||||
{
|
|
||||||
color = HttpUtils::ToLower(color);
|
|
||||||
|
|
||||||
|
|
||||||
if(color.size() < 1) return false;
|
|
||||||
else if(color[0] != '#') {
|
|
||||||
if(color == "aliceblue") {col = Colors::AliceBlue; return true;}
|
|
||||||
else if(color == "antiquewhite") {col = Colors::AntiqueWhite; return true;}
|
|
||||||
else if(color == "aqua") {col = Colors::Aqua; return true;}
|
|
||||||
else if(color == "aquamarine") {col = Colors::Aquamarine; return true;}
|
|
||||||
else if(color == "azure"){ col = Colors::Azure; return true; }
|
|
||||||
else if(color == "beige"){ col = Colors::Beige; return true; }
|
|
||||||
else if(color == "bisque"){ col = Colors::Bisque; return true; }
|
|
||||||
else if(color == "black"){ col = Colors::Black; return true; }
|
|
||||||
else if(color == "blanchedalmond"){ col = Colors::BlanchedAlmond; return true; }
|
|
||||||
else if(color == "blue"){ col = Colors::Blue; return true; }
|
|
||||||
else if(color == "blueviolet"){ col = Colors::BlueViolet; return true; }
|
|
||||||
else if(color == "brown"){ col = Colors::Brown; return true; }
|
|
||||||
else if(color == "burlywood"){ col = Colors::BurlyWood; return true; }
|
|
||||||
else if(color == "cadetblue"){ col = Colors::CadetBlue; return true; }
|
|
||||||
else if(color == "chartreuse"){ col = Colors::Chartreuse; return true; }
|
|
||||||
else if(color == "chocolate"){ col = Colors::Chocolate; return true; }
|
|
||||||
else if(color == "coral"){ col = Colors::Coral; return true; }
|
|
||||||
else if(color == "cornflowerblue"){ col = Colors::CornflowerBlue; return true; }
|
|
||||||
else if(color == "cornsilk"){ col = Colors::Cornsilk; return true; }
|
|
||||||
else if(color == "crimson"){ col = Colors::Crimson; return true; }
|
|
||||||
else if(color == "cyan"){ col = Colors::Cyan; return true; }
|
|
||||||
else if(color == "darkblue"){ col = Colors::DarkBlue; return true; }
|
|
||||||
else if(color == "darkcyan"){ col = Colors::DarkCyan; return true; }
|
|
||||||
else if(color == "darkgoldenrod"){ col = Colors::DarkGoldenRod; return true; }
|
|
||||||
else if(color == "darkgray"){ col = Colors::DarkGray; return true; }
|
|
||||||
else if(color == "darkgrey"){ col = Colors::DarkGrey; return true; }
|
|
||||||
else if(color == "darkgreen"){ col = Colors::DarkGreen; return true; }
|
|
||||||
else if(color == "darkkhaki"){ col = Colors::DarkKhaki; return true; }
|
|
||||||
else if(color == "darkmagenta"){ col = Colors::DarkMagenta; return true; }
|
|
||||||
else if(color == "darkolivegreen"){ col = Colors::DarkOliveGreen; return true; }
|
|
||||||
else if(color == "darkorange"){ col = Colors::DarkOrange; return true; }
|
|
||||||
else if(color == "darkorchid"){ col = Colors::DarkOrchid; return true; }
|
|
||||||
else if(color == "darkred"){ col = Colors::DarkRed; return true; }
|
|
||||||
else if(color == "darksalmon"){ col = Colors::DarkSalmon; return true; }
|
|
||||||
else if(color == "darkseagreen"){ col = Colors::DarkSeaGreen; return true; }
|
|
||||||
else if(color == "darkslateblue"){ col = Colors::DarkSlateBlue; return true; }
|
|
||||||
else if(color == "darkslategray"){ col = Colors::DarkSlateGray; return true; }
|
|
||||||
else if(color == "darkslategrey"){ col = Colors::DarkSlateGrey; return true; }
|
|
||||||
else if(color == "darkturquoise"){ col = Colors::DarkTurquoise; return true; }
|
|
||||||
else if(color == "darkviolet"){ col = Colors::DarkViolet; return true; }
|
|
||||||
else if(color == "deeppink"){ col = Colors::DeepPink; return true; }
|
|
||||||
else if(color == "deepskyblue"){ col = Colors::DeepSkyBlue; return true; }
|
|
||||||
else if(color == "dimgray"){ col = Colors::DimGray; return true; }
|
|
||||||
else if(color == "dimgrey"){ col = Colors::DimGrey; return true; }
|
|
||||||
else if(color == "dodgerblue"){ col = Colors::DodgerBlue; return true; }
|
|
||||||
else if(color == "firebrick"){ col = Colors::FireBrick; return true; }
|
|
||||||
else if(color == "floralwhite"){ col = Colors::FloralWhite; return true; }
|
|
||||||
else if(color == "forestgreen"){ col = Colors::ForestGreen; return true; }
|
|
||||||
else if(color == "fuchsia"){ col = Colors::Fuchsia; return true; }
|
|
||||||
else if(color == "gainsboro"){ col = Colors::Gainsboro; return true; }
|
|
||||||
else if(color == "ghostwhite"){ col = Colors::GhostWhite; return true; }
|
|
||||||
else if(color == "gold"){ col = Colors::Gold; return true; }
|
|
||||||
else if(color == "goldenrod"){ col = Colors::GoldenRod; return true; }
|
|
||||||
else if(color == "gray"){ col = Colors::Gray; return true; }
|
|
||||||
else if(color == "grey"){ col = Colors::Grey; return true; }
|
|
||||||
else if(color == "green"){ col = Colors::Green; return true; }
|
|
||||||
else if(color == "greenyellow"){ col = Colors::GreenYellow; return true; }
|
|
||||||
else if(color == "honeydew"){ col = Colors::HoneyDew; return true; }
|
|
||||||
else if(color == "hotpink"){ col = Colors::HotPink; return true; }
|
|
||||||
else if(color == "indianred"){ col = Colors::IndianRed; return true; }
|
|
||||||
else if(color == "indigo"){ col = Colors::Indigo; return true; }
|
|
||||||
else if(color == "ivory"){ col = Colors::Ivory; return true; }
|
|
||||||
else if(color == "khaki"){ col = Colors::Khaki; return true; }
|
|
||||||
else if(color == "lavender"){ col = Colors::Lavender; return true; }
|
|
||||||
else if(color == "lavenderblush"){ col = Colors::LavenderBlush; return true; }
|
|
||||||
else if(color == "lawngreen"){ col = Colors::LawnGreen; return true; }
|
|
||||||
else if(color == "lemonchiffon"){ col = Colors::LemonChiffon; return true; }
|
|
||||||
else if(color == "lightblue"){ col = Colors::LightBlue; return true; }
|
|
||||||
else if(color == "lightcoral"){ col = Colors::LightCoral; return true; }
|
|
||||||
else if(color == "lightcyan"){ col = Colors::LightCyan; return true; }
|
|
||||||
else if(color == "lightgoldenrodyellow"){ col = Colors::LightGoldenRodYellow; return true; }
|
|
||||||
else if(color == "lightgray"){ col = Colors::LightGray; return true; }
|
|
||||||
else if(color == "lightgrey"){ col = Colors::LightGrey; return true; }
|
|
||||||
else if(color == "lightgreen"){ col = Colors::LightGreen; return true; }
|
|
||||||
else if(color == "lightpink"){ col = Colors::LightPink; return true; }
|
|
||||||
else if(color == "lightsalmon"){ col = Colors::LightSalmon; return true; }
|
|
||||||
else if(color == "lightseagreen"){ col = Colors::LightSeaGreen; return true; }
|
|
||||||
else if(color == "lightskyblue"){ col = Colors::LightSkyBlue; return true; }
|
|
||||||
else if(color == "lightslategray"){ col = Colors::LightSlateGray; return true; }
|
|
||||||
else if(color == "lightslategrey"){ col = Colors::LightSlateGrey; return true; }
|
|
||||||
else if(color == "lightsteelblue"){ col = Colors::LightSteelBlue; return true; }
|
|
||||||
else if(color == "lightyellow"){ col = Colors::LightYellow; return true; }
|
|
||||||
else if(color == "lime"){ col = Colors::Lime; return true; }
|
|
||||||
else if(color == "limegreen"){ col = Colors::LimeGreen; return true; }
|
|
||||||
else if(color == "linen"){ col = Colors::Linen; return true; }
|
|
||||||
else if(color == "magenta"){ col = Colors::Magenta; return true; }
|
|
||||||
else if(color == "maroon"){ col = Colors::Maroon; return true; }
|
|
||||||
else if(color == "mediumaquamarine"){ col = Colors::MediumAquaMarine; return true; }
|
|
||||||
else if(color == "mediumblue"){ col = Colors::MediumBlue; return true; }
|
|
||||||
else if(color == "mediumorchid"){ col = Colors::MediumOrchid; return true; }
|
|
||||||
else if(color == "mediumpurple"){ col = Colors::MediumPurple; return true; }
|
|
||||||
else if(color == "mediumseagreen"){ col = Colors::MediumSeaGreen; return true; }
|
|
||||||
else if(color == "mediumslateblue"){ col = Colors::MediumSlateBlue; return true; }
|
|
||||||
else if(color == "mediumspringgreen"){ col = Colors::MediumSpringGreen; return true; }
|
|
||||||
else if(color == "mediumturquoise"){ col = Colors::MediumTurquoise; return true; }
|
|
||||||
else if(color == "mediumvioletred"){ col = Colors::MediumVioletRed; return true; }
|
|
||||||
else if(color == "midnightblue"){ col = Colors::MidnightBlue; return true; }
|
|
||||||
else if(color == "mintcream"){ col = Colors::MintCream; return true; }
|
|
||||||
else if(color == "mistyrose"){ col = Colors::MistyRose; return true; }
|
|
||||||
else if(color == "moccasin"){ col = Colors::Moccasin; return true; }
|
|
||||||
else if(color == "navajowhite"){ col = Colors::NavajoWhite; return true; }
|
|
||||||
else if(color == "navy"){ col = Colors::Navy; return true; }
|
|
||||||
else if(color == "oldlace"){ col = Colors::OldLace; return true; }
|
|
||||||
else if(color == "olive"){ col = Colors::Olive; return true; }
|
|
||||||
else if(color == "olivedrab"){ col = Colors::OliveDrab; return true; }
|
|
||||||
else if(color == "orange"){ col = Colors::Orange; return true; }
|
|
||||||
else if(color == "orangered"){ col = Colors::OrangeRed; return true; }
|
|
||||||
else if(color == "orchid"){ col = Colors::Orchid; return true; }
|
|
||||||
else if(color == "palegoldenrod"){ col = Colors::PaleGoldenRod; return true; }
|
|
||||||
else if(color == "palegreen"){ col = Colors::PaleGreen; return true; }
|
|
||||||
else if(color == "paleturquoise"){ col = Colors::PaleTurquoise; return true; }
|
|
||||||
else if(color == "palevioletred"){ col = Colors::PaleVioletRed; return true; }
|
|
||||||
else if(color == "papayawhip"){ col = Colors::PapayaWhip; return true; }
|
|
||||||
else if(color == "peachpuff"){ col = Colors::PeachPuff; return true; }
|
|
||||||
else if(color == "peru"){ col = Colors::Peru; return true; }
|
|
||||||
else if(color == "pink"){ col = Colors::Pink; return true; }
|
|
||||||
else if(color == "plum"){ col = Colors::Plum; return true; }
|
|
||||||
else if(color == "powderblue"){ col = Colors::PowderBlue; return true; }
|
|
||||||
else if(color == "purple"){ col = Colors::Purple; return true; }
|
|
||||||
else if(color == "rebeccapurple"){ col = Colors::RebeccaPurple; return true; }
|
|
||||||
else if(color == "red"){ col = Colors::Red; return true; }
|
|
||||||
else if(color == "rosybrown"){ col = Colors::RosyBrown; return true; }
|
|
||||||
else if(color == "saddlebrown"){ col = Colors::SaddleBrown; return true; }
|
|
||||||
else if(color == "salmon"){ col = Colors::Salmon; return true; }
|
|
||||||
else if(color == "sandybrown"){ col = Colors::SandyBrown; return true; }
|
|
||||||
else if(color == "seagreen"){ col = Colors::SeaGreen; return true; }
|
|
||||||
else if(color == "seashell"){ col = Colors::SeaShell; return true; }
|
|
||||||
else if(color == "sienna"){ col = Colors::Sienna; return true; }
|
|
||||||
else if(color == "silver"){ col = Colors::Silver; return true; }
|
|
||||||
else if(color == "skyblue"){ col = Colors::SkyBlue; return true; }
|
|
||||||
else if(color == "slateblue"){ col = Colors::SlateBlue; return true; }
|
|
||||||
else if(color == "slategray"){ col = Colors::SlateGray; return true; }
|
|
||||||
else if(color == "slategrey"){ col = Colors::SlateGrey; return true; }
|
|
||||||
else if(color == "snow"){ col = Colors::Snow; return true; }
|
|
||||||
else if(color == "springgreen"){ col = Colors::SpringGreen; return true; }
|
|
||||||
else if(color == "steelblue"){ col = Colors::SteelBlue; return true; }
|
|
||||||
else if(color == "tan"){ col = Colors::Tan; return true; }
|
|
||||||
else if(color == "teal"){ col = Colors::Teal; return true; }
|
|
||||||
else if(color == "thistle"){ col = Colors::Thistle; return true; }
|
|
||||||
else if(color == "tomato"){ col = Colors::Tomato; return true; }
|
|
||||||
else if(color == "turquoise"){ col = Colors::Turquoise; return true; }
|
|
||||||
else if(color == "violet"){ col = Colors::Violet; return true; }
|
|
||||||
else if(color == "wheat"){ col = Colors::Wheat; return true; }
|
|
||||||
else if(color == "white"){ col = Colors::White; return true; }
|
|
||||||
else if(color == "whitesmoke"){ col = Colors::WhiteSmoke; return true; }
|
|
||||||
else if(color == "yellow"){ col = Colors::Yellow; return true; }
|
|
||||||
else if(color == "yellowgreen"){ col = Colors::YellowGreen; return true; }
|
|
||||||
}
|
|
||||||
else if(color.size() == 4)
|
|
||||||
{
|
|
||||||
for(size_t i = 1; i < 4; i++)
|
|
||||||
if((color[i] < 'a' || color[i] > 'f') && (color[i] < '0' || color[i] > '9')) return false;
|
|
||||||
uint8_t r = HttpUtils::HexToNibble(color[1]);
|
|
||||||
uint8_t g = HttpUtils::HexToNibble(color[2]);
|
|
||||||
uint8_t b = HttpUtils::HexToNibble(color[3]);
|
|
||||||
col.Red = r | r << 4;
|
|
||||||
col.Green = g | g << 4;
|
|
||||||
col.Blue = b | b << 4;
|
|
||||||
col.Alpha = 255;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(color.size() == 5)
|
|
||||||
{
|
|
||||||
for(size_t i = 1; i < 5; i++)
|
|
||||||
if((color[i] < 'a' || color[i] > 'f') && (color[i] < '0' || color[i] > '9')) return false;
|
|
||||||
uint8_t r = HttpUtils::HexToNibble(color[1]);
|
|
||||||
uint8_t g = HttpUtils::HexToNibble(color[2]);
|
|
||||||
uint8_t b = HttpUtils::HexToNibble(color[3]);
|
|
||||||
uint8_t a = HttpUtils::HexToNibble(color[4]);
|
|
||||||
col.Red = r | r << 4;
|
|
||||||
col.Green = g | g << 4;
|
|
||||||
col.Blue = b | b << 4;
|
|
||||||
col.Alpha = a | a << 4;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(color.size() == 7)
|
|
||||||
{
|
|
||||||
for(size_t i = 1; i < 7; i++)
|
|
||||||
if((color[i] < 'a' || color[i] > 'f') && (color[i] < '0' || color[i] > '9')) return false;
|
|
||||||
uint8_t r = (HttpUtils::HexToNibble(color[1]) << 4) | HttpUtils::HexToNibble(color[2]);
|
|
||||||
uint8_t g = (HttpUtils::HexToNibble(color[3]) << 4) | HttpUtils::HexToNibble(color[4]);
|
|
||||||
uint8_t b = (HttpUtils::HexToNibble(color[5]) << 4) | HttpUtils::HexToNibble(color[6]);
|
|
||||||
col.Red = r;
|
|
||||||
col.Green = g;
|
|
||||||
col.Blue = b;
|
|
||||||
col.Alpha = 255;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if(color.size() == 9)
|
|
||||||
{
|
|
||||||
for(size_t i = 1; i < 9; i++)
|
|
||||||
if((color[i] < 'a' || color[i] > 'f') && (color[i] < '0' || color[i] > '9')) return false;
|
|
||||||
uint8_t r = (HttpUtils::HexToNibble(color[1]) << 4) | HttpUtils::HexToNibble(color[2]);
|
|
||||||
uint8_t g = (HttpUtils::HexToNibble(color[3]) << 4) | HttpUtils::HexToNibble(color[4]);
|
|
||||||
uint8_t b = (HttpUtils::HexToNibble(color[5]) << 4) | HttpUtils::HexToNibble(color[6]);
|
|
||||||
uint8_t a = (HttpUtils::HexToNibble(color[7]) << 4) | HttpUtils::HexToNibble(color[8]);
|
|
||||||
|
|
||||||
col.Red = r;
|
|
||||||
col.Green = g;
|
|
||||||
col.Blue = b;
|
|
||||||
col.Alpha = a;
|
|
||||||
return true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color Color::Parse(std::string color)
|
|
||||||
{
|
|
||||||
Color c;
|
|
||||||
if(Color::TryParse(color,c)) return c;
|
|
||||||
throw TextException("Could not parse color");
|
|
||||||
}
|
|
||||||
bool Color::operator!=(Color other)
|
|
||||||
{
|
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
bool Color::operator==(Color other)
|
|
||||||
{
|
|
||||||
return Red == other.Red && Green == other.Green && Blue == other.Blue && Alpha == other.Alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
#include "TessesFramework/Graphics/Image.hpp"
|
|
||||||
|
|
||||||
namespace Tesses::Framework::Graphics {
|
|
||||||
|
|
||||||
Image::Image()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Image::Image(uint32_t w, uint32_t h)
|
|
||||||
{
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
SetSize(w,h);
|
|
||||||
}
|
|
||||||
Image::Image(uint32_t w,uint32_t h,std::vector<Color> data)
|
|
||||||
{
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
this->data = data;
|
|
||||||
if(this->data.size() != w * h) throw TextException("data size does not match the factor of width and height");
|
|
||||||
}
|
|
||||||
uint32_t Image::Width()
|
|
||||||
{
|
|
||||||
return this->w;
|
|
||||||
}
|
|
||||||
uint32_t Image::Height()
|
|
||||||
{
|
|
||||||
return this->h;
|
|
||||||
}
|
|
||||||
void Image::SetSize(uint32_t w, uint32_t h)
|
|
||||||
{
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
this->data.resize(w * h);
|
|
||||||
}
|
|
||||||
void Image::SetSize(uint32_t w, uint32_t h, Color c)
|
|
||||||
{
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
this->data.resize(w * h);
|
|
||||||
for(size_t i = 0; i < this->data.size(); i++) this->data[i] = c;
|
|
||||||
}
|
|
||||||
void Image::SetPixel(uint32_t x, uint32_t y, Color c)
|
|
||||||
{
|
|
||||||
this->data[y*w+x] = c;
|
|
||||||
}
|
|
||||||
Color Image::GetPixel(uint32_t x, uint32_t y)
|
|
||||||
{
|
|
||||||
return this->data[y*w+x];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Color>& Image::Data()
|
|
||||||
{
|
|
||||||
return this->data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,201 +0,0 @@
|
|||||||
#include "TessesFramework/Graphics/ImageFormats/Bitmap.hpp"
|
|
||||||
#include "TessesFramework/Streams/ByteWriter.hpp"
|
|
||||||
#include "TessesFramework/Streams/MemoryStream.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
namespace Tesses::Framework::Graphics::ImageFormats {
|
|
||||||
Bitmap::Bitmap()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void Bitmap::Load(Tesses::Framework::Streams::Stream* strm, Image* image)
|
|
||||||
{
|
|
||||||
uint8_t header[14];
|
|
||||||
if(strm->ReadBlock(header,14) < 14) throw TextException("Invalid bmp file, header to small.");
|
|
||||||
if(header[0] != 0x42 || header[1] != 0x4D) throw TextException("Invalid bmp file, does not start with BM.");
|
|
||||||
uint8_t info_header[40];
|
|
||||||
if(strm->ReadBlock(info_header,40) < 40) throw TextException("Invalid bmp file, info header is too small.");
|
|
||||||
if(info_header[0] != 40 || info_header[1] != 0 || info_header[2] != 0 || info_header[3] != 0) throw TextException("Invald bmp file, info header size is corrupt.");
|
|
||||||
uint32_t width = 0;
|
|
||||||
width |= (uint32_t)info_header[4];
|
|
||||||
width |= (uint32_t)info_header[5] << 8;
|
|
||||||
width |= (uint32_t)info_header[6] << 16;
|
|
||||||
width |= (uint32_t)info_header[7] << 24;
|
|
||||||
uint32_t height = 0;
|
|
||||||
height |= (uint32_t)info_header[8];
|
|
||||||
height |= (uint32_t)info_header[9] << 8;
|
|
||||||
height |= (uint32_t)info_header[10] << 16;
|
|
||||||
height |= (uint32_t)info_header[11] << 24;
|
|
||||||
|
|
||||||
int32_t h0= *(int32_t*)&height;
|
|
||||||
bool isInverted=h0 < 0;
|
|
||||||
if(isInverted) height = (uint32_t)(-h0);
|
|
||||||
|
|
||||||
image->SetSize(width,height);
|
|
||||||
uint16_t planes = 0;
|
|
||||||
planes |= (uint16_t)info_header[12];
|
|
||||||
planes |= (uint16_t)info_header[13] << 8;
|
|
||||||
if(planes != 1) throw TextException("Planes is not 1");
|
|
||||||
uint16_t bpp = 0;
|
|
||||||
bpp |= (uint16_t)info_header[14];
|
|
||||||
bpp |= (uint16_t)info_header[15] << 8;
|
|
||||||
uint32_t compression = 0;
|
|
||||||
compression |= (uint32_t)info_header[16];
|
|
||||||
compression |= (uint32_t)info_header[17] << 8;
|
|
||||||
compression |= (uint32_t)info_header[18] << 16;
|
|
||||||
compression |= (uint32_t)info_header[19] << 24;
|
|
||||||
|
|
||||||
if(compression != 0) throw TextException("This bmp decoder does not support compression");
|
|
||||||
uint32_t imageSize = 0;
|
|
||||||
imageSize |= (uint32_t)info_header[20];
|
|
||||||
imageSize |= (uint32_t)info_header[21] << 8;
|
|
||||||
imageSize |= (uint32_t)info_header[22] << 16;
|
|
||||||
imageSize |= (uint32_t)info_header[23] << 24;
|
|
||||||
|
|
||||||
uint32_t colorsUsed = 0;
|
|
||||||
colorsUsed |= (uint32_t)info_header[32];
|
|
||||||
colorsUsed |= (uint32_t)info_header[33] << 8;
|
|
||||||
colorsUsed |= (uint32_t)info_header[34] << 16;
|
|
||||||
colorsUsed |= (uint32_t)info_header[35] << 24;
|
|
||||||
|
|
||||||
std::vector<Color> col={};
|
|
||||||
|
|
||||||
if(colorsUsed > 0)
|
|
||||||
{
|
|
||||||
col.resize(colorsUsed);
|
|
||||||
uint8_t* buff = new uint8_t[colorsUsed*4];
|
|
||||||
if(strm->ReadBlock(buff,colorsUsed*4) != colorsUsed*4) { delete buff; throw TextException("Could not read colors");}
|
|
||||||
for(size_t i = 0; i < colorsUsed; i++)
|
|
||||||
{
|
|
||||||
col[i].Red = buff[i * 4 + 2];
|
|
||||||
col[i].Green = buff[i * 4 + 1];
|
|
||||||
col[i].Blue = buff[i * 4];
|
|
||||||
col[i].Alpha = 255;
|
|
||||||
}
|
|
||||||
delete buff;
|
|
||||||
}
|
|
||||||
std::vector<Color>& pixel_out = image->Data();
|
|
||||||
if(bpp == 24)
|
|
||||||
{
|
|
||||||
uint32_t stride = 3 * width;
|
|
||||||
uint32_t m = stride % 4;
|
|
||||||
if(m != 0) stride += 4 - (m % 4);
|
|
||||||
|
|
||||||
uint8_t* buffer = new uint8_t[stride];
|
|
||||||
for(uint32_t y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint32_t yOut = isInverted ? y : ((height - y)-1);
|
|
||||||
if(strm->ReadBlock(buffer,stride) != stride)
|
|
||||||
{
|
|
||||||
delete buffer;
|
|
||||||
throw TextException("Bmp image data is truncated");
|
|
||||||
}
|
|
||||||
for(uint32_t x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
pixel_out[yOut * width + x].Red = buffer[x*3+2];
|
|
||||||
pixel_out[yOut * width + x].Green = buffer[x*3+1];
|
|
||||||
pixel_out[yOut * width + x].Blue = buffer[x*3];
|
|
||||||
pixel_out[yOut * width + x].Alpha=255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete buffer;
|
|
||||||
}
|
|
||||||
else if(bpp == 16)
|
|
||||||
{
|
|
||||||
uint32_t stride = 2 * width;
|
|
||||||
uint32_t m = stride % 4;
|
|
||||||
if(m != 0) stride += 4 - (m % 4);
|
|
||||||
|
|
||||||
uint8_t* buffer = new uint8_t[stride];
|
|
||||||
for(uint32_t y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
uint32_t yOut =isInverted ? y : ((height - y)-1);
|
|
||||||
if(strm->ReadBlock(buffer,stride) != stride)
|
|
||||||
{
|
|
||||||
delete buffer;
|
|
||||||
throw TextException("Bmp image data is truncated");
|
|
||||||
}
|
|
||||||
for(uint32_t x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
uint16_t px = (uint16_t)(buffer[x*2+1] << 8) | (uint16_t)buffer[x*2];
|
|
||||||
uint16_t red = (px & 0xF800) >> 11;
|
|
||||||
uint16_t green = (px & 0x07E0) >> 5;
|
|
||||||
uint16_t blue = (px & 0x001F);
|
|
||||||
red = (red * 255 + 15) / 31;
|
|
||||||
green = (green * 255 + 31) / 63;
|
|
||||||
blue = (blue * 255 + 15) / 31;
|
|
||||||
pixel_out[yOut * width + x].Red = red;
|
|
||||||
pixel_out[yOut * width + x].Green = green;
|
|
||||||
pixel_out[yOut * width + x].Blue = blue;
|
|
||||||
pixel_out[yOut * width + x].Alpha=255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete buffer;
|
|
||||||
}
|
|
||||||
else if(bpp == 8)
|
|
||||||
{
|
|
||||||
uint32_t stride = width;
|
|
||||||
|
|
||||||
uint8_t* buffer = new uint8_t[stride];
|
|
||||||
for(uint32_t y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
uint32_t yOut =isInverted ? y : ((height - y)-1);
|
|
||||||
if(strm->ReadBlock(buffer,stride) != stride)
|
|
||||||
{
|
|
||||||
delete buffer;
|
|
||||||
throw TextException("Bmp image data is truncated");
|
|
||||||
}
|
|
||||||
for(uint32_t x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
pixel_out[yOut * width + x] = col.at (buffer[x]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete buffer;
|
|
||||||
}
|
|
||||||
else throw TextException("Bitdepth " + std::to_string(bpp) + "bpp is not supported yet.");
|
|
||||||
}
|
|
||||||
void Bitmap::Save(Tesses::Framework::Streams::Stream* strm, Image* image,std::string flags)
|
|
||||||
{
|
|
||||||
Tesses::Framework::Streams::MemoryStream memStrm(true);
|
|
||||||
Tesses::Framework::Streams::ByteWriter writer(memStrm);
|
|
||||||
uint32_t stride = image->Width() * 3;
|
|
||||||
uint32_t m = stride % 4;
|
|
||||||
if(m != 0) stride += 4 - (m % 4);
|
|
||||||
uint32_t sz = (stride * image->Height())+14+40;
|
|
||||||
memStrm.WriteBlock((const uint8_t*)"BM",2);
|
|
||||||
|
|
||||||
writer.WriteU32LE(sz);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
writer.WriteU32LE(14+40);
|
|
||||||
writer.WriteU32LE(40);
|
|
||||||
writer.WriteU32LE(image->Width());
|
|
||||||
writer.WriteU32LE(image->Height());
|
|
||||||
writer.WriteU16LE(1);
|
|
||||||
writer.WriteU16LE(24);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
writer.WriteU32LE(0);
|
|
||||||
memStrm.Seek(0,Tesses::Framework::Streams::SeekOrigin::Begin);
|
|
||||||
memStrm.CopyTo(strm);
|
|
||||||
uint8_t* buffer = new uint8_t[stride];
|
|
||||||
memset(buffer,0,stride);
|
|
||||||
auto width = image->Width();
|
|
||||||
auto height = image->Height();
|
|
||||||
for(uint32_t y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint32_t yOut = (height - y)-1;
|
|
||||||
for(uint32_t x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
auto c = image->GetPixel(x,yOut);
|
|
||||||
buffer[x*3+2] = c.Red;
|
|
||||||
buffer[x*3+1] = c.Green;
|
|
||||||
buffer[x*3] = c.Blue;
|
|
||||||
}
|
|
||||||
strm->WriteBlock(buffer,stride);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#include "TessesFramework/Graphics/ImageFormats/ImageFormat.hpp"
|
|
||||||
|
|
||||||
namespace Tesses::Framework::Graphics::ImageFormats
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
ImageFormat::~ImageFormat()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "TessesFramework/Graphics/Renderers/ImageRenderer.hpp"
|
|
||||||
|
|
||||||
namespace Tesses::Framework::Graphics::Renderers {
|
|
||||||
|
|
||||||
|
|
||||||
ImageRenderer::ImageRenderer(Image* image)
|
|
||||||
{
|
|
||||||
this->image = image;
|
|
||||||
}
|
|
||||||
uint32_t ImageRenderer::Width()
|
|
||||||
{
|
|
||||||
return this->image->Width();
|
|
||||||
}
|
|
||||||
uint32_t ImageRenderer::Height()
|
|
||||||
{
|
|
||||||
return this->image->Height();
|
|
||||||
}
|
|
||||||
void ImageRenderer::SetPixel(Point pt,Color c)
|
|
||||||
{
|
|
||||||
this->image->SetPixel(pt.X,pt.Y,c);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "TessesFramework/Graphics/Renderers/Renderer.hpp"
|
|
||||||
namespace Tesses::Framework::Graphics::Renderers {
|
|
||||||
|
|
||||||
void Renderer::DrawImage(Point pt, Image* image)
|
|
||||||
{
|
|
||||||
auto width = std::min(image->Width(),Width()- pt.X);
|
|
||||||
auto height = std::min(image->Height(),Height()-pt.Y);
|
|
||||||
for(uint32_t y = 0; y < height; y++)
|
|
||||||
{
|
|
||||||
for(uint32_t x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
this->SetPixel(Point(x+pt.X,y+pt.Y),image->GetPixel(x,y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void Renderer::DrawRectangle(Rectangle rect, Color c, bool fill)
|
|
||||||
{
|
|
||||||
|
|
||||||
int32_t xMin = rect.Location.X;
|
|
||||||
int32_t xMax = (rect.Size.Width + xMin)-1;
|
|
||||||
int64_t yMin = rect.Location.Y;
|
|
||||||
int64_t yMax = (rect.Size.Height + yMin)-1;
|
|
||||||
if(fill)
|
|
||||||
{
|
|
||||||
for(int32_t y = yMin; y <= yMax;y++)
|
|
||||||
{
|
|
||||||
for(int32_t x = xMin; x <=xMax;x++)
|
|
||||||
{
|
|
||||||
SetPixel(Point(x,y),c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(int32_t x = xMin; x <=xMax;x++)
|
|
||||||
{
|
|
||||||
SetPixel(Point(x,yMin),c);
|
|
||||||
SetPixel(Point(x,yMax),c);
|
|
||||||
}
|
|
||||||
for(int32_t y = yMin; y <= yMax;y++)
|
|
||||||
{
|
|
||||||
SetPixel(Point(xMin,y),c);
|
|
||||||
SetPixel(Point(xMax,y),c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Renderer::~Renderer()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -6,6 +6,7 @@
|
|||||||
#include "TessesFramework/Http/HttpStream.hpp"
|
#include "TessesFramework/Http/HttpStream.hpp"
|
||||||
#include "TessesFramework/Streams/BufferedStream.hpp"
|
#include "TessesFramework/Streams/BufferedStream.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
using Stream = Tesses::Framework::Streams::Stream;
|
using Stream = Tesses::Framework::Streams::Stream;
|
||||||
using NetworkStream = Tesses::Framework::Streams::NetworkStream;
|
using NetworkStream = Tesses::Framework::Streams::NetworkStream;
|
||||||
using ClientTLSStream = Tesses::Framework::Crypto::ClientTLSStream;
|
using ClientTLSStream = Tesses::Framework::Crypto::ClientTLSStream;
|
||||||
@ -25,6 +26,24 @@ namespace Tesses::Framework::Http
|
|||||||
HttpRequestBody::~HttpRequestBody()
|
HttpRequestBody::~HttpRequestBody()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
TextHttpRequestBody::TextHttpRequestBody(std::string text, std::string mimeType)
|
||||||
|
{
|
||||||
|
this->text = text;
|
||||||
|
this->mimeType = mimeType;
|
||||||
|
}
|
||||||
|
void TextHttpRequestBody::HandleHeaders(HttpDictionary& dict)
|
||||||
|
{
|
||||||
|
dict.SetValue("Content-Type",this->mimeType);
|
||||||
|
dict.SetValue("Content-Length",std::to_string(this->text.size()));
|
||||||
|
}
|
||||||
|
void TextHttpRequestBody::Write(Tesses::Framework::Streams::Stream* strm)
|
||||||
|
{
|
||||||
|
strm->WriteBlock((const uint8_t*)this->text.c_str(),this->text.size());
|
||||||
|
}
|
||||||
|
TextHttpRequestBody::~TextHttpRequestBody()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamHttpRequestBody::StreamHttpRequestBody(Stream* strm, bool owns, std::string mimeType)
|
StreamHttpRequestBody::StreamHttpRequestBody(Stream* strm, bool owns, std::string mimeType)
|
||||||
|
|||||||
161
src/Mail/Smtp.cpp
Normal file
161
src/Mail/Smtp.cpp
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
#include "TessesFramework/Mail/Smtp.hpp"
|
||||||
|
#include "TessesFramework/Crypto/MbedHelpers.hpp"
|
||||||
|
#include "TessesFramework/Streams/MemoryStream.hpp"
|
||||||
|
#include "TessesFramework/TextStreams/StreamWriter.hpp"
|
||||||
|
#include "TessesFramework/Http/HttpUtils.hpp"
|
||||||
|
namespace Tesses::Framework::Mail
|
||||||
|
{
|
||||||
|
static void SMTP_ATTACHMENT_WRITE(std::string& myStr, Tesses::Framework::Streams::MemoryStream& strm)
|
||||||
|
{
|
||||||
|
std::string txt = Tesses::Framework::Crypto::Base64_Encode(strm.GetBuffer());
|
||||||
|
bool first=true;
|
||||||
|
size_t read;
|
||||||
|
size_t offset = 0;
|
||||||
|
do {
|
||||||
|
if(!first) myStr.append("\r\n");
|
||||||
|
read = std::min<size_t>(72, txt.size()-offset);
|
||||||
|
if(read > 0)
|
||||||
|
myStr.insert(myStr.end(),txt.begin()+offset,txt.begin()+offset+read);
|
||||||
|
|
||||||
|
offset+=read;
|
||||||
|
first=false;
|
||||||
|
} while(read > 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SMTPBody::~SMTPBody()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SMTPStringBody::SMTPStringBody()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
SMTPStringBody::SMTPStringBody(std::string text, std::string mimeType)
|
||||||
|
{
|
||||||
|
this->text = text;
|
||||||
|
this->mimeType=mimeType;
|
||||||
|
}
|
||||||
|
void SMTPStringBody::Write(Tesses::Framework::Streams::Stream* strm)
|
||||||
|
{
|
||||||
|
strm->WriteBlock((const uint8_t*)this->text.c_str(),this->text.size());
|
||||||
|
}
|
||||||
|
SMTPStreamBody::SMTPStreamBody(std::string mimeType,Tesses::Framework::Streams::Stream* strm, bool owns)
|
||||||
|
{
|
||||||
|
this->mimeType = mimeType;
|
||||||
|
this->stream = strm;
|
||||||
|
this->owns=owns;
|
||||||
|
}
|
||||||
|
SMTPStreamBody::SMTPStreamBody(std::string mimeType,Tesses::Framework::Streams::Stream& strm) : SMTPStreamBody(mimeType,&strm,false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void SMTPStreamBody::Write(Tesses::Framework::Streams::Stream* strm)
|
||||||
|
{
|
||||||
|
this->stream->Seek(0L,Tesses::Framework::Streams::SeekOrigin::Begin);
|
||||||
|
this->stream->CopyTo(strm);
|
||||||
|
}
|
||||||
|
SMTPStreamBody::~SMTPStreamBody()
|
||||||
|
{
|
||||||
|
if(this->owns)
|
||||||
|
delete this->stream;
|
||||||
|
}
|
||||||
|
SMTPClient::SMTPClient(Tesses::Framework::Streams::Stream* stream,bool owns)
|
||||||
|
{
|
||||||
|
this->strm = stream;
|
||||||
|
this->owns = owns;
|
||||||
|
this->body = nullptr;
|
||||||
|
}
|
||||||
|
SMTPClient::SMTPClient(Tesses::Framework::Streams::Stream& strm) : SMTPClient(&strm,false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void SMTPClient::Send()
|
||||||
|
{
|
||||||
|
std::string emailHeaders = "EHLO ";
|
||||||
|
emailHeaders.append(this->domain);
|
||||||
|
emailHeaders.append("\r\nAUTH LOGIN\r\n");
|
||||||
|
std::vector<uint8_t> data;
|
||||||
|
data.insert(data.begin(), this->username.begin(),this->username.end());
|
||||||
|
|
||||||
|
emailHeaders.append(Tesses::Framework::Crypto::Base64_Encode(data));
|
||||||
|
emailHeaders.append("\r\n");
|
||||||
|
data.clear();
|
||||||
|
data.insert(data.begin(),this->password.begin(),this->password.end());
|
||||||
|
emailHeaders.append(Tesses::Framework::Crypto::Base64_Encode(data));
|
||||||
|
emailHeaders.append("\r\n");
|
||||||
|
emailHeaders.append("MAIL FROM:<");
|
||||||
|
|
||||||
|
emailHeaders.append(this->from);
|
||||||
|
emailHeaders.append(">\r\n");
|
||||||
|
|
||||||
|
emailHeaders.append("RCPT TO:<");
|
||||||
|
emailHeaders.append(to);
|
||||||
|
emailHeaders.append(">\r\n");
|
||||||
|
|
||||||
|
emailHeaders.append("DATA\r\n");
|
||||||
|
std::string boundary = "joel&<<94292025209248";
|
||||||
|
emailHeaders.append("From: ");
|
||||||
|
emailHeaders.append(this->from_name);
|
||||||
|
emailHeaders.append(" <");
|
||||||
|
emailHeaders.append(this->from);
|
||||||
|
emailHeaders.append(">\r\nSubject: ");
|
||||||
|
emailHeaders.append(this->subject);
|
||||||
|
emailHeaders.append("\r\n");
|
||||||
|
emailHeaders.append("Content-Type: multipart/mixed; boundary=");
|
||||||
|
emailHeaders.append(boundary);
|
||||||
|
emailHeaders.append("\r\n\r\n--");
|
||||||
|
emailHeaders.append(boundary);
|
||||||
|
emailHeaders.append("\r\nContent-Type: ");
|
||||||
|
emailHeaders.append(this->body->mimeType);
|
||||||
|
emailHeaders.append("; charset=utf-8\r\n\r\n");
|
||||||
|
Tesses::Framework::TextStreams::StreamWriter writer(this->strm,false);
|
||||||
|
writer.Write(emailHeaders);
|
||||||
|
this->body->Write(this->strm);
|
||||||
|
|
||||||
|
if(this->attachments.empty())
|
||||||
|
{
|
||||||
|
emailHeaders="\r\n--";
|
||||||
|
emailHeaders.append(boundary);
|
||||||
|
emailHeaders.append("--\r\n.\r\n");
|
||||||
|
writer.Write(emailHeaders);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(auto item : this->attachments)
|
||||||
|
{
|
||||||
|
emailHeaders="\r\n--";
|
||||||
|
emailHeaders.append(boundary);
|
||||||
|
emailHeaders.append("\r\n");
|
||||||
|
emailHeaders.append("Content-Type: ");
|
||||||
|
emailHeaders.append(item.second->mimeType);
|
||||||
|
emailHeaders.append("; name=\"");
|
||||||
|
std::string name = Tesses::Framework::Http::HttpUtils::UrlPathEncode(item.first,true);
|
||||||
|
emailHeaders.append(name);
|
||||||
|
emailHeaders.append("\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"");
|
||||||
|
emailHeaders.append(name);
|
||||||
|
emailHeaders.append("\"\r\n\r\n");
|
||||||
|
Tesses::Framework::Streams::MemoryStream ms(true);
|
||||||
|
item.second->Write(&ms);
|
||||||
|
SMTP_ATTACHMENT_WRITE(emailHeaders,ms);
|
||||||
|
//emailHeaders.append(Tesses::Framework::Crypto::Base64_Encode(ms.GetBuffer()));
|
||||||
|
writer.Write(emailHeaders);
|
||||||
|
}
|
||||||
|
|
||||||
|
emailHeaders="\r\n--";
|
||||||
|
emailHeaders.append(boundary);
|
||||||
|
emailHeaders.append("--\r\n.\r\n");
|
||||||
|
writer.Write(emailHeaders);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SMTPClient::~SMTPClient()
|
||||||
|
{
|
||||||
|
delete this->body;
|
||||||
|
for(auto& item : this->attachments)
|
||||||
|
{
|
||||||
|
delete item.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user