ProcessResult CaptchaListener::blockArrived(JabberDataBlockRef block, const ResourceContextRef rc){ JabberDataBlockRef challenge=block->findChildNamespace("challenge", "urn:xmpp:tmp:challenge"); if (!challenge) return BLOCK_REJECTED; JabberDataBlockRef xdata=challenge->findChildNamespace("x", "jabber:x:data"); const std::string &jid=block->getAttribute("from"); const std::string &id=block->getAttribute("id"); CaptchaForm::ref rform=CaptchaForm::createCaptchaForm(tabs->getHWnd(), jid, id, rc); tabs->addWindow(rform); tabs->switchByWndRef(rform); rform->bindXData(xdata); return BLOCK_PROCESSED; }
LRESULT CALLBACK VirtualListView::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { VirtualListView *p=(VirtualListView *) GetWindowLong(hWnd, GWL_USERDATA); int klav=0; switch (message) { case WM_CREATE: { p=(VirtualListView *) (((CREATESTRUCT *)lParam)->lpCreateParams); SetWindowLong(hWnd, GWL_USERDATA, (LONG) p ); //p->listScrollHWND=CreateWindow(_T("SCROLLBAR"), NULL, // SBS_VERT | WS_VISIBLE | WS_CHILD, // 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, // hWnd, NULL, g_hInst, NULL); break; } case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; HDC wnd; wnd = BeginPaint(hWnd, &ps); HBITMAP buf=CreateCompatibleBitmap(wnd, p->clientRect.right, p->clientRect.bottom); hdc=CreateCompatibleDC(NULL); SelectObject(hdc, buf); PatBlt(hdc, 0, 0, p->clientRect.right, p->clientRect.bottom, WHITENESS); // TODO: Add any drawing code here... SetBkMode(hdc, OPAQUE); int y=-p->winTop; int index=0; if (p->odrlist.get()) { ODRList::const_iterator i=p->odrlist->begin(); while (i!=p->odrlist->end()) { ODRRef odr=*i; i++; bool oddIndex=(index & 1) && p->colorInterleaving; index++; bool focused = (odr.get()==p->cursorPos.get()); RECT ritem={0, y, p->clientRect.right, y} ; odr->measure(hdc, ritem); //int iHeight=odr->getHeight(); //y+=iHeight; y=ritem.bottom; //index++; if (ritem.bottom < 0) continue; if (ritem.top > p->clientRect.bottom) continue; int bkColor=COLORS[12]; if (focused) { // focused item SetTextColor(hdc, COLORS[8]); bkColor=(GetFocus()==hWnd)?COLORS[9]:COLORS[10]; //DrawFocusRect(hdc, &ritem); } else { //usual item SetTextColor(hdc, odr->getColor()); bkColor= (oddIndex)? COLORS[11] : COLORS[12]; } HBRUSH bkBrush=CreateSolidBrush(bkColor); SetBkColor(hdc, bkColor); ritem.right=p->clientRect.right; //full window-wide cursor FillRect(hdc, &ritem, bkBrush); DeleteObject(bkBrush); odr->draw(hdc, ritem); } } RECT rc = {0, 0, 100, 100}; SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.fMask=SIF_PAGE |SIF_POS |SIF_RANGE; si.nPage=p->clientRect.bottom; si.nPos=p->winTop; si.nMin=0; si.nMax=y+p->winTop; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); /*int titleBgnd=0x808080; HBRUSH tb=CreateSolidBrush(titleBgnd); SetBkColor(hdc, titleBgnd); SetTextColor(hdc, 0x000000); LPCTSTR t=p->title.c_str(); DrwText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP); rc.right=p->clientRect.right; FillRect(hdc, &rc, tb); DrwText(hdc, t, -1, &rc, DT_LEFT | DT_TOP); DeleteObject(tb);*/ BitBlt(wnd, 0,0,p->clientRect.right, p->clientRect.bottom, hdc, 0,0, SRCCOPY); DeleteDC(hdc); DeleteObject(buf); EndPaint(hWnd, &ps); break; } case WM_SIZE: { //HDWP hdwp; int height=GET_Y_LPARAM(lParam); int width=GET_X_LPARAM(lParam); // Calculate the display rectangle, assuming the // tab control is the size of the client area. SetRect(&(p->clientRect), 0, 0, width, height ); /*hdwp = BeginDeferWindowPos(1); DeferWindowPos(hdwp, p->listScrollHWND, HWND_TOP, width-SCROLLWIDTH, tabHeight, SCROLLWIDTH, height-tabHeight, SWP_NOZORDER ); EndDeferWindowPos(hdwp); */ p->cursorFit(); SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.fMask=SIF_PAGE |SIF_POS; si.nPage=height; si.nPos=p->winTop; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); break; } case WM_LBUTTONDOWN: { SetFocus(hWnd); ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (!(focused)) break; InvalidateRect(p->getHWnd(), NULL, true); SHRGINFO shrg; shrg.cbSize = sizeof(shrg); shrg.hwndClient = hWnd; shrg.ptDown.x = LOWORD(lParam); shrg.ptDown.y = HIWORD(lParam); shrg.dwFlags = SHRG_RETURNCMD /*| SHRG_NOANIMATION*/; if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU) { HMENU hmenu = p->getContextMenu(); VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get()); if (velement) hmenu=velement->getContextMenu(hmenu); if (hmenu==NULL) break; POINT pt={LOWORD(lParam), HIWORD(lParam) }; ClientToScreen(hWnd, &pt); int cmdId=TrackPopupMenuEx(hmenu, /*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, hWnd, NULL); bool cmdProcessed=false; if (velement) cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox); if (!cmdProcessed) p->OnCommand(cmdId, NULL); DestroyMenu(hmenu); } break; } case WM_LBUTTONDBLCLK: { ODRRef oldCursor=p->cursorPos; ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (!(focused)) break; InvalidateRect(p->getHWnd(), NULL, true); if (focused==oldCursor) p->eventOk(); break; } case WM_SETFOCUS: case WM_KILLFOCUS: { InvalidateRect(p->getHWnd(), NULL, true); break; } case WM_KEYDOWN: {bool kl2=1; int vKey=(int)wParam; int lkeyData=lParam; if (lkeyData & 0x80000000) break; //keyRelease switch (vKey) { /* UFO START */ case VK_RIGHT: PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::NEXTTAB, 0); break; case VK_3:kl2=0; // MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0); SCROLLINFO si2; si2.cbSize=sizeof(SCROLLINFO); si2.fMask=SIF_ALL; GetScrollInfo(p->thisHWnd, SB_VERT, &si2); //TODO: flicker-free scrolling /* case SB_LINEDOWN: */// si2.nPos+=tabHeight; break; //case SB_LINEUP: si2.nPos-=tabHeight; //case SB_ENDSCROLL: break; /*//case SB_PAGEUP: */// si2.nPos-=si2.nPage; //case SB_PAGEDOWN: si2.nPos+=si2.nPage; break; if (si2.nPos<0) si2.nPos=0; if (si2.nPos+(int)si2.nPage >= si2.nMax) si2.nPos=si2.nMax-si2.nPage; p->winTop= si2.nPos; //TODO: flicker-free scrolling InvalidateRect(p->getHWnd(), NULL, true); si2.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si2, TRUE); break; case VK_9:kl2=0; SCROLLINFO si3; si3.cbSize=sizeof(SCROLLINFO); si3.fMask=SIF_ALL; GetScrollInfo(p->thisHWnd, SB_VERT, &si3); //TODO: flicker-free scrolling /* case SB_LINEDOWN: */// si3.nPos+=tabHeight; //case SB_LINEUP: si2.nPos-=tabHeight; //case SB_ENDSCROLL: break; /*//case SB_PAGEUP: */// si2.nPos-=si2.nPage; //case SB_PAGEDOWN: si2.nPos+=si2.nPage; break; if (si3.nPos<0) si3.nPos=0; if (si3.nPos+(int)si3.nPage >= si3.nMax) si3.nPos=si3.nMax-si3.nPage; p->winTop= si3.nPos; //TODO: flicker-free scrolling InvalidateRect(p->getHWnd(), NULL, true); si3.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si3, TRUE); break; // MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0); case VK_LEFT: PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::PREVTAB, 0); break; /* UFO END */ case VK_UP: p->moveCursor(-1); break; case VK_DOWN: p->moveCursor(1); break; case VK_RETURN: if (lkeyData &0xc0000000) break; p->eventOk(); break; } if(kl2)p->cursorFit(); InvalidateRect(p->getHWnd(), NULL, true); SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.nPos=p->winTop; si.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); break; } case WM_VSCROLL: { int scrollCode=(int)LOWORD(wParam); int nPos=(int)HIWORD(wParam); SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.fMask=SIF_ALL; GetScrollInfo(p->thisHWnd, SB_VERT, &si); //TODO: flicker-free scrolling switch (scrollCode) { case SB_LINEDOWN: si.nPos+=tabHeight; break; case SB_LINEUP: si.nPos-=tabHeight; break; case SB_ENDSCROLL: break; case SB_PAGEUP: si.nPos-=si.nPage; break; case SB_PAGEDOWN: si.nPos+=si.nPage; break; case SB_THUMBTRACK: case SB_THUMBPOSITION: si.nPos=si.nTrackPos; break; //default: si.nPos=si.nTrackPos; break; } if (si.nPos<0) si.nPos=0; if (si.nPos+(int)si.nPage >= si.nMax) si.nPos=si.nMax-si.nPage; p->winTop= si.nPos; //TODO: flicker-free scrolling InvalidateRect(p->getHWnd(), NULL, true); si.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); return true; } case WM_COMMAND: { int cmdId=LOWORD(wParam); p->OnCommand(cmdId, lParam); break; } case WM_VIRTUALLIST_REPLACE: { //TODO: create interconnecting message object to avoid pointers ODRListRef r=ODRListRef((ODRList *)lParam); p->bindODRList(r); //юурсмц ╧5 //p->bindODRList(ODRSet::ref((ODRSet *)lParam)); //юурсмц ╧3 p->notifyListUpdate(true); break; } case WM_DESTROY: //TODO: Destroy all child data associated eith this window return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK VirtualListView::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { VirtualListView *p=(VirtualListView *) GetWindowLong(hWnd, GWL_USERDATA); int klav=0; lParamst=lParam; //printf(" \nmess: 0x%06X x:%d y:%d",message,GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)); switch (message) { case WM_CREATE: { p=(VirtualListView *) (((CREATESTRUCT *)lParam)->lpCreateParams); SetWindowLong(hWnd, GWL_USERDATA, (LONG) p ); //p->listScrollHWND=CreateWindow(_T("SCROLLBAR"), NULL, // SBS_VERT | WS_VISIBLE | WS_CHILD, // 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, // hWnd, NULL, g_hInst, NULL); break; } case CLEARMESS: {/*int result=MessageBox( p->getHWnd(), L"ќчистить окно от сообщений?", L"ќчистить", MB_YESNO | MB_ICONWARNING);*/ PostMessage(p->parentHWnd, CLEARMESS, NULL, false);} case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; HDC wnd; wnd = BeginPaint(hWnd, &ps); HBITMAP buf=CreateCompatibleBitmap(wnd, p->clientRect.right, p->clientRect.bottom); hdc=CreateCompatibleDC(NULL); SelectObject(hdc, buf); PatBlt(hdc, 0, 0, p->clientRect.right, p->clientRect.bottom, WHITENESS); // TODO: Add any drawing code here... SetBkMode(hdc, OPAQUE); int y=-p->winTop; int index=0; if (p->odrlist.get()) { ODRList::const_iterator i=p->odrlist->begin(); while (i!=p->odrlist->end()) { ODRRef odr=*i; i++; bool oddIndex=(index & 1) && p->colorInterleaving; index++; bool focused = (odr.get()==p->cursorPos.get()); RECT ritem={0, y, p->clientRect.right, y} ; odr->measure(hdc, ritem); //int iHeight=odr->getHeight(); //y+=iHeight; y=ritem.bottom; //index++; if (ritem.bottom < 0) continue; if (ritem.top > p->clientRect.bottom) continue; int bkColor=COLORS[12]; if (focused) { // focused item SetTextColor(hdc, COLORS[8]); bkColor=(GetFocus()==hWnd)?COLORS[9]:COLORS[10]; //DrawFocusRect(hdc, &ritem); } else { //usual item SetTextColor(hdc, odr->getColor()); bkColor= (oddIndex)? COLORS[11] : COLORS[12]; } HBRUSH bkBrush=CreateSolidBrush(bkColor); SetBkColor(hdc, bkColor); ritem.right=p->clientRect.right; //full window-wide cursor FillRect(hdc, &ritem, bkBrush); DeleteObject(bkBrush); odr->draw(hdc, ritem,1); } } RECT rc = {0, 0, 100, 100}; SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.fMask=SIF_PAGE |SIF_POS |SIF_RANGE; si.nPage=p->clientRect.bottom; si.nPos=p->winTop; si.nMin=0; si.nMax=y+p->winTop; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); /*int titleBgnd=0x808080; HBRUSH tb=CreateSolidBrush(titleBgnd); SetBkColor(hdc, titleBgnd); SetTextColor(hdc, 0x000000); LPCTSTR t=p->title.c_str(); DrwText(hdc, t, -1, &rc, DT_CALCRECT | DT_LEFT | DT_TOP); rc.right=p->clientRect.right; FillRect(hdc, &rc, tb); DrwText(hdc, t, -1, &rc, DT_LEFT | DT_TOP); DeleteObject(tb);*/ BitBlt(wnd, 0,0,p->clientRect.right, p->clientRect.bottom, hdc, 0,0, SRCCOPY); DeleteDC(hdc); DeleteObject(buf); EndPaint(hWnd, &ps); break; } case WM_SIZE: { //HDWP hdwp; int height=GET_Y_LPARAM(lParam); int width=GET_X_LPARAM(lParam); // Calculate the display rectangle, assuming the // tab control is the size of the client area. SetRect(&(p->clientRect), 0, 0, width, height ); /*hdwp = BeginDeferWindowPos(1); DeferWindowPos(hdwp, p->listScrollHWND, HWND_TOP, width-SCROLLWIDTH, tabHeight, SCROLLWIDTH, height-tabHeight, SWP_NOZORDER ); EndDeferWindowPos(hdwp); */ p->cursorFit(); SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.fMask=SIF_PAGE |SIF_POS; si.nPage=height; si.nPos=p->winTop; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); break; } case MSGListFocus: { SetFocus(hWnd); break; } case WM_LBUTTONDOWN: { smile_aktiv=40; xmouse=GET_X_LPARAM(lParam); ymouse=GET_Y_LPARAM(lParam); movemode=0;//неопределили пока zaderzhka=0; xmouse_d=0; ymouse_d=0; taptrue=1; if(movetrue){break;} SetFocus(hWnd); ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (!(focused)) break; InvalidateRect(p->getHWnd(), NULL, true); SHRGINFO shrg; shrg.cbSize = sizeof(shrg); shrg.hwndClient = hWnd; shrg.ptDown.x = LOWORD(lParam); shrg.ptDown.y = HIWORD(lParam); shrg.dwFlags = SHRG_RETURNCMD /*| SHRG_NOANIMATION*/; if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU) { HMENU hmenu = p->getContextMenu(); VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get()); if (velement) hmenu=velement->getContextMenu(hmenu); if (hmenu==NULL) break; POINT pt={LOWORD(lParam), HIWORD(lParam) }; ClientToScreen(hWnd, &pt); int cmdId=TrackPopupMenuEx(hmenu, /*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, hWnd, NULL); bool cmdProcessed=false; if (velement) cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox); if (!cmdProcessed) p->OnCommand(cmdId, NULL); DestroyMenu(hmenu); }else{ //нажатие на иконки p->is_icon_klik(xmouse); } break; } case WM_LBUTTONDBLCLK: { smile_aktiv=40 ; ODRRef oldCursor=p->cursorPos; ODRRef focused=p->moveCursorTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (!(focused)) break; InvalidateRect(p->getHWnd(), NULL, true); if (focused==oldCursor) p->eventOk(); break; } case WM_SETFOCUS: case WM_KILLFOCUS: { InvalidateRect(p->getHWnd(), NULL, true); break; } case WM_MOUSEMOVE: {//скролл тасканием //movetrue=1; smile_aktiv=40 ; if(zaderzhka>0){ printf("mode %d X: %d Y: %d\n",movemode,xmouse_d,ymouse_d); if(movemode){ //собственно само движение if(movemode==1){ //верт if(ymouse_d<0){ PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEDOWN, 0); //PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEDOWN, 0); }else{ PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEUP, 0); // PostMessage(p->getHWnd(), WM_VSCROLL, SB_LINEUP, 0); } }else{ //гориз if (abs(xmouse_d)>50){ if (xmouse_d<0){ PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::NEXTTAB, 0);} else{PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::PREVTAB, 0);} xmouse_d=0; }} } else //определ¤ем movemode 1-вертик 2-гориз {int absx,absy; absx=xmouse_d;absy=ymouse_d; if(xmouse_d<0)absx=xmouse_d*(-1); if(ymouse_d<0)absy=ymouse_d*(-1); if(absx > absy){movemode=2;}else{movemode=1;} movetrue=1;taptrue=0; printf("mode %d ax: %d ay: %d\n",movemode,absx,absy); } zaderzhka=0;ymouse_d=0; }else{zaderzhka++; xmouse_d=xmouse_d+GET_X_LPARAM(lParam)-xmouse; ymouse_d=ymouse_d+GET_Y_LPARAM(lParam)- ymouse; xmouse=GET_X_LPARAM(lParam); ymouse=GET_Y_LPARAM(lParam); } break;} case WM_LBUTTONUP: {if(movetrue==1 && taptrue==1){ movetrue=0; PostMessage(p->getHWnd(), WM_LBUTTONDOWN, 0, lParamst); } break; } case WM_KEYDOWN: {bool kl2=1; smile_aktiv=40 ; int vKey=(int)wParam; int lkeyData=lParam; if (lkeyData & 0x80000000) break; //keyRelease switch (vKey) { /* UFO START */ case VK_5: { ODRRef focused=p->cursorPos; if (!(focused)) break; InvalidateRect(p->getHWnd(), NULL, true); HMENU hmenu = p->getContextMenu(); VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get()); if (velement) hmenu=velement->getContextMenu(hmenu); if (hmenu==NULL) break; POINT pt={LOWORD(lParam), HIWORD(lParam) }; ClientToScreen(hWnd, &pt); int cmdId=TrackPopupMenuEx(hmenu, /*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, hWnd, NULL); bool cmdProcessed=false; if (velement) cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox); if (!cmdProcessed) p->OnCommand(cmdId, NULL); DestroyMenu(hmenu); break; } case VK_RIGHT: PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::NEXTTAB, 0); break; case VK_3:kl2=0; // MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0); SCROLLINFO si2; si2.cbSize=sizeof(SCROLLINFO); si2.fMask=SIF_ALL; GetScrollInfo(p->thisHWnd, SB_VERT, &si2); //TODO: flicker-free scrolling /* case SB_LINEDOWN: */// si2.nPos+=tabHeight; break; //case SB_LINEUP: si2.nPos-=tabHeight; //case SB_ENDSCROLL: break; /*//case SB_PAGEUP: */// si2.nPos-=si2.nPage; //case SB_PAGEDOWN: si2.nPos+=si2.nPage; break; if (si2.nPos<0) si2.nPos=0; if (si2.nPos+(int)si2.nPage >= si2.nMax) si2.nPos=si2.nMax-si2.nPage; p->winTop= si2.nPos; //TODO: flicker-free scrolling InvalidateRect(p->getHWnd(), NULL, true); si2.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si2, TRUE); break; case VK_9:kl2=0; SCROLLINFO si3; si3.cbSize=sizeof(SCROLLINFO); si3.fMask=SIF_ALL; GetScrollInfo(p->thisHWnd, SB_VERT, &si3); //TODO: flicker-free scrolling /* case SB_LINEDOWN: */// si3.nPos+=tabHeight; //case SB_LINEUP: si2.nPos-=tabHeight; //case SB_ENDSCROLL: break; /*//case SB_PAGEUP: */// si2.nPos-=si2.nPage; //case SB_PAGEDOWN: si2.nPos+=si2.nPage; break; if (si3.nPos<0) si3.nPos=0; if (si3.nPos+(int)si3.nPage >= si3.nMax) si3.nPos=si3.nMax-si3.nPage; p->winTop= si3.nPos; //TODO: flicker-free scrolling InvalidateRect(p->getHWnd(), NULL, true); si3.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si3, TRUE); break; // MessageBox(hWnd, TEXT("Clicked 3"), TEXT("!"), 0); case VK_LEFT: PostMessage(tabs->getHWnd(), WM_COMMAND, TabsCtrl::PREVTAB, 0); break; /* UFO END */ case VK_UP: p->moveCursor(-1); break; case VK_DOWN: /* UFO START */ // переключаем фокус в поле ввода после второго нажати¤ кнопки вниз на последнем сообщении if (p->cursorAtEnd() && IsWindow(p->hEditBox) ) SetFocus(p->hEditBox); /* UFO END */ p->moveCursor(1); break; case VK_RETURN: SHRGINFO shrg; shrg.cbSize = sizeof(shrg); shrg.hwndClient = hWnd; shrg.ptDown.x = LOWORD(lParam); shrg.ptDown.y = HIWORD(lParam); shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION; if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU) { ODRRef focused=p->cursorPos; if (!(focused)) break; InvalidateRect(p->getHWnd(), NULL, true); HMENU hmenu = p->getContextMenu(); VirtualListElement *velement=dynamic_cast<VirtualListElement *>(focused.get()); if (velement) hmenu=velement->getContextMenu(hmenu); if (hmenu==NULL) break; POINT pt={LOWORD(lParam), HIWORD(lParam) }; ClientToScreen(hWnd, &pt); int cmdId=TrackPopupMenuEx(hmenu, /*TPM_LEFTALIGN |*/ TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, hWnd, NULL); bool cmdProcessed=false; if (velement) cmdProcessed=velement->OnMenuCommand(cmdId, p->getHWnd(), p->hEditBox); if (!cmdProcessed) p->OnCommand(cmdId, NULL); DestroyMenu(hmenu); break; } if (lkeyData &0xc0000000) break; p->eventOk(); break; } if(kl2)p->cursorFit(); InvalidateRect(p->getHWnd(), NULL, true); SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.nPos=p->winTop; si.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); break; } case WM_VSCROLL: { smile_aktiv=40 ; int scrollCode=(int)LOWORD(wParam); int nPos=(int)HIWORD(wParam); SCROLLINFO si; si.cbSize=sizeof(SCROLLINFO); si.fMask=SIF_ALL; GetScrollInfo(p->thisHWnd, SB_VERT, &si); //TODO: flicker-free scrolling switch (scrollCode) { case SB_LINEDOWN: si.nPos+=tabHeight; break; case SB_LINEUP: si.nPos-=tabHeight; break; case SB_ENDSCROLL: break; case SB_PAGEUP: si.nPos-=si.nPage; break; case SB_PAGEDOWN: si.nPos+=si.nPage; break; case SB_THUMBTRACK: case SB_THUMBPOSITION: si.nPos=si.nTrackPos; break; //default: si.nPos=si.nTrackPos; break; } if (si.nPos<0) si.nPos=0; if (si.nPos+(int)si.nPage >= si.nMax) si.nPos=si.nMax-si.nPage; p->winTop= si.nPos; //TODO: flicker-free scrolling InvalidateRect(p->getHWnd(), NULL, true); si.fMask=SIF_POS; SetScrollInfo(p->thisHWnd, SB_VERT, &si, TRUE); return true; } case WM_COMMAND: { int cmdId=LOWORD(wParam); p->OnCommand(cmdId, lParam); break; } case WM_VIRTUALLIST_REPLACE: { //TODO: create interconnecting message object to avoid pointers ODRListRef r=ODRListRef((ODRList *)lParam); p->bindODRList(r); //ј’“”Ќ√ є5 //p->bindODRList(ODRSet::ref((ODRSet *)lParam)); //ј’“”Ќ√ є3 p->notifyListUpdate(true); break; } case WM_DESTROY: //TODO: Destroy all child data associated eith this window return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void ServiceDiscovery::registerForm() { WndRef rform=RegisterForm::createRegisterForm(tabs->getHWnd(), jid, rc); tabs->addWindow(rform); tabs->switchByWndRef(rform); }
void ServiceDiscovery::execute() { WndRef exeForm=AdHocForm::createAdHocForm(tabs->getHWnd(), jid, node, rc); tabs->addWindow(exeForm); tabs->switchByWndRef(exeForm); }
void ServiceDiscovery::joingc() { DlgMucJoin::createDialog(tabs->getHWnd(), rc, jid); }
void ServiceDiscovery::vcard() { WndRef vcardForm=VcardForm::createVcardForm(tabs->getHWnd(), jid, rc, false); tabs->addWindow(vcardForm); tabs->switchByWndRef(vcardForm); }
ProcessResult ProcessMuc::blockArrived(JabberDataBlockRef block, const ResourceContextRef rc){ JabberDataBlockRef xmuc=block->findChildNamespace("x", "http://jabber.org/protocol/muc#user"); if (!xmuc) return BLOCK_REJECTED; const std::string &from=block->getAttribute("from"); const std::string &type=block->getAttribute("type"); Jid roomNode; roomNode.setJid(from); std::string message; //1. group MucGroup::ref roomGrp; roomGrp=boost::dynamic_pointer_cast<MucGroup> (rc->roster->findGroup(roomNode.getBareJid())); if (!roomGrp) return BLOCK_PROCESSED; //dropped presence MucContact::ref c=getMucContactEntry(from, rc); MPA action=NONE; if (type=="error") { JabberDataBlockRef error=block->getChildByName("error"); int errCode=atoi(error->getAttribute("code").c_str()); //todo: if (status>=Presence.PRESENCE_OFFLINE) testMeOffline(); action=LEAVE; //todo: if (errCode!=409 || status>=Presence.PRESENCE_OFFLINE) setStatus(presenceType); std::string errText=error->getChildText("text"); if (errText.length()>0) message=errText; // if error description is provided by server else // legacy codes switch (errCode) { case 401: message="Password required"; case 403: message="You are banned in this room"; case 404: message="Room does not exists"; case 405: message="You can't create room on this server"; case 406: message="Reserved roomnick must be used"; case 407: message="This room is members-only"; case 409: message="Nickname is already in use by another occupant"; case 503: message="Maximum number of users has been reached in this room"; default: message=*(error->toXML()); } } else { JabberDataBlockRef item=xmuc->getChildByName("item"); MucContact::Role role = getRoleIndex(item->getAttribute("role")); c->sortKey=MucContact::MODERATOR-role; MucContact::Affiliation affiliation = getAffiliationIndex(item->getAttribute("affiliation")); boolean roleChanged= c->role != role; boolean affiliationChanged= c->affiliation !=affiliation; c->role=role; c->affiliation=affiliation; //setSortKey(nick); switch (role) { case MucContact::MODERATOR: c->transpIndex=icons::ICON_MODERATOR_INDEX; break; case MucContact::VISITOR: { Skin * il= dynamic_cast<Skin *>(skin.get()); c->transpIndex=(il)? il->getBaseIndex("visitors") : 0; break; } default: c->transpIndex=0; } JabberDataBlockRef statusBlock=xmuc->getChildByName("status"); int statusCode=(statusBlock)? atoi(statusBlock->getAttribute("code").c_str()) : 0; message=c->jid.getResource(); // nick if (type=="unavailable") { action=LEAVE; std::string reason=item->getChildText("reason"); switch (statusCode) { case 303: message+=" is now known as "; message+=item->getAttribute("nick"); c->jid.setResource(item->getAttribute("nick")); c->rosterJid=c->jid.getJid(); //for vCard c->update(); action=NONE; break; case 307: //kick case 301: //ban message+=(statusCode==307)?" was kicked " : " was banned "; message+="("; message+=reason; message+=")"; if (c->realJid.length()>0){ message+=" - "; message+=c->realJid; } break; case 321: message+=" has been unaffiliated and kicked from members-only room"; break; case 322: message+=" has been kicked because room became members-only"; break; default: { message+=" has left the channel"; const std::string & status=block->getChildText("status"); if (status.length()) { message+=" ("; message+=status; message+=")"; } } } } else { //onlines action=ENTER; if (c->status>=presence::OFFLINE) { // first online std::string realJid=item->getAttribute("jid"); if (realJid.length()) { c->realJid=realJid; message+=" ("; message+=realJid; //for moderating purposes message+=")"; } message+=" has joined the channel as "; message+=roleName[role]; if (affiliation!=MucContact::NONE) { message+=" and "; message+=affiliationName[affiliation-MucContact::OUTCAST]; const std::string & status=block->getChildText("status"); if (status.length()) { message+=" ("; message+=status; message+=")"; } } } else { //change status message+=" is now "; if ( roleChanged ) message+=roleName[role]; if (affiliationChanged) { if (roleChanged) message+=" and "; message+=(affiliation==MucContact::NONE)? "unaffiliated" : affiliationName[affiliation-MucContact::OUTCAST]; } if (!roleChanged && !affiliationChanged) { const std::string &show=block->getChildText("show"); if (show.length()==0) message+="online"; else message+=show; const std::string & status=block->getChildText("status"); if (status.length()) { message+=" ("; message+=status; message+=")"; } } } } } if (c.get()==roomGrp->selfContact.get()) { switch (action) { case ENTER: // room contact is online roomGrp->room->status=presence::ONLINE; break; case LEAVE: // room contact is offline roomGrp->room->status=presence::OFFLINE; // make all occupants offline rc->roster->setStatusByFilter(roomNode.getBareJid(), presence::OFFLINE); break; } } { ChatView *cv = dynamic_cast<ChatView *>(tabs->getWindowByODR(c).get()); bool ascroll=(cv==NULL)? false: cv->autoScroll(); c->processPresence(block); if (ascroll) { cv->moveEnd(); } if (cv) if (IsWindowVisible(cv->getHWnd())) cv->redraw(); } rc->roster->makeViewList(); { Message::ref msg=Message::ref(new Message(message, from, false, Message::PRESENCE, Message::extractXDelay(block) )); Contact::ref room=roomGrp->room; ChatView *cv = dynamic_cast<ChatView *>(tabs->getWindowByODR(room).get()); bool ascroll=(cv==NULL)? false: cv->autoScroll(); room->messageList->push_back(msg); if (ascroll) { cv->moveEnd(); } if (cv) if (IsWindowVisible(cv->getHWnd())) cv->redraw(); } return BLOCK_PROCESSED; }