diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-11 18:21:01 +0200 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-11 18:21:01 +0200 |
commit | cfa929299063067d13bf8349292b9bc22b43e4bf (patch) | |
tree | 82ea46a720b3aa0cab49f079a8ef53952b059a32 /protocols | |
parent | 6a668c99fcd6549b3b17085a738a93fdd5eb9719 (diff) |
code cleaning
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber_groupchat.cpp | 543 |
1 files changed, 268 insertions, 275 deletions
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 3c72a7f379..b421cc2c3a 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -349,6 +349,8 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo) SendMessage(hwndList, CB_SHOWDROPDOWN, TRUE, 0);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static void sttJoinDlgShowRecentItems(HWND hwndDlg, int newCount)
{
RECT rcTitle, rcLastItem;
@@ -383,334 +385,325 @@ class CJabberDlgGcJoin : public CJabberDlgBase {
typedef CJabberDlgBase CSuper;
+ wchar_t *m_jid;
+
CCtrlButton btnOk;
public:
- CJabberDlgGcJoin(CJabberProto *proto, wchar_t *jid);
- ~CJabberDlgGcJoin();
+ CJabberDlgGcJoin(CJabberProto *proto, wchar_t *jid) :
+ CSuper(proto, IDD_GROUPCHAT_JOIN),
+ btnOk(this, IDOK),
+ m_jid(mir_wstrdup(jid))
+ {
+ btnOk.OnClick = Callback(this, &CJabberDlgGcJoin::OnBtnOk);
+ }
+
+ ~CJabberDlgGcJoin()
+ {
+ mir_free(m_jid);
+ }
protected:
- wchar_t *m_jid;
- bool OnInitDialog() override;
- void OnDestroy();
-
- void OnBtnOk(CCtrlButton*);
-
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
-};
-
-CJabberDlgGcJoin::CJabberDlgGcJoin(CJabberProto *proto, wchar_t *jid) :
- CSuper(proto, IDD_GROUPCHAT_JOIN),
- btnOk(this, IDOK),
- m_jid(mir_wstrdup(jid))
-{
- btnOk.OnClick = Callback(this, &CJabberDlgGcJoin::OnBtnOk);
-}
+ bool OnInitDialog()
+ {
+ CSuper::OnInitDialog();
-CJabberDlgGcJoin::~CJabberDlgGcJoin()
-{
- mir_free(m_jid);
-}
+ Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP));
-bool CJabberDlgGcJoin::OnInitDialog()
-{
- CSuper::OnInitDialog();
+ JabberGcRecentInfo *pInfo = nullptr;
+ if (m_jid)
+ pInfo = new JabberGcRecentInfo(m_proto, m_jid);
+ else if (OpenClipboard(m_hwnd)) {
+ HANDLE hData = GetClipboardData(CF_UNICODETEXT);
+
+ if (hData) {
+ wchar_t *buf = (wchar_t *)GlobalLock(hData);
+ if (buf && wcschr(buf, '@') && !wcschr(buf, ' '))
+ pInfo = new JabberGcRecentInfo(m_proto, buf);
+ GlobalUnlock(hData);
+ }
+ CloseClipboard();
+ }
- Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP));
+ if (pInfo) {
+ pInfo->fillForm(m_hwnd);
+ delete pInfo;
+ }
- JabberGcRecentInfo *pInfo = nullptr;
- if (m_jid)
- pInfo = new JabberGcRecentInfo(m_proto, m_jid);
- else if (OpenClipboard(m_hwnd)) {
- HANDLE hData = GetClipboardData(CF_UNICODETEXT);
+ ptrW tszNick(m_proto->getWStringA("Nick"));
+ if (tszNick == nullptr)
+ tszNick = JabberNickFromJID(m_proto->m_szJabberJID);
+ SetDlgItemText(m_hwnd, IDC_NICK, tszNick);
+
+ TEXTMETRIC tm = { 0 };
+ HDC hdc = GetDC(m_hwnd);
+ GetTextMetrics(hdc, &tm);
+ ReleaseDC(m_hwnd, hdc);
+ sttTextLineHeight = tm.tmHeight;
+ SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight - 1);
+
+ LOGFONT lf = { 0 };
+ HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
+ GetObject(hfnt, sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
+
+ SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks"));
+ SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0);
+ SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, TRUE, 0);
+
+ m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr");
+
+ int i;
+ for (i = 0; i < 5; i++) {
+ wchar_t jid[JABBER_MAX_JID_LEN];
+ JabberGcRecentInfo info(m_proto);
+ if (!info.loadRecent(i))
+ break;
- if (hData) {
- wchar_t *buf = (wchar_t *)GlobalLock(hData);
- if (buf && wcschr(buf, '@') && !wcschr(buf, ' '))
- pInfo = new JabberGcRecentInfo(m_proto, buf);
- GlobalUnlock(hData);
+ mir_snwprintf(jid, L"%s@%s (%s)", info.m_room, info.m_server, info.m_nick ? info.m_nick : TranslateT("<no nick>"));
+ SetDlgItemText(m_hwnd, IDC_RECENT1 + i, jid);
}
- CloseClipboard();
+ sttJoinDlgShowRecentItems(m_hwnd, i);
+ return true;
}
- if (pInfo) {
- pInfo->fillForm(m_hwnd);
- delete pInfo;
- }
+ void OnDestroy() override
+ {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0));
+ m_proto->m_pDlgJabberJoinGroupchat = nullptr;
+ DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0));
- ptrW tszNick(m_proto->getWStringA("Nick"));
- if (tszNick == nullptr)
- tszNick = JabberNickFromJID(m_proto->m_szJabberJID);
- SetDlgItemText(m_hwnd, IDC_NICK, tszNick);
-
- TEXTMETRIC tm = { 0 };
- HDC hdc = GetDC(m_hwnd);
- GetTextMetrics(hdc, &tm);
- ReleaseDC(m_hwnd, hdc);
- sttTextLineHeight = tm.tmHeight;
- SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight - 1);
-
- LOGFONT lf = { 0 };
- HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
- GetObject(hfnt, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
-
- SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks"));
- SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0);
- SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, TRUE, 0);
-
- m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr");
-
- int i;
- for (i = 0; i < 5; i++) {
- wchar_t jid[JABBER_MAX_JID_LEN];
- JabberGcRecentInfo info(m_proto);
- if (!info.loadRecent(i))
- break;
+ CSuper::OnDestroy();
- mir_snwprintf(jid, L"%s@%s (%s)", info.m_room, info.m_server, info.m_nick ? info.m_nick : TranslateT("<no nick>"));
- SetDlgItemText(m_hwnd, IDC_RECENT1 + i, jid);
+ mir_free(m_jid); m_jid = nullptr;
}
- sttJoinDlgShowRecentItems(m_hwnd, i);
- return true;
-}
-
-void CJabberDlgGcJoin::OnDestroy()
-{
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0));
- m_proto->m_pDlgJabberJoinGroupchat = nullptr;
- DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0));
-
- CSuper::OnDestroy();
- mir_free(m_jid); m_jid = nullptr;
-}
-
-void CJabberDlgGcJoin::OnBtnOk(CCtrlButton*)
-{
- wchar_t text[128];
- GetDlgItemText(m_hwnd, IDC_SERVER, text, _countof(text));
- wchar_t *server = NEWWSTR_ALLOCA(text), *room;
-
- m_proto->ComboAddRecentString(m_hwnd, IDC_SERVER, "joinWnd_rcSvr", server);
+ void OnBtnOk(CCtrlButton*)
+ {
+ wchar_t text[128];
+ GetDlgItemText(m_hwnd, IDC_SERVER, text, _countof(text));
+ wchar_t *server = NEWWSTR_ALLOCA(text), *room;
- GetDlgItemText(m_hwnd, IDC_ROOM, text, _countof(text));
- room = NEWWSTR_ALLOCA(text);
+ m_proto->ComboAddRecentString(m_hwnd, IDC_SERVER, "joinWnd_rcSvr", server);
- GetDlgItemText(m_hwnd, IDC_NICK, text, _countof(text));
- wchar_t *nick = NEWWSTR_ALLOCA(text);
+ GetDlgItemText(m_hwnd, IDC_ROOM, text, _countof(text));
+ room = NEWWSTR_ALLOCA(text);
- GetDlgItemText(m_hwnd, IDC_PASSWORD, text, _countof(text));
- wchar_t *password = NEWWSTR_ALLOCA(text);
- m_proto->GroupchatJoinRoom(server, room, nick, password);
-}
+ GetDlgItemText(m_hwnd, IDC_NICK, text, _countof(text));
+ wchar_t *nick = NEWWSTR_ALLOCA(text);
-INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_DELETEITEM:
- {
- LPDELETEITEMSTRUCT lpdis = (LPDELETEITEMSTRUCT)lParam;
- if (lpdis->CtlID != IDC_ROOM)
- break;
+ GetDlgItemText(m_hwnd, IDC_PASSWORD, text, _countof(text));
+ wchar_t *password = NEWWSTR_ALLOCA(text);
+ m_proto->GroupchatJoinRoom(server, room, nick, password);
+ }
- RoomInfo *info = (RoomInfo *)lpdis->itemData;
- mir_free(info->line1);
- mir_free(info->line2);
- mir_free(info);
- }
- break;
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
+ {
+ switch (msg) {
+ case WM_DELETEITEM:
+ {
+ LPDELETEITEMSTRUCT lpdis = (LPDELETEITEMSTRUCT)lParam;
+ if (lpdis->CtlID != IDC_ROOM)
+ break;
+
+ RoomInfo *info = (RoomInfo *)lpdis->itemData;
+ mir_free(info->line1);
+ mir_free(info->line2);
+ mir_free(info);
+ }
+ break;
- case WM_MEASUREITEM:
- {
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
- if (lpmis->CtlID != IDC_ROOM)
- break;
+ case WM_MEASUREITEM:
+ {
+ LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
+ if (lpmis->CtlID != IDC_ROOM)
+ break;
- lpmis->itemHeight = 2 * sttTextLineHeight;
- if (lpmis->itemID == -1)
- lpmis->itemHeight = sttTextLineHeight - 1;
+ lpmis->itemHeight = 2 * sttTextLineHeight;
+ if (lpmis->itemID == -1)
+ lpmis->itemHeight = sttTextLineHeight - 1;
- }
- break;
+ }
+ break;
- case WM_DRAWITEM:
- {
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlID != IDC_ROOM)
- break;
+ case WM_DRAWITEM:
+ {
+ LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
+ if (lpdis->CtlID != IDC_ROOM)
+ break;
- RoomInfo *info = (RoomInfo *)SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETITEMDATA, lpdis->itemID, 0);
- COLORREF clLine1, clBack;
+ RoomInfo *info = (RoomInfo *)SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETITEMDATA, lpdis->itemID, 0);
+ COLORREF clLine1, clBack;
- if (lpdis->itemState & ODS_SELECTED) {
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
- clBack = GetSysColor(COLOR_HIGHLIGHT);
- clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
- }
- else {
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
- clBack = GetSysColor(COLOR_WINDOW);
- clLine1 = GetSysColor(COLOR_WINDOWTEXT);
- }
- COLORREF clLine2 = RGB(
- GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
- GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
-
- SetBkMode(lpdis->hDC, TRANSPARENT);
-
- RECT rc = lpdis->rcItem;
- rc.bottom -= (rc.bottom - rc.top) / 2;
- rc.left += 20;
- SetTextColor(lpdis->hDC, clLine1);
- DrawText(lpdis->hDC, info->line1, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
-
- rc = lpdis->rcItem;
- rc.top += (rc.bottom - rc.top) / 2;
- rc.left += 20;
- SetTextColor(lpdis->hDC, clLine2);
- DrawText(lpdis->hDC, info->line2, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
-
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("group"), 16, 16, 0, nullptr, DI_NORMAL);
- switch (info->overlay) {
- case RoomInfo::ROOM_WAIT:
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_progress"), 16, 16, 0, nullptr, DI_NORMAL);
- break;
- case RoomInfo::ROOM_FAIL:
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_fail"), 16, 16, 0, nullptr, DI_NORMAL);
- break;
- case RoomInfo::ROOM_BOOKMARK:
- DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_ok"), 16, 16, 0, nullptr, DI_NORMAL);
- break;
- }
- }
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_SERVER:
- switch (HIWORD(wParam)) {
- case CBN_EDITCHANGE:
- case CBN_SELCHANGE:
- {
- int iqid = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA);
- if (iqid) {
- m_proto->m_iqManager.ExpireIq(iqid);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, 0);
- }
- SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_RESETCONTENT, 0, 0);
+ if (lpdis->itemState & ODS_SELECTED) {
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
+ clBack = GetSysColor(COLOR_HIGHLIGHT);
+ clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
+ }
+ else {
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
+ clBack = GetSysColor(COLOR_WINDOW);
+ clLine1 = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ COLORREF clLine2 = RGB(
+ GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
+ GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
+
+ SetBkMode(lpdis->hDC, TRANSPARENT);
+
+ RECT rc = lpdis->rcItem;
+ rc.bottom -= (rc.bottom - rc.top) / 2;
+ rc.left += 20;
+ SetTextColor(lpdis->hDC, clLine1);
+ DrawText(lpdis->hDC, info->line1, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
+
+ rc = lpdis->rcItem;
+ rc.top += (rc.bottom - rc.top) / 2;
+ rc.left += 20;
+ SetTextColor(lpdis->hDC, clLine2);
+ DrawText(lpdis->hDC, info->line2, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
+
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("group"), 16, 16, 0, nullptr, DI_NORMAL);
+ switch (info->overlay) {
+ case RoomInfo::ROOM_WAIT:
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_progress"), 16, 16, 0, nullptr, DI_NORMAL);
+ break;
+ case RoomInfo::ROOM_FAIL:
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_fail"), 16, 16, 0, nullptr, DI_NORMAL);
+ break;
+ case RoomInfo::ROOM_BOOKMARK:
+ DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_ok"), 16, 16, 0, nullptr, DI_NORMAL);
+ break;
}
- break;
}
break;
- case IDC_ROOM:
- switch (HIWORD(wParam)) {
- case CBN_DROPDOWN:
- if (!SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETCOUNT, 0, 0)) {
- int iqid = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA);
- if (iqid) {
- m_proto->m_iqManager.ExpireIq(iqid);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, 0);
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_SERVER:
+ switch (HIWORD(wParam)) {
+ case CBN_EDITCHANGE:
+ case CBN_SELCHANGE:
+ {
+ int iqid = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA);
+ if (iqid) {
+ m_proto->m_iqManager.ExpireIq(iqid);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, 0);
+ }
+ SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_RESETCONTENT, 0, 0);
}
+ break;
+ }
+ break;
- SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_RESETCONTENT, 0, 0);
+ case IDC_ROOM:
+ switch (HIWORD(wParam)) {
+ case CBN_DROPDOWN:
+ if (!SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETCOUNT, 0, 0)) {
+ int iqid = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA);
+ if (iqid) {
+ m_proto->m_iqManager.ExpireIq(iqid);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, 0);
+ }
- int len = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_SERVER)) + 1;
- wchar_t *server = (wchar_t*)_alloca(len * sizeof(wchar_t));
- GetDlgItemText(m_hwnd, IDC_SERVER, server, len);
+ SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_RESETCONTENT, 0, 0);
- if (*server) {
- sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_WAIT, TranslateT("Loading..."), TranslateT("Please wait for room list to download."), L"");
+ int len = GetWindowTextLength(GetDlgItem(m_hwnd, IDC_SERVER)) + 1;
+ wchar_t *server = (wchar_t*)_alloca(len * sizeof(wchar_t));
+ GetDlgItemText(m_hwnd, IDC_SERVER, server, len);
- CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
- pInfo->SetTimeout(30000);
- XmlNodeIq iq(pInfo);
- iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
- m_proto->m_ThreadInfo->send(iq);
+ if (*server) {
+ sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_WAIT, TranslateT("Loading..."), TranslateT("Please wait for room list to download."), L"");
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, pInfo->GetIqId());
+ CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
+ pInfo->SetTimeout(30000);
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(JABBER_FEAT_DISCO_ITEMS);
+ m_proto->m_ThreadInfo->send(iq);
+
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, pInfo->GetIqId());
+ }
+ else
+ sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_FAIL,
+ TranslateT("Jabber Error"),
+ TranslateT("Please specify group chat directory first."),
+ L"");
}
- else
- sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_FAIL,
- TranslateT("Jabber Error"),
- TranslateT("Please specify group chat directory first."),
- L"");
+ break;
}
break;
- }
- break;
-
- case IDC_BOOKMARKS:
- {
- HMENU hMenu = CreatePopupMenu();
- LISTFOREACH(i, m_proto, LIST_BOOKMARK)
+ case IDC_BOOKMARKS:
{
- JABBER_LIST_ITEM *item = nullptr;
- if (item = m_proto->ListGetItemPtrFromIndex(i))
- if (!mir_wstrcmp(item->type, L"conference"))
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)item, item->name);
- }
- AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)-1, TranslateT("Bookmarks..."));
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel"));
-
- RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BOOKMARKS), &rc);
- CheckDlgButton(m_hwnd, IDC_BOOKMARKS, BST_CHECKED);
- int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
- CheckDlgButton(m_hwnd, IDC_BOOKMARKS, BST_UNCHECKED);
- DestroyMenu(hMenu);
-
- if (res == -1)
- m_proto->OnMenuHandleBookmarks(0, 0);
- else if (res) {
- JABBER_LIST_ITEM *item = (JABBER_LIST_ITEM *)res;
- wchar_t *room = NEWWSTR_ALLOCA(item->jid);
- if (room) {
- wchar_t *server = wcschr(room, '@');
- if (server) {
- *server++ = 0;
-
- SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_SERVER, CBN_EDITCHANGE), (LPARAM)GetDlgItem(m_hwnd, IDC_SERVER));
-
- SetDlgItemText(m_hwnd, IDC_SERVER, server);
- SetDlgItemText(m_hwnd, IDC_ROOM, room);
- SetDlgItemText(m_hwnd, IDC_NICK, item->nick);
- SetDlgItemText(m_hwnd, IDC_PASSWORD, item->password);
+ HMENU hMenu = CreatePopupMenu();
+
+ LISTFOREACH(i, m_proto, LIST_BOOKMARK)
+ {
+ JABBER_LIST_ITEM *item = nullptr;
+ if (item = m_proto->ListGetItemPtrFromIndex(i))
+ if (!mir_wstrcmp(item->type, L"conference"))
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)item, item->name);
+ }
+ AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)-1, TranslateT("Bookmarks..."));
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel"));
+
+ RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BOOKMARKS), &rc);
+ CheckDlgButton(m_hwnd, IDC_BOOKMARKS, BST_CHECKED);
+ int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
+ CheckDlgButton(m_hwnd, IDC_BOOKMARKS, BST_UNCHECKED);
+ DestroyMenu(hMenu);
+
+ if (res == -1)
+ m_proto->OnMenuHandleBookmarks(0, 0);
+ else if (res) {
+ JABBER_LIST_ITEM *item = (JABBER_LIST_ITEM *)res;
+ wchar_t *room = NEWWSTR_ALLOCA(item->jid);
+ if (room) {
+ wchar_t *server = wcschr(room, '@');
+ if (server) {
+ *server++ = 0;
+
+ SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_SERVER, CBN_EDITCHANGE), (LPARAM)GetDlgItem(m_hwnd, IDC_SERVER));
+
+ SetDlgItemText(m_hwnd, IDC_SERVER, server);
+ SetDlgItemText(m_hwnd, IDC_ROOM, room);
+ SetDlgItemText(m_hwnd, IDC_NICK, item->nick);
+ SetDlgItemText(m_hwnd, IDC_PASSWORD, item->password);
+ }
}
}
}
+ break;
+
+ case IDC_RECENT1:
+ case IDC_RECENT2:
+ case IDC_RECENT3:
+ case IDC_RECENT4:
+ case IDC_RECENT5:
+ JabberGcRecentInfo info(m_proto, LOWORD(wParam) - IDC_RECENT1);
+ info.fillForm(m_hwnd);
+ if (GetAsyncKeyState(VK_CONTROL))
+ break;
+
+ OnBtnOk(nullptr);
+ Close();
}
break;
- case IDC_RECENT1:
- case IDC_RECENT2:
- case IDC_RECENT3:
- case IDC_RECENT4:
- case IDC_RECENT5:
- JabberGcRecentInfo info(m_proto, LOWORD(wParam) - IDC_RECENT1);
- info.fillForm(m_hwnd);
- if (GetAsyncKeyState(VK_CONTROL))
- break;
-
- OnBtnOk(nullptr);
- Close();
+ case WM_JABBER_CHECK_ONLINE:
+ if (!m_proto->m_bJabberOnline)
+ EndDialog(m_hwnd, 0);
+ break;
}
- break;
- case WM_JABBER_CHECK_ONLINE:
- if (!m_proto->m_bJabberOnline)
- EndDialog(m_hwnd, 0);
- break;
+ return CSuper::DlgProc(msg, wParam, lParam);
}
-
- return CSuper::DlgProc(msg, wParam, lParam);
-}
+};
void CJabberProto::GroupchatJoinRoomByJid(HWND, wchar_t *jid)
{
|