diff options
19 files changed, 358 insertions, 350 deletions
diff --git a/plugins/SendScreenshotPlus/res/resource.rc b/plugins/SendScreenshotPlus/res/resource.rc index a4dea6124a..f00b5a45bd 100644 --- a/plugins/SendScreenshotPlus/res/resource.rc +++ b/plugins/SendScreenshotPlus/res/resource.rc @@ -2,10 +2,10 @@ // #include "..\src\resource.h" -#define MBS_DEFBUTTON 0x00001000L // default button -#define MBS_PUSHBUTTON 0x00002000L // toggle button -#define MBS_FLAT 0x00004000L // flat button -#define MBS_DOWNARROW 0x00008000L // has arrow on the right +#define MBS_DEFBUTTON 0x00001000L // default button +#define MBS_PUSHBUTTON 0x00002000L // toggle button +#define MBS_FLAT 0x00004000L // flat button +#define MBS_DOWNARROW 0x00008000L // has arrow on the right #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index d954ff7350..98a22dfe63 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -39,10 +39,8 @@ CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync, bool bSilent) : m_pszFileDesc(nullptr), m_pszSendTyp(nullptr), m_pszProto(nullptr), - // m_hContact(hContact), // initialized below m_EnableItem(0), m_ChatRoom(0), - // m_PFflag(0), m_cbEventMsg(0), m_hSend(nullptr), m_hOnSend(nullptr), @@ -200,6 +198,7 @@ void CSend::svcSendMsgExit(const char* szMessage) m_pszFileDesc = mir_a2u(szMessage); Exit(CSEND_DIALOG); return; } + if (m_ChatRoom) { CMStringW tmp(szMessage); if (m_pszFileDesc) { @@ -232,12 +231,14 @@ void CSend::svcSendMsgExit(const char* szMessage) m_szEventMsg.Append(_T2A(m_pszFileDesc)); m_cbEventMsg = m_szEventMsg.GetLength() + 1; } - //create a HookEventObj on ME_PROTO_ACK - if (!m_hOnSend) { + + // create a HookEventObj on ME_PROTO_ACK + if (!m_hOnSend) m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this); - } - //start PSS_MESSAGE service + + // start PSS_MESSAGE service m_hSend = (HANDLE)ProtoChainSend(m_hContact, PSS_MESSAGE, NULL, ptrA(mir_utf8encode(m_szEventMsg))); + // check we actually got an ft handle back from the protocol if (!m_hSend) { Unhook(); @@ -249,12 +250,13 @@ void CSend::svcSendMsgExit(const char* szMessage) void CSend::svcSendFileExit() { - //szMessage should be encoded as the File followed by the description, the - //separator being a single nul (\0). If there is no description, do not forget - //to end the File with two nuls. + // szMessage should be encoded as the File followed by the description, the + // separator being a single nul (\0). If there is no description, do not forget + // to end the File with two nuls. if (m_bSilent) { Exit(ACKRESULT_SUCCESS); return; } + if (!m_hContact) { Error(LPGENW("%s requires a valid contact!"), m_pszSendTyp); Exit(ACKRESULT_FAILED); return; @@ -269,7 +271,7 @@ void CSend::svcSendFileExit() m_cbEventMsg = m_szEventMsg.GetLength() + 1; - //create a HookEventObj on ME_PROTO_ACK + // Сreate a HookEventObj on ME_PROTO_ACK if (!m_hOnSend) { m_hOnSend = HookEventObj(ME_PROTO_ACK, OnSend, this); } @@ -301,15 +303,15 @@ int CSend::OnSend(void *obj, WPARAM, LPARAM lParam) return 0; switch (ack->result) { - case ACKRESULT_INITIALISING: //SetFtStatus(hwndDlg, LPGENW("Initialising..."), FTS_TEXT); break; - case ACKRESULT_CONNECTING: //SetFtStatus(hwndDlg, LPGENW("Connecting..."), FTS_TEXT); break; - case ACKRESULT_CONNECTPROXY: //SetFtStatus(hwndDlg, LPGENW("Connecting to proxy..."), FTS_TEXT); break; - case ACKRESULT_LISTENING: //SetFtStatus(hwndDlg, LPGENW("Waiting for connection..."), FTS_TEXT); break; - case ACKRESULT_CONNECTED: //SetFtStatus(hwndDlg, LPGENW("Connected"), FTS_TEXT); break; - case ACKRESULT_SENTREQUEST: //SetFtStatus(hwndDlg, LPGENW("Decision sent"), FTS_TEXT); break; - case ACKRESULT_NEXTFILE: //SetFtStatus(hwndDlg, LPGENW("Moving to next file..."), FTS_TEXT); - case ACKRESULT_FILERESUME: // - case ACKRESULT_DATA: //transfer is on progress + case ACKRESULT_INITIALISING: // SetFtStatus(hwndDlg, LPGENW("Initialising..."), FTS_TEXT); break; + case ACKRESULT_CONNECTING: // SetFtStatus(hwndDlg, LPGENW("Connecting..."), FTS_TEXT); break; + case ACKRESULT_CONNECTPROXY: // SetFtStatus(hwndDlg, LPGENW("Connecting to proxy..."), FTS_TEXT); break; + case ACKRESULT_LISTENING: // SetFtStatus(hwndDlg, LPGENW("Waiting for connection..."), FTS_TEXT); break; + case ACKRESULT_CONNECTED: // SetFtStatus(hwndDlg, LPGENW("Connected"), FTS_TEXT); break; + case ACKRESULT_SENTREQUEST: // SetFtStatus(hwndDlg, LPGENW("Decision sent"), FTS_TEXT); break; + case ACKRESULT_NEXTFILE: // SetFtStatus(hwndDlg, LPGENW("Moving to next file..."), FTS_TEXT); + case ACKRESULT_FILERESUME: + case ACKRESULT_DATA: // transfer is on progress break; case ACKRESULT_DENIED: self->Unhook(); @@ -318,9 +320,9 @@ int CSend::OnSend(void *obj, WPARAM, LPARAM lParam) case ACKRESULT_FAILED: self->Unhook(); self->Exit(ack->result); - //type=ACKTYPE_MESSAGE, result=success/failure, (char*)lParam=error message or NULL. - //type=ACKTYPE_URL, result=success/failure, (char*)lParam=error message or NULL. - //type=ACKTYPE_FILE, result=ACKRESULT_FAILED then lParam=(LPARAM)(const char*)szReason + // type=ACKTYPE_MESSAGE, result=success/failure, (char*)lParam=error message or NULL. + // type=ACKTYPE_URL, result=success/failure, (char*)lParam=error message or NULL. + // type=ACKTYPE_FILE, result=ACKRESULT_FAILED then lParam=(LPARAM)(const char*)szReason break; case ACKRESULT_SUCCESS: self->Unhook(); @@ -406,7 +408,7 @@ void CSend::Exit(unsigned int Result) MsgBoxService(NULL, (LPARAM)&m_box); err = false; break; - case GC_RESULT_WRONGVER: //.You appear to be using the wrong version of GC API. + case GC_RESULT_WRONGVER: // You appear to be using the wrong version of GC API. Error(L"%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. @@ -429,7 +431,7 @@ void CSend::Exit(unsigned int Result) DeleteFile(m_pszFile), m_pszFile = nullptr; } if (m_bAsync) - delete this;/// deletes derived class since destructor is virtual (which also auto-calls base dtor) + delete this; // deletes derived class since destructor is virtual (which also auto-calls base dtor) } ///////////////////////////////////////////////////////////////////////////////////////// @@ -498,7 +500,7 @@ int JSON_Get_(const char* json, size_t jsonlen, const char* variable, const char char* tmp; const char* c; const char* jsonend = json + jsonlen; - /// get needle + // get needle if (!jsonlen || *json != '{') return 0; for (tmp = needle, c = *variable == '[' ? variable + 1 : variable; *c != '[' && *c != ']'; ++c) { @@ -507,12 +509,12 @@ int JSON_Get_(const char* json, size_t jsonlen, const char* variable, const char if (tmp < needle + sizeof(needle) - 1) *tmp++ = *c; } *tmp = '\0'; - /// get child needle (if any) + // get child needle (if any) if (*c == ']') ++c; if (c == jsonend) return 0; needlechild = c; - /// parse JSON + // parse JSON for (c = json + 1; c < jsonend && (*c == '"' || *c == '\'');) { for (++c, tmp = var; c < jsonend && (*c != '"' && *c != '\''); ++c) if (tmp < var + sizeof(var) - 1) *tmp++ = *c; diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h index 5dcdb24224..00b347de8e 100644 --- a/plugins/SendScreenshotPlus/src/CSend.h +++ b/plugins/SendScreenshotPlus/src/CSend.h @@ -31,22 +31,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////////////// -#define SS_AUTOSEND 1 -#define SS_DELETEAFTERSSEND 2 +#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_chkDeleteAfterSend), TRUE); -#define SS_DLG_DESCRIPTION 4 //Button_Enable(GetDlgItem(Owner, ID_chkDesc), TRUE); +#define SS_DLG_AUTOSEND 1 // Button_Enable(GetDlgItem(Owner, ID_chkEmulateClick), TRUE); +#define SS_DLG_DELETEAFTERSSEND 2 // Button_Enable(GetDlgItem(Owner, ID_chkDeleteAfterSend), TRUE); +#define SS_DLG_DESCRIPTION 4 // Button_Enable(GetDlgItem(Owner, ID_chkDesc), TRUE); -#define GC_RESULT_SUCCESS 200 -#define GC_RESULT_WRONGVER 201 -#define GC_RESULT_ERROR 202 -#define GC_RESULT_NOSESSION 209 +#define GC_RESULT_SUCCESS 200 +#define GC_RESULT_WRONGVER 201 +#define GC_RESULT_ERROR 202 +#define GC_RESULT_NOSESSION 209 -const wchar_t SS_ERR_INIT[] =LPGENW("Unable to initiate %s."); -const wchar_t SS_ERR_MAPI[] =LPGENW("MAPI error (%i):\n%s."); -const wchar_t SS_ERR_RESPONSE[] =LPGENW("Unknown response from %s (%i)"); -const wchar_t SS_ERR_NORESPONSE[] =LPGENW("Got no response from %s (%i)"); +const wchar_t SS_ERR_INIT[] = LPGENW("Unable to initiate %s."); +const wchar_t SS_ERR_MAPI[] = LPGENW("MAPI error (%i):\n%s."); +const wchar_t SS_ERR_RESPONSE[] = LPGENW("Unknown response from %s (%i)"); +const wchar_t SS_ERR_NORESPONSE[] = LPGENW("Got no response from %s (%i)"); ///////////////////////////////////////////////////////////////////////////////////////// @@ -78,21 +78,21 @@ protected: CMStringA m_URL; CMStringA m_URLthumb; static int OnSend(void *obj, WPARAM wParam, LPARAM lParam); - wchar_t* m_pszSendTyp; //hold string for error mess - char* m_pszProto; //Contact Proto Modul - MCONTACT m_hContact; //Contact handle - BYTE m_EnableItem; //hold flag for send type - BYTE m_ChatRoom; //is Contact chatroom + wchar_t* m_pszSendTyp; // hold string for error mess + char* m_pszProto; // Contact Proto Module + MCONTACT m_hContact; // Contact handle + BYTE m_EnableItem; // hold flag for send type + BYTE m_ChatRoom; // is Contact chatroom void Error(LPCTSTR pszFormat, ...); void svcSendFileExit(); void svcSendMsgExit(const char* szMessage); void Exit(unsigned int Result); - DWORD m_cbEventMsg; //sizeof EventMsg(T) buffer - CMStringA m_szEventMsg; //EventMsg char* - HANDLE m_hSend; //protocol send handle - HANDLE m_hOnSend; //HookEventObj on ME_PROTO_ACK + DWORD m_cbEventMsg; // sizeof EventMsg(T) buffer + CMStringA m_szEventMsg; // EventMsg char* + HANDLE m_hSend; // protocol send handle + HANDLE m_hOnSend; // HookEventObj on ME_PROTO_ACK MSGBOX m_box; wchar_t* m_ErrorMsg; @@ -129,12 +129,12 @@ protected: int flags; }; - static const char* GetHTMLContent(char* str, const char* startTag, const char* endTag); /// changes "str", can be successfully used only once + static const char* GetHTMLContent(char* str, const char* startTag, const char* endTag); // changes "str", can be successfully used only once static int GetJSONString(const char* json, size_t jsonlen, const char* variable, char* value, size_t valuesize); static int GetJSONInteger(const char* json, size_t jsonlen, const char* variable,int defvalue); static bool GetJSONBool(const char* json, size_t jsonlen, const char* variable); - void HTTPFormDestroy(NETLIBHTTPREQUEST* nlhr); /// use to free data inside "nlhr" created by HTTPFormCreate - int HTTPFormCreate(NETLIBHTTPREQUEST* nlhr, int requestType, const char* url, HTTPFormData* frm, size_t frmNum); /// returns "0" on success, Exit() will be called on failure (stop processing) + void HTTPFormDestroy(NETLIBHTTPREQUEST* nlhr); // use to free data inside "nlhr" created by HTTPFormCreate + int HTTPFormCreate(NETLIBHTTPREQUEST* nlhr, int requestType, const char* url, HTTPFormData* frm, size_t frmNum); // returns "0" on success, Exit() will be called on failure (stop processing) }; #endif diff --git a/plugins/SendScreenshotPlus/src/CSendCloudFile.cpp b/plugins/SendScreenshotPlus/src/CSendCloudFile.cpp index 842ebaee24..f4daa446b4 100644 --- a/plugins/SendScreenshotPlus/src/CSendCloudFile.cpp +++ b/plugins/SendScreenshotPlus/src/CSendCloudFile.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CSendCloudFile::CSendCloudFile(HWND Owner, MCONTACT hContact, bool bAsync, const char *service) : CSend(Owner, hContact, bAsync), m_service(service) { - /// @todo : re-enable SS_DLG_DELETEAFTERSSEND with full implemention of Dropbox upload with progress, msg and sounds + // @todo : re-enable SS_DLG_DELETEAFTERSSEND with full implemention of Dropbox upload with progress, msg and sounds m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND; m_pszSendTyp = TranslateT("CloudFile transfer"); } @@ -54,7 +54,7 @@ int CSendCloudFile::Send() void CSendCloudFile::SendThread() { - /// @todo : SS_DLG_DESCRIPTION and SS_DLG_DELETEAFTERSSEND are of no use as of now since we don't track upload progress + // @todo : SS_DLG_DESCRIPTION and SS_DLG_DELETEAFTERSSEND are of no use as of now since we don't track upload progress CFUPLOADDATA ud = { m_service, m_pszFile, L"SendSS" }; CFUPLOADRESULT ur = { }; diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.cpp b/plugins/SendScreenshotPlus/src/CSendEmail.cpp index 6bb0271af9..679827d289 100644 --- a/plugins/SendScreenshotPlus/src/CSendEmail.cpp +++ b/plugins/SendScreenshotPlus/src/CSendEmail.cpp @@ -66,18 +66,18 @@ int CSendEmail::Send() m_FriendlyName = mir_u2a(ptrW(Contact_GetInfo(CNF_DISPLAY, m_hContact, m_pszProto))); m_Subject = mir_u2a(m_pszFileDesc); - //SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject); + // SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject); - //start Send thread + // start Send thread mir_forkthread(&CSendEmail::SendThreadWrapper, this); return 0; } 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. + // 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]; @@ -87,7 +87,7 @@ void CSendEmail::SendThread() HINSTANCE hMAPILib = ::LoadLibrary(L"MAPI32.DLL"); if (hMAPILib == nullptr) { - //return -1; + // return -1; Error(SS_ERR_INIT, m_pszSendTyp); Exit(ACKRESULT_FAILED); return; } @@ -95,7 +95,7 @@ void CSendEmail::SendThread() lpMAPISendMail = (MAPIFUNC)GetProcAddress(hMAPILib, "MAPISendMail"); if (lpMAPISendMail == nullptr) { ::FreeLibrary(hMAPILib); - //return -2; + // return -2; Error(SS_ERR_INIT, m_pszSendTyp); Exit(ACKRESULT_FAILED); return; } @@ -111,8 +111,8 @@ void CSendEmail::SendThread() Msg.nFileCount = 1; Msg.lpFiles = arrfileDesc; - Msg.lpszNoteText = ""; //body - Msg.lpszSubject = m_Subject; //subject + Msg.lpszNoteText = ""; // body + Msg.lpszSubject = m_Subject; // subject Msg.nRecipCount = 1; MapiRecipDesc recip; @@ -120,13 +120,13 @@ void CSendEmail::SendThread() recip.ulRecipClass = MAPI_TO; if (m_FriendlyName && m_FriendlyName[0] != NULL) { - recip.lpszName = m_FriendlyName; //friendly name set to contact's name + recip.lpszName = m_FriendlyName; // friendly name set to contact's name } else { - recip.lpszName = m_Email; //friendly name set to contact's email + recip.lpszName = m_Email; // friendly name set to contact's email } - recip.lpszAddress = m_Email; //email + recip.lpszAddress = m_Email; // email recip.ulEIDSize = 0; recip.lpEntryID = nullptr; Msg.lpRecips = &recip; @@ -138,7 +138,7 @@ void CSendEmail::SendThread() wchar_t* err; switch (res) { case SUCCESS_SUCCESS: - //The call succeeded and the message was sent. + // The call succeeded and the message was sent. Exit(ACKRESULT_SUCCESS); return; // No message was sent case MAPI_E_AMBIGUOUS_RECIPIENT: diff --git a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp index aa45383304..6523accc97 100644 --- a/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp +++ b/plugins/SendScreenshotPlus/src/CSendFTPFile.cpp @@ -64,7 +64,7 @@ int CSendFTPFile::Send() m_pszFileName = (char*)mir_realloc(m_pszFileName, size); m_pszFileName[size - 1] = NULL; - //start Send thread + // start Send thread mir_forkthread(&CSendFTPFile::SendThreadWrapper, this); return 0; } @@ -78,7 +78,7 @@ void CSendFTPFile::SendThread() Exit(ret); return; } - //Can't delete the file since FTP File plugin will use it + // Can't delete the file since FTP File plugin will use it m_bDeleteAfterSend = false; if (m_URL && *m_URL) {/// @fixme : m_URL never set diff --git a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp index c0e9978259..93a3fb9b1c 100644 --- a/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHTTPServer.cpp @@ -73,7 +73,7 @@ int CSendHTTPServer::Send() m_fsi.nMaxDownloads = -1; // -1 = infinite m_fsi.pszRealPath = m_fsi_pszRealPath; - //start Send thread + // start Send thread mir_forkthread(&CSendHTTPServer::SendThreadWrapper, this); return 0; } @@ -83,17 +83,17 @@ void CSendHTTPServer::SendThread() INT_PTR ret; if (ServiceExists(MS_HTTP_GET_LINK)) { - //patched plugin version + // patched plugin version ret = CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi); if (!ret) { m_URL = ptrA((char*)CallService(MS_HTTP_GET_LINK, (WPARAM)m_fsi.pszSrvPath, 0)); } } else { - //original plugin + // original plugin m_fsi.dwOptions = OPT_SEND_LINK; - //send DATA and wait for reply + // send DATA and wait for reply ret = CallService(MS_HTTP_ADD_CHANGE_REMOVE, (WPARAM)m_hContact, (LPARAM)&m_fsi); } @@ -102,7 +102,7 @@ void CSendHTTPServer::SendThread() Exit(ret); return; } - //Share the file by HTTP Server plugin, SendSS does not own the file anymore = auto-delete won't work + // 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) { diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp index 4c6e6acdea..df2a08f419 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp @@ -45,7 +45,7 @@ CSendHost_ImageShack::~CSendHost_ImageShack() int CSendHost_ImageShack::Send() { - if (!g_hNetlibUser) { /// check Netlib + if (!g_hNetlibUser) { // check Netlib Error(SS_ERR_INIT, m_pszSendTyp); Exit(ACKRESULT_FAILED); return !m_bAsync; @@ -53,9 +53,9 @@ int CSendHost_ImageShack::Send() memset(&m_nlhr, 0, sizeof(m_nlhr)); char* tmp; tmp = mir_u2a(m_pszFile); HTTPFormData frm[] = { - //{ "Referer", HTTPFORM_HEADER("http://www.imageshack.us/upload_api.php") }, + // { "Referer", HTTPFORM_HEADER("http://www.imageshack.us/upload_api.php") }, { "fileupload", HTTPFORM_FILE(tmp) }, - //{ "rembar", "yes" },// no info bar on thumb + // { "rembar", "yes" },// no info bar on thumb { "public", "no" }, { "key", HTTPFORM_8BIT(DEVKEY_IMAGESHACK) }, }; @@ -63,7 +63,7 @@ int CSendHost_ImageShack::Send() mir_free(tmp); if (error) return !m_bAsync; - /// start upload thread + // start upload thread if (m_bAsync) { mir_forkthread(&CSendHost_ImageShack::SendThreadWrapper, this); return 0; @@ -74,12 +74,12 @@ int CSendHost_ImageShack::Send() void CSendHost_ImageShack::SendThread() { - /// send DATA and wait for m_nlreply + // send DATA and wait for m_nlreply NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &m_nlhr); HTTPFormDestroy(&m_nlhr); if (reply) { if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->dataLength) { - reply->pData[reply->dataLength - 1] = '\0';/// make sure its null terminated + reply->pData[reply->dataLength - 1] = '\0'; // make sure its null terminated const char* url = nullptr; url = GetHTMLContent(reply->pData, "<image_link>", "</image_link>"); if (url && *url) { @@ -91,20 +91,20 @@ void CSendHost_ImageShack::SendThread() else m_URLthumb.Empty(); + svcSendMsgExit(url); Netlib_FreeHttpRequest(reply); - svcSendMsgExit(url); return; + return; } - else {/// check error mess from server - url = GetHTMLContent(reply->pData, "<error ", "</error>"); - wchar_t* err = nullptr; - if (url) err = mir_a2u(url); - if (!err || !*err) {/// fallback to server response mess - mir_free(err); - err = mir_a2u(reply->pData); - } - Error(L"%s", err); + + url = GetHTMLContent(reply->pData, "<error ", "</error>"); + wchar_t* err = nullptr; + if (url) err = mir_a2u(url); + if (!err || !*err) { // fallback to server response mess mir_free(err); + err = mir_a2u(reply->pData); } + Error(L"%s", err); + mir_free(err); } else Error(SS_ERR_RESPONSE, m_pszSendTyp, reply->resultCode); diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp index 6c6dabb716..21730d165f 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp @@ -30,7 +30,7 @@ CSendHost_Imgur::~CSendHost_Imgur() int CSendHost_Imgur::Send() { - if (!g_hNetlibUser) { /// check Netlib + if (!g_hNetlibUser) { // check Netlib Error(SS_ERR_INIT, m_pszSendTyp); Exit(ACKRESULT_FAILED); return !m_bAsync; @@ -40,15 +40,13 @@ int CSendHost_Imgur::Send() HTTPFormData frm[] = { { "Authorization", HTTPFORM_HEADER("Client-ID 2a7303d78abe041") }, { "image", HTTPFORM_FILE(tmp) }, - // {"name",""},// filename (detected if multipart / form-data) - // {"title",""}, - // {"description",""}, }; - int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, "https://api.imgur.com/3/image", frm, sizeof(frm) / sizeof(HTTPFormData)); + + int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, "https://api.imgur.com/3/image", frm, _countof(frm)); mir_free(tmp); if (error) return !m_bAsync; - /// start upload thread + // start upload thread if (m_bAsync) { mir_forkthread(&CSendHost_Imgur::SendThread, this); return 0; @@ -60,7 +58,7 @@ int CSendHost_Imgur::Send() void CSendHost_Imgur::SendThread(void* obj) { CSendHost_Imgur* self = (CSendHost_Imgur*)obj; - /// send DATA and wait for m_nlreply + // send DATA and wait for m_nlreply NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr); self->HTTPFormDestroy(&self->m_nlhr); if (reply) { diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp index d18d1a3e03..45171cf0b7 100644 --- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp +++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp @@ -32,7 +32,7 @@ static const char kHostURL[] = "https://uploadpie.com/"; int CSendHost_UploadPie::Send() { - if (!g_hNetlibUser) { /// check Netlib + if (!g_hNetlibUser) { // check Netlib Error(SS_ERR_INIT, m_pszSendTyp); Exit(ACKRESULT_FAILED); return !m_bAsync; @@ -40,22 +40,18 @@ int CSendHost_UploadPie::Send() memset(&m_nlhr, 0, sizeof(m_nlhr)); char* tmp; tmp = mir_u2a(m_pszFile); HTTPFormData frm[] = { - { "MAX_FILE_SIZE", HTTPFORM_INT(3145728) },// ?? - { "upload", HTTPFORM_INT(1) },// ?? + { "MAX_FILE_SIZE", HTTPFORM_INT(3145728) }, + { "upload", HTTPFORM_INT(1) }, { "uploadedfile", HTTPFORM_FILE(tmp) }, - { "expire", HTTPFORM_INT(m_expire) },// 30m - //{ "expire", HTTPFORM_INT(2) },// 1h - //{ "expire", HTTPFORM_INT(3) },// 6h - //{ "expire", HTTPFORM_INT(4) },// 1d - //{ "expire", HTTPFORM_INT(5) },// 1w - //{ "x", HTTPFORM_INT(130) },// relative X coordinate of "BAKE FILE" button (unused?) - //{ "y", HTTPFORM_INT(17) },// relative Y coordinate of "BAKE FILE" button (unused?) + { "expire", HTTPFORM_INT(m_expire) }, }; - int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, kHostURL, frm, sizeof(frm) / sizeof(HTTPFormData)); + + int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, kHostURL, frm, _countof(frm)); mir_free(tmp); if (error) return !m_bAsync; - /// start upload thread + + // start upload thread if (m_bAsync) { mir_forkthread(&CSendHost_UploadPie::SendThread, this); return 0; @@ -67,12 +63,12 @@ int CSendHost_UploadPie::Send() void CSendHost_UploadPie::SendThread(void* obj) { CSendHost_UploadPie* self = (CSendHost_UploadPie*)obj; - /// send DATA and wait for m_nlreply + // send DATA and wait for m_nlreply NETLIBHTTPREQUEST* reply = Netlib_HttpTransaction(g_hNetlibUser, &self->m_nlhr); self->HTTPFormDestroy(&self->m_nlhr); if (reply) { if (reply->resultCode >= 200 && reply->resultCode < 300 && reply->dataLength) { - reply->pData[reply->dataLength - 1] = '\0';/// make sure its null terminated + reply->pData[reply->dataLength - 1] = '\0'; // make sure its null terminated char* url = reply->pData; do { char* pos; @@ -93,7 +89,7 @@ void CSendHost_UploadPie::SendThread(void* obj) Netlib_FreeHttpRequest(reply); self->svcSendMsgExit(url); return; } - else {/// check error mess from server + else { // check error mess from server const char* err = GetHTMLContent(reply->pData, "<p id=\"error\"", "</p>"); wchar_t* werr; if (err) werr = mir_a2u(err); diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp index ab4595b3f9..a1e603d2fc 100644 --- a/plugins/SendScreenshotPlus/src/Main.cpp +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -232,14 +232,17 @@ int hook_ModulesLoaded(WPARAM, LPARAM) g_myGlobals.PluginHTTPExist = ServiceExists(MS_HTTP_ACCEPT_CONNECTIONS); g_myGlobals.PluginFTPExist = ServiceExists(MS_FTPFILE_UPLOAD); g_myGlobals.PluginCloudFileExist = ServiceExists(MS_CLOUDFILE_UPLOAD); + // Netlib register NETLIBUSER nlu = {}; nlu.szSettingsModule = __PLUGIN_NAME; nlu.szDescriptiveName.w = TranslateT("SendSS HTTP connections"); nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; //|NUF_NOHTTPSOPTION; g_hNetlibUser = Netlib_RegisterUser(&nlu); + // load my button class / or use UInfoEx CtrlButtonLoadModule(); + // Folders plugin support m_hFolderScreenshot = FoldersRegisterCustomPathT(LPGEN("SendSS"), LPGEN("Screenshots"), PROFILE_PATHW L"\\" CURRENT_PROFILEW L"\\Screenshots"); @@ -248,9 +251,11 @@ int hook_ModulesLoaded(WPARAM, LPARAM) int hook_SystemPreShutdown(WPARAM, LPARAM) { - TfrmMain::Unload();// " + TfrmMain::Unload(); + // Netlib unregister Netlib_CloseHandle(g_hNetlibUser); + // uninitialize classes CtrlButtonUnloadModule(); return 0; @@ -265,18 +270,43 @@ int hook_PrebuildContactMenu(WPARAM hContact, LPARAM) return 0; } +static int TabsrmmButtonsInit(WPARAM, LPARAM) +{ + // SRMM toolbar button + BBButton bbd = {}; + bbd.pszModuleName = MODULENAME; + bbd.dwButtonID = 1; + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON; + bbd.dwDefPos = 201; + bbd.hIcon = GetIconHandle(ICO_MAINXS); + Srmm_AddButton(&bbd, &g_plugin); + return 0; +} + +static int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam) +{ + CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; + if (!mir_strcmp(cbcd->pszModule, MODULENAME) && cbcd->dwButtonId == 1) + CallService(MS_SENDSS_OPENDIALOG, hContact, 0); + + return 0; +} + int CMPlugin::Load() { - /// hook events + // hook events HookEvent(ME_SYSTEM_MODULESLOADED, hook_ModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPreShutdown); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, hook_PrebuildContactMenu); - - /// icons + + HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed); + HookTemporaryEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonsInit); + + // icons g_plugin.registerIcon(MODULENAME, ICONS, MODULENAME); g_plugin.registerIcon(MODULENAME "/" LPGEN("Buttons"), ICONS_BTN, MODULENAME); - /// services + // services #define srv_reg(name) CreateServiceFunction(MODULENAME "/" #name, service_##name); srv_reg(OpenCaptureDialog); srv_reg(SendDesktop); @@ -306,7 +336,7 @@ int CMPlugin::Load() mi.position = 1000001; g_hMenu2 = Menu_AddContactMenuItem(&mi); - /// hotkey's + // hotkey's HOTKEYDESC hkd = {}; hkd.pszName = "Open SendSS+"; hkd.szDescription.w = LPGENW("Open SendSS+"); @@ -316,8 +346,8 @@ int CMPlugin::Load() hkd.dwFlags = HKD_UNICODE; g_plugin.addHotkey(&hkd); - /// register highlighter window class - HBRUSH brush = CreateSolidBrush(0x0000FF00);//owned by class + // register highlighter window class + HBRUSH brush = CreateSolidBrush(0x0000FF00); // owned by class WNDCLASS wndclass = { CS_HREDRAW | CS_VREDRAW, DefWindowProc, 0, 0, g_plugin.getInst(), nullptr, nullptr, brush, nullptr, L"SendSSHighlighter" }; g_clsTargetHighlighter = RegisterClass(&wndclass); return 0; diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp index 25bce13651..9b7efd9d0c 100644 --- a/plugins/SendScreenshotPlus/src/UMainForm.cpp +++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp @@ -33,10 +33,10 @@ void TfrmMain::Unload() { std::list<TfrmMain*> lst; for (CHandleMapping::iterator iter = _HandleMapping.begin(); iter != _HandleMapping.end(); ++iter) { - lst.push_back(iter->second);//we can't delete inside loop.. not MT compatible + lst.push_back(iter->second); // we can't delete inside loop.. not MT compatible } while (!lst.empty()) { - DestroyWindow(lst.front()->m_hWnd);//deletes class + DestroyWindow(lst.front()->m_hWnd); // deletes class lst.pop_front(); } } @@ -70,7 +70,7 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureTabPage(HWND hDlg, UINT uMsg, WPARAM w return (INT_PTR)GetStockObject(WHITE_BRUSH); case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_btnExplore) { /// local file tab + if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_btnExplore) { // local file tab OPENFILENAME ofn = { sizeof(OPENFILENAME) }; wchar_t filename[MAX_PATH]; GetDlgItemText(hDlg, ID_edtSize, filename, _countof(filename)); @@ -80,7 +80,6 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureTabPage(HWND hDlg, UINT uMsg, WPARAM w ofn.nFilterIndex = 1; ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH; - // ofn.lpstrInitialDir = m_FDestFolder; ofn.Flags = OFN_FILEMUSTEXIST | OFN_READONLY; if (GetOpenFileName(&ofn)) { SetDlgItemText(hDlg, ID_edtSize, filename); @@ -113,7 +112,7 @@ INT_PTR CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARA return 0; } SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetStockObject(WHITE_BRUSH); //GetSysColorBrush(COLOR_WINDOW); + return (INT_PTR)GetStockObject(WHITE_BRUSH); } CHandleMapping::iterator wnd; @@ -124,12 +123,11 @@ INT_PTR CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARA return 0; } wnd = _HandleMapping.find(hWnd); - if (wnd == _HandleMapping.end()) { //something screwed up dialog! - return 0; //do not use ::DefWindowProc(hWnd, msg, wParam, lParam); - } + if (wnd == _HandleMapping.end()) + return 0; switch (msg) { - case WM_DROPFILES:{ /// Drag&Drop of local files + case WM_DROPFILES:{ // Drag&Drop of local files wchar_t filename[MAX_PATH]; if (!DragQueryFile((HDROP)wParam, 0, filename, MAX_PATH)) *filename = '\0'; DragFinish((HDROP)wParam); @@ -178,7 +176,7 @@ int EnumCloudFileServices(const CFSERVICEINFO *serviceInfo, void *param) void TfrmMain::wmInitdialog(WPARAM, LPARAM) { HWND hCtrl; - /// Taskbar and Window icon + // Taskbar and Window icon Window_SetIcon_IcoLib(m_hWnd, GetIconHandle(ICO_MAIN)); wchar_t *pt = mir_wstrdup(Clist_GetContactDisplayName(m_hContact)); @@ -189,25 +187,24 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) } mir_free(pt); - /// Headerbar + // Headerbar SendDlgItemMessage(m_hWnd, IDC_HEADERBAR, WM_SETICON, ICON_BIG, (LPARAM)GetIcon(ICO_MAIN)); - /// Timed controls + // Timed controls CheckDlgButton(m_hWnd, ID_chkTimed, m_opt_chkTimed ? BST_CHECKED : BST_UNCHECKED); SetDlgItemInt(m_hWnd, ID_edtTimed, (UINT)m_opt_edtTimed, FALSE); SendDlgItemMessage(m_hWnd, ID_upTimed, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, 1)); - chkTimedClick(); //enable disable Timed controls + chkTimedClick(); // enable disable Timed controls - /// create Image list for tab control + // create Image list for tab control if (!m_himlTab) { - //m_himlTab = ImageList_Create(16, 16, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 2, 0); m_himlTab = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1); ImageList_AddIcon(m_himlTab, GetIcon(ICO_TARGET)); ImageList_AddIcon(m_himlTab, GetIcon(ICO_MONITOR)); ImageList_AddIcon(m_himlTab, GetIconBtn(ICO_BTN_FOLDER)); } - /// create the tab control. + // create the tab control. { m_hwndTab = GetDlgItem(m_hWnd, IDC_CAPTURETAB); TabCtrl_SetImageList(m_hwndTab, m_himlTab); @@ -218,17 +215,18 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) itab.hwndTab = m_hwndTab; itab.tcih.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE; - /// Add a tab for each of the three child dialog boxes. + // Add a tab for each of the three child dialog boxes. itab.tcih.pszText = TranslateT("Window"); itab.tcih.iImage = 0; itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureWindow); TabCtrl_InsertItem(m_hwndTab, 0, &itab); - /// get tab boundaries (required after 1st tab) + + // get tab boundaries (required after 1st tab) GetClientRect(m_hwndTab, &rcTab); MapWindowPoints(m_hwndTab, m_hWnd, (POINT*)&rcTab, 2); TabCtrl_AdjustRect(m_hwndTab, 0, &rcTab); rcTab.bottom -= rcTab.top; rcTab.right -= rcTab.left; - /// + SetWindowPos(itab.hwndTabPage, HWND_TOP, rcTab.left, rcTab.top, rcTab.right, rcTab.bottom, 0); CheckDlgButton(itab.hwndTabPage, ID_chkIndirectCapture, m_opt_chkIndirectCapture ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(itab.hwndTabPage, ID_chkClientArea, m_opt_chkClientArea ? BST_CHECKED : BST_UNCHECKED); @@ -245,14 +243,14 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) ComboBox_SetCurSel(hCtrl, 0); if (m_MonitorCount > 1) { wchar_t tszTemp[120]; - for (size_t mon = 0; mon < m_MonitorCount; ++mon) { /// @todo : fix format for non MSVC compilers + for (size_t mon = 0; mon < m_MonitorCount; ++mon) { // @todo : fix format for non MSVC compilers mir_snwprintf(tszTemp, L"%Iu. %s%s", mon + 1, TranslateT("Monitor"), (m_Monitors[mon].dwFlags & MONITORINFOF_PRIMARY) ? TranslateT(" (primary)") : L"" ); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, tszTemp), mon + 1); } - ComboBox_SelectItemData(hCtrl, m_opt_cboxDesktop); //use Workaround for MS bug ComboBox_SelectItemData + ComboBox_SelectItemData(hCtrl, m_opt_cboxDesktop); // use Workaround for MS bug ComboBox_SelectItemData } PostMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(ID_edtCaption, CBN_SELCHANGE), (LPARAM)hCtrl); @@ -262,25 +260,26 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) TabCtrl_InsertItem(m_hwndTab, 2, &itab); SetWindowPos(itab.hwndTabPage, HWND_TOP, rcTab.left, rcTab.top, rcTab.right, rcTab.bottom, 0); - /// select tab and set m_hwndTabPage + // select tab and set m_hwndTabPage TabCtrl_SetCurSel(m_hwndTab, m_opt_tabCapture); itab.tcih.mask = TCIF_PARAM; TabCtrl_GetItem(m_hwndTab, m_opt_tabCapture, &itab); m_hwndTabPage = itab.hwndTabPage; ShowWindow(m_hwndTabPage, SW_SHOW); - /// enable Drag&Drop for local file pane + // enable Drag&Drop for local file pane typedef BOOL(WINAPI *ChangeWindowMessageFilterEx_t)(HWND hwnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct); ChangeWindowMessageFilterEx_t pChangeWindowMessageFilterEx; pChangeWindowMessageFilterEx = (ChangeWindowMessageFilterEx_t)GetProcAddress(GetModuleHandleA("user32"), "ChangeWindowMessageFilterEx"); - if (pChangeWindowMessageFilterEx) { /// Win7+, UAC fix + if (pChangeWindowMessageFilterEx) { // Win7+, UAC fix pChangeWindowMessageFilterEx(m_hWnd, WM_DROPFILES, MSGFLT_ALLOW, nullptr); pChangeWindowMessageFilterEx(m_hWnd, WM_COPYDATA, MSGFLT_ALLOW, nullptr); pChangeWindowMessageFilterEx(m_hWnd, 0x0049/*WM_COPYGLOBALDATA*/, MSGFLT_ALLOW, nullptr); } DragAcceptFiles(m_hWnd, 1); } - /// init Format combo box + + // init Format combo box { hCtrl = GetDlgItem(m_hWnd, ID_cboxFormat); ComboBox_ResetContent(hCtrl); @@ -289,9 +288,10 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, L"BMP"), 2); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, L"TIF"), 3); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, L"GIF"), 4); - ComboBox_SelectItemData(hCtrl, m_opt_cboxFormat); //use Workaround for MS bug ComboBox_SelectItemData + ComboBox_SelectItemData(hCtrl, m_opt_cboxFormat);// use Workaround for MS bug ComboBox_SelectItemData } - /// init SendBy combo box + + // init SendBy combo box { hCtrl = GetDlgItem(m_hWnd, ID_cboxSendBy); ComboBox_ResetContent(hCtrl); @@ -326,9 +326,10 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Upload Pie (1d)")), new UPLOAD_INFO(SS_UPLOADPIE, (void*)4)); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Upload Pie (1w)")), new UPLOAD_INFO(SS_UPLOADPIE, (void*)5)); ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, L"Imgur"), new UPLOAD_INFO(SS_IMGUR)); - ComboBox_SelectItemData(hCtrl, m_opt_cboxSendBy); //use Workaround for MS bug ComboBox_SelectItemData + ComboBox_SelectItemData(hCtrl, m_opt_cboxSendBy); // use Workaround for MS bug ComboBox_SelectItemData } - /// init footer options + + // init footer options CheckDlgButton(m_hWnd, ID_chkOpenAgain, m_opt_chkOpenAgain ? BST_CHECKED : BST_UNCHECKED); if (hCtrl = GetDlgItem(m_hWnd, ID_btnExplore)) { @@ -369,7 +370,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) SetWindowText(hCtrl, TranslateT("&Capture")); SendMessage(hCtrl, BUTTONSETDEFAULT, 1, NULL); } - cboxSendByChange(nullptr); //enable disable controls + cboxSendByChange(nullptr); // enable disable controls TranslateDialogDefault(m_hWnd); } @@ -379,9 +380,11 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM) void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) { + HICON hIcon; + int IDControl = LOWORD(wParam); switch (HIWORD(wParam)) { - case BN_CLICKED: //Button controls + case BN_CLICKED: // Button controls switch (IDControl) { case IDCANCEL: // ESC pressed this->Close(); @@ -406,46 +409,45 @@ void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) case ID_btnExplore: TfrmMain::btnExploreClick(); break; - case ID_chkDesc:{ - m_opt_btnDesc = !m_opt_btnDesc; - HICON hIcon = GetIconBtn(m_opt_btnDesc ? ICO_BTN_DESCON : ICO_BTN_DESC); - SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - break; } - case ID_chkDeleteAfterSend:{ - m_opt_btnDeleteAfterSend = !m_opt_btnDeleteAfterSend; - HICON hIcon = GetIconBtn(m_opt_btnDeleteAfterSend ? ICO_BTN_DELON : ICO_BTN_DEL); - SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - if (m_cSend) m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; - break; } - case ID_chkEditor:{ - m_opt_chkEditor = !m_opt_chkEditor; - HICON hIcon = GetIconBtn(m_opt_chkEditor ? ICO_BTN_EDITON : ICO_BTN_EDIT); - SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - break; } + case ID_chkDesc: + m_opt_btnDesc = !m_opt_btnDesc; + hIcon = GetIconBtn(m_opt_btnDesc ? ICO_BTN_DESCON : ICO_BTN_DESC); + SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + break; + case ID_chkDeleteAfterSend: + m_opt_btnDeleteAfterSend = !m_opt_btnDeleteAfterSend; + hIcon = GetIconBtn(m_opt_btnDeleteAfterSend ? ICO_BTN_DELON : ICO_BTN_DEL); + SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + if (m_cSend) m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; + break; + case ID_chkEditor: + m_opt_chkEditor = !m_opt_chkEditor; + hIcon = GetIconBtn(m_opt_chkEditor ? ICO_BTN_EDITON : ICO_BTN_EDIT); + SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + break; case ID_chkOpenAgain: m_opt_chkOpenAgain = Button_GetCheck((HWND)lParam); break; case ID_btnCapture: TfrmMain::btnCaptureClick(); break; - default: - break; } break; - case CBN_SELCHANGE: //ComboBox controls - switch (IDControl) { - //lParam = Handle to the control - case ID_cboxFormat: //not finish + + case CBN_SELCHANGE: // ComboBox controls + switch (IDControl) { // lParam = Handle to the control + case ID_cboxFormat: // not finish m_opt_cboxFormat = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); break; case ID_cboxSendBy: - { - UPLOAD_INFO *upload = (UPLOAD_INFO*)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); - m_opt_cboxSendBy = upload->sendBy; - cboxSendByChange(upload->param); + { + UPLOAD_INFO *upload = (UPLOAD_INFO*)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); + m_opt_cboxSendBy = upload->sendBy; + cboxSendByChange(upload->param); + } break; - } - case ID_edtCaption: //cboxDesktopChange + + case ID_edtCaption: // cboxDesktopChange m_opt_cboxDesktop = (BYTE)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)); m_hTargetWindow = nullptr; if (m_opt_cboxDesktop > 0) { @@ -455,29 +457,23 @@ void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) edtSizeUpdate(m_VirtualScreen, GetParent((HWND)lParam), ID_edtSize); } break; - default: - break; } break; - case EN_CHANGE: //Edit controls - switch (IDControl) { - //lParam = Handle to the control + + case EN_CHANGE: // Edit controls + switch (IDControl) { // lParam = Handle to the control case ID_edtQuality: m_opt_edtQuality = (BYTE)GetDlgItemInt(m_hWnd, ID_edtQuality, nullptr, FALSE); break; case ID_edtTimed: m_opt_edtTimed = (BYTE)GetDlgItemInt(m_hWnd, ID_edtTimed, nullptr, FALSE); break; - default: - break; } break; - default: - break; } } -//WM_CLOSE: +// WM_CLOSE: void TfrmMain::wmClose(WPARAM, LPARAM) { HWND hCtrl = GetDlgItem(m_hWnd, ID_cboxSendBy); @@ -490,15 +486,15 @@ void TfrmMain::wmClose(WPARAM, LPARAM) return; } -//WM_TIMER: +// WM_TIMER: const int g_iTargetBorder = 7; void TfrmMain::SetTargetWindow(HWND hwnd) { if (!hwnd) { POINT point; GetCursorPos(&point); hwnd = WindowFromPoint(point); - // if(!((GetAsyncKeyState(VK_SHIFT)|GetAsyncKeyState(VK_MENU))&0x8000)) - for (HWND hTMP; (hTMP = GetParent(hwnd)); hwnd = hTMP); + for (HWND hTMP; (hTMP = GetParent(hwnd)); hwnd = hTMP) + ; } m_hTargetWindow = hwnd; int len = GetWindowTextLength(m_hTargetWindow) + 1; @@ -507,7 +503,7 @@ void TfrmMain::SetTargetWindow(HWND hwnd) lpTitle = (wchar_t*)mir_alloc(len*sizeof(wchar_t)); GetWindowText(m_hTargetWindow, lpTitle, len); } - else {//no WindowText present, use WindowClass + else { // no WindowText present, use WindowClass lpTitle = (wchar_t*)mir_alloc(64 * sizeof(wchar_t)); RealGetWindowClass(m_hTargetWindow, lpTitle, 64); } @@ -518,14 +514,14 @@ void TfrmMain::SetTargetWindow(HWND hwnd) void TfrmMain::wmTimer(WPARAM wParam, LPARAM) { - if (wParam == ID_imgTarget) {// Timer for Target selector + if (wParam == ID_imgTarget) { // Timer for Target selector static int primarymouse; if (!m_hTargetHighlighter) { primarymouse = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; m_hTargetHighlighter = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, (wchar_t*)g_clsTargetHighlighter, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr); if (!m_hTargetHighlighter) return; SetLayeredWindowAttributes(m_hTargetHighlighter, 0, 123, LWA_ALPHA); - SetSystemCursor(CopyCursor(GetIcon(ICO_TARGET)), OCR_IBEAM);//text cursor + SetSystemCursor(CopyCursor(GetIcon(ICO_TARGET)), OCR_IBEAM); // text cursor SetSystemCursor(CopyCursor(GetIcon(ICO_TARGET)), OCR_NORMAL); SetActiveWindow(m_hTargetHighlighter); // activate highlighter to fix focus problems with UAC (unelevated GetAsyncKeyState() fails if an elevated app got focus) Hide(); @@ -567,7 +563,7 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM) HRGN hRgnHole = CreateRectRgn(g_iTargetBorder, g_iTargetBorder, width - g_iTargetBorder, height - g_iTargetBorder); CombineRgn(hRegnNew, hRegnNew, hRgnHole, RGN_XOR); DeleteObject(hRgnHole); - SetWindowRgn(m_hTargetHighlighter, hRegnNew, FALSE);//cleans up hRegnNew + SetWindowRgn(m_hTargetHighlighter, hRegnNew, FALSE); // cleans up hRegnNew } else SetWindowRgn(m_hTargetHighlighter, nullptr, FALSE); } @@ -575,11 +571,11 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM) } return; } - if (wParam == ID_chkTimed) {// Timer for Screenshot + if (wParam == ID_chkTimed) { // Timer for Screenshot #ifdef _DEBUG OutputDebugStringA("SS Bitmap Timer Start\r\n"); #endif - if (!m_bCapture) { //only start once + if (!m_bCapture) { // only start once if (m_Screenshot) { FreeImage_Unload(m_Screenshot); m_Screenshot = nullptr; @@ -592,7 +588,7 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM) case 1: m_Screenshot = CaptureMonitor((m_opt_cboxDesktop > 0) ? m_Monitors[m_opt_cboxDesktop - 1].szDevice : nullptr); break; - case 2: /// edge case, existing local file + case 2: // edge case, existing local file break; #ifdef _DEBUG default: @@ -600,7 +596,7 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM) #endif } m_bCapture = false; - if (m_Screenshot || m_opt_tabCapture == 2) { /// @note : test without "if" + if (m_Screenshot || m_opt_tabCapture == 2) { // @note : test without "if" KillTimer(m_hWnd, ID_chkTimed); #ifdef _DEBUG OutputDebugStringA("SS Bitmap Timer Stop (CaptureDone)\r\n"); @@ -611,40 +607,40 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM) } } -//WM_NOTIFY: +// WM_NOTIFY: void TfrmMain::wmNotify(WPARAM, LPARAM lParam) { switch (((LPNMHDR)lParam)->idFrom) { - case IDC_CAPTURETAB: //TabControl IDC_CAPTURETAB + case IDC_CAPTURETAB: + // HWND hwndFrom; = member is handle to the tab control + // UINT_PTR idFrom; = member is the child window identifier of the tab control. + // UINT code; = member is TCN_SELCHANGE switch (((LPNMHDR)lParam)->code) { - // HWND hwndFrom; = member is handle to the tab control - // UINT_PTR idFrom; = member is the child window identifier of the tab control. - // UINT code; = member is TCN_SELCHANGE - case TCN_SELCHANGING:{ - if (!m_hwndTabPage) break; + case TCN_SELCHANGING: + if (m_hwndTabPage) { ShowWindow(m_hwndTabPage, SW_HIDE); m_hwndTabPage = nullptr; - break; } - case TCN_SELCHANGE:{ + } + break; + + case TCN_SELCHANGE: + { TAB_INFO itab = { TCIF_PARAM }; m_opt_tabCapture = TabCtrl_GetCurSel(m_hwndTab); TabCtrl_GetItem(m_hwndTab, m_opt_tabCapture, &itab); m_hwndTabPage = itab.hwndTabPage; - ShowWindow(m_hwndTabPage, SW_SHOW); - break; } - default: + } + ShowWindow(m_hwndTabPage, SW_SHOW); break; } break; - default: - break; } } -//UM_EVENT: +// UM_EVENT: void TfrmMain::UMevent(WPARAM, LPARAM lParam) { - //HWND hWnd = (HWND)wParam; + // HWND hWnd = (HWND)wParam; switch (lParam) { case EVT_CaptureDone: if (!m_Screenshot && m_opt_tabCapture != 2) { @@ -655,8 +651,10 @@ void TfrmMain::UMevent(WPARAM, LPARAM lParam) } FormClose(); break; + case EVT_SendFileDone: break; + case EVT_CheckOpenAgain: if (m_opt_chkOpenAgain) { if (m_Screenshot) { @@ -670,8 +668,6 @@ void TfrmMain::UMevent(WPARAM, LPARAM lParam) Close(); } break; - default: - break; } } @@ -725,7 +721,6 @@ void TfrmMain::LoadOptions(void) m_AlphaColor.rgbBlue = GetBValue(rgb); m_AlphaColor.rgbReserved = 0; - // m_opt_chkEmulateClick = db_get_b(NULL, MODULENAME, "AutoSend", 1); m_opt_edtQuality = db_get_b(NULL, MODULENAME, "JpegQuality", 75); m_opt_tabCapture = db_get_b(NULL, MODULENAME, "Capture", 0); @@ -750,7 +745,6 @@ void TfrmMain::SaveOptions(void) db_set_dw(NULL, MODULENAME, "AlphaColor", (DWORD)RGB(m_AlphaColor.rgbRed, m_AlphaColor.rgbGreen, m_AlphaColor.rgbBlue)); - // db_set_b(NULL, MODULENAME, "AutoSend", m_opt_chkEmulateClick); db_set_b(NULL, MODULENAME, "JpegQuality", m_opt_edtQuality); db_set_b(NULL, MODULENAME, "Capture", m_opt_tabCapture); @@ -779,10 +773,11 @@ void TfrmMain::Init(wchar_t* DestFolder, MCONTACT Contact) // create window m_hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMainForm), nullptr, DlgTfrmMain, (LPARAM)this); - //register object + + // register object _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); - //check Contact + // check Contact if (m_cSend) m_cSend->SetContact(Contact); } @@ -812,11 +807,11 @@ void TfrmMain::btnCaptureClick() TfrmMain::Hide(); if (m_opt_chkTimed) { - SetTimer(m_hWnd, ID_chkTimed, m_opt_edtTimed ? m_opt_edtTimed * 1000 : 500, nullptr); /// calls EVT_CaptureDone + SetTimer(m_hWnd, ID_chkTimed, m_opt_edtTimed ? m_opt_edtTimed * 1000 : 500, nullptr); // calls EVT_CaptureDone return; } - if (m_opt_tabCapture == 1) { /// desktop needs always time to update from TfrmMain::Hide() - SetTimer(m_hWnd, ID_chkTimed, 500, nullptr); /// calls EVT_CaptureDone + if (m_opt_tabCapture == 1) { // desktop needs always time to update from TfrmMain::Hide() + SetTimer(m_hWnd, ID_chkTimed, 500, nullptr); // calls EVT_CaptureDone return; } if (m_opt_tabCapture != 2) { @@ -840,35 +835,35 @@ void TfrmMain::cboxSendByChange(void *param) { BOOL bState; HICON hIcon; - BYTE itemFlag = SS_DLG_DESCRIPTION; //SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND | + BYTE itemFlag = SS_DLG_DESCRIPTION; if (m_cSend) delete m_cSend; switch (m_opt_cboxSendBy) { - case SS_FILESEND: //"File Transfer" + case SS_FILESEND: // "File Transfer" m_cSend = new CSendFile(m_hWnd, m_hContact, true); break; - case SS_EMAIL: //"E-mail" + case SS_EMAIL: // "E-mail" m_cSend = new CSendEmail(m_hWnd, m_hContact, true); break; - case SS_HTTPSERVER: //"HTTP Server" + case SS_HTTPSERVER: // "HTTP Server" m_cSend = new CSendHTTPServer(m_hWnd, m_hContact, true); break; - case SS_FTPFILE: //"FTP File" + case SS_FTPFILE: // "FTP File" m_cSend = new CSendFTPFile(m_hWnd, m_hContact, true); break; - case SS_CLOUDFILE: //"CloudFile" + case SS_CLOUDFILE: // "CloudFile" m_cSend = new CSendCloudFile(m_hWnd, m_hContact, false, (char*)param); break; - case SS_IMAGESHACK: //"ImageShack" + case SS_IMAGESHACK: // "ImageShack" m_cSend = new CSendHost_ImageShack(m_hWnd, m_hContact, true); break; - case SS_UPLOADPIE: //"Upload Pie" + case SS_UPLOADPIE: // "Upload Pie" m_cSend = new CSendHost_UploadPie(m_hWnd, m_hContact, true, (INT_PTR)param); break; case SS_IMGUR: m_cSend = new CSendHost_Imgur(m_hWnd, m_hContact, true); break; - default: //SS_JUSTSAVE - "Just save it " + default: m_cSend = nullptr; break; } @@ -910,13 +905,12 @@ void TfrmMain::edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl pt.x = cliRect.left; pt.y = cliRect.top; ClientToScreen(hWnd, &pt); - pt.x = pt.x - rect.left; //offset x for client area - pt.y = pt.y - rect.top; //offset y for client area + pt.x = pt.x - rect.left; // offset x for client area + pt.y = pt.y - rect.top; // offset y for client area rect = cliRect; } - // _itow_s(rect.right - rect.left, B, 33, 10); + _itow(rect.right - rect.left, B, 10); - // _itow_s(rect.bottom - rect.top, H, 16, 10); _itow(rect.bottom - rect.top, H, 10); mir_wstrncat(B, L"x", _countof(B) - mir_wstrlen(B)); mir_wstrncat(B, H, _countof(B) - mir_wstrlen(B)); @@ -926,9 +920,7 @@ void TfrmMain::edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl void TfrmMain::edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl) { wchar_t B[33], H[16]; - // _itow_s(ABS(rect.right - rect.left), B, 33, 10); _itow(ABS(rect.right - rect.left), B, 10); - // _itow_s(ABS(rect.bottom - rect.top), H, 16, 10); _itow(ABS(rect.bottom - rect.top), H, 10); mir_wstrncat(B, L"x", _countof(B) - mir_wstrlen(B)); mir_wstrncat(B, H, _countof(B) - mir_wstrlen(B)); @@ -940,7 +932,7 @@ void TfrmMain::edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl) INT_PTR TfrmMain::SaveScreenshot(FIBITMAP *dib) { if (!dib) - return 1; //error + return 1; // generate file name unsigned FileNumber = db_get_dw(NULL, MODULENAME, "FileNumber", 0) + 1; @@ -1000,7 +992,7 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP *dib) } break; - case 3: //TIFF (miranda freeimage interface do not support save tiff, we udse GDI+) + case 3: // TIFF (miranda freeimage interface do not support save tiff, we udse GDI+) wszFileName.Append(L".tif"); { FIBITMAP *dib32 = FreeImage_Composite(dib_new, FALSE, &m_AlphaColor, nullptr); @@ -1015,7 +1007,7 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP *dib) ret = TRUE; break; - case 4: //GIF + case 4: // GIF wszFileName.Append(L".gif"); { HBITMAP hBmp = FreeImage_CreateHBITMAPFromDIB(dib_new); @@ -1029,7 +1021,7 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP *dib) FreeImage_Unload(dib_new); if (!ret) - return 1; // error + return 1; db_set_dw(NULL, MODULENAME, "FileNumber", FileNumber); replaceStrW(m_pszFile, wszFileName); @@ -1041,7 +1033,7 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP *dib) m_cSend->SetFile(m_pszFile); m_cSend->SetDescription(wszFileDesc); } - return 0; // OK + return 0; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1049,20 +1041,20 @@ INT_PTR TfrmMain::SaveScreenshot(FIBITMAP *dib) void TfrmMain::FormClose() { bool bCanDelete = m_opt_btnDeleteAfterSend; - if (m_opt_tabCapture == 2) { /// existing file + if (m_opt_tabCapture == 2) { // existing file wchar_t description[1024]; GetDlgItemText(m_hwndTabPage, ID_edtCaption, description, _countof(description)); if (!IsWindowEnabled(GetDlgItem(m_hWnd, ID_chkDesc)) || !m_opt_btnDesc) *description = '\0'; if (m_cSend) { - m_cSend->m_bDeleteAfterSend = false; /// well... guess it's better to not delete existing files for now... + m_cSend->m_bDeleteAfterSend = false; // well... guess it's better to not delete existing files for now... m_cSend->SetFile(m_pszFile); m_cSend->SetDescription(description); } bCanDelete = false; } - else if (SaveScreenshot(m_Screenshot)) { /// Saving the screenshot - Show(); // Error from SaveScreenshot + else if (SaveScreenshot(m_Screenshot)) { // Saving the screenshot + Show(); // Error from SaveScreenshot return; } @@ -1086,12 +1078,12 @@ void TfrmMain::FormClose() PostMessage(nullptr, WM_QUIT, 0, 0); // forward for outer message loops break; } + // process dialog messages (of unknown dialogs) HWND hwndDlgModeless = GetActiveWindow(); - // HWND hwndDlgModeless = msg.hwnd; - // for(HWND hTMP; (hTMP=GetAncestor(hwndDlgModeless,GA_PARENT)) && IsChild(hTMP,hwndDlgModeless); hwndDlgModeless=hTMP); if (hwndDlgModeless != nullptr && IsDialogMessage(hwndDlgModeless, &msg)) /* Wine fix. */ continue; + // process messages TranslateMessage(&msg); DispatchMessage(&msg); diff --git a/plugins/SendScreenshotPlus/src/UMainForm.h b/plugins/SendScreenshotPlus/src/UMainForm.h index 971ce85a61..61c20bf50f 100644 --- a/plugins/SendScreenshotPlus/src/UMainForm.h +++ b/plugins/SendScreenshotPlus/src/UMainForm.h @@ -59,9 +59,9 @@ struct UPLOAD_INFO struct TAB_INFO { TCITEMHEADER tcih; - HWND hwndMain; //main window - HWND hwndTab; //tab control - HWND hwndTabPage; //current child dialog box + HWND hwndMain; // main window + HWND hwndTab; // tab control + HWND hwndTabPage; // current child dialog box }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -74,12 +74,12 @@ public: TfrmMain(); ~TfrmMain(); - BYTE m_opt_tabCapture; //capure tab page - BYTE m_opt_cboxDesktop; //TRadioButton *rbtnDesktop; - BYTE m_opt_chkTimed; //TCheckBox *chkTimed; - BYTE m_opt_cboxSendBy; //TComboBox *cboxSendBy; - BYTE m_opt_btnDesc; //TCheckBox *chkDesc; - BYTE m_opt_chkEditor; //TCheckBox *chkEditor; + BYTE m_opt_tabCapture; // capture tab page + BYTE m_opt_cboxDesktop; // TRadioButton *rbtnDesktop; + BYTE m_opt_chkTimed; // TCheckBox *chkTimed; + BYTE m_opt_cboxSendBy; // TComboBox *cboxSendBy; + BYTE m_opt_btnDesc; // TCheckBox *chkDesc; + BYTE m_opt_chkEditor; // TCheckBox *chkEditor; bool m_bOnExitSave; static void Unload(); @@ -98,7 +98,7 @@ private: HWND m_hTargetHighlighter; wchar_t* m_FDestFolder; wchar_t* m_pszFile; - FIBITMAP* m_Screenshot;//Graphics::TBitmap *Screenshot; + FIBITMAP* m_Screenshot; RGBQUAD m_AlphaColor; CSend* m_cSend; @@ -112,21 +112,21 @@ private: static void edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl); protected: - MONITORINFOEX* m_Monitors; - size_t m_MonitorCount; - RECT m_VirtualScreen; - - BYTE m_opt_chkOpenAgain; //TCheckBox *chkOpenAgain; - BYTE m_opt_chkIndirectCapture; //TCheckBox *chkIndirectCapture; - BYTE m_opt_chkClientArea; //TCheckBox *chkClientArea; - BYTE m_opt_edtQuality; //TLabeledEdit *edtQuality; - bool m_opt_btnDeleteAfterSend; //TCheckBox *chkDeleteAfterSend; - BYTE m_opt_cboxFormat; //TComboBox *cboxFormat; - BYTE m_opt_edtTimed; //TLabeledEdit *edtTimed; - bool m_bCapture; //is capture active - HWND m_hwndTab; //TabControl handle - HWND m_hwndTabPage; //TabControl activ page handle - HIMAGELIST m_himlTab; //TabControl imagelist + MONITORINFOEX* m_Monitors; + size_t m_MonitorCount; + RECT m_VirtualScreen; + + BYTE m_opt_chkOpenAgain; // TCheckBox *chkOpenAgain; + BYTE m_opt_chkIndirectCapture; // TCheckBox *chkIndirectCapture; + BYTE m_opt_chkClientArea; // TCheckBox *chkClientArea; + BYTE m_opt_edtQuality; // TLabeledEdit *edtQuality; + bool m_opt_btnDeleteAfterSend; // TCheckBox *chkDeleteAfterSend; + BYTE m_opt_cboxFormat; // TComboBox *cboxFormat; + BYTE m_opt_edtTimed; // TLabeledEdit *edtTimed; + bool m_bCapture; // is capture active + 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; diff --git a/plugins/SendScreenshotPlus/src/Utils.cpp b/plugins/SendScreenshotPlus/src/Utils.cpp index 95307269b9..8111a61cb5 100644 --- a/plugins/SendScreenshotPlus/src/Utils.cpp +++ b/plugins/SendScreenshotPlus/src/Utils.cpp @@ -53,7 +53,7 @@ static BOOL CALLBACK MonitorInfoEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM 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 FALSE; // stop enumeration if error return TRUE; } @@ -83,14 +83,16 @@ FIBITMAP* CaptureWindow(HWND hCapture, BOOL bClientArea, BOOL bIndirectCapture) { FIBITMAP* dib; HWND hForegroundWin; - RECT rect;//cropping rect + RECT rect; // cropping rect if (!hCapture || !IsWindow(hCapture)) return nullptr; - hForegroundWin = GetForegroundWindow(); // old foreground window - SetForegroundWindow(hCapture); // force target foreground - BringWindowToTop(hCapture); // bring it to top as well - /// redraw window to prevent runtime artifacts in picture + + hForegroundWin = GetForegroundWindow(); // old foreground window + SetForegroundWindow(hCapture); // force target foreground + BringWindowToTop(hCapture); // bring it to top as well + + // redraw window to prevent runtime artifacts in picture UpdateWindow(hCapture); HWND hParent = GetAncestor(hCapture, GA_PARENT); @@ -115,29 +117,34 @@ FIBITMAP* CaptureWindow(HWND hCapture, BOOL bClientArea, BOOL bIndirectCapture) HDC hDCsrc; GetWindowRect(hCapture, &rect); if (hParent) - hDCsrc = GetDC(hCapture);//hCapture is part of a window, capture that + hDCsrc = GetDC(hCapture); // hCapture is part of a window, capture that else - hDCsrc = GetWindowDC(hCapture);//entire window w/ title bar + hDCsrc = GetWindowDC(hCapture); // entire window w/ title bar rect.right = ABS(rect.right - rect.left); rect.bottom = ABS(rect.bottom - rect.top); rect.left = rect.top = 0; // capture window and get FIBITMAP dib = CreateDIBFromDC(hDCsrc, &rect, hCapture); ReleaseDC(hCapture, hDCsrc); - if (bClientArea) {//we could capture directly, but doing so breaks GetWindowRgn() and also includes artifacts... + + // we could capture directly, but doing so breaks GetWindowRgn() and also includes artifacts... + if (bClientArea) { GetWindowRect(hCapture, &rect); RECT rectCA; GetClientRect(hCapture, &rectCA); ClientToScreen(hCapture, (POINT*)&rectCA); rectCA.left = ABS(rectCA.left - rect.left); rectCA.top = ABS(rectCA.top - rect.top); rectCA.right += rectCA.left; rectCA.bottom += rectCA.top; - /// crop the window to ClientArea + + // crop the window to ClientArea FIBITMAP* dibClient = FreeImage_Copy(dib, rectCA.left, rectCA.top, rectCA.right, rectCA.bottom); FreeImage_Unload(dib); dib = dibClient; } } - if (hForegroundWin) {//restore previous foreground window + + // restore previous foreground window + if (hForegroundWin) { SetForegroundWindow(hForegroundWin); BringWindowToTop(hForegroundWin); } @@ -149,7 +156,7 @@ FIBITMAP* CaptureMonitor(const wchar_t* szDevice, const RECT* cropRect/*=NULL*/) HDC hScrDC; RECT rect; - /// get screen resolution + // get screen resolution if (!szDevice) { hScrDC = CreateDC(L"DISPLAY", nullptr, nullptr, nullptr); rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN); @@ -187,7 +194,7 @@ FIBITMAP* CreateDIBFromDC(HDC hDC, const RECT* rect, HWND hCapture/*=NULL*/) hScrDC = GetDC(hCapture); HDC hMemDC = CreateCompatibleDC(hScrDC); // create a bitmap compatible with the screen DC - HBITMAP hBitmap = CreateCompatibleBitmap(hScrDC, width, height);//width,height + HBITMAP hBitmap = CreateCompatibleBitmap(hScrDC, width, height); // select new bitmap into memory DC SelectObject(hMemDC, hBitmap); @@ -203,8 +210,8 @@ FIBITMAP* CreateDIBFromDC(HDC hDC, const RECT* rect, HWND hCapture/*=NULL*/) // we have to create our own new alpha channel. bool bFixAlpha = true; bool bInvert = false; - HBRUSH hBr = CreateSolidBrush(RGB(255, 255, 255));//Create a SolidBrush object for non transparent area - HBITMAP hMask = CreateBitmap(width, height, 1, 1, nullptr);// Create monochrome (1 bit) B+W mask bitmap. + HBRUSH hBr = CreateSolidBrush(RGB(255, 255, 255)); // Create a SolidBrush object for non transparent area + HBITMAP hMask = CreateBitmap(width, height, 1, 1, nullptr); // Create monochrome (1 bit) B+W mask bitmap. HDC hMaskDC = CreateCompatibleDC(nullptr); SelectBitmap(hMaskDC, hMask); HRGN hRgn = CreateRectRgn(0, 0, 0, 0); @@ -234,7 +241,7 @@ FIBITMAP* CreateDIBFromDC(HDC hDC, const RECT* rect, HWND hCapture/*=NULL*/) } } else { - if (!hCapture) SetRectRgn(hRgn, 0, 0, width, height);//client area only, no transparency + if (!hCapture) SetRectRgn(hRgn, 0, 0, width, height); // client area only, no transparency FillRgn(hMaskDC, hRgn, hBr); } DeleteObject(hRgn); @@ -250,6 +257,7 @@ FIBITMAP* CreateDIBFromDC(HDC hDC, const RECT* rect, HWND hCapture/*=NULL*/) DeleteDC(hMaskDC); DeleteObject(hMask); DeleteObject(hBr); + // clean up DeleteDC(hMemDC); DeleteObject(hBitmap); @@ -369,8 +377,8 @@ void SaveGIF(HBITMAP hBmp, const wchar_t *szFilename) void SaveTIF(HBITMAP hBmp, const wchar_t *szFilename) { - //http://www.codeproject.com/Messages/1406708/How-to-reduce-the-size-of-an-Image-using-GDIplus.aspx - ULONG_PTR gdiplusToken; + // 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, nullptr); diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp index 37f965e87f..1eb38d2747 100644 --- a/plugins/SendScreenshotPlus/src/ctrl_button.cpp +++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp @@ -40,7 +40,7 @@ typedef struct TMBCtrl BYTE bFocus; int stateId; // button state - int defbutton; // default button + int defbutton; // default button int pbState; wchar_t cHot; } BTNCTRL, *LPBTNCTRL; @@ -656,7 +656,7 @@ void CtrlButtonUnloadModule() UnregisterClass(UINFOBUTTONCLASS, g_plugin.getInst()); } -void CtrlButtonLoadModule()/// @fixme : compatibility with UInfoEx is everything but perfect... we get a huge problem if UInfoEx is unloaded... +void CtrlButtonLoadModule() // @fixme : compatibility with UInfoEx is everything but perfect... we get a huge problem if UInfoEx is unloaded... { if (ServiceExists("UserInfo/vCard/Export")) return; WNDCLASSEX wc; diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp index 82751abf8a..5603dca892 100644 --- a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp @@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/// SendSS compatibility: +// SendSS compatibility: #include "stdafx.h" #define ghInst g_plugin.getInst() #define myGlobals g_myGlobals @@ -35,7 +35,7 @@ HICON Skin_GetIcon_SendSS(unsigned short id) return GetIconBtn(id); } #define IcoLib_GetIcon Skin_GetIcon_SendSS -/// original UserInfoEx codebase (almost): +// original UserInfoEx codebase (almost): typedef struct _MSGPOPUPDATA { @@ -300,9 +300,7 @@ static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l MoveCtrl(hDlg, TXT_MESSAGE, -mpt.x - icoWidth, -mpt.y - InfoBarHeight, needX, needY); MoveCtrl(hDlg, STATIC_LINE2, -mpt.x, -mpt.y + needY - InfoBarHeight, needX, 0); - // // Do pushbutton positioning - // RECT rcOk, rcAll, rcNone, rcCancel; // get button rectangles @@ -412,7 +410,6 @@ static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l SetDlgItemText(hDlg, IDOK, LPGENW("Yes")); retAll = IDALL; SetDlgItemText(hDlg, IDALL, LPGENW("All")); - //retNon = IDNONE; SetDlgItemText(hDlg, IDNONE, LPGENW("None")); retCancel = IDNO; SetDlgItemText(hDlg, IDCANCEL, LPGENW("No")); @@ -504,7 +501,7 @@ static INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM, LPARAM lParam) if (pmpd) { POPUPDATAT_V2 pd = { 0 }; pd.cbSize = sizeof(pd); - pd.lchContact = NULL; //(HANDLE)wParam; + pd.lchContact = NULL; // (HANDLE)wParam; // icon pd.lchIcon = MsgLoadIcon(pMsgBox); mir_wstrncpy(pd.lptzContactName, pMsgBox->ptszTitle, _countof(pd.lptzContactName)); diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.h b/plugins/SendScreenshotPlus/src/dlg_msgbox.h index c343b7caa0..b3c59dc97b 100644 --- a/plugins/SendScreenshotPlus/src/dlg_msgbox.h +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.h @@ -39,37 +39,26 @@ For valid icon values use one of the following MB_ICON_... Funktion returns: IDOK, IDYES, IDALL, IDNO or IDCANCEL
*/
-/*
- Defined in winuser.h
- ********************
-
-#define MB_OK 0x00000000L
-#define MB_OKCANCEL 0x00000001L
-#define MB_ABORTRETRYIGNORE 0x00000002L
-#define MB_YESNOCANCEL 0x00000003L
-#define MB_YESNO 0x00000004L
-#define MB_RETRYCANCEL 0x00000005L
-*/
-#define MB_YESALLNO 0x00000007L
-#define MB_TYPE(p) ((p)&MB_TYPEMASK)
+#define MB_YESALLNO 0x00000007L
+#define MB_TYPE(p) ((p)&MB_TYPEMASK)
/*
valid predefined icon values
*/
-#define MB_ICON_NONE 0x00000000L // 0 - no icon
-#define MB_ICON_ERROR 0x00000010L // 16 - error icon
-#define MB_ICON_QUESTION 0x00000020L // 32 - question mark
-#define MB_ICON_WARNING 0x00000030L // 48 - warning
-#define MB_ICON_INFO 0x00000040L // 64 - info
-#define MB_ICON_OTHER 0x00000080L // 240 - use icon _MSGBOX->hiMsg
-#define MB_ICON_INDEX(p) (((p)&MB_ICONMASK)>>4)
+#define MB_ICON_NONE 0x00000000L // 0 - no icon
+#define MB_ICON_ERROR 0x00000010L // 16 - error icon
+#define MB_ICON_QUESTION 0x00000020L // 32 - question mark
+#define MB_ICON_WARNING 0x00000030L // 48 - warning
+#define MB_ICON_INFO 0x00000040L // 64 - info
+#define MB_ICON_OTHER 0x00000080L // 240 - use icon _MSGBOX->hiMsg
+#define MB_ICON_INDEX(p) (((p)&MB_ICONMASK)>>4)
/*
flags
*/
-#define MB_INFOBAR 0x00000100L
-#define MB_NOPOPUP 0x00000200L
-#define MB_CUSTOMCOLOR 0x00000300L
+#define MB_INFOBAR 0x00000100L
+#define MB_NOPOPUP 0x00000200L
+#define MB_CUSTOMCOLOR 0x00000300L
typedef struct _MSGBOX
{
diff --git a/plugins/SendScreenshotPlus/src/resource.h b/plugins/SendScreenshotPlus/src/resource.h index e91be463d1..7d14ecec9d 100644 --- a/plugins/SendScreenshotPlus/src/resource.h +++ b/plugins/SendScreenshotPlus/src/resource.h @@ -5,9 +5,7 @@ #define IDOK 1 #define IDA_btnClose 1 #define IDCANCEL 2 -//#define IDB_Bmp1 2 #define IDABORT 3 -//#define IDB_Bmp2 3 #define IDRETRY 4 #define IDIGNORE 5 #define IDYES 6 @@ -34,8 +32,6 @@ #define IDI_FOLDER 194 #define IDI_ARROWL 195 #define IDI_ARROWR 196 -//#define IDI_OVERLAYON 198 -//#define IDI_OVERLAYOFF 199 #define IDI_DESC 200 #define IDI_DESCON 201 #define IDI_DEL 202 @@ -43,7 +39,6 @@ #define IDI_UPDATE 204 #define IDI_OK 205 #define IDI_CANCEL 206 -//#define IDI_APPLY 207 #define IDI_EDIT 207 #define IDI_EDITON 208 #define IDI_COPY 209 @@ -95,13 +90,13 @@ #define ID_edtURL 2010 #define ID_bvlDesc 2011 #define ID_bvlLine 2012 -#define ID_btnCopy 2013//group I +#define ID_btnCopy 2013 #define ID_btnBBC 2014 -#define ID_btnThumbCopy 2015//group II +#define ID_btnThumbCopy 2015 #define ID_btnThumbBBC 2016 -#define ID_btnThumbBBC2 2017//end group I +#define ID_btnThumbBBC2 2017 #define ID_edtURLthumbLabel 2018 -#define ID_edtURLthumb 2019//end group II +#define ID_edtURLthumb 2019 #define IDE_StatusBar 2501 // Next default values for new objects diff --git a/plugins/SendScreenshotPlus/src/stdafx.h b/plugins/SendScreenshotPlus/src/stdafx.h index 3ace09ca3e..3fec3a8af1 100644 --- a/plugins/SendScreenshotPlus/src/stdafx.h +++ b/plugins/SendScreenshotPlus/src/stdafx.h @@ -67,6 +67,7 @@ using namespace std; #include <m_popup.h> #include <m_icolib.h> #include <m_string.h> +#include <m_message.h> #include <m_folders.h> #include <m_HTTPServer.h> @@ -100,21 +101,21 @@ using namespace std; #define MSGINFO (text) MessageBox(NULL, text, L"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_UPLOAD exist - BOOLEAN PluginCloudFileExist: 1; // CloudFile or MS_CLOUDFILE_UPLOAD exists + 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_UPLOAD exist + BOOLEAN PluginCloudFileExist: 1; // CloudFile or MS_CLOUDFILE_UPLOAD exists } MGLOBAL, *LPMGLOBAL; ///////////////////////////////////////////////////////////////////////////////////////// -#define ERROR_TITLE TranslateT("SendScreenshot - Error") +#define ERROR_TITLE TranslateT("SendScreenshot - Error") // Miranda Database Key -#define MODULENAME "SendSS" +#define MODULENAME "SendSS" struct CMPlugin : public PLUGIN<CMPlugin> { @@ -128,13 +129,14 @@ extern ATOM g_clsTargetHighlighter; extern MGLOBAL g_myGlobals; extern HNETLIBUSER g_hNetlibUser; -enum{ - ICO_MAIN=0, +enum +{ + ICO_MAIN = 0, ICO_MAINXS, ICO_TARGET, ICO_MONITOR, ICO_END_, - ICO_BTN_HELP=0, + ICO_BTN_HELP = 0, ICO_BTN_FOLDER, ICO_BTN_DESC, ICO_BTN_DESCON, @@ -145,7 +147,6 @@ enum{ ICO_BTN_UPDATE, ICO_BTN_OK, ICO_BTN_CANCEL, -// ICO_BTN_APPLY, ICO_BTN_EDIT, ICO_BTN_EDITON, ICO_BTN_COPY, |