[Commits] : Tuxbox-GIT: apps branch master updated. CVS-Final-418-ga06c2c6
Tuxbox Sources
Brought to you by:
dbt1
|
From: Thilo G. <tux...@ne...> - 2014-10-03 17:19:55
|
Project "Tuxbox-GIT: apps":
The branch, master has been updated
via a06c2c6403315904a2f803ab6417c4c554d072bf (commit)
via e732447ca2f05d66a4f62104f3c2ff2f3b5c3629 (commit)
via 57f9c8b8f10d219e7f8e654939e15f63a194b2a0 (commit)
via 8e0aa4c0b9a0cb55c6b5da795cf2cb66414ab811 (commit)
via 703d44902bdd72a8490aaf90c765997992d87767 (commit)
via 43294adfaa570486a5dd118ffa3d55569e47bcf6 (commit)
via bf71299a4d1a9939273cbd178dc7a2b6c1d9cee2 (commit)
via 11f4071bcc45888c9edad68b3bf0a9e84ea0359d (commit)
via c91f0f579924a2cce9d74f87fadbdf411e2d1aeb (commit)
from d6b9cf22da9ab7ae02fdcf366fee87f396c6015c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a06c2c6403315904a2f803ab6417c4c554d072bf
Author: GetAway <get...@t-...>
Date: Sun Sep 28 19:37:57 2014 +0200
input: add utf8_to_latin1 encoding version bump 1.40
Signed-off-by: GetAway <get...@t-...>
Signed-off-by: Thilo Graf <db...@no...>
diff --git a/tuxbox/tools/input/input.c b/tuxbox/tools/input/input.c
index 2e227ce..23d518f 100644
--- a/tuxbox/tools/input/input.c
+++ b/tuxbox/tools/input/input.c
@@ -36,7 +36,7 @@
#define NCF_FILE "/var/tuxbox/config/neutrino.conf"
#define ECF_FILE "/var/tuxbox/config/engima/config"
#define BUFSIZE 1024
-#define I_VERSION 1.39
+#define I_VERSION 1.40
#define FONT "/share/fonts/pakenham.ttf"
diff --git a/tuxbox/tools/input/text.c b/tuxbox/tools/input/text.c
index 5cabd92..cde98c8 100644
--- a/tuxbox/tools/input/text.c
+++ b/tuxbox/tools/input/text.c
@@ -155,8 +155,8 @@ int stringlen = 0;
int RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color)
{
- int stringlen, ex, charwidth,i,found;
- char rstr[256], *rptr=rstr, rc;
+ int stringlen = 0, ex = 0, charwidth = 0, i = 0, found = 0;
+ char rstr[256]={0}, *rptr=rstr, rc=' ';
int varcolor=color;
//set size
@@ -232,6 +232,50 @@ int RenderString(char *string, int sx, int sy, int maxwidth, int layout, int siz
}
else
{
+ int uml = 0;
+ switch(*rptr) /* skip Umlauts */
+ {
+ case '\xc4':
+ case '\xd6':
+ case '\xdc':
+ case '\xe4':
+ case '\xf6':
+ case '\xfc':
+ case '\xdf': uml=1; break;
+ }
+ if (uml == 0)
+ {
+ // UTF8_to_Latin1 encoding
+ if (((*rptr) & 0xf0) == 0xf0) /* skip (can't be encoded in Latin1) */
+ {
+ rptr++;
+ if ((*rptr) == 0)
+ *rptr='\x3f'; // ? question mark
+ rptr++;
+ if ((*rptr) == 0)
+ *rptr='\x3f';
+ rptr++;
+ if ((*rptr) == 0)
+ *rptr='\x3f';
+ }
+ else if (((*rptr) & 0xe0) == 0xe0) /* skip (can't be encoded in Latin1) */
+ {
+ rptr++;
+ if ((*rptr) == 0)
+ *rptr='\x3f';
+ rptr++;
+ if ((*rptr) == 0)
+ *rptr='\x3f';
+ }
+ else if (((*rptr) & 0xc0) == 0xc0)
+ {
+ char c = (((*rptr) & 3) << 6);
+ rptr++;
+ if ((*rptr) == 0)
+ *rptr='\x3f';
+ *rptr = (c | ((*rptr) & 0x3f));
+ }
+ }
if((charwidth = RenderChar(*rptr, sx, sy, ex, varcolor)) == -1) return sx; /* string > maxwidth */
sx += charwidth;
}
commit e732447ca2f05d66a4f62104f3c2ff2f3b5c3629
Author: Christian Schuett <Gau...@ho...>
Date: Fri Sep 12 23:20:57 2014 +0200
Neutrino: move theme loading to class CThemes
this avoids keeping default theme data multiple times and removes
duplicate code in classes CNeutrinoApp and CThemes
based on patches by martii <m4...@gm...> in Neutrino-MP Git and
[CST] Focus <foc...@gm...> in Coolstream Git
Signed-off-by: Christian Schuett <Gau...@ho...>
Signed-off-by: Thilo Graf <db...@no...>
diff --git a/tuxbox/neutrino/src/gui/themes.cpp b/tuxbox/neutrino/src/gui/themes.cpp
index 4981d07..000d152 100644
--- a/tuxbox/neutrino/src/gui/themes.cpp
+++ b/tuxbox/neutrino/src/gui/themes.cpp
@@ -46,7 +46,7 @@
#define THEMEDIR THEMESDIR "/"
#define USERDIR "/var" THEMEDIR
-#define FILE_PREFIX ".theme"
+#define FILE_SUFFIX ".theme"
CThemes::CThemes(const neutrino_locale_t title, const char * const IconName)
: themefile('\t')
@@ -84,10 +84,10 @@ int CThemes::exec(CMenuTarget* parent, const std::string & actionKey)
if ( strstr(themeFile.c_str(), "{U}") != 0 )
{
themeFile.erase(0, 3);
- readFile((char*)((std::string)USERDIR + themeFile + FILE_PREFIX).c_str());
+ readFile((char*)((std::string)USERDIR + themeFile + FILE_SUFFIX).c_str());
}
else
- readFile((char*)((std::string)THEMEDIR + themeFile + FILE_PREFIX).c_str());
+ readFile((char*)((std::string)THEMEDIR + themeFile + FILE_SUFFIX).c_str());
}
return res;
}
@@ -185,8 +185,8 @@ int CThemes::Show()
int res = themes.exec(NULL, "");
selected = themes.getSelected();
- if (file_name.length() > 1) {
- saveFile((char*)((std::string)USERDIR + file_name + FILE_PREFIX).c_str());
+ if (file_name.length() > 0) {
+ saveFile((char*)((std::string)USERDIR + file_name + FILE_SUFFIX).c_str());
}
if (hasThemeChanged) {
@@ -293,47 +293,7 @@ void CThemes::readFile(char* themename)
{
if(themefile.loadConfig(themename))
{
- g_settings.menu_Head_alpha = themefile.getInt32( "menu_Head_alpha", 0x00 );
- g_settings.menu_Head_red = themefile.getInt32( "menu_Head_red", 0x00 );
- g_settings.menu_Head_green = themefile.getInt32( "menu_Head_green", 0x0A );
- g_settings.menu_Head_blue = themefile.getInt32( "menu_Head_blue", 0x19 );
- g_settings.menu_Head_Text_alpha = themefile.getInt32( "menu_Head_Text_alpha", 0x00 );
- g_settings.menu_Head_Text_red = themefile.getInt32( "menu_Head_Text_red", 0x5f );
- g_settings.menu_Head_Text_green = themefile.getInt32( "menu_Head_Text_green", 0x46 );
- g_settings.menu_Head_Text_blue = themefile.getInt32( "menu_Head_Text_blue", 0x00 );
- g_settings.menu_Content_alpha = themefile.getInt32( "menu_Content_alpha", 0x14 );
- g_settings.menu_Content_red = themefile.getInt32( "menu_Content_red", 0x00 );
- g_settings.menu_Content_green = themefile.getInt32( "menu_Content_green", 0x0f );
- g_settings.menu_Content_blue = themefile.getInt32( "menu_Content_blue", 0x23 );
- g_settings.menu_Content_Text_alpha = themefile.getInt32( "menu_Content_Text_alpha", 0x00 );
- g_settings.menu_Content_Text_red = themefile.getInt32( "menu_Content_Text_red", 0x64 );
- g_settings.menu_Content_Text_green = themefile.getInt32( "menu_Content_Text_green", 0x64 );
- g_settings.menu_Content_Text_blue = themefile.getInt32( "menu_Content_Text_blue", 0x64 );
- g_settings.menu_Content_Selected_alpha = themefile.getInt32( "menu_Content_Selected_alpha", 0x14 );
- g_settings.menu_Content_Selected_red = themefile.getInt32( "menu_Content_Selected_red", 0x19 );
- g_settings.menu_Content_Selected_green = themefile.getInt32( "menu_Content_Selected_green", 0x37 );
- g_settings.menu_Content_Selected_blue = themefile.getInt32( "menu_Content_Selected_blue", 0x64 );
- g_settings.menu_Content_Selected_Text_alpha = themefile.getInt32( "menu_Content_Selected_Text_alpha", 0x00 );
- g_settings.menu_Content_Selected_Text_red = themefile.getInt32( "menu_Content_Selected_Text_red", 0x00 );
- g_settings.menu_Content_Selected_Text_green = themefile.getInt32( "menu_Content_Selected_Text_green", 0x00 );
- g_settings.menu_Content_Selected_Text_blue = themefile.getInt32( "menu_Content_Selected_Text_blue", 0x00 );
- g_settings.menu_Content_inactive_alpha = themefile.getInt32( "menu_Content_inactive_alpha", 0x14 );
- g_settings.menu_Content_inactive_red = themefile.getInt32( "menu_Content_inactive_red", 0x00 );
- g_settings.menu_Content_inactive_green = themefile.getInt32( "menu_Content_inactive_green", 0x0f );
- g_settings.menu_Content_inactive_blue = themefile.getInt32( "menu_Content_inactive_blue", 0x23 );
- g_settings.menu_Content_inactive_Text_alpha = themefile.getInt32( "menu_Content_inactive_Text_alpha", 0x00 );
- g_settings.menu_Content_inactive_Text_red = themefile.getInt32( "menu_Content_inactive_Text_red", 55 );
- g_settings.menu_Content_inactive_Text_green = themefile.getInt32( "menu_Content_inactive_Text_green", 70 );
- g_settings.menu_Content_inactive_Text_blue = themefile.getInt32( "menu_Content_inactive_Text_blue", 85 );
- g_settings.infobar_alpha = themefile.getInt32( "infobar_alpha", 0x14 );
- g_settings.infobar_red = themefile.getInt32( "infobar_red", 0x00 );
- g_settings.infobar_green = themefile.getInt32( "infobar_green", 0x0e );
- g_settings.infobar_blue = themefile.getInt32( "infobar_blue", 0x23 );
- g_settings.infobar_Text_alpha = themefile.getInt32( "infobar_Text_alpha", 0x00 );
- g_settings.infobar_Text_red = themefile.getInt32( "infobar_Text_red", 0x64 );
- g_settings.infobar_Text_green = themefile.getInt32( "infobar_Text_green", 0x64 );
- g_settings.infobar_Text_blue = themefile.getInt32( "infobar_Text_blue", 0x64 );
-
+ getColors(themefile);
colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
hasThemeChanged = true;
}
@@ -343,105 +303,104 @@ void CThemes::readFile(char* themename)
void CThemes::saveFile(char * themename)
{
- themefile.setInt32( "menu_Head_alpha", g_settings.menu_Head_alpha );
- themefile.setInt32( "menu_Head_red", g_settings.menu_Head_red );
- themefile.setInt32( "menu_Head_green", g_settings.menu_Head_green );
- themefile.setInt32( "menu_Head_blue", g_settings.menu_Head_blue );
- themefile.setInt32( "menu_Head_Text_alpha", g_settings.menu_Head_Text_alpha );
- themefile.setInt32( "menu_Head_Text_red", g_settings.menu_Head_Text_red );
- themefile.setInt32( "menu_Head_Text_green", g_settings.menu_Head_Text_green );
- themefile.setInt32( "menu_Head_Text_blue", g_settings.menu_Head_Text_blue );
- themefile.setInt32( "menu_Content_alpha", g_settings.menu_Content_alpha );
- themefile.setInt32( "menu_Content_red", g_settings.menu_Content_red );
- themefile.setInt32( "menu_Content_green", g_settings.menu_Content_green );
- themefile.setInt32( "menu_Content_blue", g_settings.menu_Content_blue );
- themefile.setInt32( "menu_Content_Text_alpha", g_settings.menu_Content_Text_alpha );
- themefile.setInt32( "menu_Content_Text_red", g_settings.menu_Content_Text_red );
- themefile.setInt32( "menu_Content_Text_green", g_settings.menu_Content_Text_green );
- themefile.setInt32( "menu_Content_Text_blue", g_settings.menu_Content_Text_blue );
- themefile.setInt32( "menu_Content_Selected_alpha", g_settings.menu_Content_Selected_alpha );
- themefile.setInt32( "menu_Content_Selected_red", g_settings.menu_Content_Selected_red );
- themefile.setInt32( "menu_Content_Selected_green", g_settings.menu_Content_Selected_green );
- themefile.setInt32( "menu_Content_Selected_blue", g_settings.menu_Content_Selected_blue );
- themefile.setInt32( "menu_Content_Selected_Text_alpha", g_settings.menu_Content_Selected_Text_alpha );
- themefile.setInt32( "menu_Content_Selected_Text_red", g_settings.menu_Content_Selected_Text_red );
- themefile.setInt32( "menu_Content_Selected_Text_green", g_settings.menu_Content_Selected_Text_green );
- themefile.setInt32( "menu_Content_Selected_Text_blue", g_settings.menu_Content_Selected_Text_blue );
- themefile.setInt32( "menu_Content_inactive_alpha", g_settings.menu_Content_inactive_alpha );
- themefile.setInt32( "menu_Content_inactive_red", g_settings.menu_Content_inactive_red );
- themefile.setInt32( "menu_Content_inactive_green", g_settings.menu_Content_inactive_green );
- themefile.setInt32( "menu_Content_inactive_blue", g_settings.menu_Content_inactive_blue );
- themefile.setInt32( "menu_Content_inactive_Text_alpha", g_settings.menu_Content_inactive_Text_alpha );
- themefile.setInt32( "menu_Content_inactive_Text_red", g_settings.menu_Content_inactive_Text_red );
- themefile.setInt32( "menu_Content_inactive_Text_green", g_settings.menu_Content_inactive_Text_green );
- themefile.setInt32( "menu_Content_inactive_Text_blue", g_settings.menu_Content_inactive_Text_blue );
- themefile.setInt32( "infobar_alpha", g_settings.infobar_alpha );
- themefile.setInt32( "infobar_red", g_settings.infobar_red );
- themefile.setInt32( "infobar_green", g_settings.infobar_green );
- themefile.setInt32( "infobar_blue", g_settings.infobar_blue );
- themefile.setInt32( "infobar_Text_alpha", g_settings.infobar_Text_alpha );
- themefile.setInt32( "infobar_Text_red", g_settings.infobar_Text_red );
- themefile.setInt32( "infobar_Text_green", g_settings.infobar_Text_green );
- themefile.setInt32( "infobar_Text_blue", g_settings.infobar_Text_blue );
-
+ setColors(themefile);
if (!themefile.saveConfig(themename))
printf("[neutrino theme] %s write error\n", themename);
}
-
-
// setup default Color Sheme (Neutrino)
void CThemes::setupDefaultColors()
{
- g_settings.menu_Head_alpha = 0x00;
- g_settings.menu_Head_red = 0x00;
- g_settings.menu_Head_green = 0x0A;
- g_settings.menu_Head_blue = 0x19;
-
- g_settings.menu_Head_Text_alpha = 0x00;
- g_settings.menu_Head_Text_red = 0x5f;
- g_settings.menu_Head_Text_green = 0x46;
- g_settings.menu_Head_Text_blue = 0x00;
-
- g_settings.menu_Content_alpha = 0x14;
- g_settings.menu_Content_red = 0x00;
- g_settings.menu_Content_green = 0x0f;
- g_settings.menu_Content_blue = 0x23;
-
- g_settings.menu_Content_Text_alpha = 0x00;
- g_settings.menu_Content_Text_red = 0x64;
- g_settings.menu_Content_Text_green = 0x64;
- g_settings.menu_Content_Text_blue = 0x64;
-
- g_settings.menu_Content_Selected_alpha = 0x14;
- g_settings.menu_Content_Selected_red = 0x19;
- g_settings.menu_Content_Selected_green = 0x37;
- g_settings.menu_Content_Selected_blue = 0x64;
-
- g_settings.menu_Content_Selected_Text_alpha = 0x00;
- g_settings.menu_Content_Selected_Text_red = 0x00;
- g_settings.menu_Content_Selected_Text_green = 0x00;
- g_settings.menu_Content_Selected_Text_blue = 0x00;
-
- g_settings.menu_Content_inactive_alpha = 0x14;
- g_settings.menu_Content_inactive_red = 0x00;
- g_settings.menu_Content_inactive_green = 0x0f;
- g_settings.menu_Content_inactive_blue = 0x23;
-
- g_settings.menu_Content_inactive_Text_alpha = 0x00;
- g_settings.menu_Content_inactive_Text_red = 55;
- g_settings.menu_Content_inactive_Text_green = 70;
- g_settings.menu_Content_inactive_Text_blue = 85;
-
- g_settings.infobar_alpha = 0x14;
- g_settings.infobar_red = 0x00;
- g_settings.infobar_green = 0x0e;
- g_settings.infobar_blue = 0x23;
-
- g_settings.infobar_Text_alpha = 0x00;
- g_settings.infobar_Text_red = 0x64;
- g_settings.infobar_Text_green = 0x64;
- g_settings.infobar_Text_blue = 0x64;
+ CConfigFile empty(':');
+ getColors(empty);
+}
+
+void CThemes::getColors(CConfigFile &configfile)
+{
+ g_settings.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 );
+ g_settings.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 );
+ g_settings.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A );
+ g_settings.menu_Head_blue = configfile.getInt32( "menu_Head_blue", 0x19 );
+ g_settings.menu_Head_Text_alpha = configfile.getInt32( "menu_Head_Text_alpha", 0x00 );
+ g_settings.menu_Head_Text_red = configfile.getInt32( "menu_Head_Text_red", 0x5f );
+ g_settings.menu_Head_Text_green = configfile.getInt32( "menu_Head_Text_green", 0x46 );
+ g_settings.menu_Head_Text_blue = configfile.getInt32( "menu_Head_Text_blue", 0x00 );
+ g_settings.menu_Content_alpha = configfile.getInt32( "menu_Content_alpha", 0x14 );
+ g_settings.menu_Content_red = configfile.getInt32( "menu_Content_red", 0x00 );
+ g_settings.menu_Content_green = configfile.getInt32( "menu_Content_green", 0x0f );
+ g_settings.menu_Content_blue = configfile.getInt32( "menu_Content_blue", 0x23 );
+ g_settings.menu_Content_Text_alpha = configfile.getInt32( "menu_Content_Text_alpha", 0x00 );
+ g_settings.menu_Content_Text_red = configfile.getInt32( "menu_Content_Text_red", 0x64 );
+ g_settings.menu_Content_Text_green = configfile.getInt32( "menu_Content_Text_green", 0x64 );
+ g_settings.menu_Content_Text_blue = configfile.getInt32( "menu_Content_Text_blue", 0x64 );
+ g_settings.menu_Content_Selected_alpha = configfile.getInt32( "menu_Content_Selected_alpha", 0x14 );
+ g_settings.menu_Content_Selected_red = configfile.getInt32( "menu_Content_Selected_red", 0x19 );
+ g_settings.menu_Content_Selected_green = configfile.getInt32( "menu_Content_Selected_green", 0x37 );
+ g_settings.menu_Content_Selected_blue = configfile.getInt32( "menu_Content_Selected_blue", 0x64 );
+ g_settings.menu_Content_Selected_Text_alpha = configfile.getInt32( "menu_Content_Selected_Text_alpha", 0x00 );
+ g_settings.menu_Content_Selected_Text_red = configfile.getInt32( "menu_Content_Selected_Text_red", 0x00 );
+ g_settings.menu_Content_Selected_Text_green = configfile.getInt32( "menu_Content_Selected_Text_green", 0x00 );
+ g_settings.menu_Content_Selected_Text_blue = configfile.getInt32( "menu_Content_Selected_Text_blue", 0x00 );
+ g_settings.menu_Content_inactive_alpha = configfile.getInt32( "menu_Content_inactive_alpha", 0x14 );
+ g_settings.menu_Content_inactive_red = configfile.getInt32( "menu_Content_inactive_red", 0x00 );
+ g_settings.menu_Content_inactive_green = configfile.getInt32( "menu_Content_inactive_green", 0x0f );
+ g_settings.menu_Content_inactive_blue = configfile.getInt32( "menu_Content_inactive_blue", 0x23 );
+ g_settings.menu_Content_inactive_Text_alpha = configfile.getInt32( "menu_Content_inactive_Text_alpha", 0x00 );
+ g_settings.menu_Content_inactive_Text_red = configfile.getInt32( "menu_Content_inactive_Text_red", 55 );
+ g_settings.menu_Content_inactive_Text_green = configfile.getInt32( "menu_Content_inactive_Text_green", 70 );
+ g_settings.menu_Content_inactive_Text_blue = configfile.getInt32( "menu_Content_inactive_Text_blue", 85 );
+ g_settings.infobar_alpha = configfile.getInt32( "infobar_alpha", 0x14 );
+ g_settings.infobar_red = configfile.getInt32( "infobar_red", 0x00 );
+ g_settings.infobar_green = configfile.getInt32( "infobar_green", 0x0e );
+ g_settings.infobar_blue = configfile.getInt32( "infobar_blue", 0x23 );
+ g_settings.infobar_Text_alpha = configfile.getInt32( "infobar_Text_alpha", 0x00 );
+ g_settings.infobar_Text_red = configfile.getInt32( "infobar_Text_red", 0x64 );
+ g_settings.infobar_Text_green = configfile.getInt32( "infobar_Text_green", 0x64 );
+ g_settings.infobar_Text_blue = configfile.getInt32( "infobar_Text_blue", 0x64 );
+}
+
+void CThemes::setColors(CConfigFile &configfile)
+{
+ configfile.setInt32( "menu_Head_alpha", g_settings.menu_Head_alpha );
+ configfile.setInt32( "menu_Head_red", g_settings.menu_Head_red );
+ configfile.setInt32( "menu_Head_green", g_settings.menu_Head_green );
+ configfile.setInt32( "menu_Head_blue", g_settings.menu_Head_blue );
+ configfile.setInt32( "menu_Head_Text_alpha", g_settings.menu_Head_Text_alpha );
+ configfile.setInt32( "menu_Head_Text_red", g_settings.menu_Head_Text_red );
+ configfile.setInt32( "menu_Head_Text_green", g_settings.menu_Head_Text_green );
+ configfile.setInt32( "menu_Head_Text_blue", g_settings.menu_Head_Text_blue );
+ configfile.setInt32( "menu_Content_alpha", g_settings.menu_Content_alpha );
+ configfile.setInt32( "menu_Content_red", g_settings.menu_Content_red );
+ configfile.setInt32( "menu_Content_green", g_settings.menu_Content_green );
+ configfile.setInt32( "menu_Content_blue", g_settings.menu_Content_blue );
+ configfile.setInt32( "menu_Content_Text_alpha", g_settings.menu_Content_Text_alpha );
+ configfile.setInt32( "menu_Content_Text_red", g_settings.menu_Content_Text_red );
+ configfile.setInt32( "menu_Content_Text_green", g_settings.menu_Content_Text_green );
+ configfile.setInt32( "menu_Content_Text_blue", g_settings.menu_Content_Text_blue );
+ configfile.setInt32( "menu_Content_Selected_alpha", g_settings.menu_Content_Selected_alpha );
+ configfile.setInt32( "menu_Content_Selected_red", g_settings.menu_Content_Selected_red );
+ configfile.setInt32( "menu_Content_Selected_green", g_settings.menu_Content_Selected_green );
+ configfile.setInt32( "menu_Content_Selected_blue", g_settings.menu_Content_Selected_blue );
+ configfile.setInt32( "menu_Content_Selected_Text_alpha", g_settings.menu_Content_Selected_Text_alpha );
+ configfile.setInt32( "menu_Content_Selected_Text_red", g_settings.menu_Content_Selected_Text_red );
+ configfile.setInt32( "menu_Content_Selected_Text_green", g_settings.menu_Content_Selected_Text_green );
+ configfile.setInt32( "menu_Content_Selected_Text_blue", g_settings.menu_Content_Selected_Text_blue );
+ configfile.setInt32( "menu_Content_inactive_alpha", g_settings.menu_Content_inactive_alpha );
+ configfile.setInt32( "menu_Content_inactive_red", g_settings.menu_Content_inactive_red );
+ configfile.setInt32( "menu_Content_inactive_green", g_settings.menu_Content_inactive_green );
+ configfile.setInt32( "menu_Content_inactive_blue", g_settings.menu_Content_inactive_blue );
+ configfile.setInt32( "menu_Content_inactive_Text_alpha", g_settings.menu_Content_inactive_Text_alpha );
+ configfile.setInt32( "menu_Content_inactive_Text_red", g_settings.menu_Content_inactive_Text_red );
+ configfile.setInt32( "menu_Content_inactive_Text_green", g_settings.menu_Content_inactive_Text_green );
+ configfile.setInt32( "menu_Content_inactive_Text_blue", g_settings.menu_Content_inactive_Text_blue );
+ configfile.setInt32( "infobar_alpha", g_settings.infobar_alpha );
+ configfile.setInt32( "infobar_red", g_settings.infobar_red );
+ configfile.setInt32( "infobar_green", g_settings.infobar_green );
+ configfile.setInt32( "infobar_blue", g_settings.infobar_blue );
+ configfile.setInt32( "infobar_Text_alpha", g_settings.infobar_Text_alpha );
+ configfile.setInt32( "infobar_Text_red", g_settings.infobar_Text_red );
+ configfile.setInt32( "infobar_Text_green", g_settings.infobar_Text_green );
+ configfile.setInt32( "infobar_Text_blue", g_settings.infobar_Text_blue );
}
bool CColorSetupNotifier::changeNotify(const neutrino_locale_t, void *)
diff --git a/tuxbox/neutrino/src/gui/themes.h b/tuxbox/neutrino/src/gui/themes.h
index f82015f..2148dcc 100644
--- a/tuxbox/neutrino/src/gui/themes.h
+++ b/tuxbox/neutrino/src/gui/themes.h
@@ -52,12 +52,15 @@ class CThemes : public CMenuTarget
void saveFile(char* themename);
void readThemes(CMenuWidget &);
void rememberOldTheme(bool remember);
+ void setupDefaultColors();
public:
CThemes(const neutrino_locale_t title = LOCALE_COLORTHEMEMENU_HEAD2, const char * const IconName = NEUTRINO_ICON_COLORS);
~CThemes();
- void setupDefaultColors();
int exec(CMenuTarget* parent, const std::string & actionKey);
+
+ static void getColors(CConfigFile &configfile);
+ static void setColors(CConfigFile &configfile);
};
#endif
diff --git a/tuxbox/neutrino/src/neutrino.cpp b/tuxbox/neutrino/src/neutrino.cpp
index ec360d9..6a1ebcb 100644
--- a/tuxbox/neutrino/src/neutrino.cpp
+++ b/tuxbox/neutrino/src/neutrino.cpp
@@ -107,6 +107,7 @@
#endif
#include "gui/rc_lock.h"
#include "gui/update.h"
+#include "gui/themes.h"
#include <system/setting_helpers.h>
#include <system/settings.h>
@@ -452,57 +453,9 @@ int CNeutrinoApp::loadSetup()
//widget settings
g_settings.widget_fade = configfile.getBool("widget_fade" , true );
- //colors (neutrino defaultcolors)
- g_settings.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 );
- g_settings.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 );
- g_settings.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A );
- g_settings.menu_Head_blue = configfile.getInt32( "menu_Head_blue", 0x19 );
-
- g_settings.menu_Head_Text_alpha = configfile.getInt32( "menu_Head_Text_alpha", 0x00 );
- g_settings.menu_Head_Text_red = configfile.getInt32( "menu_Head_Text_red", 0x5f );
- g_settings.menu_Head_Text_green = configfile.getInt32( "menu_Head_Text_green", 0x46 );
- g_settings.menu_Head_Text_blue = configfile.getInt32( "menu_Head_Text_blue", 0x00 );
-
- g_settings.menu_Content_alpha = configfile.getInt32( "menu_Content_alpha", 0x14 );
- g_settings.menu_Content_red = configfile.getInt32( "menu_Content_red", 0x00 );
- g_settings.menu_Content_green = configfile.getInt32( "menu_Content_green", 0x0f );
- g_settings.menu_Content_blue = configfile.getInt32( "menu_Content_blue", 0x23 );
-
- g_settings.menu_Content_Text_alpha = configfile.getInt32( "menu_Content_Text_alpha", 0x00 );
- g_settings.menu_Content_Text_red = configfile.getInt32( "menu_Content_Text_red", 0x64 );
- g_settings.menu_Content_Text_green = configfile.getInt32( "menu_Content_Text_green", 0x64 );
- g_settings.menu_Content_Text_blue = configfile.getInt32( "menu_Content_Text_blue", 0x64 );
-
- g_settings.menu_Content_Selected_alpha = configfile.getInt32( "menu_Content_Selected_alpha", 0x14 );
- g_settings.menu_Content_Selected_red = configfile.getInt32( "menu_Content_Selected_red", 0x19 );
- g_settings.menu_Content_Selected_green = configfile.getInt32( "menu_Content_Selected_green", 0x37 );
- g_settings.menu_Content_Selected_blue = configfile.getInt32( "menu_Content_Selected_blue", 0x64 );
-
- g_settings.menu_Content_Selected_Text_alpha = configfile.getInt32( "menu_Content_Selected_Text_alpha", 0x00 );
- g_settings.menu_Content_Selected_Text_red = configfile.getInt32( "menu_Content_Selected_Text_red", 0x00 );
- g_settings.menu_Content_Selected_Text_green = configfile.getInt32( "menu_Content_Selected_Text_green", 0x00 );
- g_settings.menu_Content_Selected_Text_blue = configfile.getInt32( "menu_Content_Selected_Text_blue", 0x00 );
-
- g_settings.menu_Content_inactive_alpha = configfile.getInt32( "menu_Content_inactive_alpha", 0x14 );
- g_settings.menu_Content_inactive_red = configfile.getInt32( "menu_Content_inactive_red", 0x00 );
- g_settings.menu_Content_inactive_green = configfile.getInt32( "menu_Content_inactive_green", 0x0f );
- g_settings.menu_Content_inactive_blue = configfile.getInt32( "menu_Content_inactive_blue", 0x23 );
-
- g_settings.menu_Content_inactive_Text_alpha = configfile.getInt32( "menu_Content_inactive_Text_alpha", 0x00 );
- g_settings.menu_Content_inactive_Text_red = configfile.getInt32( "menu_Content_inactive_Text_red", 55 );
- g_settings.menu_Content_inactive_Text_green = configfile.getInt32( "menu_Content_inactive_Text_green", 70 );
- g_settings.menu_Content_inactive_Text_blue = configfile.getInt32( "menu_Content_inactive_Text_blue", 85 );
-
- g_settings.infobar_alpha = configfile.getInt32( "infobar_alpha", 0x14 );
- g_settings.infobar_red = configfile.getInt32( "infobar_red", 0x00 );
- g_settings.infobar_green = configfile.getInt32( "infobar_green", 0x0e );
- g_settings.infobar_blue = configfile.getInt32( "infobar_blue", 0x23 );
-
- g_settings.infobar_Text_alpha = configfile.getInt32( "infobar_Text_alpha", 0x00 );
- g_settings.infobar_Text_red = configfile.getInt32( "infobar_Text_red", 0x64 );
- g_settings.infobar_Text_green = configfile.getInt32( "infobar_Text_green", 0x64 );
- g_settings.infobar_Text_blue = configfile.getInt32( "infobar_Text_blue", 0x64 );
-
+ //colors
+ CThemes::getColors(configfile);
+
//corners
g_settings.rounded_corners = configfile.getBool("rounded_corners", true);
@@ -1040,56 +993,8 @@ void CNeutrinoApp::saveSetup()
configfile.setBool("widget_fade" , g_settings.widget_fade);
//colors
- configfile.setInt32( "menu_Head_alpha", g_settings.menu_Head_alpha );
- configfile.setInt32( "menu_Head_red", g_settings.menu_Head_red );
- configfile.setInt32( "menu_Head_green", g_settings.menu_Head_green );
- configfile.setInt32( "menu_Head_blue", g_settings.menu_Head_blue );
-
- configfile.setInt32( "menu_Head_Text_alpha", g_settings.menu_Head_Text_alpha );
- configfile.setInt32( "menu_Head_Text_red", g_settings.menu_Head_Text_red );
- configfile.setInt32( "menu_Head_Text_green", g_settings.menu_Head_Text_green );
- configfile.setInt32( "menu_Head_Text_blue", g_settings.menu_Head_Text_blue );
-
- configfile.setInt32( "menu_Content_alpha", g_settings.menu_Content_alpha );
- configfile.setInt32( "menu_Content_red", g_settings.menu_Content_red );
- configfile.setInt32( "menu_Content_green", g_settings.menu_Content_green );
- configfile.setInt32( "menu_Content_blue", g_settings.menu_Content_blue );
-
- configfile.setInt32( "menu_Content_Text_alpha", g_settings.menu_Content_Text_alpha );
- configfile.setInt32( "menu_Content_Text_red", g_settings.menu_Content_Text_red );
- configfile.setInt32( "menu_Content_Text_green", g_settings.menu_Content_Text_green );
- configfile.setInt32( "menu_Content_Text_blue", g_settings.menu_Content_Text_blue );
-
- configfile.setInt32( "menu_Content_Selected_alpha", g_settings.menu_Content_Selected_alpha );
- configfile.setInt32( "menu_Content_Selected_red", g_settings.menu_Content_Selected_red );
- configfile.setInt32( "menu_Content_Selected_green", g_settings.menu_Content_Selected_green );
- configfile.setInt32( "menu_Content_Selected_blue", g_settings.menu_Content_Selected_blue );
-
- configfile.setInt32( "menu_Content_Selected_Text_alpha", g_settings.menu_Content_Selected_Text_alpha );
- configfile.setInt32( "menu_Content_Selected_Text_red", g_settings.menu_Content_Selected_Text_red );
- configfile.setInt32( "menu_Content_Selected_Text_green", g_settings.menu_Content_Selected_Text_green );
- configfile.setInt32( "menu_Content_Selected_Text_blue", g_settings.menu_Content_Selected_Text_blue );
-
- configfile.setInt32( "menu_Content_inactive_alpha", g_settings.menu_Content_inactive_alpha );
- configfile.setInt32( "menu_Content_inactive_red", g_settings.menu_Content_inactive_red );
- configfile.setInt32( "menu_Content_inactive_green", g_settings.menu_Content_inactive_green );
- configfile.setInt32( "menu_Content_inactive_blue", g_settings.menu_Content_inactive_blue );
-
- configfile.setInt32( "menu_Content_inactive_Text_alpha", g_settings.menu_Content_inactive_Text_alpha );
- configfile.setInt32( "menu_Content_inactive_Text_red", g_settings.menu_Content_inactive_Text_red );
- configfile.setInt32( "menu_Content_inactive_Text_green", g_settings.menu_Content_inactive_Text_green );
- configfile.setInt32( "menu_Content_inactive_Text_blue", g_settings.menu_Content_inactive_Text_blue );
-
- configfile.setInt32( "infobar_alpha", g_settings.infobar_alpha );
- configfile.setInt32( "infobar_red", g_settings.infobar_red );
- configfile.setInt32( "infobar_green", g_settings.infobar_green );
- configfile.setInt32( "infobar_blue", g_settings.infobar_blue );
-
- configfile.setInt32( "infobar_Text_alpha", g_settings.infobar_Text_alpha );
- configfile.setInt32( "infobar_Text_red", g_settings.infobar_Text_red );
- configfile.setInt32( "infobar_Text_green", g_settings.infobar_Text_green );
- configfile.setInt32( "infobar_Text_blue", g_settings.infobar_Text_blue );
-
+ CThemes::setColors(configfile);
+
//corners
configfile.setBool( "rounded_corners", g_settings.rounded_corners );
commit 57f9c8b8f10d219e7f8e654939e15f63a194b2a0
Author: GetAway <get...@t-...>
Date: Fri Sep 12 11:12:59 2014 +0200
Port CS-tuxmail SSL Support
Signed-off-by: GetAway <get...@t-...>
Signed-off-by: Thilo Graf <db...@no...>
diff --git a/tuxbox/plugins/tuxmail/daemon/Makefile.am b/tuxbox/plugins/tuxmail/daemon/Makefile.am
index 2cf1aa6..6cfc701 100644
--- a/tuxbox/plugins/tuxmail/daemon/Makefile.am
+++ b/tuxbox/plugins/tuxmail/daemon/Makefile.am
@@ -2,4 +2,4 @@ bin_PROGRAMS = tuxmaild
tuxmaild_SOURCES = tuxmaild.c
-tuxmaild_LDADD = -lpthread
+tuxmaild_LDADD = -lpthread -lssl -lcrypto
diff --git a/tuxbox/plugins/tuxmail/daemon/tuxmaild.c b/tuxbox/plugins/tuxmail/daemon/tuxmaild.c
index 65b34af..bd8de6a 100644
--- a/tuxbox/plugins/tuxmail/daemon/tuxmaild.c
+++ b/tuxbox/plugins/tuxmail/daemon/tuxmaild.c
@@ -66,6 +66,7 @@ int ReadConf()
fprintf(fd_conf, "SUSER0=\n");
fprintf(fd_conf, "SPASS0=\n");
fprintf(fd_conf, "INBOX0=\n");
+ fprintf(fd_conf, "SSL0=0\n");
fclose(fd_conf);
@@ -251,6 +252,14 @@ int ReadConf()
sscanf(ptr + 7, "%s", account_db[index-'0'].inbox);
}
}
+ else if((ptr = strstr(line_buffer, "SSL")) && (*(ptr+4) == '='))
+ {
+ char index = *(ptr+3);
+ if((index >= '0') && (index <= '9'))
+ {
+ sscanf(ptr + 5, "%d", &account_db[index-'0'].ssl);
+ }
+ }
}
// check for update
@@ -359,6 +368,7 @@ int ReadConf()
fprintf(fd_conf, "SUSER%d=%s\n", loop, account_db[loop].suser);
fprintf(fd_conf, "SPASS%d=%s\n", loop, account_db[loop].spass);
fprintf(fd_conf, "INBOX%d=%s\n", loop, account_db[loop].inbox);
+ fprintf(fd_conf, "SSL%d=%d\n", loop, account_db[loop].ssl);
if(!account_db[loop + 1].name[0])
{
@@ -1444,7 +1454,7 @@ void writeFOut( char *s)
* SendPOPCommand (0=fail, 1=done)
******************************************************************************/
-int SendPOPCommand(int command, char *param)
+int SendPOPCommand(int command, char *param, int ssl)
{
struct hostent *server;
struct sockaddr_in SockAddr;
@@ -1511,6 +1521,48 @@ int SendPOPCommand(int command, char *param)
return 0;
}
+ if(ssl == 1)
+ {
+ // Init SSL struct
+ printf("TuxMailD <Init SSL for POP3>\n");
+ c = malloc (sizeof (connection));
+ c->sslHandle = NULL;
+ c->sslContext = NULL;
+
+ SSL_load_error_strings ();
+ SSL_library_init ();
+
+ c->sslContext = SSL_CTX_new (SSLv23_client_method ());
+ if (c->sslContext == NULL) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not set SSL client method") : printf("TuxMailD <could not set SSL client method>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ c->sslHandle = SSL_new (c->sslContext);
+ if (c->sslHandle == NULL) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not create SSL struct for the connection") : printf("TuxMailD <could not create SSL struct for the connection>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ if (!SSL_set_fd (c->sslHandle, sock)) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not connect SSL struct to the socket") : printf("TuxMailD <could not connect SSL struct to socket>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ if (SSL_connect (c->sslHandle) != 1) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not handle SSL handshake") : printf("TuxMailD <could not handle SSL handshake>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+ }
+
break;
case USER:
@@ -1583,7 +1635,10 @@ int SendPOPCommand(int command, char *param)
}
}
- send(sock, send_buffer, strlen(send_buffer), 0);
+ if(ssl == 1)
+ SSL_write (c->sslHandle, send_buffer, strlen(send_buffer));
+ else
+ send(sock, send_buffer, strlen(send_buffer), 0);
}
// get server response
@@ -1602,7 +1657,7 @@ int SendPOPCommand(int command, char *param)
if(command == RETR)
{
- while(recv(sock, &recv_buffer[3], 1, 0) > 0)
+ while((ssl == 1 ? SSL_read (c->sslHandle, &recv_buffer[3], 1) : recv(sock, &recv_buffer[3], 1, 0)) > 0)
{
if((nRead) && (nRead < 75000))
{
@@ -1611,8 +1666,8 @@ int SendPOPCommand(int command, char *param)
}
// scan for header-end
- if(!nRead && recv_buffer[3] == '\n' && recv_buffer[1] == '\n')
- {
+ if(!nRead && recv_buffer[3] == '\n' && recv_buffer[1] == '\n')
+ {
nRead++;
}
@@ -1630,7 +1685,7 @@ int SendPOPCommand(int command, char *param)
}
else
{
- while(recv(sock, &recv_buffer[stringindex], 1, 0) > 0)
+ while((ssl == 1 ? SSL_read (c->sslHandle, &recv_buffer[stringindex], 1) : recv(sock, &recv_buffer[stringindex], 1, 0)) > 0)
{
if(command == TOP)
{
@@ -1869,6 +1924,19 @@ int SendPOPCommand(int command, char *param)
case QUIT:
close(sock);
+
+ if(ssl == 1)
+ {
+ if (c->sslHandle)
+ {
+ SSL_shutdown (c->sslHandle);
+ SSL_free (c->sslHandle);
+ }
+ if (c->sslContext)
+ SSL_CTX_free (c->sslContext);
+
+ free (c);
+ }
}
}
else
@@ -1882,6 +1950,19 @@ int SendPOPCommand(int command, char *param)
close(sock);
+ if(ssl == 1)
+ {
+ if (c->sslHandle)
+ {
+ SSL_shutdown (c->sslHandle);
+ SSL_free (c->sslHandle);
+ }
+ if (c->sslContext)
+ SSL_CTX_free (c->sslContext);
+
+ free (c);
+ }
+
return 0;
}
@@ -1892,7 +1973,7 @@ int SendPOPCommand(int command, char *param)
* SendIMAPCommand (0=fail, 1=done)
******************************************************************************/
-int SendIMAPCommand(int command, char *param, char *param2)
+int SendIMAPCommand(int command, char *param, char *param2, int ssl)
{
struct hostent *server;
struct sockaddr_in SockAddr;
@@ -1959,6 +2040,48 @@ int SendIMAPCommand(int command, char *param, char *param2)
return 0;
}
+ if(ssl == 1)
+ {
+ // Init SSL struct
+ printf("TuxMailD <Init SSL for IMAP>\n");
+ c = malloc (sizeof (connection));
+ c->sslHandle = NULL;
+ c->sslContext = NULL;
+
+ SSL_load_error_strings ();
+ SSL_library_init ();
+
+ c->sslContext = SSL_CTX_new (SSLv23_client_method ());
+ if (c->sslContext == NULL) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not set SSL client method") : printf("TuxMailD <could not set SSL client method>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ c->sslHandle = SSL_new (c->sslContext);
+ if (c->sslHandle == NULL) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not create SSL struct for the connection") : printf("TuxMailD <could not create SSL struct for the connection>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ if (!SSL_set_fd (c->sslHandle, sock)) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not connect SSL struct to the socket") : printf("TuxMailD <could not connect SSL struct to socket>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ if (SSL_connect (c->sslHandle) != 1) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not handle SSL handshake") : printf("TuxMailD <could not handle SSL handshake>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+ }
+
break;
case LOGIN:
@@ -2053,7 +2176,10 @@ int SendIMAPCommand(int command, char *param, char *param2)
}
}
- send(sock, send_buffer, strlen(send_buffer), 0);
+ if(ssl == 1)
+ SSL_write (c->sslHandle, send_buffer, strlen(send_buffer));
+ else
+ send(sock, send_buffer, strlen(send_buffer), 0);
}
// get server response
@@ -2072,7 +2198,7 @@ int SendIMAPCommand(int command, char *param, char *param2)
if(command == RETR)
{
- while(recv(sock, &recv_buffer[stringindex], 1, 0) > 0)
+ while((ssl == 1 ? SSL_read (c->sslHandle, &recv_buffer[stringindex], 1) : recv(sock, &recv_buffer[stringindex], 1, 0)) > 0)
{
// read line by line
if((nRead) && (nRead < 75000))
@@ -2127,7 +2253,7 @@ int SendIMAPCommand(int command, char *param, char *param2)
}
else
{
- while(recv(sock, &recv_buffer[stringindex], 1, 0) > 0)
+ while((ssl == 1 ? SSL_read (c->sslHandle, &recv_buffer[stringindex], 1) : recv(sock, &recv_buffer[stringindex], 1, 0)) > 0)
{
// read line by line and end if leading character hast been '?' or after one line after INIT
if(recv_buffer[stringindex] == '\n')
@@ -2439,6 +2565,20 @@ int SendIMAPCommand(int command, char *param, char *param2)
case LOGOUT:
close(sock);
+
+ if(ssl == 1)
+ {
+ if (c->sslHandle)
+ {
+ SSL_shutdown (c->sslHandle);
+ SSL_free (c->sslHandle);
+ }
+ if (c->sslContext)
+ SSL_CTX_free (c->sslContext);
+
+ free (c);
+ }
+
return 1;
default:
@@ -2448,6 +2588,19 @@ int SendIMAPCommand(int command, char *param, char *param2)
slog ? syslog(LOG_DAEMON | LOG_INFO, "IMAP Server (%s)", recv_buffer) : printf("TuxMailD <IMAP Server (%s)>\n", recv_buffer);
close(sock);
+
+ if(ssl == 1)
+ {
+ if (c->sslHandle)
+ {
+ SSL_shutdown (c->sslHandle);
+ SSL_free (c->sslHandle);
+ }
+ if (c->sslContext)
+ SSL_CTX_free (c->sslContext);
+ free (c);
+ }
+
return 0;
}
@@ -2455,7 +2608,7 @@ int SendIMAPCommand(int command, char *param, char *param2)
* SendSMTPCommand (0=fail, 1=done)
******************************************************************************/
-int SendSMTPCommand(int command, char *param)
+int SendSMTPCommand(int command, char *param, int ssl)
{
FILE *fd_log;
static int sock;
@@ -2518,6 +2671,48 @@ int SendSMTPCommand(int command, char *param)
return 0;
}
+ if(ssl == 1)
+ {
+ // Init SSL struct
+ printf("TuxMailD <Init SSL for SMTP>\n");
+ c = malloc (sizeof (connection));
+ c->sslHandle = NULL;
+ c->sslContext = NULL;
+
+ SSL_load_error_strings ();
+ SSL_library_init ();
+
+ c->sslContext = SSL_CTX_new (SSLv23_client_method ());
+ if (c->sslContext == NULL) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not set SSL client method") : printf("TuxMailD <could not set SSL client method>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ c->sslHandle = SSL_new (c->sslContext);
+ if (c->sslHandle == NULL) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not create SSL struct for the connection") : printf("TuxMailD <could not create SSL struct for the connection>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ if (!SSL_set_fd (c->sslHandle, sock)) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not connect SSL struct to the socket") : printf("TuxMailD <could not connect SSL struct to socket>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+
+ if (SSL_connect (c->sslHandle) != 1) {
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "could not handle SSL handshake") : printf("TuxMailD <could not handle SSL handshake>\n");
+
+ ERR_print_errors_fp (stderr);
+ return 0;
+ }
+ }
+
break;
case EHLO:
@@ -2583,7 +2778,10 @@ int SendSMTPCommand(int command, char *param)
}
}
- send(sock, &send_buffer, strlen(send_buffer), 0);
+ if(ssl == 1)
+ SSL_write (c->sslHandle, &send_buffer, strlen(send_buffer));
+ else
+ send(sock, &send_buffer, strlen(send_buffer), 0);
}
// get server response
@@ -2596,7 +2794,10 @@ int SendSMTPCommand(int command, char *param)
return 1;
}
- recv(sock, &recv_buffer, sizeof(recv_buffer), 0);
+ if(ssl == 1)
+ SSL_read (c->sslHandle, &recv_buffer, sizeof(recv_buffer));
+ else
+ recv(sock, &recv_buffer, sizeof(recv_buffer), 0);
if(logging == 'Y')
{
@@ -2659,6 +2860,19 @@ int SendSMTPCommand(int command, char *param)
close(sock);
+ if(ssl == 1)
+ {
+ if (c->sslHandle)
+ {
+ SSL_shutdown (c->sslHandle);
+ SSL_free (c->sslHandle);
+ }
+ if (c->sslContext)
+ SSL_CTX_free (c->sslContext);
+
+ free (c);
+ }
+
if(strncmp(recv_buffer, "221", 3))
{
return 0;
@@ -2685,11 +2899,22 @@ int SendSMTPCommand(int command, char *param)
}
}
- send(sock, &send_buffer, strlen(send_buffer), 0);
+ if(ssl == 1)
+ {
+ SSL_write (c->sslHandle, send_buffer, strlen(send_buffer));
- memset(recv_buffer, 0, sizeof(recv_buffer));
+ memset(recv_buffer, 0, sizeof(recv_buffer));
- recv(sock, &recv_buffer, sizeof(recv_buffer), 0);
+ SSL_read (c->sslHandle, &recv_buffer, sizeof(recv_buffer));
+ }
+ else
+ {
+ send(sock, &send_buffer, strlen(send_buffer), 0);
+
+ memset(recv_buffer, 0, sizeof(recv_buffer));
+
+ recv(sock, &recv_buffer, sizeof(recv_buffer), 0);
+ }
if(logging == 'Y')
{
@@ -2707,6 +2932,19 @@ int SendSMTPCommand(int command, char *param)
close(sock);
+ if(ssl == 1)
+ {
+ if (c->sslHandle)
+ {
+ SSL_shutdown (c->sslHandle);
+ SSL_free (c->sslHandle);
+ }
+ if (c->sslContext)
+ SSL_CTX_free (c->sslContext);
+
+ free (c);
+ }
+
return 0;
}
@@ -2739,7 +2977,7 @@ int SendMail(int account)
{
linebuffer[strlen(linebuffer) - 1] = '\0';
- if(!SendSMTPCommand(INIT, linebuffer))
+ if(!SendSMTPCommand(INIT, linebuffer, account_db[account].ssl))
{
fclose(mail);
@@ -2755,7 +2993,7 @@ int SendMail(int account)
{
linebuffer[strlen(linebuffer) - 1] = '\0';
- if(!SendSMTPCommand(EHLO, linebuffer))
+ if(!SendSMTPCommand(EHLO, linebuffer, account_db[account].ssl))
{
fclose(mail);
@@ -2781,7 +3019,7 @@ int SendMail(int account)
EncodeBase64(decodedstring, strlen(account_db[account].suser) + strlen(account_db[account].spass) + 2);
}
- if(!SendSMTPCommand(AUTH, encodedstring))
+ if(!SendSMTPCommand(AUTH, encodedstring, account_db[account].ssl))
{
fclose(mail);
@@ -2796,7 +3034,7 @@ int SendMail(int account)
{
linebuffer[strlen(linebuffer) - 1] = '\0';
- if(!SendSMTPCommand(MAIL, linebuffer))
+ if(!SendSMTPCommand(MAIL, linebuffer, account_db[account].ssl))
{
fclose(mail);
@@ -2812,7 +3050,7 @@ int SendMail(int account)
{
linebuffer[strlen(linebuffer) - 1] = '\0';
- if(!SendSMTPCommand(RCPT, linebuffer))
+ if(!SendSMTPCommand(RCPT, linebuffer, account_db[account].ssl))
{
fclose(mail);
@@ -2822,7 +3060,7 @@ int SendMail(int account)
// send data
- if(!SendSMTPCommand(DATA1, ""))
+ if(!SendSMTPCommand(DATA1, "", account_db[account].ssl))
{
fclose(mail);
@@ -2835,7 +3073,7 @@ int SendMail(int account)
{
linebuffer[strlen(linebuffer) - 1] = '\0';
- if(!SendSMTPCommand(DATA2, linebuffer))
+ if(!SendSMTPCommand(DATA2, linebuffer, account_db[account].ssl))
{
fclose(mail);
@@ -2845,7 +3083,7 @@ int SendMail(int account)
memset(linebuffer, 0, sizeof(linebuffer));
}
- if(!SendSMTPCommand(DATA3, ""))
+ if(!SendSMTPCommand(DATA3, "", account_db[account].ssl))
{
fclose(mail);
@@ -2854,7 +3092,7 @@ int SendMail(int account)
// send quit
- if(!SendSMTPCommand(QUIT, ""))
+ if(!SendSMTPCommand(QUIT, "", account_db[account].ssl))
{
fclose(mail);
@@ -2892,7 +3130,7 @@ int SaveMail(int account, char* mailuid)
if( !imap1 )
{
- if(!SendPOPCommand(INIT, account_db[account].pop3))
+ if(!SendPOPCommand(INIT, account_db[account].pop3, account_db[account].ssl))
{
if(fd_mail)
{
@@ -2902,7 +3140,7 @@ int SaveMail(int account, char* mailuid)
return 0;
}
- if(!SendPOPCommand(USER, account_db[account].user))
+ if(!SendPOPCommand(USER, account_db[account].user, account_db[account].ssl))
{
if(fd_mail)
{
@@ -2912,7 +3150,7 @@ int SaveMail(int account, char* mailuid)
return 0;
}
- if(!SendPOPCommand(PASS, account_db[account].pass))
+ if(!SendPOPCommand(PASS, account_db[account].pass, account_db[account].ssl))
{
if(fd_mail)
{
@@ -2922,7 +3160,7 @@ int SaveMail(int account, char* mailuid)
return 0;
}
- if(!SendPOPCommand(STAT, ""))
+ if(!SendPOPCommand(STAT, "", account_db[account].ssl))
{
if(fd_mail)
{
@@ -2934,7 +3172,7 @@ int SaveMail(int account, char* mailuid)
}
else
{
- if(!SendIMAPCommand(INIT, account_db[account].imap, ""))
+ if(!SendIMAPCommand(INIT, account_db[account].imap, "", account_db[account].ssl))
{
if(fd_mail)
{
@@ -2945,7 +3183,7 @@ int SaveMail(int account, char* mailuid)
}
// login to mail server
- if(!SendIMAPCommand(LOGIN, account_db[account].user, account_db[account].pass))
+ if(!SendIMAPCommand(LOGIN, account_db[account].user, account_db[account].pass, account_db[account].ssl))
{
if(fd_mail)
{
@@ -2956,7 +3194,7 @@ int SaveMail(int account, char* mailuid)
}
// select folder, get mail count and UID
- if(!SendIMAPCommand(SELECT, account_db[account].inbox, ""))
+ if(!SendIMAPCommand(SELECT, account_db[account].inbox, "", account_db[account].ssl))
{
if(fd_mail)
{
@@ -2977,7 +3215,7 @@ int SaveMail(int account, char* mailuid)
if( !imap1 )
{
- if(!SendPOPCommand(UIDL, mailnumber))
+ if(!SendPOPCommand(UIDL, mailnumber, account_db[account].ssl))
{
if(fd_mail)
{
@@ -2989,7 +3227,7 @@ int SaveMail(int account, char* mailuid)
}
else
{
- if(!SendIMAPCommand(UIDL, mailnumber, ""))
+ if(!SendIMAPCommand(UIDL, mailnumber, "", account_db[account].ssl))
{
if(fd_mail)
{
@@ -3007,7 +3245,7 @@ int SaveMail(int account, char* mailuid)
if( !imap1 )
{
- if(!SendPOPCommand(RETR, mailnumber))
+ if(!SendPOPCommand(RETR, mailnumber, account_db[account].ssl))
{
if(fd_mail)
{
@@ -3018,12 +3256,12 @@ int SaveMail(int account, char* mailuid)
}
fclose(fd_mail);
- SendPOPCommand(QUIT, "");
+ SendPOPCommand(QUIT, "", account_db[account].ssl);
}
else
{
char seen = 0;
- if(!SendIMAPCommand(FLAGS, mailnumber, &seen))
+ if(!SendIMAPCommand(FLAGS, mailnumber, &seen, account_db[account].ssl))
{
if(fd_mail)
{
@@ -3033,7 +3271,7 @@ int SaveMail(int account, char* mailuid)
return 0;
}
- if((!seen) || (!SendIMAPCommand(RETR, mailnumber, "")))
+ if((!seen) || (!SendIMAPCommand(RETR, mailnumber, "", account_db[account].ssl)))
{
if(fd_mail)
{
@@ -3045,7 +3283,7 @@ int SaveMail(int account, char* mailuid)
if( seen == 'U' )
{
- if(!SendIMAPCommand(UNSEEN, mailnumber, ""))
+ if(!SendIMAPCommand(UNSEEN, mailnumber, "", account_db[account].ssl))
{
if(fd_mail)
{
@@ -3057,7 +3295,7 @@ int SaveMail(int account, char* mailuid)
}
fclose(fd_mail);
- SendIMAPCommand(LOGOUT, "", "");
+ SendIMAPCommand(LOGOUT, "", "", account_db[account].ssl);
}
return 1;
@@ -3068,11 +3306,11 @@ int SaveMail(int account, char* mailuid)
if( !imap1 )
{
- SendPOPCommand(QUIT, "");
+ SendPOPCommand(QUIT, "", account_db[account].ssl);
}
else
{
- SendIMAPCommand(LOGOUT, "", "");
+ SendIMAPCommand(LOGOUT, "", "", account_db[account].ssl);
}
}
@@ -3331,7 +3569,7 @@ int AddNewMailFile(int account, char *mailnumber, FILE *fd_status)
{
if( !imap )
{
- if(!SendPOPCommand(RETR, mailnumber))
+ if(!SendPOPCommand(RETR, mailnumber, account_db[account].ssl))
{
idx1 = 0;
fclose(fd_mail);
@@ -3348,12 +3586,12 @@ int AddNewMailFile(int account, char *mailnumber, FILE *fd_status)
{
char seen=0;
- if(!SendIMAPCommand(FLAGS, mailnumber, &seen))
+ if(!SendIMAPCommand(FLAGS, mailnumber, &seen, account_db[account].ssl))
{
seen=0;
}
- if((!seen) || (!SendIMAPCommand(RETR, mailnumber, "")))
+ if((!seen) || (!SendIMAPCommand(RETR, mailnumber, "", account_db[account].ssl)))
{
// printf("error write email nr: %s at %stuxmail.idx%u.%u\n",mailnumber,maildir,account,idx1);
idx1 = 0;
@@ -3364,7 +3602,7 @@ int AddNewMailFile(int account, char *mailnumber, FILE *fd_status)
// printf("write email nr: %s at %stuxmail.idx%u.%u\n",mailnumber,maildir,account,idx1);
if( seen == 'U' )
{
- SendIMAPCommand(UNSEEN, mailnumber, "");
+ SendIMAPCommand(UNSEEN, mailnumber, "", account_db[account].ssl);
}
fclose(fd_mail);
@@ -3429,19 +3667,19 @@ int CheckAccount(int account)
imap = 1;
// init connection to server
- if(!SendIMAPCommand(INIT, account_db[account].imap, ""))
+ if(!SendIMAPCommand(INIT, account_db[account].imap, "", account_db[account].ssl))
{
return 0;
}
// login to mail server
- if(!SendIMAPCommand(LOGIN, account_db[account].user, account_db[account].pass))
+ if(!SendIMAPCommand(LOGIN, account_db[account].user, account_db[account].pass, account_db[account].ssl))
{
return 0;
}
// select folder, get mail count and UID
- if(!SendIMAPCommand(SELECT, account_db[account].inbox, ""))
+ if(!SendIMAPCommand(SELECT, account_db[account].inbox, "", account_db[account].ssl))
{
return 0;
}
@@ -3449,27 +3687,27 @@ int CheckAccount(int account)
else
{
// get mail count
- if(!SendPOPCommand(INIT, account_db[account].pop3))
+ if(!SendPOPCommand(INIT, account_db[account].pop3, account_db[account].ssl))
{
return 0;
}
- if(!SendPOPCommand(USER, account_db[account].user))
+ if(!SendPOPCommand(USER, account_db[account].user, account_db[account].ssl))
{
return 0;
}
- if(!SendPOPCommand(PASS, account_db[account].pass))
+ if(!SendPOPCommand(PASS, account_db[account].pass, account_db[account].ssl))
{
return 0;
}
- if(!SendPOPCommand(STAT, ""))
+ if(!SendPOPCommand(STAT, "", account_db[account].ssl))
{
return 0;
}
- if(!SendPOPCommand(RSET, ""))
+ if(!SendPOPCommand(RSET, "", account_db[account].ssl))
{
return 0;
}
@@ -3543,7 +3781,7 @@ int CheckAccount(int account)
if( !imap )
{
- if(!SendPOPCommand(UIDL, mailnumber))
+ if(!SendPOPCommand(UIDL, mailnumber, account_db[account].ssl))
{
free(known_uids);
@@ -3557,7 +3795,7 @@ int CheckAccount(int account)
}
else
{
- if(!SendIMAPCommand(UIDL, mailnumber, ""))
+ if(!SendIMAPCommand(UIDL, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3574,7 +3812,7 @@ int CheckAccount(int account)
{
if( !imap )
{
- if(!SendPOPCommand(TOP, mailnumber))
+ if(!SendPOPCommand(TOP, mailnumber, account_db[account].ssl))
{
free(known_uids);
@@ -3589,7 +3827,7 @@ int CheckAccount(int account)
else
{
char seen;
- if(!SendIMAPCommand(FLAGS, mailnumber, &seen))
+ if(!SendIMAPCommand(FLAGS, mailnumber, &seen, account_db[account].ssl))
{
free(known_uids);
@@ -3601,7 +3839,7 @@ int CheckAccount(int account)
return 0;
}
- if(!SendIMAPCommand(FETCH, mailnumber, ""))
+ if(!SendIMAPCommand(FETCH, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3615,7 +3853,7 @@ int CheckAccount(int account)
if( seen == 'U' )
{
- if(!SendIMAPCommand(UNSEEN, mailnumber, ""))
+ if(!SendIMAPCommand(UNSEEN, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3635,7 +3873,7 @@ int CheckAccount(int account)
if( !imap )
{
- if(!SendPOPCommand(DELE, mailnumber))
+ if(!SendPOPCommand(DELE, mailnumber, account_db[account].ssl))
{
free(known_uids);
@@ -3649,7 +3887,7 @@ int CheckAccount(int account)
}
else
{
- if(!SendIMAPCommand(DELE, mailnumber, ""))
+ if(!SendIMAPCommand(DELE, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3689,7 +3927,7 @@ int CheckAccount(int account)
{
if( !imap )
{
- if(!SendPOPCommand(DELE, mailnumber))
+ if(!SendPOPCommand(DELE, mailnumber, account_db[account].ssl))
{
free(known_uids);
@@ -3703,7 +3941,7 @@ int CheckAccount(int account)
}
else
{
- if(!SendIMAPCommand(DELE, mailnumber, ""))
+ if(!SendIMAPCommand(DELE, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3756,7 +3994,7 @@ int CheckAccount(int account)
{
if( !imap )
{
- if(!SendPOPCommand(TOP, mailnumber))
+ if(!SendPOPCommand(TOP, mailnumber, account_db[account].ssl))
{
free(known_uids);
@@ -3771,7 +4009,7 @@ int CheckAccount(int account)
else
{
char seen;
- if(!SendIMAPCommand(FLAGS, mailnumber, &seen))
+ if(!SendIMAPCommand(FLAGS, mailnumber, &seen, account_db[account].ssl))
{
free(known_uids);
@@ -3783,7 +4021,7 @@ int CheckAccount(int account)
return 0;
}
- if(!SendIMAPCommand(FETCH, mailnumber, ""))
+ if(!SendIMAPCommand(FETCH, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3797,7 +4035,7 @@ int CheckAccount(int account)
if( seen == 'U' )
{
- if(!SendIMAPCommand(UNSEEN, mailnumber, ""))
+ if(!SendIMAPCommand(UNSEEN, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3815,7 +4053,7 @@ int CheckAccount(int account)
{
if( !imap )
{
- if(!SendPOPCommand(DELE, mailnumber))
+ if(!SendPOPCommand(DELE, mailnumber, account_db[account].ssl))
{
free(known_uids);
@@ -3829,7 +4067,7 @@ int CheckAccount(int account)
}
else
{
- if(!SendIMAPCommand(DELE, mailnumber, ""))
+ if(!SendIMAPCommand(DELE, mailnumber, "", account_db[account].ssl))
{
free(known_uids);
@@ -3934,7 +4172,7 @@ int CheckAccount(int account)
if(( !deleted_messages ) && ( !imap ))
{
- if(!SendPOPCommand(RSET, ""))
+ if(!SendPOPCommand(RSET, "", account_db[account].ssl))
{
return 0;
}
@@ -3979,22 +4217,22 @@ int CheckAccount(int account)
if( !imap )
{
- if(!SendPOPCommand(QUIT, ""))
+ if(!SendPOPCommand(QUIT, "", account_db[account].ssl))
{
return 0;
}
}
else
{
- if(!SendIMAPCommand(EXPUNGE, "", ""))
+ if(!SendIMAPCommand(EXPUNGE, "", "", account_db[account].ssl))
{
return 0;
}
- if(!SendIMAPCommand(CLOSE, "", ""))
+ if(!SendIMAPCommand(CLOSE, "", "", account_db[account].ssl))
{
return 0;
}
- if(!SendIMAPCommand(LOGOUT, "", ""))
+ if(!SendIMAPCommand(LOGOUT, "", "", account_db[account].ssl))
{
return 0;
}
@@ -4556,7 +4794,7 @@ void SigHandler(int signal)
int main(int argc, char **argv)
{
- char cvs_revision[] = "$Revision: 1.51 $";
+ char cvs_revision[] = "$Revision: 1.51A $";
int param, nodelay = 0, account, mailstatus, unread_mailstatus;
pthread_t thread_id;
void *thread_result = 0;
@@ -4671,7 +4909,7 @@ int main(int argc, char **argv)
{
case 0:
- slog ? syslog(LOG_DAEMON | LOG_INFO, "%s started [%s]", versioninfo, timeinfo) : printf("TuxMailD %s started [%s]\n", versioninfo, timeinfo);
+ slog ? syslog(LOG_DAEMON | LOG_INFO, "%s started [%s]", versioninfo, timeinfo) : printf("TuxMailD %s (with SSL support) started [%s]\n", versioninfo, timeinfo);
setsid();
chdir("/");
diff --git a/tuxbox/plugins/tuxmail/daemon/tuxmaild.h b/tuxbox/plugins/tuxmail/daemon/tuxmaild.h
index 9a30e63..06c024f 100644
--- a/tuxbox/plugins/tuxmail/daemon/tuxmaild.h
+++ b/tuxbox/plugins/tuxmail/daemon/tuxmaild.h
@@ -21,6 +21,10 @@
#include <arpa/inet.h>
#include <syslog.h>
+#include <openssl/rand.h>
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
#include "audio.h"
#define DSP "/dev/sound/dsp"
@@ -157,6 +161,7 @@ struct
int mail_new;
int mail_unread;
int mail_read;
+ int ssl;
}account_db[10];
@@ -195,6 +200,14 @@ struct CHUNK
unsigned long ChunkSize;
};
+// SSL
+typedef struct {
+ SSL *sslHandle;
+ SSL_CTX *sslContext;
+} connection;
+
+connection *c;
+
// some data
char versioninfo[12];
diff --git a/tuxbox/plugins/tuxmail/tuxmail.c b/tuxbox/plugins/tuxmail/tuxmail.c
index 204bce1..42abecc 100644
--- a/tuxbox/plugins/tuxmail/tuxmail.c
+++ b/tuxbox/plugins/tuxmail/tuxmail.c
@@ -201,6 +201,14 @@ void ReadConf()
sscanf(ptr + 7, "%s", maildb[index-'0'].inbox);
}
}
+ else if ( ( ptr = strstr ( line_buffer, "SSL" ) ) && ( * ( ptr+4 ) == '=' ) )
+ {
+ char index = * ( ptr+3 );
+ if ( ( index >= '0' ) && ( index <= '9' ) )
+ {
+ sscanf ( ptr + 5, "%d", &maildb[index-'0'].ssl );
+ }
+ }
}
fclose(fd_conf);
@@ -287,6 +295,7 @@ int WriteConf()
fprintf(fd_conf, "SUSER%d=%s\n", loop, maildb[loop].suser);
fprintf(fd_conf, "SPASS%d=%s\n", loop, maildb[loop].spass);
fprintf(fd_conf, "INBOX%d=%s\n", loop, maildb[loop].inbox);
+ fprintf(fd_conf, "SSL%d=%d\n", loop, maildb[loop].ssl );
if(!maildb[loop + 1].user[0])
{
break;
@@ -1459,7 +1468,7 @@ void PaintSmtpMailHeader( int nEditDirectStyle , int nConfigPage)
RenderString(linebuffer, 2*BORDERSIZE+380, BORDERSIZE+3*FONTHEIGHT_SMALL-6 , VIEWX-4*BORDERSIZE, LEFT, NORMAL, WHITE);
int i;
- for( i=2; i<14; i++)
+ for( i=2; i<15; i++)
{
switch( i )
{
@@ -1515,6 +1524,13 ...
[truncated message content] |