summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2013-11-05 16:06:51 +0000
committerRené Schümann <white06tiger@gmail.com>2013-11-05 16:06:51 +0000
commit36dffc5b63263b87e6cf63e74edd404b7ede7c42 (patch)
treefe1df7704c6f8494725eb8bddd4a3ba9f2a5a388 /plugins/SendScreenshotPlus/src
parent8dcf6f373552f30639b9557c5c11f9c9dc81fef1 (diff)
// 2 out of X
* cleanup (nothing functional) commented out unused functions, simplified some code, removed "unused" returns git-svn-id: http://svn.miranda-ng.org/main/trunk@6787 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus/src')
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp750
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.h202
-rw-r--r--plugins/SendScreenshotPlus/src/CSendEmail.cpp430
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp270
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHTTPServer.h114
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.cpp572
-rw-r--r--plugins/SendScreenshotPlus/src/CSendImageShack.h131
-rw-r--r--plugins/SendScreenshotPlus/src/UAboutForm.cpp10
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp151
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.h24
-rw-r--r--plugins/SendScreenshotPlus/src/Utils.cpp915
-rw-r--r--plugins/SendScreenshotPlus/src/Utils.h142
-rw-r--r--plugins/SendScreenshotPlus/src/ctrl_button.cpp40
-rw-r--r--plugins/SendScreenshotPlus/src/global.h289
-rw-r--r--plugins/SendScreenshotPlus/src/mir_icolib.h138
15 files changed, 2057 insertions, 2121 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index 9c20a086f3..e7c1638360 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -1,375 +1,375 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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"
-
-//---------------------------------------------------------------------------
-CSend::CSend(HWND Owner, HANDLE 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(){
- 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);
-}
-
-//---------------------------------------------------------------------------
-void CSend::SetContact(HANDLE 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);
-}
-
-//---------------------------------------------------------------------------
-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 = BYINDEX | HCONTACT | ID;
- CallService(MS_GC_GETINFO, 0, (LPARAM) &gci);
- if (gci.hContact == m_hContact) {
- GCDEST gcd = {0};
- gcd.pszModule = m_pszProto;
- gcd.iType = GC_EVENT_SENDMESSAGE;
- gcd.ptszID = gci.pszID;
-
- GCEVENT gce = {0};
- gce.cbSize = sizeof(GCEVENT);
- gce.pDest = &gcd;
- gce.bIsMe = TRUE;
- gce.dwFlags = GC_TCHAR|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;
- }
- }
- Exit(res);
-}
-
-void CSend::svcSendChat(const char* szMessage) {
- if (!m_ChatRoom) {
- svcSendMsg(szMessage);
- 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);
- }
- svcSendChat();
-}
-
-void CSend::svcSendFile() {
-//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);
- m_cbEventMsg=lstrlenA(szFile)+2;
- m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
- ZeroMemory(m_szEventMsg, m_cbEventMsg);
- lstrcpyA(m_szEventMsg,szFile);
- 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(szFile)+1,temp);
- m_szEventMsg[m_cbEventMsg-1] = 0;
- mir_freeAndNil(temp);
- }
- mir_freeAndNil(szFile);
-
- //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 miranda PSS_FILE based on mir ver (T)
- 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);
- mir_free(pDesc);
- mir_free(ppFile[0]);
-
- // check we actually got an ft handle back from the protocol
- if (!m_hSend) {
- Unhook();
- Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
- }
-}
-
-//---------------------------------------------------------------------------
-int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){
- ACKDATA *ack=(ACKDATA*)lParam;
- if(ack->hProcess!= m_hSend) return 0;
- /* if(dat->waitingForAcceptance) {
- SetTimer(hwndDlg,1,1000,NULL);
- dat->waitingForAcceptance=0;
- }
- */
-
- 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
- break;
- case ACKRESULT_DENIED:
- Unhook();
- Exit(ack->result);
- 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);
- break;
- default:
- return 0;
- break;
- }
- return 0;
-}
-
-void CSend::DB_EventAdd(WORD EventType)
-{
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.szModule = m_pszProto;
- dbei.eventType = EventType;
- dbei.flags = DBEF_SENT;
- dbei.timestamp = time(NULL);
- dbei.flags |= DBEF_UTF;
- dbei.cbBlob= m_cbEventMsg;
- dbei.pBlob = (PBYTE)m_szEventMsg;
- db_event_add(m_hContact, &dbei);
-}
-
-//---------------------------------------------------------------------------
-void CSend::AfterSendDelete() {
- if (m_pszFile && m_bDeleteAfterSend && (m_EnableItem & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND) {
- DeleteFile(m_pszFile);
- }
-}
-
-//---------------------------------------------------------------------------
-void CSend::Exit(unsigned int Result) {
- bool err = true;
- if (m_hWndO && IsWindow(m_hWndO)){
- ;
- }
- 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:
- err = false;
- break;
- }
- if (err){
- SkinPlaySound("FileFailed");
- if(m_ErrorMsg && m_ErrorMsg[0] != 0) 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;
-}
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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"
+
+//---------------------------------------------------------------------------
+CSend::CSend(HWND Owner, HANDLE 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(){
+ 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);
+}
+
+//---------------------------------------------------------------------------
+void CSend::SetContact(HANDLE 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);
+}
+
+//---------------------------------------------------------------------------
+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 = BYINDEX | HCONTACT | ID;
+ CallService(MS_GC_GETINFO, 0, (LPARAM) &gci);
+ if (gci.hContact == m_hContact) {
+ GCDEST gcd = {0};
+ gcd.pszModule = m_pszProto;
+ gcd.iType = GC_EVENT_SENDMESSAGE;
+ gcd.ptszID = gci.pszID;
+
+ GCEVENT gce = {0};
+ gce.cbSize = sizeof(GCEVENT);
+ gce.pDest = &gcd;
+ gce.bIsMe = TRUE;
+ gce.dwFlags = GC_TCHAR|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;
+ }
+ }
+ Exit(res);
+}
+
+void CSend::svcSendChat(const char* szMessage) {
+ if (!m_ChatRoom) {
+ svcSendMsg(szMessage);
+ 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);
+ }
+ svcSendChat();
+}
+
+void CSend::svcSendFile() {
+//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);
+ m_cbEventMsg=lstrlenA(szFile)+2;
+ m_szEventMsg=(char*)mir_realloc(m_szEventMsg, sizeof(char)*m_cbEventMsg);
+ ZeroMemory(m_szEventMsg, m_cbEventMsg);
+ lstrcpyA(m_szEventMsg,szFile);
+ 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(szFile)+1,temp);
+ m_szEventMsg[m_cbEventMsg-1] = 0;
+ mir_freeAndNil(temp);
+ }
+ mir_freeAndNil(szFile);
+
+ //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 miranda PSS_FILE based on mir ver (T)
+ 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);
+ mir_free(pDesc);
+ mir_free(ppFile[0]);
+
+ // check we actually got an ft handle back from the protocol
+ if (!m_hSend) {
+ Unhook();
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ }
+}
+
+//---------------------------------------------------------------------------
+int __cdecl CSend::OnSend(WPARAM wParam, LPARAM lParam){
+ ACKDATA *ack=(ACKDATA*)lParam;
+ if(ack->hProcess!= m_hSend) return 0;
+ /* if(dat->waitingForAcceptance) {
+ SetTimer(hwndDlg,1,1000,NULL);
+ dat->waitingForAcceptance=0;
+ }
+ */
+
+ 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
+ break;
+ case ACKRESULT_DENIED:
+ Unhook();
+ Exit(ack->result);
+ 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);
+ break;
+ default:
+ return 0;
+ break;
+ }
+ return 0;
+}
+
+void CSend::DB_EventAdd(WORD EventType)
+{
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = m_pszProto;
+ dbei.eventType = EventType;
+ dbei.flags = DBEF_SENT;
+ dbei.timestamp = time(NULL);
+ dbei.flags |= DBEF_UTF;
+ dbei.cbBlob= m_cbEventMsg;
+ dbei.pBlob = (PBYTE)m_szEventMsg;
+ db_event_add(m_hContact, &dbei);
+}
+
+//---------------------------------------------------------------------------
+void CSend::AfterSendDelete() {
+ if (m_pszFile && m_bDeleteAfterSend && (m_EnableItem & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND) {
+ DeleteFile(m_pszFile);
+ }
+}
+
+//---------------------------------------------------------------------------
+void CSend::Exit(unsigned int Result) {
+ bool err = true;
+ if (m_hWndO && IsWindow(m_hWndO)){
+ ;
+ }
+ 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:
+ err = false;
+ break;
+ }
+ if (err){
+ SkinPlaySound("FileFailed");
+ if(m_ErrorMsg && m_ErrorMsg[0] != 0) 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;
+}
diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h
index da8cb16cac..9b491258d0 100644
--- a/plugins/SendScreenshotPlus/src/CSend.h
+++ b/plugins/SendScreenshotPlus/src/CSend.h
@@ -1,101 +1,101 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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_H
-#define _CSEND_H
-
-//---------------------------------------------------------------------------
-#define SS_AUTOSEND 1
-#define SS_DELETEAFTERSSEND 2
-
-#define SS_DLG_AUTOSEND 1 //Button_Enable(GetDlgItem(Owner, ID_chkEmulateClick), TRUE);
-#define SS_DLG_DELETEAFTERSSEND 2 //Button_Enable(GetDlgItem(Owner, ID_btnDeleteAfterSend), TRUE);
-#define SS_DLG_DESCRIPTION 4 //Button_Enable(GetDlgItem(Owner, ID_btnDesc), TRUE);
-
-#define GC_RESULT_SUCCESS 200
-#define GC_RESULT_WRONGVER 201
-#define GC_RESULT_ERROR 202
-#define GC_RESULT_NOSESSION 209
-
-#define SS_ERR_INIT LPGENT("Unable to initiate %s.")
-#define SS_ERR_MAPI LPGENT("MAPI error (%i):\n%s.")
-
-//---------------------------------------------------------------------------
-class CSend {
- public:
- CSend(HWND Owner, HANDLE hContact, bool bFreeOnExit); // 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(HANDLE hContact);
- BYTE GetEnableItem() {return m_EnableItem;};
- LPTSTR GetErrorMsg() {return m_ErrorMsg;};
-
- LPTSTR m_pszFile;
- LPTSTR m_pszFileDesc;
-
- BOOL m_bDeleteAfterSend;
-
- private:
-
- protected:
- LPTSTR m_pszSendTyp; //hold string for error mess
- HWND m_hWndO; //window handle of caller
- HANDLE m_hContact; //Contact handle
- char* m_pszProto; //Contact Proto Modul
- BYTE m_EnableItem; //hold flag for send type
- void AfterSendDelete();
- BYTE m_ChatRoom; //is Contact chatroom
- bool m_SendSync; //send sync / async
-
- 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
-
- 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, ...);
-};
-
-#endif
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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_H
+#define _CSEND_H
+
+//---------------------------------------------------------------------------
+#define SS_AUTOSEND 1
+#define SS_DELETEAFTERSSEND 2
+
+#define SS_DLG_AUTOSEND 1 //Button_Enable(GetDlgItem(Owner, ID_chkEmulateClick), TRUE);
+#define SS_DLG_DELETEAFTERSSEND 2 //Button_Enable(GetDlgItem(Owner, ID_btnDeleteAfterSend), TRUE);
+#define SS_DLG_DESCRIPTION 4 //Button_Enable(GetDlgItem(Owner, ID_btnDesc), TRUE);
+
+#define GC_RESULT_SUCCESS 200
+#define GC_RESULT_WRONGVER 201
+#define GC_RESULT_ERROR 202
+#define GC_RESULT_NOSESSION 209
+
+#define SS_ERR_INIT LPGENT("Unable to initiate %s.")
+#define SS_ERR_MAPI LPGENT("MAPI error (%i):\n%s.")
+
+//---------------------------------------------------------------------------
+class CSend {
+ public:
+ CSend(HWND Owner, HANDLE hContact, bool bFreeOnExit); // 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(HANDLE hContact);
+ BYTE GetEnableItem() {return m_EnableItem;};
+ LPTSTR GetErrorMsg() {return m_ErrorMsg;};
+
+ LPTSTR m_pszFile;
+ LPTSTR m_pszFileDesc;
+
+ BOOL m_bDeleteAfterSend;
+
+ private:
+
+ protected:
+ LPTSTR m_pszSendTyp; //hold string for error mess
+ HWND m_hWndO; //window handle of caller
+ HANDLE m_hContact; //Contact handle
+ char* m_pszProto; //Contact Proto Modul
+ BYTE m_EnableItem; //hold flag for send type
+ void AfterSendDelete();
+ BYTE m_ChatRoom; //is Contact chatroom
+// bool m_SendSync; //send sync / async
+
+ 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
+
+ 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, ...);
+};
+
+#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.cpp b/plugins/SendScreenshotPlus/src/CSendEmail.cpp
index f2988e4c4f..79f848f68c 100644
--- a/plugins/SendScreenshotPlus/src/CSendEmail.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendEmail.cpp
@@ -1,215 +1,215 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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"
-
-//---------------------------------------------------------------------------
-CSendEmail::CSendEmail(HWND Owner, HANDLE hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit){
- m_EnableItem = SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; // SS_DLG_AUTOSEND | ;
- m_pszSendTyp = _T("Email transfer");
- m_pszFileA = NULL;
- m_pszFileName = NULL;
- m_Email = NULL;
- m_FriendlyName = NULL;
- m_Subject = NULL;
-}
-
-CSendEmail::~CSendEmail(){
- mir_free(m_pszFileA);
- mir_free(m_pszFileName);
- mir_free(m_Email);
- mir_free(m_FriendlyName);
- mir_free(m_Subject);
-}
-
-//---------------------------------------------------------------------------
-void CSendEmail::Send() {
-
- mir_freeAndNil(m_pszFileName);
- m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
-
- mir_freeAndNil(m_pszFileA);
- m_pszFileA = mir_t2a(m_pszFile);
-
-
-// AnsiString Email, Subject, FriendlyName;
- CONTACTINFO ci={0};
- ci.cbSize = sizeof(ci);
- ci.hContact = m_hContact;
- ci.szProto = m_pszProto;
- //ci.dwFlag = CNF_TCHAR;
-
- ci.dwFlag = CNF_EMAIL | CNF_TCHAR;
- CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci);
- m_Email = mir_t2a(ci.pszVal);
-
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci);
- m_FriendlyName = mir_t2a(ci.pszVal);
-
- mir_free(ci.pszVal);
-
- m_Subject = mir_t2a(m_pszFileDesc);
-
- //SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject);
-
- //start Send thread
- m_bFreeOnExit = TRUE;
- mir_forkthread(&CSendEmail::SendThreadWrapper, this);
-}
-
-void CSendEmail::SendThread() {
- //This code based on SentTo.exe application.
- //The default mail client for Simple MAPI or MAPI calls is defined by the
- //HKLM\Software\Clients\Mail::(default) registry value.
-
- LPTSTR err = NULL;
- MapiFileDesc arrfileDesc[1];
-
- typedef ULONG (FAR PASCAL *MAPIFUNC)(LHANDLE,ULONG,lpMapiMessage,FLAGS,ULONG);
- MapiMessage Msg;
- MAPIFUNC lpMAPISendMail;
-
- HINSTANCE hMAPILib = ::LoadLibrary(_T("MAPI32.DLL"));
- if (hMAPILib == NULL) {
- //return -1;
- Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
- }
-
- lpMAPISendMail = (MAPIFUNC)GetProcAddress(hMAPILib, "MAPISendMail");
- if (lpMAPISendMail == NULL) {
- ::FreeLibrary(hMAPILib);
- //return -2;
- Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
- }
-
- memset(&Msg, 0, sizeof(Msg));
-
- arrfileDesc[0].ulReserved = 0;
- arrfileDesc[0].flFlags = 0;
- arrfileDesc[0].lpFileType = NULL;
- arrfileDesc[0].nPosition = -1;
- arrfileDesc[0].lpszPathName = m_pszFileA;
- arrfileDesc[0].lpszFileName = NULL;
-
- Msg.nFileCount = 1;
- Msg.lpFiles = arrfileDesc;
- Msg.lpszNoteText = ""; //body
- Msg.lpszSubject = m_Subject; //subject
-
- Msg.nRecipCount = 1;
- MapiRecipDesc recip;
- recip.ulReserved = 0;
- recip.ulRecipClass = MAPI_TO;
-
- if (m_FriendlyName && m_FriendlyName[0]!= NULL) {
- recip.lpszName = m_FriendlyName; //friendly name set to contact's name
- }
- else {
- recip.lpszName = m_Email; //friendly name set to contact's email
- }
-
- recip.lpszAddress = m_Email; //email
- recip.ulEIDSize = 0;
- recip.lpEntryID = NULL;
- Msg.lpRecips = &recip;
-
- try {
- int res = lpMAPISendMail(NULL, NULL, &Msg, MAPI_LOGON_UI|MAPI_DIALOG, 0);
- ::FreeLibrary(hMAPILib);
-
- switch (res) {
- case SUCCESS_SUCCESS:
- //The call succeeded and the message was sent.
- 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");
- break;
- case MAPI_E_ATTACHMENT_NOT_FOUND:
- err = LPGENT("The specified attachment was not found");
- break;
- case MAPI_E_ATTACHMENT_OPEN_FAILURE:
- err = LPGENT("The specified attachment could not be opened");
- break;
- case MAPI_E_BAD_RECIPTYPE:
- err = LPGENT("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC");
- break;
- case MAPI_E_FAILURE:
- err = LPGENT("One or more unspecified errors occurred");
- break;
- case MAPI_E_INSUFFICIENT_MEMORY:
- err = LPGENT("There was insufficient memory to proceed");
- break;
- case MAPI_E_INVALID_RECIPS:
- err = LPGENT("One or more recipients were invalid or did not resolve to any address");
- break;
- case MAPI_E_LOGIN_FAILURE:
- err = LPGENT("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed");
- break;
- case MAPI_E_TEXT_TOO_LARGE:
- err = LPGENT("The text in the message was too large");
- break;
- case MAPI_E_TOO_MANY_FILES:
- err = LPGENT("There were too many file attachments");
- break;
- case MAPI_E_TOO_MANY_RECIPIENTS:
- err = LPGENT("There were too many recipients");
- break;
- case MAPI_E_UNKNOWN_RECIPIENT:
- err = LPGENT("A recipient did not appear in the address list");
- break;
- case MAPI_E_USER_ABORT:
- err = LPGENT("The user canceled one of the dialog boxes");
- break;
- default:
- err = LPGENT("Unknown Error");
- break;
- }
- Error(SS_ERR_MAPI, res, err);
- Exit(ACKRESULT_FAILED);
-
- } catch (...) {
- ::FreeLibrary(hMAPILib);
- Error(SS_ERR_INIT, m_pszSendTyp);
- Exit(ACKRESULT_FAILED);
- //return -3;
- return;
- }
-}
-
-void CSendEmail::SendThreadWrapper(void * Obj) {
- reinterpret_cast<CSendEmail*>(Obj)->SendThread();
-}
-
-//---------------------------------------------------------------------------
-
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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"
+
+//---------------------------------------------------------------------------
+CSendEmail::CSendEmail(HWND Owner, HANDLE hContact, bool bFreeOnExit)
+: CSend(Owner, hContact, bFreeOnExit){
+ m_EnableItem = SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION; // SS_DLG_AUTOSEND | ;
+ m_pszSendTyp = _T("Email transfer");
+ m_pszFileA = NULL;
+ m_pszFileName = NULL;
+ m_Email = NULL;
+ m_FriendlyName = NULL;
+ m_Subject = NULL;
+}
+
+CSendEmail::~CSendEmail(){
+ mir_free(m_pszFileA);
+ mir_free(m_pszFileName);
+ mir_free(m_Email);
+ mir_free(m_FriendlyName);
+ mir_free(m_Subject);
+}
+
+//---------------------------------------------------------------------------
+void CSendEmail::Send() {
+
+ mir_freeAndNil(m_pszFileName);
+ m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
+
+ mir_freeAndNil(m_pszFileA);
+ m_pszFileA = mir_t2a(m_pszFile);
+
+
+// AnsiString Email, Subject, FriendlyName;
+ CONTACTINFO ci={0};
+ ci.cbSize = sizeof(ci);
+ ci.hContact = m_hContact;
+ ci.szProto = m_pszProto;
+ //ci.dwFlag = CNF_TCHAR;
+
+ ci.dwFlag = CNF_EMAIL | CNF_TCHAR;
+ CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci);
+ m_Email = mir_t2a(ci.pszVal);
+
+ ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
+ CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci);
+ m_FriendlyName = mir_t2a(ci.pszVal);
+
+ mir_free(ci.pszVal);
+
+ m_Subject = mir_t2a(m_pszFileDesc);
+
+ //SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject);
+
+ //start Send thread
+ m_bFreeOnExit = TRUE;
+ mir_forkthread(&CSendEmail::SendThreadWrapper, this);
+}
+
+void CSendEmail::SendThread() {
+ //This code based on SentTo.exe application.
+ //The default mail client for Simple MAPI or MAPI calls is defined by the
+ //HKLM\Software\Clients\Mail::(default) registry value.
+
+ MapiFileDesc arrfileDesc[1];
+
+ typedef ULONG (FAR PASCAL *MAPIFUNC)(LHANDLE,ULONG,lpMapiMessage,FLAGS,ULONG);
+ MapiMessage Msg;
+ MAPIFUNC lpMAPISendMail;
+
+ HINSTANCE hMAPILib = ::LoadLibrary(_T("MAPI32.DLL"));
+ if (hMAPILib == NULL) {
+ //return -1;
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ }
+
+ lpMAPISendMail = (MAPIFUNC)GetProcAddress(hMAPILib, "MAPISendMail");
+ if (lpMAPISendMail == NULL) {
+ ::FreeLibrary(hMAPILib);
+ //return -2;
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ }
+
+ memset(&Msg, 0, sizeof(Msg));
+
+ arrfileDesc[0].ulReserved = 0;
+ arrfileDesc[0].flFlags = 0;
+ arrfileDesc[0].lpFileType = NULL;
+ arrfileDesc[0].nPosition = -1;
+ arrfileDesc[0].lpszPathName = m_pszFileA;
+ arrfileDesc[0].lpszFileName = NULL;
+
+ Msg.nFileCount = 1;
+ Msg.lpFiles = arrfileDesc;
+ Msg.lpszNoteText = ""; //body
+ Msg.lpszSubject = m_Subject; //subject
+
+ Msg.nRecipCount = 1;
+ MapiRecipDesc recip;
+ recip.ulReserved = 0;
+ recip.ulRecipClass = MAPI_TO;
+
+ if (m_FriendlyName && m_FriendlyName[0]!= NULL) {
+ recip.lpszName = m_FriendlyName; //friendly name set to contact's name
+ }
+ else {
+ recip.lpszName = m_Email; //friendly name set to contact's email
+ }
+
+ recip.lpszAddress = m_Email; //email
+ recip.ulEIDSize = 0;
+ recip.lpEntryID = NULL;
+ Msg.lpRecips = &recip;
+
+ try {
+ int res = lpMAPISendMail(NULL, NULL, &Msg, MAPI_LOGON_UI|MAPI_DIALOG, 0);
+ ::FreeLibrary(hMAPILib);
+
+ LPTSTR err;
+ switch (res) {
+ case SUCCESS_SUCCESS:
+ //The call succeeded and the message was sent.
+ 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");
+ break;
+ case MAPI_E_ATTACHMENT_NOT_FOUND:
+ err = LPGENT("The specified attachment was not found");
+ break;
+ case MAPI_E_ATTACHMENT_OPEN_FAILURE:
+ err = LPGENT("The specified attachment could not be opened");
+ break;
+ case MAPI_E_BAD_RECIPTYPE:
+ err = LPGENT("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC");
+ break;
+ case MAPI_E_FAILURE:
+ err = LPGENT("One or more unspecified errors occurred");
+ break;
+ case MAPI_E_INSUFFICIENT_MEMORY:
+ err = LPGENT("There was insufficient memory to proceed");
+ break;
+ case MAPI_E_INVALID_RECIPS:
+ err = LPGENT("One or more recipients were invalid or did not resolve to any address");
+ break;
+ case MAPI_E_LOGIN_FAILURE:
+ err = LPGENT("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed");
+ break;
+ case MAPI_E_TEXT_TOO_LARGE:
+ err = LPGENT("The text in the message was too large");
+ break;
+ case MAPI_E_TOO_MANY_FILES:
+ err = LPGENT("There were too many file attachments");
+ break;
+ case MAPI_E_TOO_MANY_RECIPIENTS:
+ err = LPGENT("There were too many recipients");
+ break;
+ case MAPI_E_UNKNOWN_RECIPIENT:
+ err = LPGENT("A recipient did not appear in the address list");
+ break;
+ case MAPI_E_USER_ABORT:
+ err = LPGENT("The user canceled one of the dialog boxes");
+ break;
+ default:
+ err = LPGENT("Unknown Error");
+ break;
+ }
+ Error(SS_ERR_MAPI, res, err);
+ Exit(ACKRESULT_FAILED);
+
+ } catch (...) {
+ ::FreeLibrary(hMAPILib);
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ Exit(ACKRESULT_FAILED);
+ //return -3;
+ return;
+ }
+}
+
+void CSendEmail::SendThreadWrapper(void * Obj) {
+ reinterpret_cast<CSendEmail*>(Obj)->SendThread();
+}
+
+//---------------------------------------------------------------------------
+
diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
index bd8a543d05..f89c12e74a 100644
--- a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp
@@ -1,135 +1,135 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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"
-
-INT_PTR (*g_MirCallService)(const char *, WPARAM, LPARAM)=NULL;
-//INT_PTR (*CallService)(const char *,WPARAM,LPARAM);
-
-
-//---------------------------------------------------------------------------
-CSendHTTPServer::CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit){
- m_EnableItem = SS_DLG_DESCRIPTION ; //| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
- m_pszSendTyp = _T("HTTPServer transfer");
- m_pszFileName = NULL;
- m_URL = NULL;
- m_fsi_pszSrvPath = NULL;
- m_fsi_pszRealPath = NULL;
-}
-
-CSendHTTPServer::~CSendHTTPServer(){
- mir_free(m_pszFileName);
- mir_free(m_URL);
- mir_free(m_fsi_pszSrvPath);
- mir_free(m_fsi_pszRealPath);
-}
-
-//---------------------------------------------------------------------------
-void CSendHTTPServer::Send() {
-
- if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, (WPARAM)true, 0) != 0) {
- Error(NULL, TranslateT("Could not start the HTTP Server plugin."));
- return;
- }
-
- if (!m_pszFileName) {
- m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
- }
- mir_freeAndNil(m_fsi_pszSrvPath);
- mir_stradd(m_fsi_pszSrvPath, "/");
- mir_stradd(m_fsi_pszSrvPath, m_pszFileName);
-
- mir_freeAndNil(m_fsi_pszRealPath);
- m_fsi_pszRealPath = mir_t2a(m_pszFile);
-
- ZeroMemory(&m_fsi, sizeof(m_fsi));
- m_fsi.lStructSize = sizeof(STFileShareInfo);
- m_fsi.pszSrvPath = m_fsi_pszSrvPath;
- m_fsi.nMaxDownloads = -1; // -1 = infinite
- m_fsi.pszRealPath = m_fsi_pszRealPath;
- //m_fsi.dwOptions = NULL; //OPT_SEND_LINK only work on single chat;
-
- //start Send thread
- m_bFreeOnExit = TRUE;
- mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this);
-}
-
-void CSendHTTPServer::SendThread() {
- INT_PTR ret;
- mir_freeAndNil(m_URL);
-
- if (ServiceExists(MS_HTTP_GET_LINK)) {
- //patched plugin version
- ret = CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi);
- if (!ret) {
- m_URL = (LPSTR)CallService(MS_HTTP_GET_LINK, (WPARAM)m_fsi.pszSrvPath, NULL);
- }
- }
- else {
- //original plugin
- m_fsi.dwOptions = OPT_SEND_LINK;
-
- //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);
- }
-
- //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;
- }
- Exit(ACKRESULT_FAILED);
-}
-
-void CSendHTTPServer::SendThreadWrapper(void * Obj) {
- reinterpret_cast<CSendHTTPServer*>(Obj)->SendThread();
-}
-
-//---------------------------------------------------------------------------
-CSendHTTPServer::CContactMapping CSendHTTPServer::_CContactMapping;
-
-INT_PTR CSendHTTPServer::MyCallService(const char *name, WPARAM wParam, LPARAM lParam) {
- CContactMapping::iterator Contact(_CContactMapping.end());
-/*
- if ( wParam == m_hContact && (
- (strcmp(name, MS_MSG_SENDMESSAGE)== 0) ||
- (strcmp(name, "SRMsg/LaunchMessageWindow")== 0) ))
- {
- m_URL= mir_strdup((char*)lParam);
- return 0;
- }*/
- return g_MirCallService(name, wParam, lParam);
-}
-
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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"
+
+INT_PTR (*g_MirCallService)(const char *, WPARAM, LPARAM)=NULL;
+//INT_PTR (*CallService)(const char *,WPARAM,LPARAM);
+
+
+//---------------------------------------------------------------------------
+CSendHTTPServer::CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit)
+: CSend(Owner, hContact, bFreeOnExit){
+ m_EnableItem = SS_DLG_DESCRIPTION ; //| SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
+ m_pszSendTyp = _T("HTTPServer transfer");
+ m_pszFileName = NULL;
+ m_URL = NULL;
+ m_fsi_pszSrvPath = NULL;
+ m_fsi_pszRealPath = NULL;
+}
+
+CSendHTTPServer::~CSendHTTPServer(){
+ mir_free(m_pszFileName);
+ mir_free(m_URL);
+ mir_free(m_fsi_pszSrvPath);
+ mir_free(m_fsi_pszRealPath);
+}
+
+//---------------------------------------------------------------------------
+void CSendHTTPServer::Send() {
+
+ if (CallService(MS_HTTP_ACCEPT_CONNECTIONS, (WPARAM)true, 0) != 0) {
+ Error(NULL, TranslateT("Could not start the HTTP Server plugin."));
+ return;
+ }
+
+ if (!m_pszFileName) {
+ m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
+ }
+ mir_freeAndNil(m_fsi_pszSrvPath);
+ mir_stradd(m_fsi_pszSrvPath, "/");
+ mir_stradd(m_fsi_pszSrvPath, m_pszFileName);
+
+ mir_freeAndNil(m_fsi_pszRealPath);
+ m_fsi_pszRealPath = mir_t2a(m_pszFile);
+
+ ZeroMemory(&m_fsi, sizeof(m_fsi));
+ m_fsi.lStructSize = sizeof(STFileShareInfo);
+ m_fsi.pszSrvPath = m_fsi_pszSrvPath;
+ m_fsi.nMaxDownloads = -1; // -1 = infinite
+ m_fsi.pszRealPath = m_fsi_pszRealPath;
+ //m_fsi.dwOptions = NULL; //OPT_SEND_LINK only work on single chat;
+
+ //start Send thread
+ m_bFreeOnExit = TRUE;
+ mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this);
+}
+
+void CSendHTTPServer::SendThread() {
+ INT_PTR ret;
+ mir_freeAndNil(m_URL);
+
+ if (ServiceExists(MS_HTTP_GET_LINK)) {
+ //patched plugin version
+ ret = CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi);
+ if (!ret) {
+ m_URL = (LPSTR)CallService(MS_HTTP_GET_LINK, (WPARAM)m_fsi.pszSrvPath, NULL);
+ }
+ }
+ else {
+ //original plugin
+ m_fsi.dwOptions = OPT_SEND_LINK;
+
+ //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);
+ }
+
+ //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;
+ }
+ Exit(ACKRESULT_FAILED);
+}
+
+void CSendHTTPServer::SendThreadWrapper(void * Obj) {
+ reinterpret_cast<CSendHTTPServer*>(Obj)->SendThread();
+}
+
+//---------------------------------------------------------------------------
+/*
+CSendHTTPServer::CContactMapping CSendHTTPServer::_CContactMapping;
+INT_PTR CSendHTTPServer::MyCallService(const char *name, WPARAM wParam, LPARAM lParam) {
+/ *
+ CContactMapping::iterator Contact(_CContactMapping.end());
+ if ( wParam == m_hContact && (
+ (strcmp(name, MS_MSG_SENDMESSAGE)== 0) ||
+ (strcmp(name, "SRMsg/LaunchMessageWindow")== 0) ))
+ {
+ m_URL= mir_strdup((char*)lParam);
+ return 0;
+ }* /
+ return g_MirCallService(name, wParam, lParam);
+}*/
+
diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.h b/plugins/SendScreenshotPlus/src/CSendHTTPServer.h
index e4008e152e..b8740e0a2b 100644
--- a/plugins/SendScreenshotPlus/src/CSendHTTPServer.h
+++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.h
@@ -1,57 +1,57 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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_HTTP_SERVER_H
-#define _CSEND_HTTP_SERVER_H
-
-//---------------------------------------------------------------------------
-class CSendHTTPServer : public CSend {
- public:
- // Deklaration Standardkonstruktor/Standarddestructor
- CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit);
- ~CSendHTTPServer();
-
- void Send();
-
- protected:
- LPSTR m_pszFileName;
- LPSTR m_URL;
- STFileShareInfo m_fsi;
- LPSTR m_fsi_pszSrvPath;
- LPSTR m_fsi_pszRealPath;
- void SendThread();
- static void SendThreadWrapper(void * Obj);
-
- typedef std::map<HANDLE, CSendHTTPServer *> CContactMapping;
- static CContactMapping _CContactMapping;
-
- static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam);
-
-};
-
-//---------------------------------------------------------------------------
-
-#endif
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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_HTTP_SERVER_H
+#define _CSEND_HTTP_SERVER_H
+
+//---------------------------------------------------------------------------
+class CSendHTTPServer : public CSend {
+ public:
+ // Deklaration Standardkonstruktor/Standarddestructor
+ CSendHTTPServer(HWND Owner, HANDLE hContact, bool bFreeOnExit);
+ ~CSendHTTPServer();
+
+ void Send();
+
+ protected:
+ LPSTR m_pszFileName;
+ LPSTR m_URL;
+ STFileShareInfo m_fsi;
+ LPSTR m_fsi_pszSrvPath;
+ LPSTR m_fsi_pszRealPath;
+ void SendThread();
+ static void SendThreadWrapper(void * Obj);
+
+ typedef std::map<HANDLE, CSendHTTPServer *> CContactMapping;
+ static CContactMapping _CContactMapping;
+
+// static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam);
+
+};
+
+//---------------------------------------------------------------------------
+
+#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
index 6396315d03..72fb4795c6 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.cpp
@@ -1,288 +1,284 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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"
-
-//---------------------------------------------------------------------------
-CSendImageShack::CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit)
-: CSend(Owner, hContact, bFreeOnExit) {
- m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION;
- m_pszSendTyp = _T("Image upload");
- m_pszFileName = NULL;
- m_pszContentType = NULL;
- m_MFDRboundary = NULL;
- m_nlreply = NULL;
- m_SendSync = false;
- m_Url = NULL;
-}
-
-CSendImageShack::~CSendImageShack(){
- mir_free(m_pszFileName);
- mir_free(m_MFDRboundary);
- // FREEHTTPREQUESTSTRUCT*
- if (m_nlreply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
- mir_free(m_Url);
-};
-
-//---------------------------------------------------------------------------
-void CSendImageShack::Send() {
- // check Netlib
- if( !hNetlibUser ) {
- //PrintError(1,TRUE);
- return;
- }
- if (!m_pszFileName) {
- m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
- }
- if (!m_pszContentType) GetContentType();
-
- // create new boundary
- MFDR_Reset();
-
- // initialize the netlib request
- ZeroMemory(&m_nlhr, sizeof(m_nlhr));
- m_nlhr.cbSize = sizeof(m_nlhr);
- m_nlhr.requestType = REQUEST_POST;
- m_nlhr.flags = NLHRF_HTTP11; //NLHRF_DUMPASTEXT;
- m_nlhr.szUrl = "http://www.imageshack.us/upload_api.php";
- m_nlhr.headersCount = 6;
- { //NETLIBHTTPHEADER start
- m_nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*m_nlhr.headersCount);
- m_nlhr.headers[0].szName = "Referer";
- m_nlhr.headers[0].szValue = "http://www.imageshack.us/upload_api.php";
- m_nlhr.headers[1].szName = "Connection";
- m_nlhr.headers[1].szValue = "Keep-alive";
- m_nlhr.headers[2].szName = "AcceptLanguage";
- m_nlhr.headers[2].szValue = "en-us, pt-br";
- m_nlhr.headers[3].szName = "Host";
- m_nlhr.headers[3].szValue = "imageshack.us";
- m_nlhr.headers[4].szName = "User-Agent";
- m_nlhr.headers[4].szValue = __USER_AGENT_STRING; //szAgent; /;
- //nlhr.headers[x].szName = "Authorization";
- //nlhr.headers[x].szValue = auth; //Basic base-64-authorization
-
- //$header .= "Content-type: multipart/form-data; boundary=" . part::getBoundary() . "\r\n";
- mir_snprintf(m_nlheader_ContentType, SIZEOF(m_nlheader_ContentType), "multipart/form-data; boundary=%s", m_MFDRboundary);
- m_nlhr.headers[m_nlhr.headersCount-1].szName = "Content-Type";
- m_nlhr.headers[m_nlhr.headersCount-1].szValue = m_nlheader_ContentType;
- } //NETLIBHTTPHEADER end
-
-//POST DATA file-header, init DATA with MultipartFormDataRequest
- //$params[] = new filepart('fileupload', $file, basename($file), $contentType, 'iso-8859-1');
- //($this->sendStart($h);)
- AppendToData("--");
- AppendToData(m_MFDRboundary);
- AppendToData("\r\n");
- //($this->sendDispositionHeader($h);)
- AppendToData("Content-Disposition: form-data; name=\"");
- AppendToData("fileupload");
- AppendToData("\"; filename=\"");
- AppendToData(m_pszFileName);
- AppendToData("\"");
- AppendToData("\r\n");
- //($this->sendContentTypeHeader($h);)
- AppendToData("Content-Type: ");
- AppendToData(m_pszContentType);
- AppendToData("; charset=");
- AppendToData("iso-8859-1");
- //($this->sendEndOfHeader($h);)
- AppendToData("\r\n");
- AppendToData("\r\n");
- //Now we add the file binary ($this->sendData($h))
- FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR );
- if( !fileId) {
- //PrintError(1,TRUE);
- return;
- }
- fseek(fileId, NULL, SEEK_END);
- size_t lenFile = ftell(fileId);
- size_t sizeDest = sizeof(char)*(m_nlhr.dataLength + lenFile + 1);
- m_nlhr.pData = (char *) mir_realloc(m_nlhr.pData, sizeDest);
- fseek(fileId, NULL, SEEK_SET );
- int i;
- int ch = fgetc( fileId );
- for( i=0; (i < (int)lenFile ) && ( feof( fileId ) == 0 ); i++ ) {
- m_nlhr.pData[m_nlhr.dataLength+i] = (char)ch;
- ch = fgetc( fileId );
- }
- m_nlhr.pData[sizeDest-1] = 0; //NULL Termination for binary data
- m_nlhr.dataLength = (int)sizeDest - 1;
- fclose(fileId);
- //($this->sendEnd($h);)
- AppendToData("\r\n");
-
-//POST DATA footer (for "optimage", 1)
-//POST DATA footer (for "optsize", optsize)
-
-//POST DATA footer (for "tags", tags)
-//POST DATA footer (for "rembar", "yes" : "no")
-//POST DATA footer (for "public", "yes" : "no")
-//POST DATA footer (for "cookie", cookie)
-
-//POST DATA footer (for "key", DEVKEY_IMAGESHACK)
- //($this->sendStart($h);)
- AppendToData("--");
- AppendToData(m_MFDRboundary);
- AppendToData("\r\n");
- //($this->sendDispositionHeader($h);)
- AppendToData("Content-Disposition: form-data; name=\"");
- AppendToData("key");
- AppendToData("\"");
- //($this->sendTransferEncodingHeader($h); )
- AppendToData("\r\n");
- AppendToData("Content-Transfer-Encoding: ");
- AppendToData("8bit"); //??"binary"
- //($this->sendEndOfHeader($h);)
- AppendToData("\r\n");
- AppendToData("\r\n");
- //($this->sendData($h);)
- AppendToData(DEVKEY_IMAGESHACK);
- //($this->sendEnd($h);)
- AppendToData("\r\n");
-
-//POST DATA Exit
- //$postdata = "--" . part::getBoundary() . "--\r\n";
- AppendToData("--");
- AppendToData(m_MFDRboundary);
- AppendToData("--\r\n");
-
-//start upload thread
- if (m_SendSync) {
- m_bFreeOnExit = FALSE;
- SendThread();
- return;
- }
- m_bFreeOnExit = TRUE;
- mir_forkthread(&CSendImageShack::SendThreadWrapper, this);
-}
-
-void CSendImageShack::SendThread() {
- //send DATA and wait for m_nlreply
- m_nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) &m_nlhr);
- mir_freeAndNil(m_nlhr.pData);
- mir_freeAndNil(m_nlhr.headers);
- if(m_nlreply){
- if( m_nlreply->resultCode >= 200 && m_nlreply->resultCode < 300 ){
- m_nlreply->pData[m_nlreply->dataLength] = 0;// make sure its null terminated
- const char* URL = NULL;
- LPTSTR err = NULL;
- 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);
- return;
- }
- m_ChatRoom ? svcSendChat(URL) : svcSendMsg(URL);
- return;
- }
- else{ //check error mess from server
- err = mir_a2t(GetTagContent(m_nlreply->pData, "<error ", "</error>"));
- if (err && err[0]!= NULL) { //parsed err messege
- Error(NULL, err);
- }
- else{ //fallback to server response mess
- mir_freeAndNil(err);
- err = mir_a2t(m_nlreply->pData);
- }
- mir_free(err);
- }
- }
- else {
- Error(NULL, TranslateT("Upload server did not respond timely."));
- }
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
- m_nlreply = NULL;
- }
- else {
- Error(SS_ERR_INIT, m_pszSendTyp);
- }
- Exit(ACKRESULT_FAILED);
-}
-
-void CSendImageShack::SendThreadWrapper(void * Obj) {
- reinterpret_cast<CSendImageShack*>(Obj)->SendThread();
-}
-
-//---------------------------------------------------------------------------
-void CSendImageShack::MFDR_Reset() {
- char Temp[64];
- DWORD dwBoundaryRand1 = GetTickCount();
- DWORD dwBoundaryRand2 = rand();
-
- mir_freeAndNil(m_MFDRboundary);
- mir_snprintf(Temp, SIZEOF(Temp), "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2);
- mir_stradd(m_MFDRboundary,Temp);
-}
-
-void CSendImageShack::GetContentType() {
- if (m_pszContentType) mir_freeAndNil(m_pszContentType);
- LPSTR FileExtension = (LPSTR)GetFileExt(m_pszFile, DBVT_ASCIIZ);
-
- if ((strcmp(FileExtension, ".jpeg")==0) || (strcmp(FileExtension, ".jpe")==0) || (strcmp(FileExtension ,".jpg")==0))
- m_pszContentType="image/jpeg";
- else if (strcmp(FileExtension, ".bmp")==0)
- m_pszContentType="image/bmp";
- else if (strcmp(FileExtension, ".png")==0)
- m_pszContentType="image/png";
- else if (strcmp(FileExtension, ".gif")==0)
- m_pszContentType="image/gif";
- else if ((strcmp(FileExtension, ".tif")==0) || (strcmp(FileExtension, ".tiff")==0))
- m_pszContentType="image/tiff";
- else
- m_pszContentType="application/octet-stream";
-
- mir_free(FileExtension);
- return;
-}
-
-void CSendImageShack::AppendToData(const char *pszVal) {
- if (!m_nlhr.pData) {
- m_nlhr.pData = mir_strdup(pszVal);
- m_nlhr.dataLength = (int)strlen(pszVal);
- }
- else {
- size_t lenVal = strlen(pszVal);
- size_t sizeNew = sizeof(char)*(m_nlhr.dataLength + lenVal + 1);
- m_nlhr.pData = (char*) mir_realloc(m_nlhr.pData, sizeNew);
-
- strcpy(m_nlhr.pData + sizeof(char)*m_nlhr.dataLength, pszVal);
- m_nlhr.pData[sizeNew-1] = 0;
- m_nlhr.dataLength = (int)sizeNew -1;
- }
-}
-
-//---------------------------------------------------------------------------
-const char * CSendImageShack::GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd) {
- char * b = strstr(pszSource, pszTagStart);
- if (!b) return NULL;
- b += strlen(pszTagStart);
- char * e = strstr(b, pszTagEnd);
- if (e) *e = 0;
- return b;
-}
-
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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"
+
+//---------------------------------------------------------------------------
+CSendImageShack::CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit)
+: CSend(Owner, hContact, bFreeOnExit) {
+ m_EnableItem = SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | SS_DLG_DESCRIPTION;
+ m_pszSendTyp = _T("Image upload");
+ m_pszFileName = NULL;
+ m_pszContentType = NULL;
+ m_MFDRboundary = NULL;
+ m_nlreply = NULL;
+ m_SendSync = false;
+ m_Url = NULL;
+}
+
+CSendImageShack::~CSendImageShack(){
+ mir_free(m_pszFileName);
+ mir_free(m_MFDRboundary);
+ // FREEHTTPREQUESTSTRUCT*
+ if (m_nlreply) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
+ mir_free(m_Url);
+};
+
+//---------------------------------------------------------------------------
+void CSendImageShack::Send() {
+ // check Netlib
+ if( !hNetlibUser ) {
+ //PrintError(1,TRUE);
+ return;
+ }
+ if (!m_pszFileName) {
+ m_pszFileName = (LPSTR)GetFileName(m_pszFile, DBVT_ASCIIZ);
+ }
+ if (!m_pszContentType) GetContentType();
+
+ // create new boundary
+ MFDR_Reset();
+
+ // initialize the netlib request
+ ZeroMemory(&m_nlhr, sizeof(m_nlhr));
+ m_nlhr.cbSize = sizeof(m_nlhr);
+ m_nlhr.requestType = REQUEST_POST;
+ m_nlhr.flags = NLHRF_HTTP11; //NLHRF_DUMPASTEXT;
+ m_nlhr.szUrl = "http://www.imageshack.us/upload_api.php";
+ m_nlhr.headersCount = 6;
+ { //NETLIBHTTPHEADER start
+ m_nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*m_nlhr.headersCount);
+ m_nlhr.headers[0].szName = "Referer";
+ m_nlhr.headers[0].szValue = "http://www.imageshack.us/upload_api.php";
+ m_nlhr.headers[1].szName = "Connection";
+ m_nlhr.headers[1].szValue = "Keep-alive";
+ m_nlhr.headers[2].szName = "AcceptLanguage";
+ m_nlhr.headers[2].szValue = "en-us, pt-br";
+ m_nlhr.headers[3].szName = "Host";
+ m_nlhr.headers[3].szValue = "imageshack.us";
+ m_nlhr.headers[4].szName = "User-Agent";
+ m_nlhr.headers[4].szValue = __USER_AGENT_STRING; //szAgent; /;
+ //nlhr.headers[x].szName = "Authorization";
+ //nlhr.headers[x].szValue = auth; //Basic base-64-authorization
+
+ //$header .= "Content-type: multipart/form-data; boundary=" . part::getBoundary() . "\r\n";
+ mir_snprintf(m_nlheader_ContentType, SIZEOF(m_nlheader_ContentType), "multipart/form-data; boundary=%s", m_MFDRboundary);
+ m_nlhr.headers[m_nlhr.headersCount-1].szName = "Content-Type";
+ m_nlhr.headers[m_nlhr.headersCount-1].szValue = m_nlheader_ContentType;
+ } //NETLIBHTTPHEADER end
+
+//POST DATA file-header, init DATA with MultipartFormDataRequest
+ //$params[] = new filepart('fileupload', $file, basename($file), $contentType, 'iso-8859-1');
+ //($this->sendStart($h);)
+ AppendToData("--");
+ AppendToData(m_MFDRboundary);
+ AppendToData("\r\n");
+ //($this->sendDispositionHeader($h);)
+ AppendToData("Content-Disposition: form-data; name=\"");
+ AppendToData("fileupload");
+ AppendToData("\"; filename=\"");
+ AppendToData(m_pszFileName);
+ AppendToData("\"");
+ AppendToData("\r\n");
+ //($this->sendContentTypeHeader($h);)
+ AppendToData("Content-Type: ");
+ AppendToData(m_pszContentType);
+ AppendToData("; charset=");
+ AppendToData("iso-8859-1");
+ //($this->sendEndOfHeader($h);)
+ AppendToData("\r\n");
+ AppendToData("\r\n");
+ //Now we add the file binary ($this->sendData($h))
+ FILE * fileId = _tfsopen(m_pszFile, _T("rb"), _SH_DENYWR );
+ if( !fileId) {
+ //PrintError(1,TRUE);
+ return;
+ }
+ fseek(fileId, NULL, SEEK_END);
+ size_t lenFile = ftell(fileId);
+ size_t sizeDest = sizeof(char)*(m_nlhr.dataLength + lenFile + 1);
+ m_nlhr.pData = (char *) mir_realloc(m_nlhr.pData, sizeDest);
+ fseek(fileId, NULL, SEEK_SET );
+ int i;
+ int ch = fgetc( fileId );
+ for( i=0; (i < (int)lenFile ) && ( feof( fileId ) == 0 ); i++ ) {
+ m_nlhr.pData[m_nlhr.dataLength+i] = (char)ch;
+ ch = fgetc( fileId );
+ }
+ m_nlhr.pData[sizeDest-1] = 0; //NULL Termination for binary data
+ m_nlhr.dataLength = (int)sizeDest - 1;
+ fclose(fileId);
+ //($this->sendEnd($h);)
+ AppendToData("\r\n");
+
+//POST DATA footer (for "optimage", 1)
+//POST DATA footer (for "optsize", optsize)
+
+//POST DATA footer (for "tags", tags)
+//POST DATA footer (for "rembar", "yes" : "no")
+//POST DATA footer (for "public", "yes" : "no")
+//POST DATA footer (for "cookie", cookie)
+
+//POST DATA footer (for "key", DEVKEY_IMAGESHACK)
+ //($this->sendStart($h);)
+ AppendToData("--");
+ AppendToData(m_MFDRboundary);
+ AppendToData("\r\n");
+ //($this->sendDispositionHeader($h);)
+ AppendToData("Content-Disposition: form-data; name=\"");
+ AppendToData("key");
+ AppendToData("\"");
+ //($this->sendTransferEncodingHeader($h); )
+ AppendToData("\r\n");
+ AppendToData("Content-Transfer-Encoding: ");
+ AppendToData("8bit"); //??"binary"
+ //($this->sendEndOfHeader($h);)
+ AppendToData("\r\n");
+ AppendToData("\r\n");
+ //($this->sendData($h);)
+ AppendToData(DEVKEY_IMAGESHACK);
+ //($this->sendEnd($h);)
+ AppendToData("\r\n");
+
+//POST DATA Exit
+ //$postdata = "--" . part::getBoundary() . "--\r\n";
+ AppendToData("--");
+ AppendToData(m_MFDRboundary);
+ AppendToData("--\r\n");
+
+//start upload thread
+ if (m_SendSync) {
+ m_bFreeOnExit = FALSE;
+ SendThread();
+ return;
+ }
+ m_bFreeOnExit = TRUE;
+ mir_forkthread(&CSendImageShack::SendThreadWrapper, this);
+}
+
+void CSendImageShack::SendThread() {
+ //send DATA and wait for m_nlreply
+ m_nlreply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) &m_nlhr);
+ mir_freeAndNil(m_nlhr.pData);
+ mir_freeAndNil(m_nlhr.headers);
+ if(m_nlreply){
+ if( m_nlreply->resultCode >= 200 && m_nlreply->resultCode < 300 ){
+ m_nlreply->pData[m_nlreply->dataLength] = 0;// make sure its null terminated
+ const char* URL = NULL;
+ 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);
+ return;
+ }
+ m_ChatRoom ? svcSendChat(URL) : svcSendMsg(URL);
+ return;
+ }else{//check error mess from server
+ LPTSTR err = mir_a2t(GetTagContent(m_nlreply->pData, "<error ", "</error>"));
+ if (!err || !*err){//fallback to server response mess
+ mir_freeAndNil(err);
+ err = mir_a2t(m_nlreply->pData);
+ }
+ Error(NULL, err);
+ mir_free(err);
+ }
+ }
+ else {
+ Error(NULL, TranslateT("Upload server did not respond timely."));
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) m_nlreply);
+ m_nlreply = NULL;
+ }
+ else {
+ Error(SS_ERR_INIT, m_pszSendTyp);
+ }
+ Exit(ACKRESULT_FAILED);
+}
+
+void CSendImageShack::SendThreadWrapper(void * Obj) {
+ reinterpret_cast<CSendImageShack*>(Obj)->SendThread();
+}
+
+//---------------------------------------------------------------------------
+void CSendImageShack::MFDR_Reset() {
+ char Temp[64];
+ DWORD dwBoundaryRand1 = GetTickCount();
+ DWORD dwBoundaryRand2 = rand();
+
+ mir_freeAndNil(m_MFDRboundary);
+ mir_snprintf(Temp, SIZEOF(Temp), "B-O-U-N-D-A-R-Y%u%u", dwBoundaryRand1, dwBoundaryRand2);
+ mir_stradd(m_MFDRboundary,Temp);
+}
+
+void CSendImageShack::GetContentType() {
+ if (m_pszContentType) mir_freeAndNil(m_pszContentType);
+ LPSTR FileExtension = (LPSTR)GetFileExt(m_pszFile, DBVT_ASCIIZ);
+
+ if ((strcmp(FileExtension, ".jpeg")==0) || (strcmp(FileExtension, ".jpe")==0) || (strcmp(FileExtension ,".jpg")==0))
+ m_pszContentType="image/jpeg";
+ else if (strcmp(FileExtension, ".bmp")==0)
+ m_pszContentType="image/bmp";
+ else if (strcmp(FileExtension, ".png")==0)
+ m_pszContentType="image/png";
+ else if (strcmp(FileExtension, ".gif")==0)
+ m_pszContentType="image/gif";
+ else if ((strcmp(FileExtension, ".tif")==0) || (strcmp(FileExtension, ".tiff")==0))
+ m_pszContentType="image/tiff";
+ else
+ m_pszContentType="application/octet-stream";
+
+ mir_free(FileExtension);
+ return;
+}
+
+void CSendImageShack::AppendToData(const char *pszVal) {
+ if (!m_nlhr.pData) {
+ m_nlhr.pData = mir_strdup(pszVal);
+ m_nlhr.dataLength = (int)strlen(pszVal);
+ }
+ else {
+ size_t lenVal = strlen(pszVal);
+ size_t sizeNew = sizeof(char)*(m_nlhr.dataLength + lenVal + 1);
+ m_nlhr.pData = (char*) mir_realloc(m_nlhr.pData, sizeNew);
+
+ strcpy(m_nlhr.pData + sizeof(char)*m_nlhr.dataLength, pszVal);
+ m_nlhr.pData[sizeNew-1] = 0;
+ m_nlhr.dataLength = (int)sizeNew -1;
+ }
+}
+
+//---------------------------------------------------------------------------
+const char * CSendImageShack::GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd) {
+ char * b = strstr(pszSource, pszTagStart);
+ if (!b) return NULL;
+ b += strlen(pszTagStart);
+ char * e = strstr(b, pszTagEnd);
+ if (e) *e = 0;
+ return b;
+}
+
diff --git a/plugins/SendScreenshotPlus/src/CSendImageShack.h b/plugins/SendScreenshotPlus/src/CSendImageShack.h
index d5343c711a..c5077e437f 100644
--- a/plugins/SendScreenshotPlus/src/CSendImageShack.h
+++ b/plugins/SendScreenshotPlus/src/CSendImageShack.h
@@ -1,66 +1,65 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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_IMAGESHACK_H
-#define _CSEND_IMAGESHACK_H
-
-//---------------------------------------------------------------------------
-class CSendImageShack : public CSend {
- public:
- // Deklaration Standardkonstruktor/Standarddestructor
- CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit);
- ~CSendImageShack();
-
- void Send();
- void SendSync(bool Sync) {m_SendSync = Sync;};
- LPSTR GetURL(){return m_Url;};
- LPSTR GetError(){return mir_t2a(m_ErrorMsg);};
-
- protected:
- LPSTR m_pszFileName;
- NETLIBHTTPREQUEST m_nlhr;
- NETLIBHTTPREQUEST* m_nlreply;
- NETLIBHTTPHEADER* m_nlheader;
- char m_nlheader_ContentType[64];
- LPSTR m_Url;
-
- void AppendToData(const char *pszVal); //append to netlib DATA
- LPSTR m_pszContentType; //hold mimeType (does not need free)
- void GetContentType(); //get mimeType
- const char * GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd);
-
- char* m_MFDRboundary;
- void MFDR_Reset();
-
- bool m_SendSync;
- void SendThread();
- static void SendThreadWrapper(void * Obj);
-
-};
-
-//---------------------------------------------------------------------------
-
-#endif
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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_IMAGESHACK_H
+#define _CSEND_IMAGESHACK_H
+
+//---------------------------------------------------------------------------
+class CSendImageShack : public CSend {
+ public:
+ // Deklaration Standardkonstruktor/Standarddestructor
+ CSendImageShack(HWND Owner, HANDLE hContact, bool bFreeOnExit);
+ ~CSendImageShack();
+
+ void Send();
+ void SendSync(bool Sync) {m_SendSync = Sync;};
+ LPSTR GetURL(){return m_Url;};
+ LPSTR GetError(){return mir_t2a(m_ErrorMsg);};
+
+ protected:
+ LPSTR m_pszFileName;
+ NETLIBHTTPREQUEST m_nlhr;
+ NETLIBHTTPREQUEST* m_nlreply;
+ char m_nlheader_ContentType[64];
+ LPSTR m_Url;
+
+ void AppendToData(const char *pszVal); //append to netlib DATA
+ LPSTR m_pszContentType; //hold mimeType (does not need free)
+ void GetContentType(); //get mimeType
+ const char * GetTagContent(char * pszSource, const char * pszTagStart, const char * pszTagEnd);
+
+ char* m_MFDRboundary;
+ void MFDR_Reset();
+
+ bool m_SendSync;
+ void SendThread();
+ static void SendThreadWrapper(void * Obj);
+
+};
+
+//---------------------------------------------------------------------------
+
+#endif
diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp
index 98a533d4ab..5007deda1f 100644
--- a/plugins/SendScreenshotPlus/src/UAboutForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp
@@ -63,10 +63,8 @@ INT_PTR CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPA
reinterpret_cast<TfrmAbout*>(lParam)->m_hWnd = hWnd;
return wnd->second->wmInitdialog(wParam, lParam);
}
- else {
- wnd = _HandleMapping.find(hWnd);
- }
- if (wnd == _HandleMapping.end()) { // something screwed up
+ wnd=_HandleMapping.find(hWnd);
+ if (wnd==_HandleMapping.end()) { // something screwed up
return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam);
}
@@ -148,9 +146,7 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) {
LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM lParam) {
//---------------------------------------------------------------------------
if (HIWORD(wParam) == BN_CLICKED) {
- int IDControl = LOWORD(wParam);
- HWND hCtrl = (HWND)lParam;
- switch(IDControl) {
+ switch(LOWORD(wParam)) {
case IDCANCEL:
case IDCLOSE:
break;
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index b925da9f52..16c6dac8c4 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -66,11 +66,9 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureWindow(HWND hDlg, UINT uMsg, WPARAM wP
//SetBkMode((HDC)wParam,OPAQUE);
//return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);
return (LRESULT)GetStockObject(WHITE_BRUSH);
- break;
default:
SetBkMode((HDC)wParam, TRANSPARENT);
return (LRESULT)GetStockObject(NULL_BRUSH);
- break;
}
break; //this return false
case WM_COMMAND:
@@ -110,11 +108,9 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureDesktop(HWND hDlg, UINT uMsg, WPARAM w
SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT));
return (LRESULT)GetStockObject(WHITE_BRUSH);
- break;
default:
SetBkMode((HDC)wParam, TRANSPARENT);
return (LRESULT)GetStockObject(NULL_BRUSH);
- break;
}
break;
case WM_COMMAND:
@@ -142,59 +138,53 @@ LRESULT CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARA
SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT));
break;
default:
- return FALSE;
+ return 0;
}
SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
return (LRESULT)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW);
}
- CHandleMapping::iterator wnd(_HandleMapping.end());
- if (msg == WM_INITDIALOG) {
+ CHandleMapping::iterator wnd;
+ if(msg==WM_INITDIALOG) {
wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast<TfrmMain*>(lParam))).first;
- reinterpret_cast<TfrmMain*>(lParam)->m_hWnd = hWnd;
- return wnd->second->wmInitdialog(wParam, lParam);
+ wnd->second->m_hWnd = hWnd;
+ wnd->second->wmInitdialog(wParam, lParam);
+ return 0;
}
- else {
- wnd = _HandleMapping.find(hWnd);
- }
- if (wnd == _HandleMapping.end()) { // something screwed up
- return FALSE; //dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam);
+ wnd=_HandleMapping.find(hWnd);
+ if(wnd==_HandleMapping.end()) { //something screwed up dialog!
+ return 0; //do not use ::DefWindowProc(hWnd, msg, wParam, lParam);
}
- switch (msg)
- {
- // case WM_INITDIALOG: done on top
+ switch (msg){
case WM_COMMAND:
- return wnd->second->wmCommand(wParam, lParam);
+ wnd->second->wmCommand(wParam, lParam);
break;
case WM_CLOSE:
- return wnd->second->wmClose(wParam, lParam);
+ wnd->second->wmClose(wParam, lParam);
break;
case WM_DESTROY:
delete wnd->second;
break;
- case UM_TAB1:
- return wnd->second->UMTab1(wParam, lParam);
- break;
case WM_NOTIFY:
- return wnd->second->wmNotify(wParam, lParam);
+ wnd->second->wmNotify(wParam, lParam);
break;
case WM_TIMER:
- return wnd->second->wmTimer(wParam, lParam);
+ wnd->second->wmTimer(wParam, lParam);
break;
case UM_CLOSING:
- return wnd->second->UMClosing(wParam, lParam);
+ wnd->second->UMClosing(wParam, lParam);
break;
case UM_EVENT:
- return wnd->second->UMevent(wParam, lParam);
+ wnd->second->UMevent(wParam, lParam);
break;
}
- return FALSE;
+ return 0;
}
//---------------------------------------------------------------------------
//WM_INITDIALOG:
-LRESULT TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) {
HWND hCtrl;
//Taskbar and Window icon
SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true));
@@ -372,11 +362,10 @@ LRESULT TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) {
// CheckDlgButton(m_hWnd,ID_chkEditor, m_opt_chkEditor ? BST_CHECKED : BST_UNCHECKED);
TranslateDialogDefault(m_hWnd);
- return FALSE;
}
//WM_COMMAND:
-LRESULT TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
//---------------------------------------------------------------------------
int IDControl = LOWORD(wParam);
switch (HIWORD(wParam)) {
@@ -385,7 +374,6 @@ LRESULT TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
case IDCANCEL:
case IDCLOSE:
break;
-
case ID_chkTimed:
m_opt_chkTimed = (BYTE)Button_GetCheck((HWND)lParam);
TfrmMain::chkTimedClick();
@@ -408,13 +396,11 @@ LRESULT TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
case ID_btnExplore:
TfrmMain::btnExploreClick();
break;
- case ID_btnDesc:
- {
+ case ID_btnDesc:{
m_opt_btnDesc = (m_opt_btnDesc == 0);
HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF);
SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
- break;
+ break;}
case ID_btnDeleteAfterSend:
{
m_opt_btnDeleteAfterSend = (m_opt_btnDeleteAfterSend == 0);
@@ -470,23 +456,22 @@ LRESULT TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) {
default:
break;
}
- return FALSE;
}
//WM_CLOSE:
-LRESULT TfrmMain::wmClose(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::wmClose(WPARAM wParam, LPARAM lParam) {
DestroyWindow(m_hWnd);
- return FALSE;
+ return;
}
//WM_TIMER:
-LRESULT TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {// @todo : improve this
if (wParam == ID_bvlTarget) { // Timer for Target selector
if (m_hCursor) { //imgTarget is activ
//LmouseButton = false
if (!GetLmouse()) {
TfrmMain::imgTargetMouseUp();
- return FALSE;
+ return;
}
//Timer action if LmouseButton = true
m_hLastWin = m_hTargetWindow;
@@ -517,7 +502,7 @@ LRESULT TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {
DrawBorderInverted(hCurrentWin);
m_hTargetWindow = hCurrentWin;
}
- return FALSE;
+ return;
}
//imgTarget is not activ (check if cursor is over ID_bvlTarget control)
RECT rc;
@@ -545,23 +530,23 @@ LRESULT TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {
m_bCapture = true;
switch (m_opt_tabCapture) {
case 0:
- m_Screenshot = CaptureWindow(m_hTargetWindow, (BOOL)m_opt_chkClientArea);
+ m_Screenshot = CaptureWindow(m_hTargetWindow, m_opt_chkClientArea);
break;
case 1:
m_Screenshot = CaptureMonitor((m_opt_cboxDesktop > 0) ? m_Monitors[m_opt_cboxDesktop-1].szDevice : NULL);
break;
default:
- KillTimer(m_hWnd,wParam);
+ KillTimer(m_hWnd,ID_chkTimed);
m_bCapture = false;
#ifdef _DEBUG
OutputDebugStringA("SS Bitmap Timer Stop (no tabCapture)\r\n" );
#endif
- return FALSE;
+ return;
}
if (!m_Screenshot) m_bCapture = false;
}
if (m_Screenshot) {
- KillTimer(m_hWnd,wParam);
+ KillTimer(m_hWnd,ID_chkTimed);
m_bCapture = false;
#ifdef _DEBUG
OutputDebugStringA("SS Bitmap Timer Stop (CaptureDone)\r\n" );
@@ -569,11 +554,10 @@ LRESULT TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {
SendMessage(m_hWnd,UM_EVENT, 0, (LPARAM)EVT_CaptureDone);
}
}
- return FALSE;
}
//WM_NOTIFY:
-LRESULT TfrmMain::wmNotify(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::wmNotify(WPARAM wParam, LPARAM lParam) {
switch(((LPNMHDR)lParam)->idFrom) {
case IDC_CAPTURETAB: //TabControl IDC_CAPTURETAB
switch (((LPNMHDR)lParam)->code) {
@@ -609,11 +593,10 @@ LRESULT TfrmMain::wmNotify(WPARAM wParam, LPARAM lParam) {
default:
break;
}
- return FALSE;
}
//UM_CLOSING:
-LRESULT TfrmMain::UMClosing(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::UMClosing(WPARAM wParam, LPARAM lParam) {
HWND hWnd = (HWND)wParam;
switch (lParam) {
case IDD_UAboutForm:
@@ -625,7 +608,6 @@ LRESULT TfrmMain::UMClosing(WPARAM wParam, LPARAM lParam) {
default:
break;
}
- return FALSE;
}
//UM_TAB1:
@@ -644,7 +626,7 @@ LRESULT TfrmMain::UMTab1(WPARAM wParam, LPARAM lParam) {
}
//UM_EVENT:
-LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
+void TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
//HWND hWnd = (HWND)wParam;
switch (lParam) {
case EVT_CaptureDone:
@@ -652,7 +634,7 @@ LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
TCHAR *err = TranslateT("Can't create a Screenshot");
MessageBox(m_hWnd,err,ERROR_TITLE,MB_OK|MB_ICONWARNING);
Show();
- return FALSE;
+ return;
}
if (m_opt_chkEditor) {
/* TfrmEdit *frmEdit=new TfrmEdit(this);
@@ -666,7 +648,7 @@ LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
delete Screenshot; // This way we can delete it after the method returns
Screenshot = NULL;
*/
- return FALSE;
+ return;
}
else {
FormClose();
@@ -682,8 +664,7 @@ LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
}
m_hTargetWindow = m_hLastWin = NULL;
Show();
- }
- else {
+ }else{
// Saving Options and close
SaveOptions();
Close();
@@ -692,7 +673,6 @@ LRESULT TfrmMain::UMevent(WPARAM wParam, LPARAM lParam) {
default:
break;
}
- return FALSE;
}
//---------------------------------------------------------------------------
@@ -798,14 +778,14 @@ void TfrmMain::Init(LPTSTR DestFolder, HANDLE Contact) {
void TfrmMain::btnCaptureClick() {
m_bFormEdit = false; //until UEditForm is includet
- if (m_opt_tabCapture == 0 && m_hTargetWindow == 0) {
+ if(m_opt_tabCapture==1) m_hTargetWindow=GetDesktopWindow();
+ else if(!m_hTargetWindow) {
TCHAR *err = TranslateT("Select a target window.");
MessageBox(m_hWnd,err,ERROR_TITLE,MB_OK|MB_ICONWARNING);
return;
}
TfrmMain::Hide();
- if (!m_hTargetWindow) m_hTargetWindow = GetDesktopWindow();
if (m_opt_chkTimed) {
SetTimer(m_hWnd, ID_chkTimed, m_opt_edtTimed ? m_opt_edtTimed*1000 : 500, NULL);
@@ -815,7 +795,7 @@ void TfrmMain::btnCaptureClick() {
SetTimer(m_hWnd, ID_chkTimed, 500, NULL);
}
else {
- m_Screenshot = CaptureWindow(m_hTargetWindow, (BOOL)(m_opt_chkClientArea));
+ m_Screenshot = CaptureWindow(m_hTargetWindow, m_opt_chkClientArea);
SendMessage(m_hWnd,UM_EVENT, 0, (LPARAM)EVT_CaptureDone);
}
}
@@ -887,12 +867,12 @@ void TfrmMain::cboxSendByChange() {
itemFlag = m_cSend->GetEnableItem();
m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend;
}
- bState = ((itemFlag & SS_DLG_DELETEAFTERSSEND) == SS_DLG_DELETEAFTERSSEND);
+ bState = (itemFlag & SS_DLG_DELETEAFTERSSEND);
hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF);
SendMessage(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0));
Button_Enable(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), bState);
- bState = ((itemFlag & SS_DLG_DESCRIPTION) == SS_DLG_DESCRIPTION);
+ bState = (itemFlag & SS_DLG_DESCRIPTION);
hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF);
SendMessage(GetDlgItem(m_hWnd, ID_btnDesc), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0));
Button_Enable(GetDlgItem(m_hWnd, ID_btnDesc), bState);
@@ -959,7 +939,7 @@ void TfrmMain::edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl) {
INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
//generate File name
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
- LPTSTR ret = NULL;
+ LPTSTR ret;
LPTSTR path = NULL;
LPTSTR pszFilename = NULL;
LPTSTR pszFileDesc = NULL;
@@ -968,8 +948,8 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
//Generate FileName
mir_tcsadd(path, m_FDestFolder);
if (path[_tcslen(path)-1] != _T('\\')) mir_tcsadd(path, _T("\\"));
- mir_tcsadd(path, _T("shot%.5ld"));
- int FileNumber=db_get_dw(NULL, SZ_SENDSS, "FileNumber", 0) + 1;
+ mir_tcsadd(path, _T("shot%.5u"));
+ unsigned FileNumber=db_get_dw(NULL, SZ_SENDSS, "FileNumber", 0) + 1;
// '00000'-'%.5ld'=0 (add more or less len if differ from 5
size_t len = (_tcslen(path)+0+1);
pszFilename = (LPTSTR)mir_alloc(sizeof(TCHAR)*(len));
@@ -1013,18 +993,9 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
break;
}
-
- if ((FIP->FI_GetICCProfile(dib_new)->flags & FIICC_COLOR_IS_CMYK) == FIICC_COLOR_IS_CMYK) {
- // we are in CMYK colour space
- bool bDummy = false;
- }
- else {
- // we are in RGB colour space
- bool bDummy = true;
- }
+// bool bDummy = !(FIP->FI_GetICCProfile(dib_new)->flags & FIICC_COLOR_IS_CMYK);
- FIBITMAP *dib32 = NULL;
- FIBITMAP *dib24 = NULL;
+ FIBITMAP *dib32,*dib24;
HWND hwndCombo = GetDlgItem(m_hWnd, ID_cboxFormat);
switch (ComboBox_GetItemData(hwndCombo, ComboBox_GetCurSel(hwndCombo))) {
case 0: //PNG
@@ -1042,18 +1013,18 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
*/
dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL);
dib24 = FIP->FI_ConvertTo24Bits(dib32);
- FIP->FI_Unload(dib32); dib32 = NULL;
+ FIP->FI_Unload(dib32);
ret = SaveImage(fif,dib24, pszFilename, _T("jpg"));
- FIP->FI_Unload(dib24); dib24 = NULL;
+ FIP->FI_Unload(dib24);
break;
case 2: //BMP
// ret = SaveImage(FIF_BMP,dib_new, pszFilename, _T("bmp")); //32bit alpha BMP
dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL);
dib24 = FIP->FI_ConvertTo24Bits(dib32);
- FIP->FI_Unload(dib32); dib32 = NULL;
+ FIP->FI_Unload(dib32);
ret = SaveImage(FIF_BMP,dib24, pszFilename, _T("bmp"));
- FIP->FI_Unload(dib24); dib24 = NULL;
+ FIP->FI_Unload(dib24);
break;
case 3: //TIFF (miranda freeimage interface do not support save tiff, we udse GDI+)
@@ -1064,11 +1035,12 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
dib32 = FIP->FI_Composite(dib_new,FALSE,&m_AlphaColor,NULL);
dib24 = FIP->FI_ConvertTo24Bits(dib32);
- FIP->FI_Unload(dib32); dib32 = NULL;
+ FIP->FI_Unload(dib32);
HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib24);
- FIP->FI_Unload(dib24); dib24 = NULL;
- ret = SaveTIF(hBmp, pszFile) ? NULL : pszFile;
+ FIP->FI_Unload(dib24);
+ SaveTIF(hBmp, pszFile);
+ ret=pszFile;
DeleteObject(hBmp);
}
break;
@@ -1077,13 +1049,13 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
{
//dib24 = FIP->FI_ConvertTo8Bits(dib_new);
//ret = SaveImage(FIF_GIF,dib24, pszFilename, _T("gif"));
- //FIP->FI_Unload(dib24); dib24 = NULL;
+ //FIP->FI_Unload(dib24);
LPTSTR pszFile = NULL;
mir_tcsadd(pszFile, pszFilename);
mir_tcsadd(pszFile, _T(".gif"));
HBITMAP hBmp = FIP->FI_CreateHBITMAPFromDIB(dib_new);
SaveGIF(hBmp, pszFile);
- ret = pszFile;
+ ret=pszFile;
DeleteObject(hBmp);
}
break;
@@ -1111,18 +1083,17 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
FIP->FI_Unload(dib_save); dib_save = NULL;
}
}*/
- FIP->FI_Unload(dib_new); dib_new = NULL;
+ FIP->FI_Unload(dib_new);
mir_freeAndNil(pszFilename);
if (ret) {
- db_set_dw(NULL, SZ_SENDSS, "FileNumber", (DWORD)FileNumber);
+ db_set_dw(NULL, SZ_SENDSS, "FileNumber", FileNumber);
mir_freeAndNil(m_pszFile);
mir_freeAndNil(m_pszFileDesc);
m_pszFile = ret;
if (IsWindowEnabled(GetDlgItem(m_hWnd, ID_btnDesc)) && m_opt_btnDesc) {
m_pszFileDesc = pszFileDesc;
- }
- else {
+ }else{
mir_tcsadd(m_pszFileDesc, _T(""));
}
@@ -1132,10 +1103,10 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP* dib) {
m_cSend->m_pszFile = mir_tstrdup(m_pszFile);
m_cSend->m_pszFileDesc = mir_tstrdup(m_pszFileDesc);
}
+ mir_free(ret);
return 0; //OK
}
- mir_freeAndNil(ret);
- mir_freeAndNil(pszFileDesc);
+ mir_free(pszFileDesc);
return 1; //error
}
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.h b/plugins/SendScreenshotPlus/src/UMainForm.h
index f49aa546ff..9ad0a146e7 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.h
+++ b/plugins/SendScreenshotPlus/src/UMainForm.h
@@ -84,8 +84,8 @@ class TfrmMain{
LPTSTR m_FDestFolder;
LPTSTR m_pszFile;
LPTSTR m_pszFileDesc;
- FIBITMAP* m_Screenshot; //Graphics::TBitmap *Screenshot;
- RGBQUAD m_AlphaColor; //
+ FIBITMAP* m_Screenshot;//Graphics::TBitmap *Screenshot;
+ RGBQUAD m_AlphaColor;
HCURSOR m_hCursor;
CSend* m_cSend;
@@ -114,24 +114,24 @@ class TfrmMain{
BYTE m_opt_cboxFormat; //TComboBox *cboxFormat;
BYTE m_opt_edtTimed; //TLabeledEdit *edtTimed;
bool m_bCapture; //is capture activ
+ HWND m_hwndTab; //TabControl handle
+ HWND m_hwndTabPage; //TabControl activ page handle
+ HIMAGELIST m_himlTab; //TabControl imagelist
typedef std::map<HWND, TfrmMain *> CHandleMapping;
static CHandleMapping _HandleMapping;
static LRESULT CALLBACK DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
- LRESULT wmInitdialog(WPARAM wParam, LPARAM lParam);
- LRESULT wmCommand(WPARAM wParam, LPARAM lParam);
- LRESULT wmClose(WPARAM wParam, LPARAM lParam);
- LRESULT wmNotify(WPARAM wParam, LPARAM lParam);
- LRESULT wmTimer(WPARAM wParam, LPARAM lParam);
+ void wmInitdialog(WPARAM wParam, LPARAM lParam);
+ void wmCommand(WPARAM wParam, LPARAM lParam);
+ void wmClose(WPARAM wParam, LPARAM lParam);
+ void wmNotify(WPARAM wParam, LPARAM lParam);
+ void wmTimer(WPARAM wParam, LPARAM lParam);
- LRESULT UMevent(WPARAM wParam, LPARAM lParam);
- LRESULT UMClosing(WPARAM wParam, LPARAM lParam);
+ void UMevent(WPARAM wParam, LPARAM lParam);
+ void UMClosing(WPARAM wParam, LPARAM lParam);
LRESULT UMTab1(WPARAM wParam, LPARAM lParam);
- HWND m_hwndTab; //TabControl handle
- HWND m_hwndTabPage; //TabControl activ page handle
- HIMAGELIST m_himlTab; //TabControl imagelist
static INT_PTR CALLBACK DlgProc_CaptureWindow (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK DlgProc_CaptureDesktop(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// LRESULT CALLBACK DlgProc_UseLastFile (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/plugins/SendScreenshotPlus/src/Utils.cpp b/plugins/SendScreenshotPlus/src/Utils.cpp
index 63affd0132..b56d953d79 100644
--- a/plugins/SendScreenshotPlus/src/Utils.cpp
+++ b/plugins/SendScreenshotPlus/src/Utils.cpp
@@ -1,171 +1,162 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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"
-
-//---------------------------------------------------------------------------
-//Workaround for MS bug ComboBox_SelectItemData
-int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data) {
- int i = 0;
- for ( i ; i < ComboBox_GetCount(hwndCtl); i++) {
- if(data == ComboBox_GetItemData(hwndCtl, i)) {
- ComboBox_SetCurSel (hwndCtl,i);
- return i;
- }
- }
- return CB_ERR;
-}
-
-//---------------------------------------------------------------------------
-// MonitorInfoEnum
-size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen) {
- MONITORS tmp = {0,0};
- if (EnumDisplayMonitors(NULL, NULL, MonitorInfoEnumProc, (LPARAM)&tmp)){
- myMonitors = tmp.info;
- memset(&virtualScreen, 0, sizeof(virtualScreen));
- for (size_t i = 0; i < tmp.count; ++i) {
- UnionRect(&virtualScreen, &virtualScreen, &tmp.info[i].rcMonitor);
- }
- return tmp.count;
- }
- else {
- if (tmp.info) mir_free(tmp.info);
- }
- return 0;
-}
-
-// MonitorInfoEnumProc - CALLBACK for MonitorInfoEnum
-BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
- MONITORS* monitors = (MONITORS*)dwData;
- monitors->count++;
- monitors->info = (MONITORINFOEX*)mir_realloc(monitors->info, sizeof(MONITORINFOEX)*monitors->count);
- monitors->info[monitors->count-1].cbSize = sizeof(MONITORINFOEX);
- if(!GetMonitorInfo(hMonitor, (LPMONITORINFO)(monitors->info + monitors->count-1))) {
- return FALSE; // stop enumeration if error
- }
- return TRUE;
-}
-
-//---------------------------------------------------------------------------
-// capture window as FIBITMAP - caller must FIP->FI_Unload(dib)
-FIBITMAP* CaptureWindow (HWND hCapture, BOOL ClientArea) {
- FIBITMAP *dib = NULL;
- HWND hForegroundWin = NULL;
- HDC hScrDC; // screen DC
- RECT rect= {0}; // screen RECT
- SIZE size; // DIB width and height = window resolution
-
- if (!hCapture || !IsWindow(hCapture)) return 0;
- hForegroundWin = GetForegroundWindow(); //Saving foreground window
- BringWindowToTop(hCapture); // This window bring the target window to the top of all others
- SetForegroundWindow(hCapture); // Make sure the target window is the foreground one
- // redraw window to prevent runtime artefact in picture
- UpdateWindow(hCapture);
-
- hScrDC = GetWindowDC(hCapture);
-
- // get window resolution
- GetWindowRect(hCapture, &rect);
- size.cx = ABS(rect.right - rect.left);
- size.cy = ABS(rect.bottom - rect.top);
-
- //capture window and get FIBITMAP
- dib = CaptureScreen(hScrDC, size, hCapture);
-
- if(ClientArea) {
- RECT rectCA = {0};
- POINT pt = {0};
- GetClientRect (hCapture, &rectCA);
- ClientToScreen(hCapture, &pt);
- //crop the window to ClientArea
- FIBITMAP* dibClient = FIP->FI_Copy(dib,
- pt.x - rect.left,
- pt.y - rect.top,
- pt.x - rect.left + rectCA.right -1,
- pt.y - rect.top + rectCA.bottom -1);
- FIP->FI_Unload(dib);
- dib = dibClient;
- }
-
- ReleaseDC(NULL, hScrDC);
-
- // Restoring foreground window
- if (hForegroundWin) {
- SetForegroundWindow(hForegroundWin);
- }
-
- return dib;
-}
-
-FIBITMAP* CaptureMonitor (LPTSTR szDevice) {
- SIZE size;
- HDC hScrDC;
- FIBITMAP *dib = NULL;
- // get screen resolution
- if(!szDevice) {
- hScrDC = GetDC(NULL); /*Get full virtualscreen*/
- size.cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
- size.cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
- }
- else {
- hScrDC = CreateDC(szDevice, NULL, NULL, NULL);
- size.cx = GetDeviceCaps(hScrDC, HORZRES);
- size.cy = GetDeviceCaps(hScrDC, VERTRES);
- }
- dib = CaptureScreen (hScrDC, size);
- ReleaseDC(NULL, hScrDC);
- return dib;
-}
-
-FIBITMAP* CaptureScreen (HDC hDC, SIZE size, HWND hCapture) {
-//HDC GetDC (NULL) entire desktp
-//HDC GetDC (HWND hWnd) client area of the specified window.
-//HDC GetWindowDC (HWND hWnd) entire window.
- FIBITMAP *dib = NULL;
- HBITMAP hBitmap; // handles to device-dependent bitmaps
- HDC hScrDC, hMemDC; // screen DC and memory DC
-
- // create a DC for the screen and create
- // a memory DC compatible to screen DC
- hScrDC = hDC ? hDC : GetDC(NULL/*Get full screen*/);
- hMemDC = CreateCompatibleDC(hScrDC);
- // create a bitmap compatible with the screen DC
- hBitmap = CreateCompatibleBitmap(hScrDC, size.cx, size.cy);
-
- // select new bitmap into memory DC
- HBITMAP hOld = (HBITMAP) SelectObject(hMemDC, hBitmap);
-
- if(hCapture) {
- PrintWindow(hCapture, hMemDC, 0/*PW_CLIENTONLY is buggy*/);
- }
- else {
- // bitblt screen DC to memory DC
- BitBlt(hMemDC, 0, 0, size.cx, size.cy, hScrDC, 0, 0, CAPTUREBLT|SRCCOPY);
- }
-
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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"
+
+//---------------------------------------------------------------------------
+//Workaround for MS bug ComboBox_SelectItemData
+int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data) {
+ int i = 0;
+ for ( i ; i < ComboBox_GetCount(hwndCtl); i++) {
+ if(data == ComboBox_GetItemData(hwndCtl, i)) {
+ ComboBox_SetCurSel (hwndCtl,i);
+ return i;
+ }
+ }
+ return CB_ERR;
+}
+
+//---------------------------------------------------------------------------
+// MonitorInfoEnum
+size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen) {
+ MONITORS tmp = {0,0};
+ if (EnumDisplayMonitors(NULL, NULL, MonitorInfoEnumProc, (LPARAM)&tmp)){
+ myMonitors = tmp.info;
+ memset(&virtualScreen, 0, sizeof(virtualScreen));
+ for (size_t i = 0; i < tmp.count; ++i) {
+ UnionRect(&virtualScreen, &virtualScreen, &tmp.info[i].rcMonitor);
+ }
+ return tmp.count;
+ }
+ else {
+ if (tmp.info) mir_free(tmp.info);
+ }
+ return 0;
+}
+
+// MonitorInfoEnumProc - CALLBACK for MonitorInfoEnum
+BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+ MONITORS* monitors = (MONITORS*)dwData;
+ ++monitors->count;
+ monitors->info = (MONITORINFOEX*)mir_realloc(monitors->info, sizeof(MONITORINFOEX)*monitors->count);
+ monitors->info[monitors->count-1].cbSize = sizeof(MONITORINFOEX);
+ if(!GetMonitorInfo(hMonitor, (LPMONITORINFO)(monitors->info + monitors->count-1))) {
+ return FALSE; // stop enumeration if error
+ }
+ return TRUE;
+}
+
+//---------------------------------------------------------------------------
+// capture window as FIBITMAP - caller must FIP->FI_Unload(dib)
+FIBITMAP* CaptureWindow (HWND hCapture, BOOL ClientArea) {
+ FIBITMAP *dib;
+ HWND hForegroundWin;
+ HDC hScrDC; // screen DC
+ RECT rect; // screen RECT
+ SIZE size; // DIB width and height = window resolution
+
+ if (!hCapture || !IsWindow(hCapture)) return 0;
+ hForegroundWin = GetForegroundWindow(); //Saving foreground window
+ BringWindowToTop(hCapture); // This window bring the target window to the top of all others
+ SetForegroundWindow(hCapture); // Make sure the target window is the foreground one
+ // redraw window to prevent runtime artefact in picture
+ UpdateWindow(hCapture);
+
+ hScrDC = GetWindowDC(hCapture);
+
+ // get window resolution
+ GetWindowRect(hCapture, &rect);
+ size.cx=ABS(rect.right-rect.left);
+ size.cy=ABS(rect.bottom-rect.top);
+ //capture window and get FIBITMAP
+ dib = CaptureScreen(hScrDC,size,hCapture);
+ ReleaseDC(hCapture,hScrDC);
+ if(ClientArea) {
+ RECT rectCA = {0};
+ POINT pt = {0};
+ GetClientRect (hCapture, &rectCA);
+ ClientToScreen(hCapture, &pt);
+ //crop the window to ClientArea
+ FIBITMAP* dibClient = FIP->FI_Copy(dib,
+ pt.x - rect.left,
+ pt.y - rect.top,
+ pt.x - rect.left + rectCA.right,
+ pt.y - rect.top + rectCA.bottom);
+ FIP->FI_Unload(dib);
+ dib = dibClient;
+ }
+ // Restoring foreground window
+ if(hForegroundWin){
+ SetForegroundWindow(hForegroundWin);
+ }
+ return dib;
+}
+
+FIBITMAP* CaptureMonitor (LPTSTR szDevice) {
+ SIZE size;
+ HDC hScrDC;
+ FIBITMAP *dib = NULL;
+ // get screen resolution
+ if(!szDevice) {
+ hScrDC = GetDC(NULL); /*Get full virtualscreen*/
+ size.cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ size.cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ }
+ else {
+ hScrDC = CreateDC(szDevice, NULL, NULL, NULL);
+ size.cx = GetDeviceCaps(hScrDC, HORZRES);
+ size.cy = GetDeviceCaps(hScrDC, VERTRES);
+ }
+ dib = CaptureScreen (hScrDC, size);
+ ReleaseDC(NULL, hScrDC);
+ return dib;
+}
+
+FIBITMAP* CaptureScreen (HDC hDC,SIZE size,HWND hCapture){
+//HDC GetDC (NULL) entire desktp
+//HDC GetDC (HWND hWnd) client area of the specified window. (may include artifacts)
+//HDC GetWindowDC (HWND hWnd) entire window.
+ FIBITMAP *dib = NULL;
+ HBITMAP hBitmap; // handles to device-dependent bitmaps
+ HDC hScrDC, hMemDC; // screen DC and memory DC
+
+ // create a DC for the screen and create
+ // a memory DC compatible to screen DC
+ if(!(hScrDC=hDC)) hScrDC=GetDC(hCapture);
+ hMemDC = CreateCompatibleDC(hScrDC);
+ // create a bitmap compatible with the screen DC
+ hBitmap = CreateCompatibleBitmap(hScrDC,size.cx,size.cy);
+ // select new bitmap into memory DC
+ SelectObject(hMemDC, hBitmap);
+
+ if(hCapture) {
+ PrintWindow(hCapture,hMemDC,0);
+ }else{// bitblt screen DC to memory DC
+ BitBlt(hMemDC,0,0,size.cx,size.cy,hScrDC,0,0,CAPTUREBLT|SRCCOPY);
+ }
dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap);
//alpha channel from window is always wrong,
@@ -241,299 +232,295 @@ FIBITMAP* CaptureScreen (HDC hDC, SIZE size, HWND hCapture) {
if(!hDC) ReleaseDC(NULL, hScrDC);
DeleteObject(hBitmap);
- #ifdef _DEBUG
- switch (FIP->FI_GetImageType(dib)){
- case FIT_UNKNOWN:
- OutputDebugStringA("FIBITMAP Typ: FIT_UNKNOWN\r\n" );
- break;
- case FIT_BITMAP:
- OutputDebugStringA("FIBITMAP Typ: FIT_BITMAP\r\n" );
- break;
- case FIT_UINT16:
- OutputDebugStringA("FIBITMAP Typ: FIT_UINT16\r\n" );
- break;
- case FIT_INT16:
- OutputDebugStringA("FIBITMAP Typ: FIT_INT16\r\n" );
- break;
- case FIT_UINT32:
- OutputDebugStringA("FIBITMAP Typ: FIT_UINT32\r\n" );
- break;
- case FIT_INT32:
- OutputDebugStringA("FIBITMAP Typ: FIT_INT32\r\n" );
- break;
- case FIT_FLOAT:
- OutputDebugStringA("FIBITMAP Typ: FIT_FLOAT\r\n" );
- break;
- case FIT_DOUBLE:
- OutputDebugStringA("FIBITMAP Typ: FIT_DOUBLE\r\n" );
- break;
- case FIT_COMPLEX:
- OutputDebugStringA("FIBITMAP Typ: FIT_COMPLEX\r\n" );
- break;
- case FIT_RGB16:
- OutputDebugStringA("FIBITMAP Typ: FIT_RGB16\r\n" );
- break;
- case FIT_RGBA16:
- OutputDebugStringA("FIBITMAP Typ: FIT_RGBA16\r\n" );
- break;
- case FIT_RGBF:
- OutputDebugStringA("FIBITMAP Typ: FIT_RGBF\r\n" );
- break;
- case FIT_RGBAF:
- OutputDebugStringA("FIBITMAP Typ: FIT_RGBAF\r\n" );
- break;
- default:
- OutputDebugStringA("FIBITMAP Typ: nicht feststellbar\r\n" );
- break;
- }
- BOOL inf = FIP->FI_IsTransparent(dib);
- OutputDebugStringA(inf ? "FIBITMAP Transparent: true\r\n" : "FIBITMAP Transparent: fase\r\n");
- #endif
-
- return dib;
-}
-
-FIBITMAP* CaptureDesktop/*emulate print screen*/() {
- FIBITMAP *dib = NULL;
- HBITMAP hBitmap; // handles to device-dependent bitmaps
- BOOL bBitmap = false;
- int i = 0;
- keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
- keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
- do {//Clipboard need time to get bitmap from keybd_event,
- i++; //we use a counter to get this time.
- bBitmap = IsClipboardFormatAvailable(CF_BITMAP);
- if(i == 500) return (FIBITMAP*)0; //emergency exit if something go wrong
- } while (!bBitmap);
- #ifdef _DEBUG
- char mess[120] = {0};
- LPSTR pszMess = mess;
- mir_snprintf(pszMess,120,"SS Bitmap counter: %i\r\n",i);
- OutputDebugStringA( pszMess );
- #endif
- //get clipboard data
- OpenClipboard(NULL);
- hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
-
- //create FIBITMAP * from HBITMAP
- FIP->FI_CorrectBitmap32Alpha(hBitmap, FALSE);
- dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap);
- CloseClipboard();
-
- return dib;
-}
-
-LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag) {
- int ret=0;
- LPTSTR pszFile = NULL;
- LPTSTR FileExt = (LPTSTR)GetFileExt (pszFilename, DBVT_TCHAR);
- if(!FileExt) {
- if(!pszExt) return NULL;
- mir_tcsadd(pszFile, pszFilename);
- mir_tcsadd(pszFile, _T("."));
- mir_tcsadd(pszFile, pszExt);
- }
- else {
- mir_tcsadd(pszFile, pszFilename);
- }
-
- if(fif==FIF_UNKNOWN) {
- fif = FIP->FI_GetFIFFromFilenameU(pszFile);
- }
- if(FIP->FI_FIFSupportsICCProfiles(fif)) {
- bool bDummy = true;
- }
-
- ret = FIP->FI_SaveU(fif, dib, pszFile, flag);
-
-
- mir_free(FileExt);
-
- if(ret) return pszFile;
- mir_free(pszFile);
- return NULL;
-}
-
-//---------------------------------------------------------------------------
-//Draws a selection border on the window under cursor
-void DrawBorderInverted(HWND hWindow) {
- if (!hWindow){
- return;
- }
- HDC hDC=GetWindowDC(hWindow);
- RECT rect={0};
- GetWindowRect(hWindow, &rect);
-
- int dcSave = SaveDC(hDC);
-
- SetROP2(hDC, R2_NOT);
-
- HPEN hPen=0;
- hPen = CreatePen(PS_SOLID, 10, RGB(0, 0, 0));
-
- SelectObject(hDC, &hPen);
- SelectObject(hDC, GetStockObject(NULL_BRUSH));
-
- Rectangle(hDC, 0, 0, rect.right-rect.left, rect.bottom-rect.top);
- Rectangle(hDC, 1, 1, rect.right-rect.left-1, rect.bottom-rect.top-1);
- Rectangle(hDC, 2, 2, rect.right-rect.left-2, rect.bottom-rect.top-2);
-
- RestoreDC(hDC, dcSave);
-}
-
-//---------------------------------------------------------------------------
-//is left mouse button down
-BOOL GetLmouse() {
- SHORT temp = GetAsyncKeyState((GetSystemMetrics(SM_SWAPBUTTON)) ? VK_RBUTTON : VK_LBUTTON);
- if ((temp & 0x8000) == 0x8000) { // LBUTTON down
- return TRUE;
- }
- return FALSE;
-}
-
-//---------------------------------------------------------------------------
-INT_PTR GetFileName(LPTSTR pszPath, UINT typ) {
- /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/
- LPTSTR slash = _tcsrchr(pszPath,_T('\\'));
- if (slash) {
- switch (typ) {
- case DBVT_ASCIIZ:
- return (INT_PTR)mir_t2a(slash+1);
- case DBVT_WCHAR:
- return (INT_PTR)mir_t2u(slash+1);
- default:
- return 0;
- }
- }
- else {
- switch (typ) {
- case DBVT_ASCIIZ:
- return (INT_PTR)mir_t2a(pszPath);
- case DBVT_WCHAR:
- return (INT_PTR)mir_t2u(pszPath);
- default:
- return 0;
- }
- }
-}
-
-INT_PTR GetFileExt (LPTSTR pszPath, UINT typ) {
- /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/
- LPTSTR slash = _tcsrchr(pszPath,_T('.'));
- if (slash) {
- switch (typ) {
- case DBVT_ASCIIZ:
- return (INT_PTR)mir_t2a(slash);
- case DBVT_WCHAR:
- return (INT_PTR)mir_t2u(slash);
- default:
- return 0;
- }
- }
- else {
- return NULL;
- }
-}
-
-//---------------------------------------------------------------------------
-BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder) {
- UINT uiNum = 0;
- UINT uiSize = 0;
- BOOL bOk = FALSE;
- Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL;
- Gdiplus::GetImageEncodersSize(&uiNum, &uiSize);
- if( uiSize > 0 ) {
- pImageCodecInfo = (Gdiplus::ImageCodecInfo *)new char[uiSize];
- if( pImageCodecInfo ) {
- Gdiplus::GetImageEncoders(uiNum, uiSize, pImageCodecInfo);
- for( UINT i = 0; i < uiNum; i++ ) {
- if( wcscmp(pImageCodecInfo[i].MimeType, wchMimeType) == 0 ) {
- clsidEncoder = pImageCodecInfo[i].Clsid;
- bOk = TRUE;
- }
- }
- }
- delete pImageCodecInfo;
- }
- return bOk;
-}
-
-INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename) {
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- ULONG_PTR gdiplusToken;
- Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
-
- Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) );
- if( pBitmap ) {
- // Get the CLSID of the PNG encoder.
- CLSID clsidEncoder;
- if( GetEncoderClsid(L"image/png", clsidEncoder)) {
- LPWSTR pswFile = mir_t2u(szFilename);
- pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL);
- mir_free(pswFile);
- }
- delete pBitmap;
- }
- Gdiplus::GdiplusShutdown(gdiplusToken);
- return 0;
-}
-
-INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename) {
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- ULONG_PTR gdiplusToken;
- Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
-
- Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) );
- if( pBitmap ) {
- // Get the CLSID of the GIF encoder.
- CLSID clsidEncoder;
- if( GetEncoderClsid(L"image/gif", clsidEncoder)) {
- LPWSTR pswFile = mir_t2u(szFilename);
- pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL);
- mir_free(pswFile);
- }
- delete pBitmap;
- }
- Gdiplus::GdiplusShutdown(gdiplusToken);
- return 0;
-}
-
-INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename) {
-//http://www.codeproject.com/Messages/1406708/How-to-reduce-the-size-of-an-Image-using-GDIplus.aspx
- ULONG_PTR gdiplusToken;
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- Gdiplus::Status stat;
- Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
-
- Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) );
- if( pBitmap ) {
- // Get the CLSID of the GIF encoder.
- CLSID EncCLSID;
- if( GetEncoderClsid(L"image/tiff", EncCLSID)) {
- //--- Create a 2-parameter array, for Compression and for Color Bit depth
- Gdiplus::EncoderParameters* EncParams = (Gdiplus::EncoderParameters*) malloc(sizeof(Gdiplus::EncoderParameters) + 1 * sizeof(Gdiplus::EncoderParameter));
- // Gdiplus::EncoderParameters pEncoderParameters;
- //--- Use LZW Compression instead of Group 4, since it works for color and G4 doesn't
- ULONG ulCompression = Gdiplus::EncoderValueCompressionLZW ;
- ULONG ulColorDepth = 24L ;
-
- EncParams->Count = 2 ;
- EncParams->Parameter[0].Guid = Gdiplus::EncoderCompression ;
- EncParams->Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong ;
- EncParams->Parameter[0].NumberOfValues = 1 ;
- EncParams->Parameter[0].Value = &ulCompression ;
- EncParams->Parameter[1].Guid = Gdiplus::EncoderColorDepth ;
- EncParams->Parameter[1].Type = Gdiplus::EncoderParameterValueTypeLong ;
- EncParams->Parameter[1].NumberOfValues = 1 ;
- EncParams->Parameter[1].Value = &ulColorDepth ;
-
- LPWSTR pswFile = mir_t2u(szFilename);
- stat = pBitmap->Save((const WCHAR*)pswFile, &EncCLSID, EncParams);
- mir_free(pswFile);
- free(EncParams);
- }
- delete pBitmap;
- }
- Gdiplus::GdiplusShutdown(gdiplusToken);
- return 0;
-}
+ #ifdef _DEBUG
+ switch (FIP->FI_GetImageType(dib)){
+ case FIT_UNKNOWN:
+ OutputDebugStringA("FIBITMAP Typ: FIT_UNKNOWN\r\n" );
+ break;
+ case FIT_BITMAP:
+ OutputDebugStringA("FIBITMAP Typ: FIT_BITMAP\r\n" );
+ break;
+ case FIT_UINT16:
+ OutputDebugStringA("FIBITMAP Typ: FIT_UINT16\r\n" );
+ break;
+ case FIT_INT16:
+ OutputDebugStringA("FIBITMAP Typ: FIT_INT16\r\n" );
+ break;
+ case FIT_UINT32:
+ OutputDebugStringA("FIBITMAP Typ: FIT_UINT32\r\n" );
+ break;
+ case FIT_INT32:
+ OutputDebugStringA("FIBITMAP Typ: FIT_INT32\r\n" );
+ break;
+ case FIT_FLOAT:
+ OutputDebugStringA("FIBITMAP Typ: FIT_FLOAT\r\n" );
+ break;
+ case FIT_DOUBLE:
+ OutputDebugStringA("FIBITMAP Typ: FIT_DOUBLE\r\n" );
+ break;
+ case FIT_COMPLEX:
+ OutputDebugStringA("FIBITMAP Typ: FIT_COMPLEX\r\n" );
+ break;
+ case FIT_RGB16:
+ OutputDebugStringA("FIBITMAP Typ: FIT_RGB16\r\n" );
+ break;
+ case FIT_RGBA16:
+ OutputDebugStringA("FIBITMAP Typ: FIT_RGBA16\r\n" );
+ break;
+ case FIT_RGBF:
+ OutputDebugStringA("FIBITMAP Typ: FIT_RGBF\r\n" );
+ break;
+ case FIT_RGBAF:
+ OutputDebugStringA("FIBITMAP Typ: FIT_RGBAF\r\n" );
+ break;
+ default:
+ OutputDebugStringA("FIBITMAP Typ: non detectable image type (error)\r\n" );
+ break;
+ }
+ BOOL inf = FIP->FI_IsTransparent(dib);
+ OutputDebugStringA(inf ? "FIBITMAP Transparent: true\r\n" : "FIBITMAP Transparent: fase\r\n");
+ #endif
+
+ return dib;
+}
+/*
+FIBITMAP* CaptureDesktop() {//emulate print screen
+ FIBITMAP *dib = NULL;
+ HBITMAP hBitmap; // handles to device-dependent bitmaps
+ BOOL bBitmap = false;
+ int i = 0;
+ keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
+ keybd_event(VK_SNAPSHOT, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+ do {//Clipboard need time to get bitmap from keybd_event,
+ i++; //we use a counter to get this time.
+ bBitmap = IsClipboardFormatAvailable(CF_BITMAP);
+ if(i == 500) return (FIBITMAP*)0; //emergency exit if something go wrong
+ } while (!bBitmap);
+ #ifdef _DEBUG
+ char mess[120] = {0};
+ LPSTR pszMess = mess;
+ mir_snprintf(pszMess,120,"SS Bitmap counter: %i\r\n",i);
+ OutputDebugStringA( pszMess );
+ #endif
+ //get clipboard data
+ OpenClipboard(NULL);
+ hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
+
+ //create FIBITMAP * from HBITMAP
+ FIP->FI_CorrectBitmap32Alpha(hBitmap, FALSE);
+ dib = FIP->FI_CreateDIBFromHBITMAP(hBitmap);
+ CloseClipboard();
+
+ return dib;
+}*/
+
+LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag) {
+ int ret=0;
+ LPTSTR pszFile = NULL;
+ LPTSTR FileExt = (LPTSTR)GetFileExt (pszFilename, DBVT_TCHAR);
+ if(!FileExt) {
+ if(!pszExt) return NULL;
+ mir_tcsadd(pszFile, pszFilename);
+ mir_tcsadd(pszFile, _T("."));
+ mir_tcsadd(pszFile, pszExt);
+ }
+ else {
+ mir_tcsadd(pszFile, pszFilename);
+ }
+
+ if(fif==FIF_UNKNOWN) {
+ fif = FIP->FI_GetFIFFromFilenameU(pszFile);
+ }
+
+ ret = FIP->FI_SaveU(fif, dib, pszFile, flag);
+
+
+ mir_free(FileExt);
+
+ if(ret) return pszFile;
+ mir_free(pszFile);
+ return NULL;
+}
+
+//---------------------------------------------------------------------------
+//Draws a selection border on the window under cursor
+void DrawBorderInverted(HWND hWindow) {
+ if (!hWindow){
+ return;
+ }
+ HDC hDC=GetWindowDC(hWindow);
+ RECT rect={0};
+ GetWindowRect(hWindow, &rect);
+
+ int dcSave = SaveDC(hDC);
+
+ SetROP2(hDC, R2_NOT);
+
+ HPEN hPen=0;
+ hPen = CreatePen(PS_SOLID, 10, RGB(0, 0, 0));
+
+ SelectObject(hDC, &hPen);
+ SelectObject(hDC, GetStockObject(NULL_BRUSH));
+
+ Rectangle(hDC, 0, 0, rect.right-rect.left, rect.bottom-rect.top);
+ Rectangle(hDC, 1, 1, rect.right-rect.left-1, rect.bottom-rect.top-1);
+ Rectangle(hDC, 2, 2, rect.right-rect.left-2, rect.bottom-rect.top-2);
+
+ RestoreDC(hDC, dcSave);
+}
+
+//---------------------------------------------------------------------------
+//is left mouse button down
+BOOL GetLmouse() {
+ SHORT temp = GetAsyncKeyState((GetSystemMetrics(SM_SWAPBUTTON)) ? VK_RBUTTON : VK_LBUTTON);
+ if ((temp & 0x8000) == 0x8000) { // LBUTTON down
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//---------------------------------------------------------------------------
+INT_PTR GetFileName(LPTSTR pszPath, UINT typ) {
+ /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/
+ LPTSTR slash = _tcsrchr(pszPath,_T('\\'));
+ if (slash) {
+ switch (typ) {
+ case DBVT_ASCIIZ:
+ return (INT_PTR)mir_t2a(slash+1);
+ case DBVT_WCHAR:
+ return (INT_PTR)mir_t2u(slash+1);
+ default:
+ return 0;
+ }
+ }
+ else {
+ switch (typ) {
+ case DBVT_ASCIIZ:
+ return (INT_PTR)mir_t2a(pszPath);
+ case DBVT_WCHAR:
+ return (INT_PTR)mir_t2u(pszPath);
+ default:
+ return 0;
+ }
+ }
+}
+
+INT_PTR GetFileExt (LPTSTR pszPath, UINT typ) {
+ /*DBVT_ASCIIZ, DBVT_WCHAR, DBVT_TCHAR*/
+ LPTSTR slash = _tcsrchr(pszPath,_T('.'));
+ if (slash) {
+ switch (typ) {
+ case DBVT_ASCIIZ:
+ return (INT_PTR)mir_t2a(slash);
+ case DBVT_WCHAR:
+ return (INT_PTR)mir_t2u(slash);
+ default:
+ return 0;
+ }
+ }
+ else {
+ return NULL;
+ }
+}
+
+//---------------------------------------------------------------------------
+BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder) {
+ UINT uiNum=0;
+ UINT uiSize=0;
+ BOOL bOk=FALSE;
+ Gdiplus::GetImageEncodersSize(&uiNum,&uiSize);
+ if(uiSize>0){
+ Gdiplus::ImageCodecInfo* pImageCodecInfo=(Gdiplus::ImageCodecInfo *)new char[uiSize];
+ if(pImageCodecInfo){
+ Gdiplus::GetImageEncoders(uiNum,uiSize,pImageCodecInfo);
+ for( UINT i=0; i<uiNum; ++i){
+ if(!wcscmp(pImageCodecInfo[i].MimeType,wchMimeType)){
+ clsidEncoder=pImageCodecInfo[i].Clsid;
+ bOk=TRUE;
+ }
+ }
+ }
+ delete pImageCodecInfo;
+ }
+ return bOk;
+}
+/*
+INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename) {
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ ULONG_PTR gdiplusToken;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) );
+ if( pBitmap ) {
+ // Get the CLSID of the PNG encoder.
+ CLSID clsidEncoder;
+ if( GetEncoderClsid(L"image/png", clsidEncoder)) {
+ LPWSTR pswFile = mir_t2u(szFilename);
+ pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL);
+ mir_free(pswFile);
+ }
+ delete pBitmap;
+ }
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+ return 0;
+}*/
+
+INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename) {
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ ULONG_PTR gdiplusToken;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) );
+ if( pBitmap ) {
+ // Get the CLSID of the GIF encoder.
+ CLSID clsidEncoder;
+ if( GetEncoderClsid(L"image/gif", clsidEncoder)) {
+ LPWSTR pswFile = mir_t2u(szFilename);
+ pBitmap->Save((const WCHAR*)pswFile, &clsidEncoder, NULL);
+ mir_free(pswFile);
+ }
+ delete pBitmap;
+ }
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+ return 0;
+}
+
+INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename) {
+//http://www.codeproject.com/Messages/1406708/How-to-reduce-the-size-of-an-Image-using-GDIplus.aspx
+ ULONG_PTR gdiplusToken;
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::Status stat;
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+
+ Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromHBITMAP(hBmp, (HPALETTE)GetStockObject(DEFAULT_PALETTE) );
+ if( pBitmap ) {
+ // Get the CLSID of the GIF encoder.
+ CLSID EncCLSID;
+ if( GetEncoderClsid(L"image/tiff", EncCLSID)) {
+ //--- Create a 2-parameter array, for Compression and for Color Bit depth
+ Gdiplus::EncoderParameters* EncParams = (Gdiplus::EncoderParameters*) malloc(sizeof(Gdiplus::EncoderParameters) + 1 * sizeof(Gdiplus::EncoderParameter));
+ // Gdiplus::EncoderParameters pEncoderParameters;
+ //--- Use LZW Compression instead of Group 4, since it works for color and G4 doesn't
+ ULONG ulCompression = Gdiplus::EncoderValueCompressionLZW ;
+ ULONG ulColorDepth = 24L ;
+
+ EncParams->Count = 2 ;
+ EncParams->Parameter[0].Guid = Gdiplus::EncoderCompression ;
+ EncParams->Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong ;
+ EncParams->Parameter[0].NumberOfValues = 1 ;
+ EncParams->Parameter[0].Value = &ulCompression ;
+ EncParams->Parameter[1].Guid = Gdiplus::EncoderColorDepth ;
+ EncParams->Parameter[1].Type = Gdiplus::EncoderParameterValueTypeLong ;
+ EncParams->Parameter[1].NumberOfValues = 1 ;
+ EncParams->Parameter[1].Value = &ulColorDepth ;
+
+ LPWSTR pswFile = mir_t2u(szFilename);
+ stat = pBitmap->Save((const WCHAR*)pswFile, &EncCLSID, EncParams);
+ mir_free(pswFile);
+ free(EncParams);
+ }
+ delete pBitmap;
+ }
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+ return 0;
+}
diff --git a/plugins/SendScreenshotPlus/src/Utils.h b/plugins/SendScreenshotPlus/src/Utils.h
index 4b539bb896..da9e13eff3 100644
--- a/plugins/SendScreenshotPlus/src/Utils.h
+++ b/plugins/SendScreenshotPlus/src/Utils.h
@@ -1,71 +1,71 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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 UTILSH
-#define UTILSH
-
-#define SPP_USERPANE 1
-
-extern FI_INTERFACE *FIP;
-
-#define ABS(x) ((x)<0?-(x):(x))
-
-typedef struct TEnumDataTemp {
-size_t count;
-MONITORINFOEX* info;
-}MONITORS;
-
-extern HWND g_hCapture;
-extern HBITMAP g_hBitmap, g_hbmMask;
-
-//---------------------------------------------------------------------------
-int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data);
-
-size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen);
-BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
-
-FIBITMAP* CaptureWindow(HWND hCapture, BOOL ClientArea);
-FIBITMAP* CaptureMonitor(LPTSTR szDevice);
-FIBITMAP* CaptureScreen(HDC hDC, SIZE size, HWND hCapture=0);
-FIBITMAP* CaptureDesktop(); /*emulate print screen (not used)*/
-LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag=0);
-
-void DrawBorderInverted(HWND hWindow);
-BOOL GetLmouse();
-INT_PTR GetFileName(LPTSTR pszPath, UINT typ);
-INT_PTR GetFileExt (LPTSTR pszPath, UINT typ);
-
-BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder);
-INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename);
-INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename);
-INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename);
-
-//---------------------------------------------------------------------------
-/* Old stuff from Borland C++
-//void ShowPopup(char *title, char *text);
-
-*/
-#endif
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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 UTILSH
+#define UTILSH
+
+#define SPP_USERPANE 1
+
+extern FI_INTERFACE *FIP;
+
+#define ABS(x) ((x)<0?-(x):(x))
+
+typedef struct TEnumDataTemp {
+size_t count;
+MONITORINFOEX* info;
+}MONITORS;
+
+extern HWND g_hCapture;
+extern HBITMAP g_hBitmap, g_hbmMask;
+
+//---------------------------------------------------------------------------
+int ComboBox_SelectItemData(HWND hwndCtl, int indexStart, LPARAM data);
+
+size_t MonitorInfoEnum(MONITORINFOEX* & myMonitors, RECT & virtualScreen);
+BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
+
+FIBITMAP* CaptureWindow(HWND hCapture, BOOL ClientArea);
+FIBITMAP* CaptureMonitor(LPTSTR szDevice);
+FIBITMAP* CaptureScreen(HDC hDC, SIZE size, HWND hCapture=0);
+//FIBITMAP* CaptureDesktop(); /*emulate print screen (not used)*/
+LPTSTR SaveImage(FREE_IMAGE_FORMAT fif, FIBITMAP* dib, LPTSTR pszFilename, LPTSTR pszExt, int flag=0);
+
+void DrawBorderInverted(HWND hWindow);
+BOOL GetLmouse();
+INT_PTR GetFileName(LPTSTR pszPath, UINT typ);
+INT_PTR GetFileExt (LPTSTR pszPath, UINT typ);
+
+BOOL GetEncoderClsid(wchar_t *wchMimeType, CLSID& clsidEncoder);
+//INT_PTR SavePNG(HBITMAP hBmp, LPTSTR szFilename);
+INT_PTR SaveGIF(HBITMAP hBmp, LPTSTR szFilename);
+INT_PTR SaveTIF(HBITMAP hBmp, LPTSTR szFilename);
+
+//---------------------------------------------------------------------------
+/* Old stuff from Borland C++
+//void ShowPopup(char *title, char *text);
+
+*/
+#endif
diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
index 3552517c67..62154334a5 100644
--- a/plugins/SendScreenshotPlus/src/ctrl_button.cpp
+++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
@@ -189,13 +189,11 @@ static VOID __fastcall PaintThemeButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClien
// calculate text rect
{
- RECT sizeText;
- HFONT hOldFont;
ccText = GetWindowTextW(ctl->hwnd, wszText, sizeof(wszText) / sizeof(WCHAR));
-
if (ccText > 0) {
- hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);
+ RECT sizeText;
+ HFONT hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);
GetThemeTextExtent(
ctl->hThemeButton,
@@ -298,13 +296,11 @@ static VOID __fastcall PaintButton(BTNCTRL *ctl, HDC hdcMem, LPRECT rcClient)
}
// calculate text rect
{
- SIZE sizeText;
- HFONT hOldFont;
ccText = GetWindowText(ctl->hwnd, szText, SIZEOF(szText));
-
if (ccText > 0) {
- hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);
+ SIZE sizeText;
+ HFONT hOldFont = (HFONT)SelectObject(hdcMem, ctl->hFont);
GetTextExtentPoint32(hdcMem, szText, ccText, &sizeText);
if (ctl->cHot) {
SIZE sizeHot;
@@ -445,16 +441,11 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L
{
PAINTSTRUCT ps;
HDC hdcPaint;
- HDC hdcMem;
- HBITMAP hbmMem;
- HDC hOld;
- RECT rcClient;
-
if (hdcPaint = BeginPaint(hwndBtn, &ps)) {
- GetClientRect(bct->hwnd, &rcClient);
- hdcMem = CreateCompatibleDC(hdcPaint);
- hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
- hOld = (HDC)SelectObject(hdcMem, hbmMem);
+ RECT rcClient; GetClientRect(bct->hwnd, &rcClient);
+ HDC hdcMem = CreateCompatibleDC(hdcPaint);
+ HBITMAP hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
+ HDC hOld = (HDC)SelectObject(hdcMem, hbmMem);
// If its a push button, check to see if it should stay pressed
if ((bct->dwStyle & MBS_PUSHBUTTON) && bct->pbState) bct->stateId = PBS_PRESSED;
@@ -611,14 +602,13 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L
case WM_TIMER: // use a timer to check if they have did a mouseout
if (wParam == BUTTON_POLLID) {
RECT rc;
- POINT pt;
-
- GetWindowRect(hwndBtn, &rc);
- GetCursorPos(&pt);
- if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave
- PostMessage(hwndBtn, WM_MOUSELEAVE, 0, 0L);
- KillTimer(hwndBtn, BUTTON_POLLID);
- }
+ POINT pt;
+ GetWindowRect(hwndBtn,&rc);
+ GetCursorPos(&pt);
+ if(!PtInRect(&rc,pt)){ // mouse must be gone, trigger mouse leave
+ PostMessage(hwndBtn,WM_MOUSELEAVE,0,0L);
+ KillTimer(hwndBtn,BUTTON_POLLID);
+ }
}
break;
case WM_ERASEBKGND:
diff --git a/plugins/SendScreenshotPlus/src/global.h b/plugins/SendScreenshotPlus/src/global.h
index 60a9cc05c6..5cceba5f3d 100644
--- a/plugins/SendScreenshotPlus/src/global.h
+++ b/plugins/SendScreenshotPlus/src/global.h
@@ -1,146 +1,143 @@
-/*
-Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 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 _GLOBAL_H_
-#define _GLOBAL_H_
-
-#define WINVER 0x0700
-#define _WIN32_WINNT 0x0700
-#define _WIN32_IE 0x0601
-
-#define _CRT_SECURE_NO_WARNINGS
-#define OEMRESOURCE
-
-#include <windows.h>
-#include <Windowsx.h>
-#include <commctrl.h>
-#include <time.h>
-#include <Shlwapi.h>
-#include <gdiplus.h>
-#include <mapi.h>
-#include <UxTheme.h>
-
-#include <map>
-#include <string>
-using namespace std;
-
-#ifdef ComboBox_SelectItemData
- // use Workaround for MS bug ComboBox_SelectItemData;
- #undef ComboBox_SelectItemData
-#endif
-
-#include <win2k.h>
-#include <msapi/vsstyle.h>
-#include <msapi/vssym32.h>
-#include <newpluginapi.h>
-#include <m_button.h>
-#include <m_chat.h>
-#include <m_clist.h>
-#include <m_contacts.h>
-#include <m_database.h>
-#include <m_imgsrvc.h>
-#include <m_langpack.h>
-#include <m_netlib.h>
-#include <m_protosvc.h>
-#include <m_skin.h>
-#include <m_popup.h>
-#include <m_icolib.h>
-
-#include <m_folders.h>
-#include <m_HTTPServer.h>
-#include <m_ftpfile.h>
-#include <m_popup2.h>
-#include <m_sendss.h>
-#include <m_userinfoex.h>
-
-#include "mir_string.h"
-#include "mir_icolib.h"
-#include "ctrl_button.h"
-#include "dlg_msgbox.h"
-#include "resource.h"
-#include "version.h"
-#include "main.h"
-#include "CSend.h"
-#include "CSendEmail.h"
-#include "CSendFile.h"
-#include "CSendFTPFile.h"
-#include "CSendHTTPServer.h"
-#include "CSendImageShack.h"
-#include "DevKey.h"
-#include "UMainForm.h"
-#include "UAboutForm.h"
-#include "Utils.h"
-
-#define UM_CLOSING WM_USER+1
-#define UM_EVENT WM_USER+2
-#define UM_TAB1 WM_USER+11
-
-// Generic Message Box for Errors
-#define MSGERROR(text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONERROR)
-#define MSGINFO (text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONINFORMATION)
-
-typedef struct _MGLOBAL {
- DWORD mirandaVersion; // mirandaVersion
- BOOLEAN PopupExist : 1; // Popup or MS_POPUP_ADDPOPUP exist
- BOOLEAN PopupActionsExist : 1; // Popup++ or MS_POPUP_REGISTERACTIONS exist
- BOOLEAN PluginHTTPExist : 1; // HTTPServer or MS_HTTP_ACCEPT_CONNECTIONS exist
- BOOLEAN PluginFTPExist : 1; // FTPFile or MS_FTPFILE_SHAREFILE exist
-
-} MGLOBAL, *LPMGLOBAL;
-
-//---------------------------------------------------------------------------
-#define ERROR_TITLE TranslateT("SendScreenshot - Error")
-
-// Miranda Database Key
-#define SZ_SENDSS "SendSS"
-#define MODNAME "SendSS"
-
-extern HINSTANCE hInst;
-extern MGLOBAL myGlobals;
-extern HANDLE hNetlibUser;
-
-#define PtrIsValid(p) (((p)!=0)&&(((HANDLE)(p))!=INVALID_HANDLE_VALUE))
-
-template<class _Elem>
-std::basic_string<_Elem> replace(const std::basic_string<_Elem> & Origninal, const std::basic_string<_Elem> & What, const std::basic_string<_Elem> & With)
-{
- std::basic_string<_Elem> res;
- size_t l = 0;
- size_t p = 0;
-
- for (size_t p = Origninal.find(What.c_str(), 0); p != std::basic_string<_Elem>::npos; p = Origninal.find(What.c_str(), l))
- {
- if (l != p)
- res.append(Origninal.c_str() + l, p - l);
- res.append(With);
- l = p + What.length();
- }
- if (l < Origninal.length())
- res.append(Origninal.c_str() + l);
-
- return res;
-}
-
-#endif
+/*
+Miranda IM: the free IM client for Microsoft* Windows*
+Copyright 2000-2009 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 _GLOBAL_H_
+#define _GLOBAL_H_
+
+#define WINVER 0x0700
+#define _WIN32_WINNT 0x0700
+#define _WIN32_IE 0x0601
+
+#define _CRT_SECURE_NO_WARNINGS
+#define OEMRESOURCE
+
+#include <windows.h>
+#include <Windowsx.h>
+#include <commctrl.h>
+#include <time.h>
+#include <Shlwapi.h>
+#include <gdiplus.h>
+#include <mapi.h>
+#include <UxTheme.h>
+
+#include <map>
+#include <string>
+using namespace std;
+
+#ifdef ComboBox_SelectItemData
+ // use Workaround for MS bug ComboBox_SelectItemData;
+ #undef ComboBox_SelectItemData
+#endif
+
+#include <win2k.h>
+#include <msapi/vsstyle.h>
+#include <msapi/vssym32.h>
+#include <newpluginapi.h>
+#include <m_button.h>
+#include <m_chat.h>
+#include <m_clist.h>
+#include <m_contacts.h>
+#include <m_database.h>
+#include <m_imgsrvc.h>
+#include <m_langpack.h>
+#include <m_netlib.h>
+#include <m_protosvc.h>
+#include <m_skin.h>
+#include <m_popup.h>
+#include <m_icolib.h>
+
+#include <m_folders.h>
+#include <m_HTTPServer.h>
+#include <m_ftpfile.h>
+#include <m_popup2.h>
+#include <m_sendss.h>
+#include <m_userinfoex.h>
+
+#include "mir_string.h"
+#include "mir_icolib.h"
+#include "ctrl_button.h"
+#include "dlg_msgbox.h"
+#include "resource.h"
+#include "version.h"
+#include "main.h"
+#include "CSend.h"
+#include "CSendEmail.h"
+#include "CSendFile.h"
+#include "CSendFTPFile.h"
+#include "CSendHTTPServer.h"
+#include "CSendImageShack.h"
+#include "DevKey.h"
+#include "UMainForm.h"
+#include "UAboutForm.h"
+#include "Utils.h"
+
+#define UM_CLOSING WM_USER+1
+#define UM_EVENT WM_USER+2
+#define UM_TAB1 WM_USER+11
+
+// Generic Message Box for Errors
+#define MSGERROR(text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONERROR)
+#define MSGINFO (text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONINFORMATION)
+
+typedef struct _MGLOBAL {
+ DWORD mirandaVersion; // mirandaVersion
+ BOOLEAN PopupExist : 1; // Popup or MS_POPUP_ADDPOPUP exist
+ BOOLEAN PopupActionsExist : 1; // Popup++ or MS_POPUP_REGISTERACTIONS exist
+ BOOLEAN PluginHTTPExist : 1; // HTTPServer or MS_HTTP_ACCEPT_CONNECTIONS exist
+ BOOLEAN PluginFTPExist : 1; // FTPFile or MS_FTPFILE_SHAREFILE exist
+
+} MGLOBAL, *LPMGLOBAL;
+
+//---------------------------------------------------------------------------
+#define ERROR_TITLE TranslateT("SendScreenshot - Error")
+
+// Miranda Database Key
+#define SZ_SENDSS "SendSS"
+#define MODNAME "SendSS"
+
+extern HINSTANCE hInst;
+extern MGLOBAL myGlobals;
+extern HANDLE hNetlibUser;
+
+#define PtrIsValid(p) (((p)!=0)&&(((HANDLE)(p))!=INVALID_HANDLE_VALUE))
+
+template<class _Elem>
+std::basic_string<_Elem> replace(const std::basic_string<_Elem> & Origninal, const std::basic_string<_Elem> & What, const std::basic_string<_Elem> & With)
+{
+ std::basic_string<_Elem> res;
+ size_t l = 0;
+ for (size_t p = Origninal.find(What.c_str(), 0); p != std::basic_string<_Elem>::npos; p = Origninal.find(What.c_str(), l))
+ {
+ if (l != p)
+ res.append(Origninal.c_str() + l, p - l);
+ res.append(With);
+ l = p + What.length();
+ }
+ if (l < Origninal.length())
+ res.append(Origninal.c_str() + l);
+
+ return res;
+}
+
+#endif
diff --git a/plugins/SendScreenshotPlus/src/mir_icolib.h b/plugins/SendScreenshotPlus/src/mir_icolib.h
index 937b67bff0..35eb2cf272 100644
--- a/plugins/SendScreenshotPlus/src/mir_icolib.h
+++ b/plugins/SendScreenshotPlus/src/mir_icolib.h
@@ -1,69 +1,69 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2009 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-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 _UINFOEX_ICONS_H_INCLUDED_
-#define _UINFOEX_ICONS_H_INCLUDED_ 1
-
-// sections
-#define SECT_COMMON MODNAME
-#define SECT_BUTTONS MODNAME"/"LPGEN("Buttons")
-#define SECT_OVERLAY MODNAME"/"LPGEN("overlays")
-
-// icons
-#define ICO_PLUG_SSWINDOW1 MODNAME"_plug_SSwindow1"
-#define ICO_PLUG_SSWINDOW2 MODNAME"_plug_SSwindow2"
-#define ICO_PLUG_SSMONITOR MODNAME"_plug_SSmonitor"
-#define ICO_PLUG_SSDEFAULT MODNAME"_plug_SSdefault"
-#define ICO_PLUG_SSTARGET MODNAME"_plug_SSTarget"
-#define ICO_PLUG_SSHELP MODNAME"_plug_SSHelp"
-#define ICO_PLUG_SSFOLDERO MODNAME"_plug_SSFolderOpen"
-#define ICO_PLUG_ARROWL MODNAME"_plug_SSArrowL"
-#define ICO_PLUG_ARROWR MODNAME"_plug_SSArrowR"
-#define ICO_PLUG_SSDESKOFF MODNAME"_plug_SSDeskOff"
-#define ICO_PLUG_SSDESKON MODNAME"_plug_SSDeskOn"
-#define ICO_PLUG_SSDELOFF MODNAME"_plug_SSDelOff"
-#define ICO_PLUG_SSDELON MODNAME"_plug_SSDelOn"
-#define ICO_PLUG_UPDATE MODNAME"_plug_update"
-#define ICO_PLUG_OK MODNAME"_plug_ok"
-#define ICO_PLUG_CANCEL MODNAME"_plug_cancel"
-#define ICO_PLUG_APPLY MODNAME"_plug_apply"
-#define ICO_PLUG_EDIT MODNAME"_plug_edit"
-#define ICO_PLUG_DOWNARROW MODNAME"_plug_downarrow"
-
-#define ICO_PLUG_OVERLAYOFF MODNAME"_plug_SSOverlayOff"
-#define ICO_PLUG_OVERLAYON MODNAME"_plug_SSOverlayOn"
-
-#define ICO_DLG_DETAILS MODNAME"_dlg_details"
-
-typedef struct TIconCtrl
-{
- LPCSTR pszIcon;
- UINT Message;
- WORD idCtrl;
-} ICONCTRL, *LPICONCTRL;
-
-HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big = false);
-
-VOID IcoLib_LoadModule();
-
-#endif /* _UINFOEX_ICONS_H_INCLUDED_ */
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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 _UINFOEX_ICONS_H_INCLUDED_
+#define _UINFOEX_ICONS_H_INCLUDED_ 1
+
+// sections
+#define SECT_COMMON MODNAME
+#define SECT_BUTTONS MODNAME"/"LPGEN("Buttons")
+#define SECT_OVERLAY MODNAME"/"LPGEN("overlays")
+
+// icons
+#define ICO_PLUG_SSWINDOW1 MODNAME"_plug_SSwindow1"
+#define ICO_PLUG_SSWINDOW2 MODNAME"_plug_SSwindow2"
+#define ICO_PLUG_SSMONITOR MODNAME"_plug_SSmonitor"
+#define ICO_PLUG_SSDEFAULT MODNAME"_plug_SSdefault"
+#define ICO_PLUG_SSTARGET MODNAME"_plug_SSTarget"
+#define ICO_PLUG_SSHELP MODNAME"_plug_SSHelp"
+#define ICO_PLUG_SSFOLDERO MODNAME"_plug_SSFolderOpen"
+#define ICO_PLUG_ARROWL MODNAME"_plug_SSArrowL"
+#define ICO_PLUG_ARROWR MODNAME"_plug_SSArrowR"
+#define ICO_PLUG_SSDESKOFF MODNAME"_plug_SSDeskOff"
+#define ICO_PLUG_SSDESKON MODNAME"_plug_SSDeskOn"
+#define ICO_PLUG_SSDELOFF MODNAME"_plug_SSDelOff"
+#define ICO_PLUG_SSDELON MODNAME"_plug_SSDelOn"
+#define ICO_PLUG_UPDATE MODNAME"_plug_update"
+#define ICO_PLUG_OK MODNAME"_plug_ok"
+#define ICO_PLUG_CANCEL MODNAME"_plug_cancel"
+#define ICO_PLUG_APPLY MODNAME"_plug_apply"
+#define ICO_PLUG_EDIT MODNAME"_plug_edit"
+#define ICO_PLUG_DOWNARROW MODNAME"_plug_downarrow"
+
+#define ICO_PLUG_OVERLAYOFF MODNAME"_plug_SSOverlayOff"
+#define ICO_PLUG_OVERLAYON MODNAME"_plug_SSOverlayOn"
+
+#define ICO_DLG_DETAILS MODNAME"_dlg_details"
+
+/*typedef struct TIconCtrl
+{
+ LPCSTR pszIcon;
+ UINT Message;
+ WORD idCtrl;
+} ICONCTRL, *LPICONCTRL;*/
+
+HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big = false);
+
+VOID IcoLib_LoadModule();
+
+#endif /* _UINFOEX_ICONS_H_INCLUDED_ */