summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus
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
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')
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp433
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.h72
-rw-r--r--plugins/SendScreenshotPlus/src/CSendEmail.cpp25
-rw-r--r--plugins/SendScreenshotPlus/src/CSendEmail.h4
-rw-r--r--plugins/SendScreenshotPlus/src/CSendFTPFile.cpp18
-rw-r--r--plugins/SendScreenshotPlus/src/CSendFTPFile.h4
-rw-r--r--plugins/SendScreenshotPlus/src/CSendFile.cpp97
-rw-r--r--plugins/SendScreenshotPlus/src/CSendFile.h93
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp22
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHTTPServer.h4
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.cpp40
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.h8
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp18
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp63
-rw-r--r--plugins/SendScreenshotPlus/src/resource.h3
15 files changed, 440 insertions, 464 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index 793a9ecca7..8ac60fb399 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -29,160 +29,176 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "global.h"
//---------------------------------------------------------------------------
-CSend::CSend(HWND Owner, MCONTACT hContact, bool bFreeOnExit) {
- m_hWndO = Owner;
- m_bFreeOnExit = bFreeOnExit;
- m_pszFile = NULL;
- m_pszFileDesc = NULL;
- m_pszProto = NULL;
- m_ChatRoom = NULL;
- m_PFflag = NULL;
- m_hContact = NULL;
- if (hContact) SetContact(hContact);
- m_hOnSend = NULL;
- m_szEventMsg = NULL;
- m_szEventMsgT = NULL;
- m_pszSendTyp = NULL;
-
- m_ErrorMsg = NULL;
- m_ErrorTitle = NULL;
+CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync) :
+ m_bDeleteAfterSend(false),
+ m_bAsync(bAsync),
+ m_pszFile(NULL),
+ m_pszFileDesc(NULL),
+ m_pszSendTyp(NULL),
+ m_pszProto(NULL),
+// m_hContact(hContact), // initialized below
+ m_EnableItem(0),
+ m_ChatRoom(0),
+// m_PFflag(0),
+ m_cbEventMsg(0),
+ m_szEventMsg(NULL),
+ m_hSend(0),
+ m_hOnSend(0),
+ m_ErrorMsg(NULL),
+ m_ErrorTitle(NULL)
+{
+ SetContact(hContact);
}
CSend::~CSend(){
mir_free(m_pszFile);
mir_free(m_pszFileDesc);
mir_free(m_szEventMsg);
- mir_free(m_szEventMsgT);
mir_free(m_ErrorMsg);
mir_free(m_ErrorTitle);
- if (m_hOnSend) UnhookEvent(m_hOnSend);
+ if(m_hOnSend) UnhookEvent(m_hOnSend);
}
//---------------------------------------------------------------------------
void CSend::SetContact(MCONTACT hContact) {
- m_hContact = hContact;
- m_pszProto = GetContactProto(hContact);
- m_ChatRoom = db_get_b(hContact, m_pszProto, "ChatRoom", 0);
- m_PFflag = hasCap(PF1_URLSEND);
- m_PFflag = hasCap(PF1_CHAT);
- m_PFflag = hasCap(PF1_IMSEND);
+ m_hContact = hContact;
+ if(hContact){
+ m_pszProto = GetContactProto(hContact);
+ m_ChatRoom = db_get_b(hContact, m_pszProto, "ChatRoom", 0);
+ /*
+ m_PFflag = hasCap(PF1_URLSEND);
+ m_PFflag = hasCap(PF1_CHAT);
+ m_PFflag = hasCap(PF1_IMSEND);// */
+ }
}
//---------------------------------------------------------------------------
-bool CSend::hasCap(unsigned int Flag) {
+/*bool CSend::hasCap(unsigned int Flag) {
return (Flag & CallContactService(m_hContact, PS_GETCAPS, PFLAGNUM_1, NULL)) == Flag;
-}
+}// */
//---------------------------------------------------------------------------
-void CSend::svcSendMsg(const char* szMessage) {
- mir_freeAndNil(m_szEventMsg);
- m_cbEventMsg=lstrlenA(szMessage)+1;
- m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
- ZeroMemory(m_szEventMsg, m_cbEventMsg);
- lstrcpyA(m_szEventMsg,szMessage);
- if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
- char *temp = mir_t2a(m_pszFileDesc);
- mir_stradd(m_szEventMsg, "\r\n");
- mir_stradd(m_szEventMsg, temp);
- m_cbEventMsg = lstrlenA(m_szEventMsg)+1;
- mir_free(temp);
- }
- //create a HookEventObj on ME_PROTO_ACK
- if (!m_hOnSend) {
- int (__cdecl CSend::*hookProc)(WPARAM, LPARAM);
- hookProc = &CSend::OnSend;
- m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this);
- }
- //start PSS_MESSAGE service
- m_hSend = (HANDLE)CallContactService(m_hContact, PSS_MESSAGE, NULL, (LPARAM)m_szEventMsg);
- // check we actually got an ft handle back from the protocol
- if (!m_hSend) {
- Unhook();
- Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
- }
-}
-/*
-void CSend::svcSendUrl(const char* url) {
-//szMessage should be encoded as the URL followed by the description, the
-//separator being a single nul (\0). If there is no description, do not forget
-//to end the URL with two nuls.
- mir_freeAndNil(m_szEventMsg)
- m_cbEventMsg=lstrlenA(url)+2;
- m_szEventMsg=(char*)mir_realloc(m_szEventMsg, m_cbEventMsg);
- ZeroMemory(m_szEventMsg, m_cbEventMsg);
- lstrcpyA(m_szEventMsg,url);
- if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
- char *temp = mir_t2a(m_pszFileDesc);
- m_cbEventMsg += lstrlenA(temp);
- m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
- lstrcpyA(m_szEventMsg+lstrlenA(url)+1,temp);
- m_szEventMsg[m_cbEventMsg-1] = 0;
- mir_free(temp);
- }
- //create a HookEventObj on ME_PROTO_ACK
- if (!m_hOnSend) {
- int (__cdecl CSend::*hookProc)(WPARAM, LPARAM);
- hookProc = &CSend::OnSend;
- m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this);
- }
- //start PSS_URL service
- m_hSend = (HANDLE)CallContactService(m_hContact, PSS_URL, NULL, (LPARAM)m_szEventMsg);
- // check we actually got an ft handle back from the protocol
- if (!m_hSend) {
- //SetFtStatus(hwndDlg, LPGENT("Unable to initiate transfer."), FTS_TEXT);
- //dat->waitingForAcceptance=0;
- Unhook();
- }
-}*/
-
-void CSend::svcSendChat() {
- GC_INFO gci = {0};
- int res = GC_RESULT_NOSESSION;
- int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_pszProto);
-
- //loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact
- gci.pszModule = m_pszProto;
- for (int i = 0; i < cnt ; i++ ) {
- gci.iItem = i;
- gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
- CallService(MS_GC_GETINFO, 0, (LPARAM)&gci);
- if (gci.hContact == m_hContact) {
- GCDEST gcd = { m_pszProto, gci.pszID, GC_EVENT_SENDMESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.bIsMe = TRUE;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszText = m_szEventMsgT;
- gce.time = time(NULL);
-
- //* returns 0 on success or error code on failure
- res = 200 + (int)CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
- break;
+INT_PTR CALLBACK CSend::ResultDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam){
+ switch(uMsg){
+ case WM_INITDIALOG:{
+ SendMessage(hwndDlg,WM_SETICON,ICON_BIG,(LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW1,1));
+ CSend* self=(CSend*)lParam;
+ TCHAR* tmp=mir_tstrdup(TranslateT("Resulting URL from\n"));
+ mir_tcsadd(tmp,self->m_pszSendTyp);
+ SetDlgItemText(hwndDlg,IDC_HEADERBAR,tmp);
+ mir_free(tmp);
+ SendMessage(GetDlgItem(hwndDlg,IDC_HEADERBAR),WM_SETICON,ICON_BIG,(LPARAM)Skin_GetIcon(ICO_COMMON_ARROWR,1));
+ SetDlgItemText(hwndDlg,ID_edtURL,self->m_ErrorTitle);
+ if(self->m_pszFileDesc)
+ SetDlgItemText(hwndDlg,ID_bvlDesc,self->m_pszFileDesc);
+ SendMessage(GetDlgItem(hwndDlg,IDOK),BUTTONSETDEFAULT,1,NULL);
+ SendMessage(GetDlgItem(hwndDlg,IDOK),BM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon(ICO_BTN_EDIT));
+ SendMessage(GetDlgItem(hwndDlg,IDCANCEL),BM_SETIMAGE,IMAGE_ICON,(LPARAM)Skin_GetIcon(ICO_BTN_CANCEL));
+ return TRUE;}
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDOK:{
+ TCHAR tmp[1024];
+ size_t len=GetDlgItemText(hwndDlg,ID_edtURL,tmp,1024);
+ int retries=3;
+ do{
+ if(!OpenClipboard(hwndDlg)){
+ Sleep(100);
+ continue;
+ }
+ EmptyClipboard();
+ HGLOBAL clipbuffer=GlobalAlloc(GMEM_MOVEABLE, len*sizeof(TCHAR)+sizeof(TCHAR));
+ TCHAR* tmp2=(TCHAR*)GlobalLock(clipbuffer);
+ mir_tcsncpy(tmp2,tmp,len+1); tmp2[len]='\0';
+ GlobalUnlock(clipbuffer);
+ SetClipboardData(CF_UNICODETEXT,clipbuffer);
+ CloseClipboard();
+ break;
+ }while(--retries);
+ DestroyWindow(hwndDlg);
+ return TRUE;}
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ return TRUE;
}
}
- Exit(res);
+ return FALSE;
}
-
-void CSend::svcSendChat(const char* szMessage) {
- if (!m_ChatRoom) {
- svcSendMsg(szMessage);
- return;
+void CSend::svcSendMsgExit(const char* szMessage) {
+ if(!m_hContact){
+ mir_free(m_ErrorTitle), m_ErrorTitle=mir_a2t(szMessage);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UResultForm),0, ResultDialogProc,(LPARAM)this);
+ Exit(ACKRESULT_SUCCESS); return;
}
- mir_freeAndNil(m_szEventMsgT);
- m_szEventMsgT = mir_a2t(szMessage);
- if (m_pszFileDesc) {
- mir_tcsadd(m_szEventMsgT, _T("\r\n"));
- mir_tcsadd(m_szEventMsgT, m_pszFileDesc);
+ if(m_ChatRoom){
+ TCHAR* tmp = mir_a2t(szMessage);
+ if (m_pszFileDesc) {
+ mir_tcsadd(tmp, _T("\r\n"));
+ mir_tcsadd(tmp, m_pszFileDesc);
+ }
+ GC_INFO gci = {0};
+ int res = GC_RESULT_NOSESSION;
+ int cnt = (int)CallService(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_pszProto);
+
+ //loop on all gc session to get the right (save) ptszID for the chatroom from m_hContact
+ gci.pszModule = m_pszProto;
+ for (int i = 0; i < cnt ; i++ ) {
+ gci.iItem = i;
+ gci.Flags = GCF_BYINDEX | GCF_HCONTACT | GCF_ID;
+ CallService(MS_GC_GETINFO, 0, (LPARAM)&gci);
+ if (gci.hContact == m_hContact) {
+ GCDEST gcd = { m_pszProto, gci.pszID, GC_EVENT_SENDMESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.bIsMe = TRUE;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszText = tmp;
+ gce.time = time(NULL);
+
+ //* returns 0 on success or error code on failure
+ res = 200 + (int)CallService(MS_GC_EVENT, 0, (LPARAM)&gce);
+ break;
+ }
+ }
+ Exit(res); return;
+ }else{
+ mir_freeAndNil(m_szEventMsg);
+ m_cbEventMsg=lstrlenA(szMessage)+1;
+ m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
+ ZeroMemory(m_szEventMsg, m_cbEventMsg);
+ lstrcpyA(m_szEventMsg,szMessage);
+ if (m_pszFileDesc && m_pszFileDesc[0] != NULL) {
+ char *temp = mir_t2a(m_pszFileDesc);
+ mir_stradd(m_szEventMsg, "\r\n");
+ mir_stradd(m_szEventMsg, temp);
+ m_cbEventMsg = lstrlenA(m_szEventMsg)+1;
+ mir_free(temp);
+ }
+ //create a HookEventObj on ME_PROTO_ACK
+ if (!m_hOnSend) {
+ m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
+ }
+ //start PSS_MESSAGE service
+ m_hSend = (HANDLE)CallContactService(m_hContact, PSS_MESSAGE, NULL, (LPARAM)m_szEventMsg);
+ // check we actually got an ft handle back from the protocol
+ if (!m_hSend) {
+ Unhook();
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED); return;
+ }
}
- svcSendChat();
+ Exit(ACKRESULT_SUCCESS);
}
-void CSend::svcSendFile() {
+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.
- mir_freeAndNil(m_szEventMsg)
- char *szFile = mir_t2a(m_pszFile);
+ if(!m_hContact){
+ Error(LPGENT("%s requires a valid contact!"), m_pszSendTyp);
+ Exit(ACKRESULT_FAILED); return;
+ }
+ mir_freeAndNil(m_szEventMsg);
+ char* szFile = mir_t2a(m_pszFile);
m_cbEventMsg=lstrlenA(szFile)+2;
m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
ZeroMemory(m_szEventMsg, m_cbEventMsg);
@@ -199,14 +215,12 @@ void CSend::svcSendFile() {
//create a HookEventObj on ME_PROTO_ACK
if (!m_hOnSend) {
- int (__cdecl CSend::*hookProc)(WPARAM, LPARAM);
- hookProc = &CSend::OnSend;
- m_hOnSend = HookEventObj(ME_PROTO_ACK, (MIRANDAHOOKOBJ)*(void **)&hookProc, this);
+ m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this);
}
// Start miranda PSS_FILE based on mir ver (T)
- TCHAR *ppFile[2]={0,0};
- TCHAR *pDesc = mir_tstrdup(m_pszFileDesc);
+ TCHAR* ppFile[2]={0,0};
+ TCHAR* pDesc = mir_tstrdup(m_pszFileDesc);
ppFile[0] = mir_tstrdup (m_pszFile);
ppFile[1] = NULL;
m_hSend = (HANDLE)CallContactService(m_hContact, PSS_FILET, (WPARAM)pDesc, (LPARAM)ppFile);
@@ -217,14 +231,16 @@ void CSend::svcSendFile() {
if (!m_hSend) {
Unhook();
Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
+ Exit(ACKRESULT_FAILED); return;
}
+ Exit(ACKRESULT_SUCCESS);
}
//---------------------------------------------------------------------------
-int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){
+int CSend::OnSend(void *obj, WPARAM wParam, LPARAM lParam){
+ CSend* self=(CSend*)obj;
ACKDATA *ack=(ACKDATA*)lParam;
- if(ack->hProcess!= m_hSend) return 0;
+ if(ack->hProcess!= self->m_hSend) return 0;
/* if(dat->waitingForAcceptance) {
SetTimer(hwndDlg,1,1000,NULL);
dat->waitingForAcceptance=0;
@@ -232,57 +248,52 @@ int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){
*/
switch(ack->result) {
- case ACKRESULT_INITIALISING: //SetFtStatus(hwndDlg, LPGENT("Initialising..."), FTS_TEXT); break;
- case ACKRESULT_CONNECTING: //SetFtStatus(hwndDlg, LPGENT("Connecting..."), FTS_TEXT); break;
- case ACKRESULT_CONNECTPROXY: //SetFtStatus(hwndDlg, LPGENT("Connecting to proxy..."), FTS_TEXT); break;
- case ACKRESULT_LISTENING: //SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); break;
- case ACKRESULT_CONNECTED: //SetFtStatus(hwndDlg, LPGENT("Connected"), FTS_TEXT); break;
- case ACKRESULT_SENTREQUEST: //SetFtStatus(hwndDlg, LPGENT("Decision sent"), FTS_TEXT); break;
- case ACKRESULT_NEXTFILE: //SetFtStatus(hwndDlg, LPGENT("Moving to next file..."), FTS_TEXT);
- case ACKRESULT_FILERESUME: //
- case ACKRESULT_DATA: //transfer is on progress
+ case ACKRESULT_INITIALISING: //SetFtStatus(hwndDlg, LPGENT("Initialising..."), FTS_TEXT); break;
+ case ACKRESULT_CONNECTING: //SetFtStatus(hwndDlg, LPGENT("Connecting..."), FTS_TEXT); break;
+ case ACKRESULT_CONNECTPROXY: //SetFtStatus(hwndDlg, LPGENT("Connecting to proxy..."), FTS_TEXT); break;
+ case ACKRESULT_LISTENING: //SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); break;
+ case ACKRESULT_CONNECTED: //SetFtStatus(hwndDlg, LPGENT("Connected"), FTS_TEXT); break;
+ case ACKRESULT_SENTREQUEST: //SetFtStatus(hwndDlg, LPGENT("Decision sent"), FTS_TEXT); break;
+ case ACKRESULT_NEXTFILE: //SetFtStatus(hwndDlg, LPGENT("Moving to next file..."), FTS_TEXT);
+ case ACKRESULT_FILERESUME: //
+ case ACKRESULT_DATA: //transfer is on progress
+ break;
+ case ACKRESULT_DENIED:
+ self->Unhook();
+ self->Exit(ack->result);
+ break;
+ case ACKRESULT_FAILED:
+ self->Unhook();
+ self->Exit(ack->result);
+ //type=ACKTYPE_MESSAGE, result=success/failure, (char*)lParam=error message or NULL.
+ //type=ACKTYPE_URL, result=success/failure, (char*)lParam=error message or NULL.
+ //type=ACKTYPE_FILE, result=ACKRESULT_FAILED then lParam=(LPARAM)(const char*)szReason
+ break;
+ case ACKRESULT_SUCCESS:
+ self->Unhook();
+ switch(ack->type) {
+ case ACKTYPE_CHAT:
break;
- case ACKRESULT_DENIED:
- Unhook();
- Exit(ack->result);
+ case ACKTYPE_MESSAGE:
+ self->DB_EventAdd((WORD)EVENTTYPE_MESSAGE);
break;
- case ACKRESULT_FAILED:
- Unhook();
- Exit(ack->result);
- //type=ACKTYPE_MESSAGE, result=success/failure, (char*)lParam=error message or NULL.
- //type=ACKTYPE_URL, result=success/failure, (char*)lParam=error message or NULL.
- //type=ACKTYPE_FILE, result=ACKRESULT_FAILED then lParam=(LPARAM)(const char*)szReason
- break;
- case ACKRESULT_SUCCESS:
- Unhook();
- switch(ack->type) {
- case ACKTYPE_CHAT:
- break;
- case ACKTYPE_MESSAGE:
- DB_EventAdd((WORD)EVENTTYPE_MESSAGE);
- break;
- case ACKTYPE_URL:
- DB_EventAdd((WORD)EVENTTYPE_URL);
- break;
- case ACKTYPE_FILE:
- m_szEventMsg = (char*) mir_realloc(m_szEventMsg, sizeof(DWORD) + m_cbEventMsg);
- memmove(m_szEventMsg+sizeof(DWORD), m_szEventMsg, m_cbEventMsg);
- m_cbEventMsg += sizeof(DWORD);
- DB_EventAdd((WORD)EVENTTYPE_FILE);
- break;
- default:
- break;
- }
- Exit(ack->result);
+ case ACKTYPE_URL:
+ self->DB_EventAdd((WORD)EVENTTYPE_URL);
break;
- default:
- return 0;
+ case ACKTYPE_FILE:
+ self->m_szEventMsg = (char*) mir_realloc(self->m_szEventMsg, sizeof(DWORD) + self->m_cbEventMsg);
+ memmove(self->m_szEventMsg+sizeof(DWORD), self->m_szEventMsg, self->m_cbEventMsg);
+ self->m_cbEventMsg += sizeof(DWORD);
+ self->DB_EventAdd((WORD)EVENTTYPE_FILE);
break;
+ }
+ self->Exit(ack->result);
+ break;
}
return 0;
}
-void CSend::DB_EventAdd(WORD EventType)
+void CSend::DB_EventAdd(WORD EventType)
{
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_pszProto;
@@ -296,18 +307,31 @@ void CSend::DB_EventAdd(WORD EventType)
}
//---------------------------------------------------------------------------
-void CSend::AfterSendDelete() {
- if (m_pszFile && m_bDeleteAfterSend && (m_EnableItem & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND) {
- DeleteFile(m_pszFile);
- }
+void CSend::Error(LPCTSTR pszFormat, ...) {
+ TCHAR tszMsg[MAX_SECONDLINE];
+
+ mir_sntprintf(tszMsg, SIZEOF(tszMsg),_T("%s - %s") ,_T(MODNAME), TranslateT("Error"));
+ mir_free(m_ErrorTitle), m_ErrorTitle = mir_tstrdup(tszMsg);
+
+ va_list vl;
+ va_start(vl, pszFormat);
+ mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl);
+ va_end(vl);
+ mir_free(m_ErrorMsg), m_ErrorMsg = mir_tstrdup(tszMsg);
+
+ ZeroMemory(&m_box, sizeof(MSGBOX));
+ m_box.cbSize = sizeof(MSGBOX);
+ m_box.hParent = NULL;
+ m_box.hiLogo = Skin_GetIcon(ICO_COMMON_SSWINDOW1);
+ m_box.hiMsg = NULL;
+ m_box.ptszTitle = m_ErrorTitle;
+ m_box.ptszMsg = m_ErrorMsg;
+ m_box.uType = MB_OK|MB_ICON_ERROR;
}
//---------------------------------------------------------------------------
-void CSend::Exit(unsigned int Result) {
+void CSend::Exit(unsigned int Result) {
bool err = true;
- if (m_hWndO && IsWindow(m_hWndO)){
- ;
- }
switch(Result) {
case ACKRESULT_SUCCESS:
case GC_RESULT_SUCCESS:
@@ -331,41 +355,16 @@ void CSend::Exit(unsigned int Result) {
break;
case ACKRESULT_FAILED:
default:
- err = false;
break;
}
- if (err){
+ if(err){
SkinPlaySound("FileFailed");
- if(m_ErrorMsg && m_ErrorMsg[0] != 0) MsgBoxService(NULL, (LPARAM)&m_box);
+ if(m_ErrorMsg) MsgBoxService(NULL, (LPARAM)&m_box);
else MsgErr(NULL, LPGENT("An unknown error has occurred."));
}
-
- AfterSendDelete();
- if(m_bFreeOnExit) delete this;
-}
-
-void CSend::Error(LPCTSTR pszFormat, ...) {
- if(!pszFormat) return;
-
- TCHAR tszTemp[MAX_SECONDLINE];
- va_list vl;
-
- mir_sntprintf(tszTemp, SIZEOF(tszTemp),_T("%s - %s") ,_T(MODNAME), TranslateT("Error"));
- mir_freeAndNil(m_ErrorTitle);
- m_ErrorTitle = mir_tstrdup(tszTemp);
-
- va_start(vl, pszFormat);
- mir_vsntprintf(tszTemp, SIZEOF(tszTemp), TranslateTS(pszFormat), vl);
- va_end(vl);
- mir_freeAndNil(m_ErrorMsg);
- m_ErrorMsg = mir_tstrdup(tszTemp);
-
- ZeroMemory(&m_box, sizeof(m_box));
- m_box.cbSize = sizeof(MSGBOX);
- m_box.hParent = NULL;
- m_box.hiLogo = IcoLib_GetIcon(ICO_PLUG_SSWINDOW1);
- m_box.hiMsg = NULL;
- m_box.ptszTitle = m_ErrorTitle;
- m_box.ptszMsg = m_ErrorMsg;
- m_box.uType = MB_OK|MB_ICON_ERROR;
+ if(m_pszFile && *m_pszFile && m_bDeleteAfterSend && m_EnableItem&SS_DLG_DELETEAFTERSSEND) {
+ DeleteFile(m_pszFile), m_pszFile=NULL;
+ }
+ if(m_bAsync)
+ delete this;/// deletes derived class since destructor is virtual (which also auto-calls base dtor)
}
diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h
index 9026f72fe7..d6972028cd 100644
--- a/plugins/SendScreenshotPlus/src/CSend.h
+++ b/plugins/SendScreenshotPlus/src/CSend.h
@@ -48,55 +48,51 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//---------------------------------------------------------------------------
class CSend {
public:
- CSend(HWND Owner, MCONTACT hContact, bool bFreeOnExit); // oder (TfrmMain & Owner)
+ CSend(HWND Owner, MCONTACT hContact, bool bAsync); // oder (TfrmMain & Owner)
virtual ~CSend();
- virtual void Send() = 0;
-// void SendSync(bool Sync) {m_SendSync = Sync;};
- bool m_bFreeOnExit; // need to "delete object;" on exit ?
- void SetContact(MCONTACT hContact);
- BYTE GetEnableItem() {return m_EnableItem;};
- LPTSTR GetErrorMsg() {return m_ErrorMsg;};
-
- LPTSTR m_pszFile;
- LPTSTR m_pszFileDesc;
-
- BOOL m_bDeleteAfterSend;
-
- private:
+ virtual int Send() = NULL; // returns 1 if sent (you must delete class) and 0 when still sending (class deletes itself)
+
+ 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);};
+ void SetDescription(TCHAR* descr){mir_free(m_pszFileDesc), m_pszFileDesc=mir_tstrdup(descr);};
+ void SetContact(MCONTACT hContact);
+ BYTE GetEnableItem() {return m_EnableItem;};
+ TCHAR* GetErrorMsg() {return m_ErrorMsg;};
+ bool m_bDeleteAfterSend;
protected:
- LPTSTR m_pszSendTyp; //hold string for error mess
- HWND m_hWndO; //window handle of caller
- MCONTACT m_hContact; //Contact handle
- char *m_pszProto; //Contact Proto Modul
- BYTE m_EnableItem; //hold flag for send type
- BYTE m_ChatRoom; //is Contact chatroom
- void AfterSendDelete();
-
- bool hasCap(unsigned int Flag);
- unsigned int m_PFflag;
-
- void svcSendFile();
- void svcSendUrl (const char* url);
- void svcSendMsg (const char* szMessage);
- void svcSendChat(); //main GC service
- void svcSendChat(const char* szMessage); //GC ansi wrapper
+ bool m_bAsync;
+ TCHAR* m_pszFile;
+ TCHAR* m_pszFileDesc;
+ static int OnSend(void *obj, WPARAM wParam, LPARAM lParam);
+ TCHAR* m_pszSendTyp; //hold string for error mess
+ char* m_pszProto; //Contact Proto Modul
+ MCONTACT m_hContact; //Contact handle
+ BYTE m_EnableItem; //hold flag for send type
+ BYTE m_ChatRoom; //is Contact chatroom
+
+ bool hasCap(unsigned int Flag);
+// unsigned int m_PFflag;
+
+ void Error(LPCTSTR pszFormat, ...);
+ void svcSendFileExit();
+ void svcSendMsgExit(const char* szMessage);
+ void Exit(unsigned int Result);
DWORD m_cbEventMsg; //sizeof EventMsg(T) buffer
char* m_szEventMsg; //EventMsg char*
- LPTSTR m_szEventMsgT; //EventMsg TCHAR*
HANDLE m_hSend; //protocol send handle
HANDLE m_hOnSend; //HookEventObj on ME_PROTO_ACK
- int __cdecl OnSend(WPARAM wParam, LPARAM lParam);
- void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = NULL;}}
- void DB_EventAdd(WORD EventType);
- void Exit(unsigned int Result);
MSGBOX m_box;
- LPTSTR m_ErrorMsg;
- LPTSTR m_ErrorTitle;
- void Error(LPCTSTR pszFormat, ...);
+ TCHAR* m_ErrorMsg;
+ TCHAR* m_ErrorTitle;
+
+ void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = NULL;}}
+ void DB_EventAdd(WORD EventType);
+
+ static INT_PTR CALLBACK ResultDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
};
#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.cpp b/plugins/SendScreenshotPlus/src/CSendEmail.cpp
index 1b1e681c31..77d21ad332 100644
--- a/plugins/SendScreenshotPlus/src/CSendEmail.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendEmail.cpp
@@ -30,10 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "global.h"
//---------------------------------------------------------------------------
-CSendEmail::CSendEmail(HWND Owner, MCONTACT hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit){
- m_EnableItem = SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; // SS_DLG_AUTOSEND | ;
- m_pszSendTyp = _T("Email transfer");
+CSendEmail::CSendEmail(HWND Owner, MCONTACT hContact, bool /*bAsync*/)
+: CSend(Owner, hContact, true){
+ m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_DELETEAFTERSSEND; // SS_DLG_AUTOSEND | ;
+ m_pszSendTyp = LPGENT("Email transfer");
m_pszFileA = NULL;
m_pszFileName = NULL;
m_Email = NULL;
@@ -50,8 +50,9 @@ CSendEmail::~CSendEmail(){
}
//---------------------------------------------------------------------------
-void CSendEmail::Send() {
-
+int CSendEmail::Send()
+{
+ if(!m_hContact) return 1;
mir_freeAndNil(m_pszFileName);
m_pszFileName = GetFileNameA(m_pszFile);
@@ -81,8 +82,8 @@ void CSendEmail::Send() {
//SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject);
//start Send thread
- m_bFreeOnExit = TRUE;
mir_forkthread(&CSendEmail::SendThreadWrapper, this);
+ return 0;
}
void CSendEmail::SendThread() {
@@ -100,7 +101,7 @@ void CSendEmail::SendThread() {
if (hMAPILib == NULL) {
//return -1;
Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
+ Exit(ACKRESULT_FAILED); return;
}
lpMAPISendMail = (MAPIFUNC)GetProcAddress(hMAPILib, "MAPISendMail");
@@ -108,7 +109,7 @@ void CSendEmail::SendThread() {
::FreeLibrary(hMAPILib);
//return -2;
Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
+ Exit(ACKRESULT_FAILED); return;
}
memset(&Msg, 0, sizeof(Msg));
@@ -150,9 +151,7 @@ void CSendEmail::SendThread() {
switch (res) {
case SUCCESS_SUCCESS:
//The call succeeded and the message was sent.
- Exit(ACKRESULT_SUCCESS);
- return;
-
+ Exit(ACKRESULT_SUCCESS); return;
// No message was sent
case MAPI_E_AMBIGUOUS_RECIPIENT:
err = LPGENT("A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set");
@@ -199,12 +198,10 @@ void CSendEmail::SendThread() {
}
Error(SS_ERR_MAPI, res, err);
Exit(ACKRESULT_FAILED);
-
} catch (...) {
::FreeLibrary(hMAPILib);
Error(SS_ERR_INIT, m_pszSendTyp);
Exit(ACKRESULT_FAILED);
- //return -3;
return;
}
}
diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.h b/plugins/SendScreenshotPlus/src/CSendEmail.h
index b24a2e9753..31dec4ed15 100644
--- a/plugins/SendScreenshotPlus/src/CSendEmail.h
+++ b/plugins/SendScreenshotPlus/src/CSendEmail.h
@@ -33,10 +33,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CSendEmail : public CSend {
public:
// Deklaration Standardkonstruktor/Standarddestructor
- CSendEmail(HWND Owner, MCONTACT hContact, bool bFreeOnExit);
+ CSendEmail(HWND Owner, MCONTACT hContact, bool bAsync);
~CSendEmail();
- void Send();
+ int Send();
protected:
char* m_pszFileA;
diff --git a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp
index 61e8a1f289..57fc704501 100644
--- a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp
@@ -31,9 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//---------------------------------------------------------------------------
-CSendFTPFile::CSendFTPFile(HWND Owner, MCONTACT hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit){
- m_EnableItem = NULL ; //SS_DLG_DESCRIPTION| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
+CSendFTPFile::CSendFTPFile(HWND Owner, MCONTACT hContact, bool /*bAsync*/)
+: CSend(Owner, hContact, true){
+ m_EnableItem = 0 ; //SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
m_pszSendTyp = LPGENT("FTPFile transfer");
m_pszFileName = NULL;
m_URL = NULL;
@@ -45,8 +45,9 @@ CSendFTPFile::~CSendFTPFile(){
}
//---------------------------------------------------------------------------
-void CSendFTPFile::Send() {
-
+int CSendFTPFile::Send()
+{
+ if(!m_hContact) return 1;
/*********************************************************************************************
* Send file (files) to the FTP server and copy file URL
* to message log or clipboard (according to plugin setting)
@@ -64,8 +65,8 @@ void CSendFTPFile::Send() {
m_pszFileName[size-1] = NULL;
//start Send thread
- m_bFreeOnExit = TRUE;
mir_forkthread(&CSendFTPFile::SendThreadWrapper, this);
+ return 0;
}
void CSendFTPFile::SendThread() {
@@ -74,15 +75,16 @@ 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);
- Exit(ret);
+ Exit(ret); return;
}
//Can't delete the file since FTP File plugin will use it
m_bDeleteAfterSend = false;
if (m_URL && m_URL[0]!= NULL) {
- m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL);
+ svcSendMsgExit(m_URL); return;
}
+ Exit(ACKRESULT_FAILED);
}
void CSendFTPFile::SendThreadWrapper(void * Obj) {
diff --git a/plugins/SendScreenshotPlus/src/CSendFTPFile.h b/plugins/SendScreenshotPlus/src/CSendFTPFile.h
index 9b30d0ec2d..fb70249f1c 100644
--- a/plugins/SendScreenshotPlus/src/CSendFTPFile.h
+++ b/plugins/SendScreenshotPlus/src/CSendFTPFile.h
@@ -33,10 +33,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CSendFTPFile : public CSend {
public:
// Deklaration Standardkonstruktor/Standarddestructor
- CSendFTPFile(HWND Owner, MCONTACT hContact, bool bFreeOnExit);
+ CSendFTPFile(HWND Owner, MCONTACT hContact, bool bAsync);
~CSendFTPFile();
- void Send();
+ int Send();
protected:
char* m_pszFileName;
diff --git a/plugins/SendScreenshotPlus/src/CSendFile.cpp b/plugins/SendScreenshotPlus/src/CSendFile.cpp
index 4fce2dc7bf..29cf1d299a 100644
--- a/plugins/SendScreenshotPlus/src/CSendFile.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendFile.cpp
@@ -1,49 +1,48 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-09 Miranda ICQ/IM project,
-
-This file is part of Send Screenshot Plus, a Miranda IM plugin.
-Copyright (c) 2010 Ing.U.Horn
-
-Parts of this file based on original sorce code
-(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-//---------------------------------------------------------------------------
-#include "global.h"
-
-//---------------------------------------------------------------------------
-CSendFile::CSendFile(HWND Owner, MCONTACT hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit){
- m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION;
- m_pszSendTyp = _T("File transfer");
-}
-
-CSendFile::~CSendFile(){
- ;
-}
-
-//---------------------------------------------------------------------------
-void CSendFile::Send() {
- m_bFreeOnExit = TRUE;
- svcSendFile();
-}
-
-//---------------------------------------------------------------------------
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
+Copyright (c) 2000-09 Miranda ICQ/IM project,
+
+This file is part of Send Screenshot Plus, a Miranda IM plugin.
+Copyright (c) 2010 Ing.U.Horn
+
+Parts of this file based on original sorce code
+(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+//---------------------------------------------------------------------------
+#include "global.h"
+
+//---------------------------------------------------------------------------
+CSendFile::CSendFile(HWND Owner, MCONTACT hContact, bool /*bAsync*/)
+: CSend(Owner, hContact, true){
+ m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION;
+ m_pszSendTyp = LPGENT("File transfer");
+}
+
+CSendFile::~CSendFile(){
+}
+
+//---------------------------------------------------------------------------
+int CSendFile::Send() {
+ svcSendFileExit();
+ return 0;
+}
+
+//---------------------------------------------------------------------------
diff --git a/plugins/SendScreenshotPlus/src/CSendFile.h b/plugins/SendScreenshotPlus/src/CSendFile.h
index 5e484c6973..b703c8703c 100644
--- a/plugins/SendScreenshotPlus/src/CSendFile.h
+++ b/plugins/SendScreenshotPlus/src/CSendFile.h
@@ -1,47 +1,46 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-09 Miranda ICQ/IM project,
-
-This file is part of Send Screenshot Plus, a Miranda IM plugin.
-Copyright (c) 2010 Ing.U.Horn
-
-Parts of this file based on original sorce code
-(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef _CSEND_FILE_H
-#define _CSEND_FILE_H
-
-//---------------------------------------------------------------------------
-class CSendFile : public CSend {
- public:
- // Deklaration Standardkonstruktor/Standarddestructor
- CSendFile(HWND Owner, MCONTACT hContact, bool bFreeOnExit);
- ~CSendFile();
-
- void Send();
-
- protected:
-
-};
-
-//---------------------------------------------------------------------------*/
-
-#endif
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
+Copyright (c) 2000-09 Miranda ICQ/IM project,
+
+This file is part of Send Screenshot Plus, a Miranda IM plugin.
+Copyright (c) 2010 Ing.U.Horn
+
+Parts of this file based on original sorce code
+(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _CSEND_FILE_H
+#define _CSEND_FILE_H
+
+//---------------------------------------------------------------------------
+class CSendFile : public CSend {
+ public:
+ // Deklaration Standardkonstruktor/Standarddestructor
+ CSendFile(HWND Owner, MCONTACT hContact, bool bAsync);
+ ~CSendFile();
+
+ int Send();
+
+ protected:
+};
+
+//---------------------------------------------------------------------------*/
+
+#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
index df8c3953bb..cb6893cd86 100644
--- a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
@@ -34,10 +34,10 @@ INT_PTR (*g_MirCallService)(const char *, WPARAM, LPARAM)=NULL;
//---------------------------------------------------------------------------
-CSendHTTPServer::CSendHTTPServer(HWND Owner, MCONTACT hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit){
+CSendHTTPServer::CSendHTTPServer(HWND Owner, MCONTACT hContact, bool /*bAsync*/)
+: CSend(Owner, hContact, true){
m_EnableItem = SS_DLG_DESCRIPTION ; //| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
- m_pszSendTyp = _T("HTTPServer transfer");
+ m_pszSendTyp = LPGENT("HTTPServer transfer");
m_pszFileName = NULL;
m_URL = NULL;
m_fsi_pszSrvPath = NULL;
@@ -52,11 +52,12 @@ CSendHTTPServer::~CSendHTTPServer(){
}
//---------------------------------------------------------------------------
-void CSendHTTPServer::Send() {
-
+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;
+ return 1;
}
if (!m_pszFileName) {
@@ -77,8 +78,8 @@ void CSendHTTPServer::Send() {
//m_fsi.dwOptions = NULL; //OPT_SEND_LINK only work on single chat;
//start Send thread
- m_bFreeOnExit = TRUE;
mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this);
+ return 0;
}
void CSendHTTPServer::SendThread() {
@@ -99,18 +100,17 @@ void CSendHTTPServer::SendThread() {
//send DATA and wait for reply
ret = CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi);
}
-
+
if (ret != 0) {
Error(TranslateT("%s (%i):\nCould not add a share to the HTTP Server plugin."),TranslateTS(m_pszSendTyp),ret);
- Exit(ret);
+ Exit(ret); return;
}
//Share the file by HTTP Server plugin, SendSS does not own the file anymore = auto-delete won't work
m_bDeleteAfterSend = false;
if (m_URL && m_URL[0]!= NULL) {
- m_ChatRoom ? svcSendChat(m_URL) : svcSendMsg(m_URL);
- return;
+ svcSendMsgExit(m_URL); return;
}
Exit(ACKRESULT_FAILED);
}
diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.h b/plugins/SendScreenshotPlus/src/CSendHTTPServer.h
index 782ec1c14a..5b62896739 100644
--- a/plugins/SendScreenshotPlus/src/CSendHTTPServer.h
+++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.h
@@ -33,10 +33,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CSendHTTPServer : public CSend {
public:
// Deklaration Standardkonstruktor/Standarddestructor
- CSendHTTPServer(HWND Owner, MCONTACT hContact, bool bFreeOnExit);
+ CSendHTTPServer(HWND Owner, MCONTACT hContact, bool bAsync);
~CSendHTTPServer();
- void Send();
+ int Send();
protected:
char* m_pszFileName;
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);
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.h b/plugins/SendScreenshotPlus/src/CSendImageShack.h
index bf8b6afbbb..d7a2e21b91 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.h
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.h
@@ -33,11 +33,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CSendImageShack : public CSend {
public:
// Deklaration Standardkonstruktor/Standarddestructor
- CSendImageShack(HWND Owner, MCONTACT hContact, bool bFreeOnExit);
+ CSendImageShack(HWND Owner, MCONTACT hContact, bool bAsync);
~CSendImageShack();
- void Send();
- void SendSync(bool Sync) {m_SendSync = Sync;};
+ int Send();
+ int SendSilent() {m_bAsync=m_Silent=true; return Send();};
char* GetURL(){return m_Url;};
char* GetError(){return mir_t2a(m_ErrorMsg);};
@@ -56,7 +56,7 @@ class CSendImageShack : public CSend {
char* m_MFDRboundary;
void MFDR_Reset();
- bool m_SendSync;
+ bool m_Silent;
void SendThread();
static void SendThreadWrapper(void * Obj);
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index 13135cebe8..e2cfc37f9a 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -277,19 +277,17 @@ INT_PTR service_EditBitmap(WPARAM wParam, LPARAM lParam) {
INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam) {
char* result = NULL;
CSendImageShack* cSend = new CSendImageShack(NULL, lParam, false);
- cSend->m_pszFile = mir_a2t((char*)wParam);
- cSend->m_bDeleteAfterSend = FALSE;
+ cSend->m_bDeleteAfterSend = false;
+ cSend->SetFile((char*)wParam);
if (lParam != NULL) {
- cSend->Send();
- return 0;
+ if(cSend->Send()) delete cSend;
+ return NULL;
}
- cSend->SendSync(TRUE);
- cSend->Send();
+ cSend->SendSilent();
if (cSend->GetURL()) {
- result = mir_strdup(cSend->GetURL());
- }
- else {
- result = cSend->GetError();
+ result=mir_strdup(cSend->GetURL());
+ }else{
+ result=cSend->GetError();
}
delete cSend;
return (INT_PTR)result;
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index bfdca1b1e4..da7ca17cb6 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -295,28 +295,24 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) {
hCtrl = GetDlgItem(m_hWnd, ID_cboxSendBy);
ComboBox_ResetContent(hCtrl);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("<Only save>")) ,SS_JUSTSAVE);
- if (m_hContact) {
+ if(m_hContact){
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("File Transfer")),SS_FILESEND);
- }
- else if(m_opt_cboxSendBy == SS_FILESEND) {
- m_opt_cboxSendBy = SS_IMAGESHACK;
- }
- ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("E-mail")) ,SS_EMAIL);
- if (myGlobals.PluginHTTPExist) {
- ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("HTTP Server")) ,SS_HTTPSERVER);
- }
- else if(m_opt_cboxSendBy == SS_HTTPSERVER) {
- m_opt_cboxSendBy = SS_IMAGESHACK;
- }
- if (myGlobals.PluginFTPExist) {
- ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("FTP File")) ,SS_FTPFILE);
- }
- else if(m_opt_cboxSendBy == SS_FTPFILE) {
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("E-mail")) ,SS_EMAIL);
+ if (myGlobals.PluginHTTPExist) {
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, _T("HTTP Server")) ,SS_HTTPSERVER);
+ }else if(m_opt_cboxSendBy == SS_HTTPSERVER) {
+ m_opt_cboxSendBy = SS_IMAGESHACK;
+ }
+ if (myGlobals.PluginFTPExist) {
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("FTP File")) ,SS_FTPFILE);
+ }else if(m_opt_cboxSendBy == SS_FTPFILE) {
+ m_opt_cboxSendBy = SS_IMAGESHACK;
+ }
+ }else if(m_opt_cboxSendBy == SS_FILESEND || m_opt_cboxSendBy == SS_EMAIL || m_opt_cboxSendBy == SS_HTTPSERVER || m_opt_cboxSendBy == SS_FTPFILE) {
m_opt_cboxSendBy = SS_IMAGESHACK;
}
- ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("ImageShack")) ,(BYTE)SS_IMAGESHACK);
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("ImageShack")), SS_IMAGESHACK);
ComboBox_SelectItemData (hCtrl, -1, m_opt_cboxSendBy); //use Workaround for MS bug ComboBox_SelectItemData
- cboxSendByChange(); //enable disable controls
}
//init footer options
CheckDlgButton(m_hWnd,ID_chkOpenAgain, m_opt_chkOpenAgain ? BST_CHECKED : BST_UNCHECKED);
@@ -768,7 +764,6 @@ void TfrmMain::SaveOptions(void) {
void TfrmMain::Init(TCHAR* DestFolder, MCONTACT Contact) {
m_FDestFolder = mir_tstrdup(DestFolder);
m_hContact = Contact;
- if(!m_hContact) m_opt_cboxSendBy = SS_JUSTSAVE;
// create window
m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UMainForm),0,DlgTfrmMain,(LPARAM)this);
@@ -818,25 +813,23 @@ void TfrmMain::cboxSendByChange() {
BOOL bState;
HICON hIcon;
BYTE itemFlag = SS_DLG_DESCRIPTION; //SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND |
- if (m_cSend && !m_cSend->m_bFreeOnExit) {
+ if(m_cSend)
delete m_cSend;
- m_cSend = NULL;
- }
switch(m_opt_cboxSendBy) {
case SS_FILESEND: //"File Transfer"
- m_cSend = new CSendFile(m_hWnd, m_hContact, false);
+ m_cSend = new CSendFile(m_hWnd, m_hContact, true);
break;
case SS_EMAIL: //"E-mail"
- m_cSend = new CSendEmail(m_hWnd, m_hContact, false);
+ m_cSend = new CSendEmail(m_hWnd, m_hContact, true);
break;
case SS_HTTPSERVER: //"HTTP Server"
- m_cSend = new CSendHTTPServer(m_hWnd, m_hContact, false);
+ m_cSend = new CSendHTTPServer(m_hWnd, m_hContact, true);
break;
case SS_FTPFILE: //"FTP File"
- m_cSend = new CSendFTPFile(m_hWnd, m_hContact, false);
+ m_cSend = new CSendFTPFile(m_hWnd, m_hContact, true);
break;
case SS_IMAGESHACK: //"ImageShack"
- m_cSend = new CSendImageShack(m_hWnd, m_hContact, false);
+ m_cSend = new CSendImageShack(m_hWnd, m_hContact, true);
break;
default: //SS_JUSTSAVE - "Just save it "
m_cSend = NULL;
@@ -1079,8 +1072,8 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
}
if(m_cSend) {
- mir_freeAndNil(m_cSend->m_pszFile); m_cSend->m_pszFile=mir_tstrdup(m_pszFile);
- mir_freeAndNil(m_cSend->m_pszFileDesc); m_cSend->m_pszFileDesc=mir_tstrdup(m_pszFileDesc);
+ m_cSend->SetFile(m_pszFile);
+ m_cSend->SetDescription(m_pszFileDesc);
}
return 0;//OK
}
@@ -1097,15 +1090,11 @@ void TfrmMain::FormClose() {
return;
}
- if (m_cSend && m_pszFile && m_hContact && !m_bFormEdit) {
- m_cSend->Send();
- if (m_cSend->m_bFreeOnExit) cboxSendByChange();
-// Not finish delete this if events from m_opt_cboxSendBy implementet
- SendMessage(m_hWnd,UM_EVENT, 0, (LPARAM)EVT_CheckOpenAgain);
- }
- else {
- SendMessage(m_hWnd,UM_EVENT, 0, (LPARAM)EVT_CheckOpenAgain);
+ if (m_cSend && m_pszFile && !m_bFormEdit) {
+ if(!m_cSend->Send()) m_cSend=NULL; // not sent now, class deletes itself later
+ cboxSendByChange();
}
+ SendMessage(m_hWnd,UM_EVENT, 0, (LPARAM)EVT_CheckOpenAgain);
}
//---------------------------------------------------------------------------
diff --git a/plugins/SendScreenshotPlus/src/resource.h b/plugins/SendScreenshotPlus/src/resource.h
index ad53242cc5..baa47eb668 100644
--- a/plugins/SendScreenshotPlus/src/resource.h
+++ b/plugins/SendScreenshotPlus/src/resource.h
@@ -22,6 +22,7 @@
#define IDD_UMain_CaptureDesktop 103
#define IDD_UEditForm 104
#define IDD_UAboutForm 105
+#define IDD_UResultForm 106
#define IDD_MSGBOX 110
#define IDD_MSGBOXDUMMI 111
#define IDR_LICENSE 120
@@ -91,6 +92,8 @@
#define ID_btnDesc 2003
#define ID_btnDeleteAfterSend 2004
#define ID_btnCapture 2005
+#define ID_edtURL 2010
+#define ID_bvlDesc 2011
#define IDE_StatusBar 2501
// Next default values for new objects