Skip to content

Commit

Permalink
Fix compilation error with build flags ENABLE_ERROR_STRING and SILENT…
Browse files Browse the repository at this point in the history
…_MODE.
  • Loading branch information
mobizt committed Jul 28, 2023
1 parent ac29412 commit 73bd314
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ESP Mail Client",
"version": "3.3.3",
"version": "3.3.4",
"keywords": "communication, email, imap, smtp, esp32, esp8266, samd, arduino",
"description": "Arduino E-Mail Client Library to send, read and get incoming email notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino Devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=ESP Mail Client

version=3.3.3
version=3.3.4

author=Mobizt

Expand Down
23 changes: 12 additions & 11 deletions src/ESP_Mail_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ESP_MAIL_CLIENT_CPP

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down Expand Up @@ -1287,21 +1287,21 @@ bool ESP_Mail_Client::beginConnection(Session_Config *session_config, void *sess
{

MB_String dbMsg;
bool isCb = false, debug = false;

ESP_MAIL_TCP_CLIENT *client = nullptr;
#if !defined(SILENT_MODE)
bool isCb = false, debug = false;
PGM_P p = isSMTP ? esp_mail_dbg_str_2 /* "connecting to SMTP server" */ : esp_mail_dbg_str_18 /* "connecting to IMAP server" */;
#endif

if (isSMTP)
{
#if defined(ENABLE_SMTP)
SMTPSession *smtp = (SMTPSession *)sessionPtr;
client = &smtp->client;
#if !defined(SILENT_MODE)
isCb = isResponseCB((void *)smtp->_customCmdResCallback, isSMTP);
debug = smtp->_debug;
client = &smtp->client;

#endif
if (!reconnect(smtp))
return false;

Expand All @@ -1311,10 +1311,11 @@ bool ESP_Mail_Client::beginConnection(Session_Config *session_config, void *sess
{
#if defined(ENABLE_IMAP)
IMAPSession *imap = (IMAPSession *)sessionPtr;
client = &imap->client;
#if !defined(SILENT_MODE)
isCb = isResponseCB((void *)imap->_customCmdResCallback, isSMTP);
debug = imap->_debug;
client = &imap->client;

#endif
if (!reconnect(imap))
return false;

Expand Down Expand Up @@ -1561,7 +1562,7 @@ String ESP_Mail_Client::errorReason(bool isSMTP, int errorCode, const char *msg)
{
MB_String ret;

#if defined(ENABLE_ERROR_STRING)
#if defined(ENABLE_ERROR_STRING) && !defined(SILENT_MODE)

// If there is server meanningful response (msg) is available, return it instead
if (strlen(msg) > 0)
Expand Down Expand Up @@ -1600,7 +1601,7 @@ String ESP_Mail_Client::errorReason(bool isSMTP, int errorCode, const char *msg)
ret = esp_mail_error_client_str_2; /* "custom Client is not yet enabled" */
break;
case MAIL_CLIENT_ERROR_NTP_TIME_SYNC_TIMED_OUT:
ret = esp_mail_error_network_str_1; /* "NTP server time reading timed out" */
ret = esp_mail_error_network_str_2; /* "NTP server time reading timed out" */
break;
case MAIL_CLIENT_ERROR_SESSION_CONFIG_WAS_NOT_ASSIGNED:
ret = esp_mail_error_session_str_1; /* "the Session_Config object was not assigned" */
Expand All @@ -1617,7 +1618,7 @@ String ESP_Mail_Client::errorReason(bool isSMTP, int errorCode, const char *msg)

#if defined(ENABLE_SMTP)
case SMTP_STATUS_SERVER_CONNECT_FAILED:
ret = esp_mail_error_network_str_2; /* "unable to connect to server" */
ret = esp_mail_error_network_str_1; /* "unable to connect to server" */
break;
case SMTP_STATUS_SMTP_GREETING_GET_RESPONSE_FAILED:
ret = esp_mail_error_smtp_str_1; /* "SMTP server greeting failed" */
Expand Down Expand Up @@ -1671,7 +1672,7 @@ String ESP_Mail_Client::errorReason(bool isSMTP, int errorCode, const char *msg)

#if defined(ENABLE_IMAP)
case IMAP_STATUS_SERVER_CONNECT_FAILED:
ret = esp_mail_error_network_str_2; /* "unable to connect to server" */
ret = esp_mail_error_network_str_1; /* "unable to connect to server" */
break;
case IMAP_STATUS_IMAP_RESPONSE_FAILED:
ret = esp_mail_error_imap_str_18; /* "server replied NO or BAD response" */
Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ESP_MAIL_CLIENT_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/ESP_Mail_Client_Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#ifndef ESP_MAIL_VERSION

#define ESP_MAIL_VERSION "3.3.3"
#define ESP_MAIL_VERSION_NUM 30303
#define ESP_MAIL_VERSION "3.3.4"
#define ESP_MAIL_VERSION_NUM 30304

/* The inconsistent file version checking to prevent mixed versions compilation. */
#define VALID_VERSION_CHECK(ver) (ver == ESP_MAIL_VERSION_NUM)
Expand Down
12 changes: 7 additions & 5 deletions src/ESP_Mail_Const.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define ESP_MAIL_CONST_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down Expand Up @@ -2551,7 +2551,7 @@ struct esp_mail_imap_response_data
char *buf = nullptr;

esp_mail_imap_response_data(int bufLen) { chunkBufSize = bufLen; };
~esp_mail_imap_response_data(){clear();}
~esp_mail_imap_response_data() { clear(); }
void clear()
{
if (response)
Expand Down Expand Up @@ -3082,7 +3082,7 @@ static const char esp_mail_error_mem_str_10[] PROGMEM = "please make sure that t
/////////////////////////
// Client error string

#if defined(ENABLE_ERROR_STRING)
#if !defined(SILENT_MODE)
static const char esp_mail_error_client_str_1[] PROGMEM = "client and/or necessary callback functions are not yet assigned";
static const char esp_mail_error_client_str_2[] PROGMEM = "custom Client is not yet enabled";
static const char esp_mail_error_client_str_3[] PROGMEM = "simple Client is required";
Expand All @@ -3099,16 +3099,18 @@ static const char esp_mail_error_client_str_11[] PROGMEM = "the Connection Reque
/////////////////////////
// Network error string

#if !defined(SILENT_MODE)
static const char esp_mail_error_network_str_1[] PROGMEM = "unable to connect to server";
#if defined(ENABLE_ERROR_STRING)
static const char esp_mail_error_network_str_1[] PROGMEM = "NTP server time reading timed out";
static const char esp_mail_error_network_str_2[] PROGMEM = "unable to connect to server";
static const char esp_mail_error_network_str_2[] PROGMEM = "NTP server time reading timed out";
static const char esp_mail_error_network_str_3[] PROGMEM = "response read timed out";
static const char esp_mail_error_network_str_4[] PROGMEM = "not connected";
static const char esp_mail_error_network_str_5[] PROGMEM = "connection timeout";
static const char esp_mail_error_network_str_6[] PROGMEM = "connection closed";
static const char esp_mail_error_network_str_7[] PROGMEM = "connection refused";
static const char esp_mail_error_network_str_8[] PROGMEM = "data sending failed";
#endif
#endif

#if defined(ENABLE_ERROR_STRING) || !defined(SILENT_MODE)
static const char esp_mail_error_network_str_9[] PROGMEM = "response read timed out";
Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define ESP_MAIL_ERROR_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define ESP_MAIL_CONFIG_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_IMAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define ESP_MAIL_IMAP_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define ESP_MAIL_PRINT_H_

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/ESP_Mail_SMTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define ESP_MAIL_SMTP_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/extras/MB_Time.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define MB_Time_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/extras/RFC2047.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define RFC2047_CPP

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/extras/RFC2047.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define RFC2047_H

#include "ESP_Mail_Client_Version.h"
#if !VALID_VERSION_CHECK(30303)
#if !VALID_VERSION_CHECK(30304)
#error "Mixed versions compilation."
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/wcs/esp8266/ESP8266_SSL_Client.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/**
*
* The Network Upgradable BearSSL Client Class, ESP8266_SSL_Client.cpp v2.0.4
* The Network Upgradable BearSSL Client Class, ESP8266_SSL_Client.cpp v2.0.5
*
* Created June 17, 2023
* Created July 28, 2023
*
* This works based on Earle F. Philhower ServerSecure class
*
Expand Down Expand Up @@ -1503,7 +1503,7 @@ namespace BearSSL
{
#if !defined(SILENT_MODE)
if (debugLevel > 0)
esp_mail_debug_print_tag(esp_mail_error_network_str_2 /* "unable to connect to server" */, esp_mail_debug_tag_type_error, true);
esp_mail_debug_print_tag(esp_mail_error_network_str_1 /* "unable to connect to server" */, esp_mail_debug_tag_type_error, true);
#endif
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/wcs/esp8266/ESP8266_SSL_Client.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/**
*
* The Network Upgradable BearSSL Client Class, ESP8266_SSL_Client.h v2.0.4
* The Network Upgradable BearSSL Client Class, ESP8266_SSL_Client.h v2.0.5
*
* Created June 17, 2023
* Created July 28, 2023
*
* This works based on Earle F. Philhower ServerSecure class
*
Expand Down

0 comments on commit 73bd314

Please sign in to comment.