/** * Protocols àcknowledgement */ int ProtoAck(WPARAM wparam,LPARAM lparam) { ACKDATA *pAck = (ACKDATA *)lparam; if (pAck->type != ACKTYPE_MESSAGE || pAck->result != ACKRESULT_SUCCESS) return 0; MESSAGE_PROC* p = arMessageProcs.find((MESSAGE_PROC*)&pAck->hProcess); if (p == NULL) return 0; if (iSendAndHistory > 0){ time_t ltime; time(<ime); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.szModule = "yaRelay"; dbei.timestamp = ltime; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (DWORD)strlen(p->msgText) + 1; dbei.pBlob = (PBYTE)p->msgText; db_event_add(hForwardTo, &dbei); } mir_free(p->msgText); arMessageProcs.remove(p); mir_free(p); return 0; }
static INT_PTR DbEventTypeGet(WPARAM wParam, LPARAM lParam) { DBEVENTTYPEDESCR tmp; tmp.module = (char*)wParam; tmp.eventType = lParam; return (INT_PTR)eventTypes.find(&tmp); }
//hookProc ME_MSG_WINDOWEVENT static int OnMsgWndEvent(WPARAM, LPARAM lParam) { MsgWndData *msgwnd; MessageWindowEventData *msgwe = (MessageWindowEventData*)lParam; /* sanity check */ if (msgwe->hContact == NULL) return 0; switch (msgwe->uType) { case MSG_WINDOW_EVT_OPENING: msgwnd = gMsgWndList.find((MsgWndData*)&msgwe->hContact); if (msgwnd == NULL) { msgwnd = new MsgWndData(msgwe->hwndWindow, msgwe->hContact); gMsgWndList.insert(msgwnd); } break; case MSG_WINDOW_EVT_CLOSE: int i = gMsgWndList.getIndex((MsgWndData*)&msgwe->hContact); if (i != -1) { delete gMsgWndList[i]; gMsgWndList.remove(i); } break; } return 0; }
bool SetRichCallback(HWND hwnd, MCONTACT hContact, bool subany, bool subnew) { RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd); if (rdt == NULL) { IRichEditOle* RichEditOle; if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0) return false; RichEditOle->Release(); rdt = new RichEditData; rdt->hwnd = hwnd; rdt->hContact = hContact; rdt->inputarea = (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY) == 0; rdt->dontReplace = false; rdt->tipActive = -1; rdt->hToolTip = NULL; g_RichEditList.insert(rdt); if (subnew) mir_subclassWindow(hwnd, RichEditSubclass); } else { if (hContact && !rdt->hContact) rdt->hContact = hContact; if (subany) mir_subclassWindow(hwnd, RichEditSubclass); } return true; }
//find the dialog info in the stored list static MsgWndData* IsMsgWnd(HWND hwnd) { WaitForSingleObject(g_hMutex, 2000); MsgWndData* res = g_MsgWndList.find((MsgWndData*)&hwnd); ReleaseMutex(g_hMutex); return res; }
static INT_PTR srvGetProvider(WPARAM, LPARAM lParam) { if (lParam == 0) return 0; CRYPTO_PROVIDER tmp; tmp.pszName = (LPSTR)lParam; return (INT_PTR)arProviders.find(&tmp); }
MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_IsProtocolLoaded(const char *szProtoName) { if (szProtoName == NULL) return NULL; PROTOCOLDESCRIPTOR tmp; tmp.szName = (char*)szProtoName; return protos.find(&tmp); }
static LRESULT CALLBACK RichEditOwnerSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RichEditOwnerData* rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd); if (rdto == NULL) return 0; switch(uMsg) { case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == 1624) { RichEditData* rdt = g_RichEditList.find((RichEditData*)&rdto->hwndInput); if (rdt && (!rdt->inputarea || opt.InputSmileys)) { rdt->dontReplace = true; CHARRANGE sel = allsel; ReplaceSmileysWithText(rdt->hwnd, sel, false); } } break; case WM_DESTROY: RichEditData* rdt = g_RichEditList.find((RichEditData*)&rdto->hwndInput); if (rdt && (!rdt->inputarea || opt.InputSmileys)) { CHARRANGE sel = allsel; rdt->dontReplace = true; ReplaceSmileysWithText(rdt->hwnd, sel, false); } break; } LRESULT result = mir_callNextSubclass(hwnd, RichEditOwnerSubclass, uMsg, wParam, lParam); switch(uMsg) { case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == 1624) { RichEditData* rdt = g_RichEditList.find((RichEditData*)&rdto->hwndInput); if (rdt) { CHARRANGE sel = allsel; if (!result) ReplaceContactSmileys(rdt, sel, false, false); rdt->dontReplace = false; } } break; } return result; }
/* * Add contact handle to requests queue */ static int amAddHandleToChain(MCONTACT hContact) { mir_cslockfull lck(amCS); if (amItems.find((HANDLE)hContact) != NULL) return 0; amItems.insert((HANDLE)hContact); lck.unlock(); SetEvent(hamProcessEvent); return 1; }
// delete contact from the list of secureIM users void delContact(HANDLE hContact) { pUinKey p = arClist.find((pUinKey)&hContact); if (p) { arClist.remove(p); cpp_delete_context(p->cntx); p->cntx = 0; mir_free(p->tmp); mir_free(p->msgSplitted); mir_free(p); } }
static INT_PTR setPos(WPARAM wParam, LPARAM lParam) { FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; RECT rc = *((LPRECT)lParam); flash_avatar_item key(hFA->hContact, *hFA, NULL); Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item) SetWindowPos(item->hFA.hWindow, HWND_TOP, rc.left, rc.top, rc.right, rc.bottom, SWP_SHOWWINDOW); return 0; }
static INT_PTR setEmoFace(WPARAM wParam, LPARAM lParam) { FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; flash_avatar_item key(hFA->hContact, *hFA, NULL); Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item && item->pFlash) { IShockwaveFlash* flash = item->pFlash; flash->SetVariable(L"face.emotion", (BSTR)lParam); } return 0; }
static INT_PTR getInfo(WPARAM wParam, LPARAM) { FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; flash_avatar_item key(hFA->hContact, *hFA, NULL); Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item) { //IShockwaveFlash* flash = item->pFlash; hFA->hWindow = item->hFA.hWindow; hFA->cUrl = item->hFA.cUrl; hFA->cProto = item->hFA.cProto; } return 0; }
TIntMenuObject* GetMenuObjbyId(int id) { switch (id) { case MO_MAIN: id = hMainMenuObject; break; case MO_CONTACT: id = hContactMenuObject; break; case MO_STATUS: id = hStatusMenuObject; break; case MO_PROTO: if (db_get_b(NULL, "CList", "MoveProtoMenus", true)) id = hStatusMenuObject; else id = hMainMenuObject; } return g_menus.find((TIntMenuObject*)&id); }
static INT_PTR setBkColor(WPARAM wParam, LPARAM lParam) { FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; COLORREF clr = (COLORREF)lParam; flash_avatar_item key(hFA->hContact, *hFA, NULL); Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item && item->pFlash) { IShockwaveFlash* flash = item->pFlash; char buf[10]; mir_snprintf(buf, sizeof(buf), "%02X%02X%02X", LOBYTE(LOWORD(clr)), HIBYTE(LOWORD(clr)), LOBYTE(HIWORD(clr))); flash->put_BGColor(_bstr_t(buf)); } return 0; }
static INT_PTR destroyAvatar(WPARAM wParam, LPARAM) { flash_avatar_item key(((FLASHAVATAR*)wParam)->hContact, *(FLASHAVATAR*)wParam, NULL); Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item) { if (item->pFlash) item->pFlash->Release(); if (item->hFA.hWindow) DestroyWindow(item->hFA.hWindow); mir_free(item->hFA.cUrl); FlashList.remove(item); delete item; } return 0; }
void SetRichOwnerCallback(HWND hwnd, HWND hwndInput, HWND hwndLog) { RichEditOwnerData* rdto = g_RichEditOwnerList.find((RichEditOwnerData*)&hwnd); if (rdto == NULL) { rdto = new RichEditOwnerData; rdto->hwnd = hwnd; rdto->hwndInput = hwndInput; rdto->hwndLog = hwndLog; g_RichEditOwnerList.insert(rdto); if (hwndLog) SendMessage(hwndLog, EM_SETUNDOLIMIT, 0, 0); mir_subclassWindow(hwnd, RichEditOwnerSubclass); } else { if (rdto->hwndInput == NULL) rdto->hwndInput = hwndInput; if (rdto->hwndLog == NULL) rdto->hwndLog = hwndLog; } }
static void MsgWndDetect(HWND hwndDlg, HANDLE hContact, msgData* datm) { MsgWndData dat; if (dat.IsMessageSendDialog(hwndDlg)) { dat.hwnd = hwndDlg; if (datm != NULL) { dat.isSend = datm->isSend != 0; dat.hContact = datm->hContact; } else dat.hContact = hContact; // Get the protocol for this contact to display correct smileys. char *protonam = GetContactProto( DecodeMetaContact(dat.hContact)); if (protonam) { strncpy(dat.ProtocolName, protonam, sizeof(dat.ProtocolName)); dat.ProtocolName[sizeof(dat.ProtocolName)-1] = 0; } WaitForSingleObject(g_hMutex, 2000); MsgWndData* msgwnd = g_MsgWndList.find((MsgWndData*)&hwndDlg); if (msgwnd == NULL) { msgwnd = new MsgWndData(dat); g_MsgWndList.insert(msgwnd); } else msgwnd = NULL; ReleaseMutex(g_hMutex); if (msgwnd != NULL) { mir_subclassWindow(hwndDlg, MessageDlgSubclass); msgwnd->CreateSmileyButton(); if (hContact == NULL) SetRichCallback(msgwnd->REdit, msgwnd->hContact, true, true); } } }
// find user in the list of secureIM users and add him, if unknow pUinKey findUinKey(HANDLE hContact) { return arClist.find((pUinKey)&hContact); }
pUinKey getUinKey(HANDLE hContact) { pUinKey p = arClist.find((pUinKey)&hContact); return (p) ? p : addContact(hContact); }
static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd); if (rdt == NULL) return 0; CHARRANGE sel; switch(uMsg) { case WM_COPY: case WM_CUT: SmileyToTextCutPrep(rdt); break; case WM_PAINT: SetPosition(hwnd); break; case EM_STREAMOUT: if (wParam & SFF_SELECTION) SmileyToTextCutPrep(rdt); else { sel = allsel; ReplaceContactSmileysWithText(rdt, sel, true); } break; case WM_KEYDOWN: if ((wParam == 'C' || wParam == VK_INSERT) && (GetKeyState(VK_CONTROL) & 0x8000)) SmileyToTextCutPrep(rdt); else if ((wParam == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) || (wParam == VK_DELETE && (GetKeyState(VK_SHIFT) & 0x8000))) SmileyToTextCutPrep(rdt); else if (wParam == VK_TAB && ((GetKeyState(VK_CONTROL) | GetKeyState(VK_SHIFT)) & 0x8000) == 0) { SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); sel.cpMin = max(sel.cpMin - 20, 0); ReplaceContactSmileysWithText(rdt, sel, true); } break; } LRESULT result = mir_callNextSubclass(hwnd, RichEditSubclass, uMsg, wParam, lParam); switch(uMsg) { case WM_MOUSEMOVE: SetTooltip(LOWORD(lParam), HIWORD(lParam), hwnd, rdt); break; case WM_PAINT: case WM_HSCROLL: case WM_VSCROLL: SetPosition(hwnd); break; case WM_COPY: case WM_CUT: SmileyToTextCutRest(rdt); break; case EM_STREAMOUT: if (wParam & SFF_SELECTION) SmileyToTextCutRest(rdt); else ReplaceContactSmileys(rdt, allsel, false, true); break; case WM_KEYDOWN: if ((wParam == 'C' || wParam == VK_INSERT) && (GetKeyState(VK_CONTROL) & 0x8000)) SmileyToTextCutRest(rdt); else if ((wParam == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) || (wParam == VK_DELETE && (GetKeyState(VK_SHIFT) & 0x8000))) SmileyToTextCutRest(rdt); else if (wParam == VK_TAB && ((GetKeyState(VK_CONTROL) | GetKeyState(VK_SHIFT)) & 0x8000) == 0) { sel.cpMax = LONG_MAX; bool hascont = rdt->hContact != NULL; ReplaceContactSmileys(rdt, sel, false, hascont); } break; case WM_CHAR: if (!rdt->inputarea || (rdt->inputarea && !opt.InputSmileys)) break; if (lParam & (1 << 28)) // ALT key break; if ((lParam & 0xFF) > 2) // Repeat rate break; if (wParam > ' ' && opt.EnforceSpaces) break; if (wParam == 0x16) { ReplaceContactSmileys(rdt, allsel, false, false); break; } if (opt.DCursorSmiley) ReplaceContactSmileys(rdt, allsel, true, true); else if (wParam >= ' ' || wParam == '\n' || wParam == '\r') { SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); sel.cpMin = max(sel.cpMin - 20, 0); sel.cpMax += 20; ReplaceContactSmileysWithText(rdt, sel, true); ReplaceContactSmileys(rdt, sel, false, true); } break; case EM_PASTESPECIAL: case WM_PASTE: case EM_REPLACESEL: case WM_SETTEXT: case EM_SETTEXTEX: if (rdt->inputarea) ReplaceContactSmileys(rdt, allsel, false, false); break; case WM_REMAKERICH: ReplaceContactSmileys(rdt, allsel, false, false); break; } return result; }
static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) { HOTKEYDESC *desc = (HOTKEYDESC *)lParam; if (desc->cbSize != sizeof(HOTKEYDESC)) return 0; THotkeyItem *item = (THotkeyItem*)mir_alloc(sizeof(THotkeyItem)); DWORD dwFlags = (desc->cbSize >= sizeof(HOTKEYDESC)) ? desc->dwFlags : 0; if (dwFlags & HKD_UNICODE) { item->ptszSection = mir_tstrdup(desc->ptszSection); item->ptszDescription = mir_tstrdup(desc->ptszDescription); } else { item->ptszSection = mir_a2u(desc->pszSection); item->ptszDescription = mir_a2u(desc->pszDescription); } item->hLangpack = (int)wParam; item->allowSubHotkeys = TRUE; item->rootHotkey = NULL; item->nSubHotkeys = 0; if (item->rootHotkey = hotkeys.find(item)) { if (item->rootHotkey->allowSubHotkeys) { char nameBuf[MAXMODULELABELLENGTH]; mir_snprintf(nameBuf, _countof(nameBuf), "%s$%d", item->rootHotkey->pszName, item->rootHotkey->nSubHotkeys); item->pszName = mir_strdup(nameBuf); item->Enabled = TRUE; item->rootHotkey->nSubHotkeys++; } else { mir_free(item->ptszSection); mir_free(item->ptszDescription); mir_free(item); return 0; } } else { item->pszName = mir_strdup(desc->pszName); item->Enabled = !db_get_b(NULL, DBMODULENAME "Off", item->pszName, 0); } item->pszService = desc->pszService ? mir_strdup(desc->pszService) : 0; item->DefHotkey = desc->DefHotKey & ~HKF_MIRANDA_LOCAL; item->Hotkey = db_get_w(NULL, DBMODULENAME, item->pszName, item->DefHotkey); item->type = item->pszService ? (THotkeyType)db_get_b(NULL, DBMODULENAME "Types", item->pszName, (desc->DefHotKey & HKF_MIRANDA_LOCAL) ? HKT_LOCAL : HKT_GLOBAL) : HKT_MANUAL; item->lParam = desc->lParam; char buf[256]; mir_snprintf(buf, "mir_hotkey_%d_%d", g_pid, g_hkid++); item->idHotkey = GlobalAddAtomA(buf); if (item->type == HKT_GLOBAL) { if (item->Enabled) { BYTE mod, vk; sttWordToModAndVk(item->Hotkey, &mod, &vk); if (vk) RegisterHotKey(g_hwndHotkeyHost, item->idHotkey, mod, vk); } } hotkeys.insert(item); if (!item->rootHotkey) { /* try to load alternatives from db */ int count, i; mir_snprintf(buf, "%s$count", item->pszName); count = (int)db_get_dw(NULL, DBMODULENAME, buf, -1); for (i = 0; i < count; i++) { mir_snprintf(buf, "%s$%d", item->pszName, i); if (!db_get_w(NULL, DBMODULENAME, buf, 0)) continue; svcHotkeyRegister(wParam, lParam); } item->allowSubHotkeys = count < 0; } else { mir_free(item->pszName); item->pszName = NULL; } return item->idHotkey; }
static TokenRegisterEntry* FindTokenRegisterByName(TCHAR *name) { TokenRegisterEntry temp; temp.nameHash = NameHashFunction(name); return tokens.find(&temp); }
static INT_PTR makeAvatar(WPARAM wParam, LPARAM) { debug("Searching for flash avatar...\n"); FLASHAVATAR* hFA = (FLASHAVATAR*)wParam; PROTO_AVATAR_INFORMATIONT AI = {0}; AI.cbSize = sizeof(AI); AI.hContact = hFA->hContact; AI.format = PA_FORMAT_UNKNOWN; flash_avatar_item key(hFA->hContact, *hFA, NULL); bool avatarOK = false; if(hFA->hContact) avatarOK = (int)CallProtoService(key.getProto(), PS_GETAVATARINFOT, 0, (LPARAM)&AI) == GAIR_SUCCESS; else { avatarOK = (int)CallProtoService(key.getProto(), PS_GETMYAVATART, (WPARAM)AI.filename, (LPARAM)255) == 0; if(avatarOK) { TCHAR* ext = _tcsrchr(AI.filename, _T('.')); if(ext && (_tcsicmp(ext, _T(".xml")) == 0)) AI.format = PA_FORMAT_XML; } } if (!avatarOK) return 0; debug("Avatar found...\n"); TCHAR url[MAX_PATH]; switch(AI.format) { case PA_FORMAT_SWF: _tcsncpy(url, AI.filename, SIZEOF(url)); break; case PA_FORMAT_XML: { int src = _topen(AI.filename, _O_BINARY | _O_RDONLY); if(src != -1) { char pBuf[2048]; char* urlBuf; _read(src, pBuf, sizeof(pBuf)); _close(src); urlBuf = strstr(pBuf, "<URL>"); if(urlBuf) _tcsncpy(url, _A2T(strtok(urlBuf + 5, "\r\n <")), SIZEOF(url)); else return 0; } else { return 0; } break; } default: destroyAvatar(wParam, 0); return 0; } Lock l(cs); flash_avatar_item *item = FlashList.find(&key); if (item) { debug("Flash already exists...\n"); hFA->hWindow = item->hFA.hWindow; ShowWindow(hFA->hWindow, SW_SHOW); if ( _tcsicmp(item->hFA.cUrl, url) != 0) { debug("Refreshing flash...\n"); IShockwaveFlash* flash = item->pFlash; mir_free(item->hFA.cUrl); FlashList.remove(item); delete item; prepareFlash(key.getProto(), url, *hFA, flash); } } else { debug("Creating new flash...\n"); RECT rc; GetWindowRect(hFA->hParentWindow, &rc); hFA->hWindow = CreateWindowEx(WS_EX_TOPMOST, _T("AtlAxWin"), _T(""), WS_VISIBLE | WS_CHILD, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hFA->hParentWindow, (HMENU) 0, g_hInst, NULL); IShockwaveFlash* flash = NULL; debug("Creating flash instance...\n"); CoCreateInstance(__uuidof(ShockwaveFlash),0,CLSCTX_ALL, __uuidof(IShockwaveFlash), (void **)&flash); debug("Initialized.\n"); prepareFlash(key.getProto(), url, *hFA, flash); } return 0; }