diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-02 12:32:44 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-02 12:32:55 +0300 |
commit | 931a7dc1ac0dbc7e6c1083583ced915e572f5b47 (patch) | |
tree | 9fe9a6448d44030e26aa7107ce16044ed413e0d0 /plugins/CloudFile/src/utils.cpp | |
parent | dd7d9954042254e66e3bbbec7195c6be8b1a0663 (diff) |
all protocols (even virtual ones) moved to the Protocols folder
Diffstat (limited to 'plugins/CloudFile/src/utils.cpp')
-rw-r--r-- | plugins/CloudFile/src/utils.cpp | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/plugins/CloudFile/src/utils.cpp b/plugins/CloudFile/src/utils.cpp deleted file mode 100644 index 79b743f5c2..0000000000 --- a/plugins/CloudFile/src/utils.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "stdafx.h" - -void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags, MCONTACT hContact) -{ - if (Miranda_IsTerminated()) - return; - - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1)) { - POPUPDATAW ppd = { 0 }; - ppd.lchContact = hContact; - wcsncpy(ppd.lpwzContactName, caption, MAX_CONTACTNAME); - wcsncpy(ppd.lpwzText, message, MAX_SECONDLINE); - ppd.lchIcon = IcoLib_GetIcon("Slack_main"); - - if (!PUAddPopupW(&ppd)) - return; - } - - MessageBox(nullptr, message, caption, MB_OK | flags); -} - -void ShowNotification(const wchar_t *message, int flags, MCONTACT hContact) -{ - ShowNotification(_A2W(MODULENAME), message, flags, hContact); -} - -MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD flags, DWORD cbBlob, PBYTE pBlob) -{ - DBEVENTINFO dbei = {}; - dbei.szModule = MODULENAME; - dbei.timestamp = time(0); - dbei.eventType = type; - dbei.cbBlob = cbBlob; - dbei.pBlob = pBlob; - dbei.flags = flags; - return db_event_add(hContact, &dbei); -} - -bool CanSendToContact(MCONTACT hContact) -{ - if (!hContact) - return false; - - const char *proto = GetContactProto(hContact); - if (!proto) - return false; - - bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0; - if (isCtrlPressed) - return true; - - bool canSend = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) != 0; - if (!canSend) - return false; - - bool isProtoOnline = Proto_GetStatus(proto) > ID_STATUS_OFFLINE; - if (!isProtoOnline) - return false; - - bool isContactOnline = Contact_GetStatus(hContact) > ID_STATUS_OFFLINE; - if (isContactOnline) - return true; - - return CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE; -} - -void SendToContact(MCONTACT hContact, const wchar_t *data) -{ - const char *szProto = GetContactProto(hContact); - if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) { - ptrW tszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID")); - Chat_SendUserMessage(szProto, tszChatRoom, data); - return; - } - - char *message = mir_utf8encodeW(data); - if (ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message) != ACKRESULT_FAILED) - AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, (DWORD)mir_strlen(message), (PBYTE)message); -} - -void PasteToInputArea(MCONTACT hContact, const wchar_t *data) -{ - CallService(MS_MSG_SENDMESSAGEW, hContact, (LPARAM)data); -} - -void PasteToClipboard(const wchar_t *data) -{ - if (OpenClipboard(nullptr)) { - EmptyClipboard(); - - size_t size = sizeof(wchar_t) * (mir_wstrlen(data) + 1); - HGLOBAL hClipboardData = GlobalAlloc(NULL, size); - if (hClipboardData) { - wchar_t *pchData = (wchar_t*)GlobalLock(hClipboardData); - mir_wstrcpy(pchData, data); - GlobalUnlock(hClipboardData); - SetClipboardData(CF_UNICODETEXT, hClipboardData); - } - CloseClipboard(); - } -} - -void Report(MCONTACT hContact, const wchar_t *data) -{ - if (g_plugin.getByte("UrlAutoSend", 1)) - SendToContact(hContact, data); - - if (g_plugin.getByte("UrlPasteToMessageInputArea", 0)) - PasteToInputArea(hContact, data); - - if (g_plugin.getByte("UrlCopyToClipboard", 0)) - PasteToClipboard(data); -} |