summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2014-04-11 00:56:58 +0000
committerRené Schümann <white06tiger@gmail.com>2014-04-11 00:56:58 +0000
commit6d08efb05a3ed58dadf7e280d4a683293961ff78 (patch)
tree6dfe2104a80d07b89d68b99691b905d2e6c57d6c
parent577556ad930d4302e51cfeda256ce3a9898bea86 (diff)
SendSS:
! translation fixes (CSendFTPFile,CSendHTTPServer) ! fixed some error handling (CSendHTTPServer,CSendImageShack) * allow silent sending with all CSend's (CSend, CSendDropbox, CSendFTPFile, CSendImageShack) we also use this for Dropbox since we don't know the upload progress * CSend's addition to r8939 (mir_freeAndNil() removed with mir_free() in some places) git-svn-id: http://svn.miranda-ng.org/main/trunk@8942 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp75
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.h4
-rw-r--r--plugins/SendScreenshotPlus/src/CSendDropbox.cpp1
-rw-r--r--plugins/SendScreenshotPlus/src/CSendFTPFile.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.cpp18
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.h2
7 files changed, 60 insertions, 49 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index 84cee53540..7de9574cf6 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -29,9 +29,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "global.h"
//---------------------------------------------------------------------------
-CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync) :
+CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync, bool bSilent) :
m_bDeleteAfterSend(false),
m_bAsync(bAsync),
+ m_bSilent(bSilent),
m_pszFile(NULL),
m_pszFileDesc(NULL),
m_pszSendTyp(NULL),
@@ -125,6 +126,9 @@ INT_PTR CALLBACK CSend::ResultDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LP
return FALSE;
}
void CSend::svcSendMsgExit(const char* szMessage) {
+ if(m_bSilent){
+ Exit(ACKRESULT_SUCCESS); return;
+ }
if(!m_hContact){
mir_free(m_ErrorTitle), m_ErrorTitle=mir_a2t(szMessage);
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UResultForm),0, ResultDialogProc,(LPARAM)this);
@@ -192,6 +196,9 @@ void CSend::svcSendFileExit() {
//szMessage should be encoded as the File followed by the description, the
//separator being a single nul (\0). If there is no description, do not forget
//to end the File with two nuls.
+ if(m_bSilent){
+ Exit(ACKRESULT_SUCCESS); return;
+ }
if(!m_hContact){
Error(LPGENT("%s requires a valid contact!"), m_pszSendTyp);
Exit(ACKRESULT_FAILED); return;
@@ -208,9 +215,9 @@ void CSend::svcSendFileExit() {
m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
lstrcpyA(m_szEventMsg+lstrlenA(szFile)+1,temp);
m_szEventMsg[m_cbEventMsg-1] = 0;
- mir_freeAndNil(temp);
+ mir_free(temp);
}
- mir_freeAndNil(szFile);
+ mir_free(szFile);
//create a HookEventObj on ME_PROTO_ACK
if (!m_hOnSend) {
@@ -329,36 +336,38 @@ void CSend::Error(LPCTSTR pszFormat, ...) {
//---------------------------------------------------------------------------
void CSend::Exit(unsigned int Result) {
- bool err = true;
- switch(Result) {
- case ACKRESULT_SUCCESS:
- case GC_RESULT_SUCCESS:
- SkinPlaySound("FileDone");
- err = false;
- break;
- case ACKRESULT_DENIED:
- SkinPlaySound("FileDenied");
- Error(_T("%s (%i):\nFile transfer denied."),TranslateTS(m_pszSendTyp),Result);
- MsgBoxService(NULL, (LPARAM)&m_box);
- err = false;
- break;
- case GC_RESULT_WRONGVER: //.You appear to be using the wrong version of GC API.
- Error(_T("%s (%i):\nYou appear to be using the wrong version of GC API"),TranslateT("GCHAT error"),Result);
- break;
- case GC_RESULT_ERROR: // An internal GC error occurred.
- Error(_T("%s (%i):\nAn internal GC error occurred."),TranslateT("GCHAT error"),Result);
- break;
- case GC_RESULT_NOSESSION: // contact has no open GC session
- Error(_T("%s (%i):\nContact has no open GC session."),TranslateT("GCHAT error"),Result);
- break;
- case ACKRESULT_FAILED:
- default:
- break;
- }
- if(err){
- SkinPlaySound("FileFailed");
- if(m_ErrorMsg) MsgBoxService(NULL, (LPARAM)&m_box);
- else MsgErr(NULL, LPGENT("An unknown error has occurred."));
+ if(!m_bSilent){
+ bool err = true;
+ switch(Result) {
+ case ACKRESULT_SUCCESS:
+ case GC_RESULT_SUCCESS:
+ SkinPlaySound("FileDone");
+ err = false;
+ break;
+ case ACKRESULT_DENIED:
+ SkinPlaySound("FileDenied");
+ Error(_T("%s (%i):\nFile transfer denied."),TranslateTS(m_pszSendTyp),Result);
+ MsgBoxService(NULL, (LPARAM)&m_box);
+ err = false;
+ break;
+ case GC_RESULT_WRONGVER: //.You appear to be using the wrong version of GC API.
+ Error(_T("%s (%i):\nYou appear to be using the wrong version of GC API"),TranslateT("GCHAT error"),Result);
+ break;
+ case GC_RESULT_ERROR: // An internal GC error occurred.
+ Error(_T("%s (%i):\nAn internal GC error occurred."),TranslateT("GCHAT error"),Result);
+ break;
+ case GC_RESULT_NOSESSION: // contact has no open GC session
+ Error(_T("%s (%i):\nContact has no open GC session."),TranslateT("GCHAT error"),Result);
+ break;
+ case ACKRESULT_FAILED:
+ default:
+ break;
+ }
+ if(err){
+ SkinPlaySound("FileFailed");
+ if(m_ErrorMsg) MsgBoxService(NULL, (LPARAM)&m_box);
+ else MsgErr(NULL, LPGENT("An unknown error has occurred."));
+ }
}
if(m_pszFile && *m_pszFile && m_bDeleteAfterSend && m_EnableItem&SS_DLG_DELETEAFTERSSEND) {
DeleteFile(m_pszFile), m_pszFile=NULL;
diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h
index d6972028cd..63047b7fd3 100644
--- a/plugins/SendScreenshotPlus/src/CSend.h
+++ b/plugins/SendScreenshotPlus/src/CSend.h
@@ -48,10 +48,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//---------------------------------------------------------------------------
class CSend {
public:
- CSend(HWND Owner, MCONTACT hContact, bool bAsync); // oder (TfrmMain & Owner)
+ CSend(HWND Owner, MCONTACT hContact, bool bAsync, bool bSilent=false); // oder (TfrmMain & Owner)
virtual ~CSend();
virtual int Send() = NULL; // returns 1 if sent (you must delete class) and 0 when still sending (class deletes itself)
+ int SendSilent() {m_bAsync=m_bSilent=true; return Send();};
void SetFile(TCHAR* file){mir_free(m_pszFile), m_pszFile=mir_tstrdup(file);};
void SetFile(char* file){mir_free(m_pszFile), m_pszFile=mir_a2t(file);};
@@ -63,6 +64,7 @@ class CSend {
bool m_bDeleteAfterSend;
protected:
bool m_bAsync;
+ bool m_bSilent;
TCHAR* m_pszFile;
TCHAR* m_pszFileDesc;
static int OnSend(void *obj, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp
index 22d85117e8..e11677931f 100644
--- a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp
@@ -62,6 +62,7 @@ void CSendDropbox::SendThread() {
Error(LPGENT("%s (%i):\nCould not add a share to the Dropbox plugin."),TranslateTS(m_pszSendTyp),ret);
Exit(ACKRESULT_FAILED); return;
}
+ m_bSilent=true;
Exit(ACKRESULT_SUCCESS);
}
diff --git a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp
index 9ec7a21efa..b52a3925e8 100644
--- a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp
@@ -74,7 +74,7 @@ void CSendFTPFile::SendThread() {
INT_PTR ret = FTPFileUploadA(m_hContact, FNUM_DEFAULT, FMODE_RAWFILE, &m_pszFileName,1);
if (ret != 0) {
- Error(TranslateT("%s (%i):\nCould not add a share to the FTP File plugin."),TranslateTS(m_pszSendTyp),ret);
+ Error(LPGENT("%s (%i):\nCould not add a share to the FTP File plugin."),TranslateTS(m_pszSendTyp),ret);
Exit(ret); return;
}
diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
index 4b9b7d9e00..cc705ba0e0 100644
--- a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
@@ -56,8 +56,9 @@ int CSendHTTPServer::Send()
{
if(!m_hContact) return 1;
if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, (WPARAM)true, 0) != 0) {
- Error(NULL, TranslateT("Could not start the HTTP Server plugin."));
- return 1;
+ Error(LPGENT("Could not start the HTTP Server plugin."));
+ Exit(ACKRESULT_FAILED);
+ return !m_bAsync;
}
if (!m_pszFileName) {
@@ -102,7 +103,7 @@ void CSendHTTPServer::SendThread() {
}
if (ret != 0) {
- Error(TranslateT("%s (%i):\nCould not add a share to the HTTP Server plugin."),TranslateTS(m_pszSendTyp),ret);
+ Error(LPGENT("%s (%i):\nCould not add a share to the HTTP Server plugin."),TranslateTS(m_pszSendTyp),ret);
Exit(ret); return;
}
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
index 0906979e86..8bfe9c02d0 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
@@ -38,7 +38,6 @@ CSendImageShack::CSendImageShack(HWND Owner, MCONTACT hContact, bool bAsync)
m_pszContentType = NULL;
m_MFDRboundary = NULL;
m_nlreply = NULL;
- m_Silent = false;
m_Url = NULL;
}
@@ -52,10 +51,10 @@ CSendImageShack::~CSendImageShack(){
//---------------------------------------------------------------------------
int CSendImageShack::Send() {
- // check Netlib
- if( !hNetlibUser ) {
- //PrintError(1,TRUE);
- return 1;
+ if(!hNetlibUser){ /// check Netlib
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ return !m_bAsync;
}
if (!m_pszFileName) {
m_pszFileName = GetFileNameA(m_pszFile);
@@ -117,8 +116,9 @@ int CSendImageShack::Send() {
//Now we add the file binary ($this->sendData($h))
FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR );
if( !fileId) {
- //PrintError(1,TRUE);
- return 1;
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ return !m_bAsync;
}
fseek(fileId, NULL, SEEK_END);
size_t lenFile = ftell(fileId);
@@ -202,11 +202,11 @@ void CSendImageShack::SendThread() {
mir_freeAndNil(err);
err = mir_a2t(m_nlreply->pData);
}
- Error(NULL, err);
+ Error(_T("%s"),err);
mir_free(err);
}
}else{
- Error(NULL, TranslateT("Upload server did not respond timely."));
+ Error(LPGENT("Upload server did not respond timely."));
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
m_nlreply = NULL;
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.h b/plugins/SendScreenshotPlus/src/CSendImageShack.h
index 92e928c9bc..06642ff47e 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.h
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.h
@@ -37,7 +37,6 @@ class CSendImageShack : public CSend {
~CSendImageShack();
int Send();
- int SendSilent() {m_bAsync=m_Silent=true; return Send();};
char* GetURL(){return m_Url;};
protected:
@@ -55,7 +54,6 @@ class CSendImageShack : public CSend {
char* m_MFDRboundary;
void MFDR_Reset();
- bool m_Silent;
void SendThread();
static void SendThreadWrapper(void * Obj);