summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2014-04-03 02:35:29 +0000
committerRené Schümann <white06tiger@gmail.com>2014-04-03 02:35:29 +0000
commitcf2713fd362cfeeeda946ead18e6b88abdff9c93 (patch)
tree5c697c37b29aab31ea056d0ad94e0c05d816c506 /plugins/SendScreenshotPlus/src/CSendImageShack.cpp
parentb87686ce677be209f6923fc8b2f11edcff7f98a0 (diff)
SendSS
!*+ re-factored CSend a bit, fixes some bugs and improved re-usability + CSend got a new dialog to display URL created if there's no target contact (used by ImageShack when called from main menu * m_bDeleteAfterSend is now m_bAsync * CSend::Send now returns 1 if sent (sync, caller deletes) and 0 if sending is in progress (class self deletes, async) * ImageShack got new method SendSilent() (we used m_SendSync before, now renamed to m_bSilent for internal use) ! fixed memory leaks and using "delete" on already deleted CSend which caused a crash ! fixed graphical issue with wrongly initialized state buttons (delete after send, add description etc) git-svn-id: http://svn.miranda-ng.org/main/trunk@8835 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus/src/CSendImageShack.cpp')
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
index d99c858f4d..d6e9809859 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
@@ -30,15 +30,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "global.h"
//---------------------------------------------------------------------------
-CSendImageShack::CSendImageShack(HWND Owner, MCONTACT hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit) {
- m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION;
- m_pszSendTyp = _T("Image upload");
+CSendImageShack::CSendImageShack(HWND Owner, MCONTACT hContact, bool bAsync)
+: CSend(Owner, hContact, bAsync) {
+ m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
+ m_pszSendTyp = LPGENT("Image upload");
m_pszFileName = NULL;
m_pszContentType = NULL;
m_MFDRboundary = NULL;
m_nlreply = NULL;
- m_SendSync = false;
+ m_Silent = false;
m_Url = NULL;
}
@@ -51,11 +51,11 @@ CSendImageShack::~CSendImageShack(){
};
//---------------------------------------------------------------------------
-void CSendImageShack::Send() {
+int CSendImageShack::Send() {
// check Netlib
if( !hNetlibUser ) {
//PrintError(1,TRUE);
- return;
+ return 1;
}
if (!m_pszFileName) {
m_pszFileName = GetFileNameA(m_pszFile);
@@ -118,7 +118,7 @@ void CSendImageShack::Send() {
FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR );
if( !fileId) {
//PrintError(1,TRUE);
- return;
+ return 1;
}
fseek(fileId, NULL, SEEK_END);
size_t lenFile = ftell(fileId);
@@ -173,13 +173,12 @@ void CSendImageShack::Send() {
AppendToData("--\r\n");
//start upload thread
- if (m_SendSync) {
- m_bFreeOnExit = FALSE;
- SendThread();
- return;
+ if(m_bAsync){
+ mir_forkthread(&CSendImageShack::SendThreadWrapper, this);
+ return 0;
}
- m_bFreeOnExit = TRUE;
- mir_forkthread(&CSendImageShack::SendThreadWrapper, this);
+ SendThread();
+ return 1;
}
void CSendImageShack::SendThread() {
@@ -194,12 +193,9 @@ void CSendImageShack::SendThread() {
URL = GetTagContent(m_nlreply->pData, "<image_link>", "</image_link>");
if (URL && URL[0]!= NULL) {
m_Url = mir_strdup(URL);
- if(m_SendSync) {
- Exit(ACKRESULT_SUCCESS);
+ if(m_Silent)
return;
- }
- m_ChatRoom ? svcSendChat(URL) : svcSendMsg(URL);
- return;
+ svcSendMsgExit(URL); return;
}else{//check error mess from server
TCHAR* err = mir_a2t(GetTagContent(m_nlreply->pData, "<error ", "</error>"));
if (!err || !*err){//fallback to server response mess
@@ -209,14 +205,12 @@ void CSendImageShack::SendThread() {
Error(NULL, err);
mir_free(err);
}
- }
- else {
+ }else{
Error(NULL, TranslateT("Upload server did not respond timely."));
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
m_nlreply = NULL;
- }
- else {
+ }else{
Error(SS_ERR_INIT, m_pszSendTyp);
}
Exit(ACKRESULT_FAILED);