Aggiunto supporto per mail senza outlook
git-svn-id: svn://10.65.10.50/branches/R_10_00@23147 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
50bf746c69
commit
941d28df75
@ -53,6 +53,8 @@ static LONG GetNextNameValue(HKEY key, LPCTSTR subkey, LPTSTR szName, LPTSTR szD
|
|||||||
#define W7STR _T("Windows 7")
|
#define W7STR _T("Windows 7")
|
||||||
#define W2012STR _T("Windows Server 2012")
|
#define W2012STR _T("Windows Server 2012")
|
||||||
#define W8STR _T("Windows 8")
|
#define W8STR _T("Windows 8")
|
||||||
|
#define W10STR _T("Windows 10")
|
||||||
|
#define W2016STR _T("Windows Server 2016")
|
||||||
|
|
||||||
#define WUNKNOWN 0
|
#define WUNKNOWN 0
|
||||||
|
|
||||||
@ -78,6 +80,8 @@ static LONG GetNextNameValue(HKEY key, LPCTSTR subkey, LPTSTR szName, LPTSTR szD
|
|||||||
#define W7 109
|
#define W7 109
|
||||||
#define W2012 110
|
#define W2012 110
|
||||||
#define W8 111
|
#define W8 111
|
||||||
|
#define W10 112
|
||||||
|
#define W2016 103
|
||||||
#define WNTLAST 199
|
#define WNTLAST 199
|
||||||
|
|
||||||
#define WCEFIRST 201
|
#define WCEFIRST 201
|
||||||
@ -572,7 +576,10 @@ Vista 2 6 0
|
|||||||
2008 2 6 0
|
2008 2 6 0
|
||||||
2008 R2 2 6 1
|
2008 R2 2 6 1
|
||||||
Win7 2 6 1 3600
|
Win7 2 6 1 3600
|
||||||
|
Win8 2 6 2
|
||||||
|
Win8.1 2 6 3
|
||||||
|
Win10 2 6 4
|
||||||
|
Win10 2 10 0
|
||||||
CE 3
|
CE 3
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -605,7 +612,7 @@ bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
|
|||||||
DWORD dwMinorVersion = osinfo.dwMinorVersion;
|
DWORD dwMinorVersion = osinfo.dwMinorVersion;
|
||||||
DWORD dwMajorVersion = osinfo.dwMajorVersion;
|
DWORD dwMajorVersion = osinfo.dwMajorVersion;
|
||||||
DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
|
DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
|
||||||
TRACE(_T("%d: %d.%d.%d\n"), dwPlatformId, dwMajorVersion, dwMinorVersion, dwBuildNumber);
|
const bool bServer = osinfo.wProductType != VER_NT_WORKSTATION;
|
||||||
|
|
||||||
if (dwPlatformId == VER_PLATFORM_WIN32_NT)
|
if (dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||||
{
|
{
|
||||||
@ -618,10 +625,9 @@ bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
|
|||||||
case 2:
|
case 2:
|
||||||
default: cp = W2003STR; nVersion = W2003; break;
|
default: cp = W2003STR; nVersion = W2003; break;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else if (dwMajorVersion == 6)
|
if (dwMajorVersion == 6)
|
||||||
{
|
{
|
||||||
const bool bServer = osinfo.wProductType != VER_NT_WORKSTATION;
|
|
||||||
switch (dwMinorVersion)
|
switch (dwMinorVersion)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -636,13 +642,27 @@ bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
|
|||||||
else
|
else
|
||||||
{ cp = W7STR; nVersion = W7; }
|
{ cp = W7STR; nVersion = W7; }
|
||||||
break;
|
break;
|
||||||
default:
|
case 2:
|
||||||
|
case 3:
|
||||||
if (bServer)
|
if (bServer)
|
||||||
{ cp = W2012STR; nVersion = W2012; }
|
{ cp = W2012STR; nVersion = W2012; }
|
||||||
else
|
else
|
||||||
{ cp = W8STR; nVersion = W8; }
|
{ cp = W8STR; nVersion = W8; }
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (bServer)
|
||||||
|
{ cp = W2016STR; nVersion = W2016; }
|
||||||
|
else
|
||||||
|
{ cp = W10STR; nVersion = W10; }
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
if (dwMajorVersion >= 10)
|
||||||
|
{
|
||||||
|
if (bServer)
|
||||||
|
{ cp = W2016STR; nVersion = W2016; }
|
||||||
|
else
|
||||||
|
{ cp = W10STR; nVersion = W10; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,9 @@ bool aga_dde_execute(unsigned long connection, const char* msg)
|
|||||||
if (connection != 0)
|
if (connection != 0)
|
||||||
{
|
{
|
||||||
wxAgaConnection* conn = (wxAgaConnection*)connection;
|
wxAgaConnection* conn = (wxAgaConnection*)connection;
|
||||||
|
const bool bLogEnabled = wxLog::EnableLogging(false);
|
||||||
ok = conn->Execute(msg, -1);
|
ok = conn->Execute(msg, -1);
|
||||||
|
wxLog::EnableLogging(bLogEnabled);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
107
xvaga/email.cpp
107
xvaga/email.cpp
@ -1,107 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: email.h
|
|
||||||
// Purpose: wxEmail: portable email client class
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 2001-08-21
|
|
||||||
// RCS-ID: $Id: email.cpp,v 1.6 2009-04-07 09:19:08 guy Exp $
|
|
||||||
// Copyright: (c) Julian Smart
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "wxinc.h"
|
|
||||||
|
|
||||||
#include "email.h"
|
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
#include "smapi.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __UNIX__
|
|
||||||
#include "wx/filefn.h"
|
|
||||||
#include "wx/timer.h"
|
|
||||||
#include "wx/wfstream.h"
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include "unistd.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Send a message.
|
|
||||||
// Specify profile, if empty use MAPI default profile
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
bool wxEmail::Send(wxMailMessage& message, const wxString& profileName, bool bUI, const wxString& WXUNUSED(sendMail))
|
|
||||||
{
|
|
||||||
wxASSERT (message.m_to.GetCount() > 0) ;
|
|
||||||
|
|
||||||
wxString profile(profileName);
|
|
||||||
|
|
||||||
wxMapiSession session;
|
|
||||||
|
|
||||||
if (!session.MapiInstalled())
|
|
||||||
return FALSE;
|
|
||||||
if (!session.Logon(profile))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return session.Send(message, bUI);
|
|
||||||
}
|
|
||||||
#elif defined(__UNIX__)
|
|
||||||
bool wxEmail::Send(wxMailMessage& message, const wxString& profileName,
|
|
||||||
bool bUI, const wxString& sendMail)
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( !message.m_to.IsEmpty(), _T("no recipients to send mail to") ) ;
|
|
||||||
|
|
||||||
|
|
||||||
// The 'from' field is optionally supplied by the app; it's not needed
|
|
||||||
// by MAPI, and on Unix, will be guessed if not supplied.
|
|
||||||
wxString from = message.m_from;
|
|
||||||
if ( from.empty() )
|
|
||||||
{
|
|
||||||
from = wxGetEmailAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString msg;
|
|
||||||
msg << wxT("To: ");
|
|
||||||
|
|
||||||
const size_t rcptCount = message.m_to.GetCount();
|
|
||||||
for (size_t rcpt = 0; rcpt < rcptCount; rcpt++)
|
|
||||||
{
|
|
||||||
if ( rcpt )
|
|
||||||
msg << wxT(", ");
|
|
||||||
msg << message.m_to[rcpt];
|
|
||||||
}
|
|
||||||
|
|
||||||
msg << wxT("\nFrom: ") << from << wxT("\nSubject: ") << message.m_subject;
|
|
||||||
msg << wxT("\n\n") << message.m_body;
|
|
||||||
|
|
||||||
wxString filename;
|
|
||||||
filename.Printf(wxT("/tmp/msg-%ld-%ld-%ld.txt"), (long) getpid(), wxGetLocalTime(),
|
|
||||||
(long) rand());
|
|
||||||
|
|
||||||
{
|
|
||||||
wxFileOutputStream stream(filename);
|
|
||||||
if (stream.Ok())
|
|
||||||
{
|
|
||||||
stream.Write(msg, msg.Length());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FALSE ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO search for a suitable sendmail if sendMail is empty
|
|
||||||
wxString sendmail(sendMail);
|
|
||||||
|
|
||||||
wxString cmd;
|
|
||||||
cmd << sendmail << wxT(" < ") << filename;
|
|
||||||
|
|
||||||
// TODO: check return code
|
|
||||||
wxSystem(cmd.c_str());
|
|
||||||
|
|
||||||
wxRemoveFile(filename);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#error Send not yet implemented for this platform.
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: email.h
|
|
||||||
// Purpose: wxEmail: portable email client class
|
|
||||||
// Author: Julian Smart
|
|
||||||
// Modified by:
|
|
||||||
// Created: 2001-08-21
|
|
||||||
// RCS-ID: $Id: email.h,v 1.4 2010-04-22 15:26:15 guy Exp $
|
|
||||||
// Copyright: (c) Julian Smart
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef _WX_EMAIL_H_
|
|
||||||
#define _WX_EMAIL_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* wxMailMessage
|
|
||||||
* Encapsulates an email message
|
|
||||||
*/
|
|
||||||
|
|
||||||
class wxMailMessage
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
// A common usage
|
|
||||||
wxMailMessage(const wxString& subject, const wxString& to,
|
|
||||||
const wxString& body, const wxString& from = wxEmptyString,
|
|
||||||
const wxString& attachment = wxEmptyString,
|
|
||||||
const wxString& attachmentTitle = wxEmptyString) : m_query_receipt(false)
|
|
||||||
{
|
|
||||||
m_to.Add(to);
|
|
||||||
m_subject = subject;
|
|
||||||
m_body = body;
|
|
||||||
m_from = from;
|
|
||||||
if (!attachment.IsEmpty())
|
|
||||||
{
|
|
||||||
m_attachments.Add(attachment);
|
|
||||||
m_attachmentTitles.Add(attachmentTitle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxMailMessage() : m_query_receipt(false) {}
|
|
||||||
|
|
||||||
//// Accessors
|
|
||||||
|
|
||||||
void AddTo(const wxString& to) { m_to.Add(to); }
|
|
||||||
void AddCc(const wxString& cc) { m_cc.Add(cc); }
|
|
||||||
void AddBcc(const wxString& bcc) { m_bcc.Add(bcc); }
|
|
||||||
void AddAttachment(const wxString& attach, const wxString& title = wxEmptyString)
|
|
||||||
{ m_attachments.Add(attach); m_attachmentTitles.Add(title); }
|
|
||||||
|
|
||||||
void SetSubject(const wxString& subject) { m_subject = subject; }
|
|
||||||
void SetBody(const wxString& body) { m_body = body; }
|
|
||||||
void SetFrom(const wxString& from) { m_from = from; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxArrayString m_to; //The To: Recipients
|
|
||||||
wxString m_from; //The From: email address (optional)
|
|
||||||
wxArrayString m_cc; //The CC: Recipients
|
|
||||||
wxArrayString m_bcc; //The BCC Recipients
|
|
||||||
wxString m_subject; //The Subject of the message
|
|
||||||
wxString m_body; //The Body of the message
|
|
||||||
wxArrayString m_attachments; //Files to attach to the email
|
|
||||||
wxArrayString m_attachmentTitles; //Titles to use for the email file attachments
|
|
||||||
bool m_query_receipt; //Query receipt message
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* wxEmail
|
|
||||||
* Miscellaneous email functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
class wxEmail
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//// Ctor/dtor
|
|
||||||
wxEmail() {};
|
|
||||||
|
|
||||||
//// Operations
|
|
||||||
|
|
||||||
// Send a message.
|
|
||||||
// Specify profile, or leave it to wxWidgets to find the current user name
|
|
||||||
static bool Send(wxMailMessage& message, const wxString& profileName = wxEmptyString,
|
|
||||||
bool bShowUI = false, const wxString& sendMail = wxT("/usr/sbin/sendmail -t"));
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif //_WX_EMAIL_H_
|
|
||||||
|
|
@ -503,4 +503,21 @@ long wxMapiSession::GetLastError() const
|
|||||||
return m_data->m_nLastError;
|
return m_data->m_nLastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxMailMessage::Send(const wxString& profileName, bool bUI, const wxString& WXUNUSED(sendMail))
|
||||||
|
{
|
||||||
|
wxASSERT(m_to.GetCount() > 0) ;
|
||||||
|
|
||||||
|
wxString profile(profileName);
|
||||||
|
|
||||||
|
wxMapiSession session;
|
||||||
|
|
||||||
|
if (!session.MapiInstalled())
|
||||||
|
return FALSE;
|
||||||
|
if (!session.Logon(profile))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return session.Send(*this, bUI);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
|
|
||||||
|
@ -12,7 +12,54 @@
|
|||||||
#ifndef _WX_SMAPI_H_
|
#ifndef _WX_SMAPI_H_
|
||||||
#define _WX_SMAPI_H_
|
#define _WX_SMAPI_H_
|
||||||
|
|
||||||
#include "email.h"
|
class wxMailMessage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// A common usage
|
||||||
|
wxMailMessage(const wxString& subject, const wxString& to,
|
||||||
|
const wxString& body, const wxString& from = wxEmptyString,
|
||||||
|
const wxString& attachment = wxEmptyString,
|
||||||
|
const wxString& attachmentTitle = wxEmptyString) : m_query_receipt(false)
|
||||||
|
{
|
||||||
|
m_to.Add(to);
|
||||||
|
m_subject = subject;
|
||||||
|
m_body = body;
|
||||||
|
m_from = from;
|
||||||
|
if (!attachment.IsEmpty())
|
||||||
|
{
|
||||||
|
m_attachments.Add(attachment);
|
||||||
|
m_attachmentTitles.Add(attachmentTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMailMessage() : m_query_receipt(false) {}
|
||||||
|
|
||||||
|
//// Accessors
|
||||||
|
|
||||||
|
void AddTo(const wxString& to) { m_to.Add(to); }
|
||||||
|
void AddCc(const wxString& cc) { m_cc.Add(cc); }
|
||||||
|
void AddBcc(const wxString& bcc) { m_bcc.Add(bcc); }
|
||||||
|
void AddAttachment(const wxString& attach, const wxString& title = wxEmptyString)
|
||||||
|
{ m_attachments.Add(attach); m_attachmentTitles.Add(title); }
|
||||||
|
|
||||||
|
void SetSubject(const wxString& subject) { m_subject = subject; }
|
||||||
|
void SetBody(const wxString& body) { m_body = body; }
|
||||||
|
void SetFrom(const wxString& from) { m_from = from; }
|
||||||
|
bool Send(const wxString& profileName = wxEmptyString,
|
||||||
|
bool bShowUI = false, const wxString& sendMail = wxT("/usr/sbin/sendmail -t"));
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxArrayString m_to; //The To: Recipients
|
||||||
|
wxString m_from; //The From: email address (optional)
|
||||||
|
wxArrayString m_cc; //The CC: Recipients
|
||||||
|
wxArrayString m_bcc; //The BCC Recipients
|
||||||
|
wxString m_subject; //The Subject of the message
|
||||||
|
wxString m_body; //The Body of the message
|
||||||
|
wxArrayString m_attachments; //Files to attach to the email
|
||||||
|
wxArrayString m_attachmentTitles; //Titles to use for the email file attachments
|
||||||
|
bool m_query_receipt; //Query receipt message
|
||||||
|
};
|
||||||
|
|
||||||
class wxMapiData;
|
class wxMapiData;
|
||||||
|
|
||||||
|
@ -15,17 +15,13 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* internal constants for sizing arrays, defaults, etc... */
|
/* internal constants for sizing arrays, defaults, etc... */
|
||||||
#define STATBAR_MAX_LEN 256 /* maximum length of status bar string */
|
//#define STATBAR_MAX_LEN 256 /* maximum length of status bar string */
|
||||||
#define STATBAR_MAX_NUM 128 /* maximum number of status bars in an app */
|
//#define STATBAR_MAX_NUM 128 /* maximum number of status bars in an app */
|
||||||
#if ( (XVTWS==MACWS) || (XVTWS==MTFWS) || (XVTWS==XOLWS) )
|
//#define STATBAR_FONT_SIZE 10 /* default font size on Windows/PM/NT/CH */
|
||||||
#define STATBAR_FONT_SIZE 12 /* default font size on Mac/XM/XOL */
|
|
||||||
#else
|
|
||||||
#define STATBAR_FONT_SIZE 10 /* default font size on Windows/PM/NT/CH */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* the following CIS functions are external and may be called by the app */
|
/* the following CIS functions are external and may be called by the app */
|
||||||
XVTDLL const char *statbar_set_title(WINDOW win, const char *text);
|
XVTDLL const char* statbar_set_title(WINDOW win, const char *text);
|
||||||
XVTDLL const char *statbar_set_default_title(WINDOW win, const char *text);
|
XVTDLL const char* statbar_set_default_title(WINDOW win, const char *text);
|
||||||
|
|
||||||
/* the following CIS functions are external and are usable in all font modes */
|
/* the following CIS functions are external and are usable in all font modes */
|
||||||
|
|
||||||
|
@ -1538,7 +1538,6 @@ BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xvt_fsys_get_default_dir(DIRECTORY *dirp)
|
void xvt_fsys_get_default_dir(DIRECTORY *dirp)
|
||||||
{
|
{
|
||||||
if (_startup_dir.IsEmpty())
|
if (_startup_dir.IsEmpty())
|
||||||
@ -1551,6 +1550,13 @@ BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp)
|
|||||||
return xvt_fsys_convert_str_to_dir(::wxGetCwd(), dirp);
|
return xvt_fsys_convert_str_to_dir(::wxGetCwd(), dirp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xvt_fsys_get_temp_dir(DIRECTORY *dirp)
|
||||||
|
{
|
||||||
|
xvt_sys_get_profile_string(NULL, "Main", "Temp", "", dirp->path, sizeof(dirp->path));
|
||||||
|
if (!*dirp->path)
|
||||||
|
wxStrcpy(dirp->path, wxFileName::GetTempDir());
|
||||||
|
}
|
||||||
|
|
||||||
static wxString get_disk_root(const char* path)
|
static wxString get_disk_root(const char* path)
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
@ -4044,6 +4050,8 @@ WINDOW xvt_vobj_get_parent(WINDOW win)
|
|||||||
|
|
||||||
char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title)
|
char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title)
|
||||||
{
|
{
|
||||||
|
if (win == NULL_WIN)
|
||||||
|
return NULL;
|
||||||
CAST_WIN(win, w);
|
CAST_WIN(win, w);
|
||||||
wxStrncpy(title, w.GetLabel(), sz_title);
|
wxStrncpy(title, w.GetLabel(), sz_title);
|
||||||
title[sz_title-1] = '\0';
|
title[sz_title-1] = '\0';
|
||||||
@ -4052,7 +4060,9 @@ char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title)
|
|||||||
|
|
||||||
BOOLEAN xvt_vobj_is_focusable(WINDOW win)
|
BOOLEAN xvt_vobj_is_focusable(WINDOW win)
|
||||||
{
|
{
|
||||||
BOOLEAN ok = win != NULL_WIN && win != PRINTER_WIN && xvt_vobj_is_valid(win);
|
BOOLEAN ok = win != NULL_WIN && win != PRINTER_WIN &&
|
||||||
|
win != TASK_WIN && win != SCREEN_WIN &&
|
||||||
|
xvt_vobj_is_valid(win);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
CAST_WIN(win, w);
|
CAST_WIN(win, w);
|
||||||
|
@ -172,8 +172,9 @@ XVTDLL BOOLEAN xvt_fsys_convert_str_to_dir(const char *path, DIRECTORY *dirp);
|
|||||||
XVTDLL BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path);
|
XVTDLL BOOLEAN xvt_fsys_convert_fspec_to_str(const FILE_SPEC *fs, char *path, int sz_path);
|
||||||
XVTDLL BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs);
|
XVTDLL BOOLEAN xvt_fsys_convert_str_to_fspec(const char *mbs, FILE_SPEC *fs);
|
||||||
|
|
||||||
XVTDLL BOOLEAN xvt_fsys_get_dir(DIRECTORY *dirp);
|
XVTDLL BOOLEAN xvt_fsys_get_dir(DIRECTORY* dirp);
|
||||||
XVTDLL void xvt_fsys_get_default_dir(DIRECTORY *dirp);
|
XVTDLL void xvt_fsys_get_default_dir(DIRECTORY* dirp);
|
||||||
|
XVTDLL void xvt_fsys_get_temp_dir(DIRECTORY* dirp);
|
||||||
XVTDLL SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs);
|
XVTDLL SLIST xvt_fsys_list_files(const char *type, const char *pat, BOOLEAN dirs);
|
||||||
XVTDLL BOOLEAN xvt_fsys_parse_pathname (const char *mbs, char *volname, char *dirname, char *leafroot, char *leafext, char *leafvers);
|
XVTDLL BOOLEAN xvt_fsys_parse_pathname (const char *mbs, char *volname, char *dirname, char *leafroot, char *leafext, char *leafvers);
|
||||||
XVTDLL void xvt_fsys_restore_dir();
|
XVTDLL void xvt_fsys_restore_dir();
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
#include "wxinc.h"
|
#include "wxinc.h"
|
||||||
#include "xvt.h"
|
#include "xvt.h"
|
||||||
|
|
||||||
#include "email.h"
|
#include "smapi.h"
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
|
#include <wx/file.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
#include <wx/mimetype.h>
|
||||||
|
|
||||||
static wxString GetMailParam(const char* key, const char* def = "")
|
static wxString GetMailParam(const char* key, const char* def = "")
|
||||||
{
|
{
|
||||||
static wxString ini;
|
static wxString ini; // C:\campo\dati\config\user.ini
|
||||||
|
|
||||||
if (ini.IsEmpty())
|
if (ini.IsEmpty())
|
||||||
{
|
{
|
||||||
wxString cu = "ADMIN";
|
wxString cu = "ADMIN";
|
||||||
@ -67,15 +70,38 @@ short xvt_mail_installed()
|
|||||||
static void AppendQuotedString(wxString& cmd, const char* key, const wxString& value)
|
static void AppendQuotedString(wxString& cmd, const char* key, const wxString& value)
|
||||||
{
|
{
|
||||||
if (!value.IsEmpty())
|
if (!value.IsEmpty())
|
||||||
|
cmd << " -" << key << " \"" << value << "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AppendAttachment(wxString& cmd, const wxString& fname, bool att = true)
|
||||||
|
{
|
||||||
|
if (wxFileName::FileExists(fname))
|
||||||
{
|
{
|
||||||
cmd += " -";
|
char ext[_MAX_EXT] = { 0 };
|
||||||
cmd += key;
|
xvt_fsys_parse_pathname (fname, NULL, NULL, NULL, ext, NULL);
|
||||||
cmd += " \"";
|
wxString mime = ext;
|
||||||
cmd += value;
|
wxFileType* ft = wxTheMimeTypesManager->GetFileTypeFromExtension(mime);
|
||||||
cmd += "\"";
|
if (ft != NULL)
|
||||||
|
{
|
||||||
|
wxArrayString aMime;
|
||||||
|
if (ft->GetMimeTypes(aMime))
|
||||||
|
mime = aMime[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (att)
|
||||||
|
{
|
||||||
|
wxString a; a << fname << "," << mime << ",a";
|
||||||
|
AppendQuotedString(cmd, "attach", a);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString a; a << fname << "," << mime << ",i";
|
||||||
|
AppendQuotedString(cmd, "attach", a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn,
|
BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn,
|
||||||
const char* subject, const char* msg,
|
const char* subject, const char* msg,
|
||||||
const char* attach, short flags)
|
const char* attach, short flags)
|
||||||
@ -125,48 +151,127 @@ BOOLEAN xvt_mail_send(const char* to, const char* cc, const char* ccn,
|
|||||||
if ((mail_inst & 0x2) && GetMailParams(server, port, user, password, from))
|
if ((mail_inst & 0x2) && GetMailParams(server, port, user, password, from))
|
||||||
{
|
{
|
||||||
wxString cmd = "servers/mailsend.exe";
|
wxString cmd = "servers/mailsend.exe";
|
||||||
AppendQuotedString(cmd, "to", Msg.m_to[0]);
|
|
||||||
AppendQuotedString(cmd, "from", from);
|
|
||||||
|
|
||||||
if (Msg.m_cc.IsEmpty())
|
|
||||||
cmd += " +cc";
|
|
||||||
else
|
|
||||||
AppendQuotedString(cmd, "cc", Msg.m_cc[0]);
|
|
||||||
|
|
||||||
if (Msg.m_bcc.IsEmpty())
|
|
||||||
cmd += " +bc";
|
|
||||||
else
|
|
||||||
AppendQuotedString(cmd, "bc", Msg.m_bcc[0]);
|
|
||||||
|
|
||||||
AppendQuotedString(cmd, "smtp", server);
|
AppendQuotedString(cmd, "smtp", server);
|
||||||
|
|
||||||
if (!port.IsEmpty())
|
if (!port.IsEmpty())
|
||||||
{
|
{
|
||||||
cmd += " -port ";
|
cmd += " -port ";
|
||||||
cmd += port;
|
cmd += port;
|
||||||
}
|
}
|
||||||
|
AppendQuotedString(cmd, "from", from);
|
||||||
|
|
||||||
|
if ((flags | 0x2) && from.Find("@") > 0)
|
||||||
|
{
|
||||||
|
//AppendQuotedString(cmd, "rt", from);
|
||||||
|
AppendQuotedString(cmd, "rrr", from);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lista dei destinatari
|
||||||
|
for (size_t i = 0; i < Msg.m_to.size(); i++)
|
||||||
|
AppendQuotedString(cmd, "to", Msg.m_to[i]);
|
||||||
|
|
||||||
|
// Lista dei destinatari in copia
|
||||||
|
for (size_t i = 0; i < Msg.m_cc.size(); i++)
|
||||||
|
AppendQuotedString(cmd, "cc", Msg.m_cc[i]);
|
||||||
|
if (cmd.Find("-cc") < 0)
|
||||||
|
cmd += " +cc"; // In assenza di destinatari in copia aggiungo +cc
|
||||||
|
|
||||||
|
// Lista dei destinatari in copia nascosta
|
||||||
|
for (size_t i = 0; i < Msg.m_bcc.size(); i++)
|
||||||
|
AppendQuotedString(cmd, "bc", Msg.m_bcc[i]);
|
||||||
|
if (from.Find("@") > 0)
|
||||||
|
{
|
||||||
|
wxString strMyself; strMyself << "c " << from;
|
||||||
|
if (cmd.Find(strMyself) < 0)
|
||||||
|
AppendQuotedString(cmd, "bc", from); // Aggiungo me stesso ai destinatari nascosti
|
||||||
|
}
|
||||||
|
if (cmd.Find("-bc") < 0)
|
||||||
|
cmd += " +bc"; // In assenza di destinatari nascosti aggiungo +bc
|
||||||
|
|
||||||
AppendQuotedString(cmd, "sub", Msg.m_subject);
|
AppendQuotedString(cmd, "sub", Msg.m_subject);
|
||||||
AppendQuotedString(cmd, "user", user);
|
AppendQuotedString(cmd, "user", user);
|
||||||
AppendQuotedString(cmd, "pass", password);
|
AppendQuotedString(cmd, "pass", password);
|
||||||
|
|
||||||
|
AppendQuotedString(cmd, "enc-type", "base64");
|
||||||
|
|
||||||
if (!Msg.m_attachments.IsEmpty())
|
if (!Msg.m_attachments.IsEmpty())
|
||||||
{
|
{
|
||||||
for (size_t a = 0; a < Msg.m_attachments.size(); a++)
|
for (size_t a = 0; a < Msg.m_attachments.size(); a++)
|
||||||
AppendQuotedString(cmd, "attach", Msg.m_attachments[a]);
|
{
|
||||||
|
const wxString& fn = Msg.m_attachments[a];
|
||||||
|
if (wxFileName::FileExists(fn))
|
||||||
|
AppendAttachment(cmd, fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString output, error;
|
wxString ftmp;
|
||||||
wxExecute(cmd, output, error, wxEXEC_SYNC);
|
if (Msg.m_body.IsEmpty())
|
||||||
|
{
|
||||||
|
if (cmd.Find("-M ") < 0)
|
||||||
|
{
|
||||||
|
wxString m; m << "Cordiali saluti\n" << from;
|
||||||
|
m.Trim();
|
||||||
|
AppendQuotedString(cmd, "M", m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxStringTokenizer tok(Msg.m_body, "\n");
|
||||||
|
Msg.m_body.Trim();
|
||||||
|
if (Msg.m_body.Find("\n") < 0)
|
||||||
|
AppendQuotedString(cmd, "M", Msg.m_body);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DIRECTORY tmp; xvt_fsys_get_temp_dir(&tmp);
|
||||||
|
xvt_fsys_build_pathname(ftmp.GetWriteBuf(_MAX_PATH), NULL, tmp.path, "msgbody", "html", NULL);
|
||||||
|
ftmp.UngetWriteBuf();
|
||||||
|
wxFile file(ftmp, wxFile::write);
|
||||||
|
file.Write("<html><body>\n");
|
||||||
|
Msg.m_body.Replace("\n", "<br>");
|
||||||
|
file.Write(Msg.m_body);
|
||||||
|
file.Write("\n</body><html>\n");
|
||||||
|
file.Close();
|
||||||
|
AppendAttachment(cmd, ftmp, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString strLog = "mailsend.log";
|
||||||
|
xvt_fsys_remove_file(strLog);
|
||||||
|
AppendQuotedString(cmd, "log", strLog);
|
||||||
|
|
||||||
|
int nRetry = wxAtoi(GetMailParam("Retry", "2"));
|
||||||
|
if (nRetry <= 0) nRetry = 2;
|
||||||
|
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
for (size_t i = 0; !ok && i < error.size(); i++)
|
for (int r = 0; r < nRetry && !ok; r++)
|
||||||
ok = error[i].find("uccess") > 0;
|
{
|
||||||
|
if (r > 0)
|
||||||
|
{
|
||||||
|
const int nSeconds = 5*r;
|
||||||
|
WINDOW w = xvt_dm_progress_create(TASK_WIN, "MailSend retrying...", nSeconds, TRUE);
|
||||||
|
for (int s = 1; s <= nSeconds; s++)
|
||||||
|
{
|
||||||
|
xvt_sys_sleep(1000);
|
||||||
|
xvt_dm_progress_set_status(w, s, nSeconds);
|
||||||
|
}
|
||||||
|
xvt_dm_progress_destroy(w);
|
||||||
|
}
|
||||||
|
wxExecute(cmd, wxEXEC_SYNC);
|
||||||
|
wxFile fLog(strLog, wxFile::read);
|
||||||
|
const wxFileOffset flen = fLog.Length();
|
||||||
|
if (flen > 0)
|
||||||
|
{
|
||||||
|
char* buff = (char*)calloc(flen+8, 1); // zero filled buffer
|
||||||
|
fLog.Read(buff, flen);
|
||||||
|
if (wxStrstr(buff, "Mail sent successfully"))
|
||||||
|
ok = TRUE;
|
||||||
|
delete [] buff;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if (mail_inst & 1)
|
if (mail_inst & 1)
|
||||||
{
|
{
|
||||||
xvt_fsys_save_dir();
|
xvt_fsys_save_dir();
|
||||||
wxEmail Mail;
|
ok = Msg.Send(wxEmptyString, ui);
|
||||||
ok = Mail.Send(Msg, wxEmptyString, ui);
|
|
||||||
xvt_fsys_restore_dir();
|
xvt_fsys_restore_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,28 +554,9 @@ long TwxWindow::DoXvtEvent(EVENT& e)
|
|||||||
|
|
||||||
void TwxWindow::OnChar(wxKeyEvent& evt)
|
void TwxWindow::OnChar(wxKeyEvent& evt)
|
||||||
{
|
{
|
||||||
static int nSkipNextDotKey = -883; // Valore indefinito
|
|
||||||
if (nSkipNextDotKey == -883) // Devo stabilire se attivare la gestione o no
|
|
||||||
{
|
|
||||||
const char* campoini = xvt_fsys_get_campo_ini();
|
|
||||||
char str[2];
|
|
||||||
xvt_sys_get_profile_string(campoini, "Main", "Point2Comma", "1", str, sizeof(str));
|
|
||||||
nSkipNextDotKey = strchr("1XY", *str) != NULL ? 0 : -1; // Dis/Abilita conversione punto in virgola
|
|
||||||
}
|
|
||||||
|
|
||||||
XVT_EVENT e(E_CHAR);
|
XVT_EVENT e(E_CHAR);
|
||||||
int k = evt.GetKeyCode();
|
int k = evt.GetKeyCode();
|
||||||
|
|
||||||
if (nSkipNextDotKey == 1)
|
|
||||||
{
|
|
||||||
nSkipNextDotKey = 0;
|
|
||||||
if (k == '.')
|
|
||||||
{
|
|
||||||
evt.Skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
case WXK_ALT:
|
case WXK_ALT:
|
||||||
@ -592,14 +573,6 @@ void TwxWindow::OnChar(wxKeyEvent& evt)
|
|||||||
case WXK_NUMPAD9:
|
case WXK_NUMPAD9:
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
return;
|
return;
|
||||||
case WXK_NUMPAD_DECIMAL: // Arriva solo dalla 2.6.3 in poi
|
|
||||||
case WXK_DECIMAL: // ??? Arriva sia '.' sia WXK_DECIMAL=340
|
|
||||||
if (nSkipNextDotKey == 0)
|
|
||||||
{
|
|
||||||
k = ','; // Trasformo il punto in virgola
|
|
||||||
nSkipNextDotKey = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WXK_NUMPAD_ADD: k = '+';break;
|
case WXK_NUMPAD_ADD: k = '+';break;
|
||||||
case WXK_DOWN : k = K_DOWN; break;
|
case WXK_DOWN : k = K_DOWN; break;
|
||||||
case WXK_END : k = K_LEND; break;
|
case WXK_END : k = K_LEND; break;
|
||||||
@ -651,6 +624,22 @@ void TwxWindow::OnKeyDown(wxKeyEvent& e)
|
|||||||
OnChar(e);
|
OnChar(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
if (k == WXK_NUMPAD_DECIMAL)
|
||||||
|
{
|
||||||
|
static int nPoint2Comma = -883; // Valore indefinito
|
||||||
|
if (nPoint2Comma == -883) // Devo stabilire se attivare la gestione o no
|
||||||
|
{
|
||||||
|
char str[4] = { 0 };
|
||||||
|
xvt_sys_get_profile_string(NULL, "Main", "Point2Comma", "1", str, sizeof(str));
|
||||||
|
nPoint2Comma = wxStrchr("1XY", *str) ? 1 : 0; // Dis/Abilita conversione punto in virgola
|
||||||
|
}
|
||||||
|
if (nPoint2Comma)
|
||||||
|
{
|
||||||
|
e.m_keyCode = ',';
|
||||||
|
OnChar(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e.Skip();
|
e.Skip();
|
||||||
}
|
}
|
||||||
@ -1006,7 +995,9 @@ void TTaskWin::OnMenu(wxCommandEvent& evt)
|
|||||||
e.v.cmd.tag = evt.GetId();
|
e.v.cmd.tag = evt.GetId();
|
||||||
|
|
||||||
if (m_MenuOwner == NULL || m_MenuOwner == this)
|
if (m_MenuOwner == NULL || m_MenuOwner == this)
|
||||||
|
{
|
||||||
_task_win_handler((WINDOW)this, &e);
|
_task_win_handler((WINDOW)this, &e);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TwxWindow* w = wxDynamicCast(m_MenuOwner, TwxWindow);
|
TwxWindow* w = wxDynamicCast(m_MenuOwner, TwxWindow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user