From b3cbd75fb723cb396ad49b528e39df0b25c4c3f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 4 Jun 2014 18:26:00 +0000 Subject: code reordering git-svn-id: http://svn.miranda-ng.org/main/trunk@9413 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/options.cpp | 135 ++++++++++++++-------------- plugins/TabSRMM/src/chat/services.cpp | 1 - plugins/TabSRMM/src/generic_msghandlers.cpp | 19 ++-- plugins/TabSRMM/src/hotkeyhandler.cpp | 8 +- plugins/TabSRMM/src/mim.cpp | 15 ++-- plugins/TabSRMM/src/msgdialog.cpp | 8 +- plugins/TabSRMM/src/msgdlgutils.cpp | 45 ++++------ plugins/TabSRMM/src/sendqueue.cpp | 66 +++++++------- plugins/TabSRMM/src/sendqueue.h | 4 +- plugins/TabSRMM/src/utils.h | 4 +- 10 files changed, 138 insertions(+), 167 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 43d9ad6537..8703a7566d 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -829,80 +829,73 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM || LOWORD(wParam) == IDC_LOGTIMESTAMP) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; + // open the base directory for MUC logs, using a standard file selector + // dialog. Simply allows the user to view what log files are there + // and possibly delete archived logs. switch (LOWORD(wParam)) { - /* - * open the base directory for MUC logs, using a standard file selector - * dialog. Simply allows the user to view what log files are there - * and possibly delete archived logs. - */ - case IDC_MUC_OPENLOGBASEDIR: { - OPENFILENAME ofn = {0}; - TCHAR tszReturnName[MAX_PATH]; - TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10]; - TCHAR tszTemp[MAX_PATH + 20], *p = 0, *p1 = 0; - - mir_sntprintf(tszTemp, MAX_PATH + 20, _T("%s"), g_Settings.pszLogDir); - - p = tszTemp; - while(*p && (*p == '\\' || *p == '.')) - p++; - - if (*p) { - if ((p1 = _tcschr(p, '\\'))) - *p1 = 0; - } + case IDC_MUC_OPENLOGBASEDIR: + { + TCHAR tszTemp[MAX_PATH + 20]; + mir_sntprintf(tszTemp, MAX_PATH + 20, _T("%s"), g_Settings.pszLogDir); - mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s%s"), M.getChatLogPath(), p); - if (PathFileExists(tszInitialDir)) - ofn.lpstrInitialDir = tszInitialDir; - else { - mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s"), M.getChatLogPath()); + TCHAR *p = tszTemp; + while(*p && (*p == '\\' || *p == '.')) + p++; + + if (*p) + if (TCHAR *p1 = _tcschr(p, '\\')) + *p1 = 0; + + TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10]; + mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s%s"), M.getChatLogPath(), p); + if (!PathFileExists(tszInitialDir)) + mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s"), M.getChatLogPath()); + + TCHAR tszReturnName[MAX_PATH]; tszReturnName[0] = 0; + mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All Files"), 0, 0, 0); + + OPENFILENAME ofn = { 0 }; ofn.lpstrInitialDir = tszInitialDir; + ofn.lpstrFilter = tszTemp; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.lpstrFile = tszReturnName; + ofn.nMaxFile = MAX_PATH; + ofn.nMaxFileTitle = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT; + ofn.lpstrDefExt = _T("log"); + GetOpenFileName(&ofn); } - - tszReturnName[0] = 0; - mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All Files"), 0, 0, 0); - - ofn.lpstrFilter = tszTemp; - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - ofn.hwndOwner = 0; - ofn.lpstrFile = tszReturnName; - ofn.nMaxFile = MAX_PATH; - ofn.nMaxFileTitle = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT; - ofn.lpstrDefExt = _T("log"); - GetOpenFileName(&ofn); break; - } - case IDC_FONTCHOOSE: { - TCHAR tszDirectory[MAX_PATH]; - LPITEMIDLIST idList; - LPMALLOC psMalloc; - BROWSEINFO bi = {0}; - - if (SUCCEEDED(CoGetMalloc(1, &psMalloc))) { - TCHAR tszTemp[MAX_PATH]; - bi.hwndOwner = hwndDlg; - bi.pszDisplayName = tszDirectory; - bi.lpszTitle = TranslateT("Select Folder"); - bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS; - bi.lpfn = BrowseCallbackProc; - bi.lParam = (LPARAM)tszDirectory; - - idList = SHBrowseForFolder(&bi); - if (idList) { - const TCHAR *szUserDir = M.getUserDir(); - SHGetPathFromIDList(idList, tszDirectory); - lstrcat(tszDirectory, _T("\\")); - M.pathToRelative(tszDirectory, tszTemp, const_cast(szUserDir)); - SetWindowText(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), lstrlen(tszTemp) > 1 ? tszTemp : DEFLOGFILENAME); + case IDC_FONTCHOOSE: + { + TCHAR tszDirectory[MAX_PATH]; + LPMALLOC psMalloc; + + if (SUCCEEDED(CoGetMalloc(1, &psMalloc))) { + BROWSEINFO bi = { 0 }; + bi.hwndOwner = hwndDlg; + bi.pszDisplayName = tszDirectory; + bi.lpszTitle = TranslateT("Select Folder"); + bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX | BIF_RETURNONLYFSDIRS; + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM)tszDirectory; + + LPITEMIDLIST idList = SHBrowseForFolder(&bi); + if (idList) { + const TCHAR *szUserDir = M.getUserDir(); + SHGetPathFromIDList(idList, tszDirectory); + lstrcat(tszDirectory, _T("\\")); + + TCHAR tszTemp[MAX_PATH]; + M.pathToRelative(tszDirectory, tszTemp, const_cast(szUserDir)); + SetWindowText(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), lstrlen(tszTemp) > 1 ? tszTemp : DEFLOGFILENAME); + } + psMalloc->Free(idList); + psMalloc->Release(); } - psMalloc->Free(idList); - psMalloc->Release(); } break; - } case IDC_LOGGING: Utils::enableDlgControl(hwndDlg, IDC_LOGDIRECTORY, IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED ? TRUE : FALSE); @@ -950,28 +943,32 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM pszText = (char *)mir_realloc(pszText, iLen + 1); GetDlgItemTextA(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen + 1); db_set_s(NULL, CHAT_MODULE, "LogTimestamp", pszText); - } else db_unset(NULL, CHAT_MODULE, "LogTimestamp"); + } + else db_unset(NULL, CHAT_MODULE, "LogTimestamp"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TIMESTAMP)); if (iLen > 0) { pszText = (char *)mir_realloc(pszText, iLen + 1); GetDlgItemTextA(hwndDlg, IDC_TIMESTAMP, pszText, iLen + 1); db_set_s(NULL, CHAT_MODULE, "HeaderTime", pszText); - } else db_unset(NULL, CHAT_MODULE, "HeaderTime"); + } + else db_unset(NULL, CHAT_MODULE, "HeaderTime"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_INSTAMP)); if (iLen > 0) { pszText = (char *)mir_realloc(pszText, iLen + 1); GetDlgItemTextA(hwndDlg, IDC_INSTAMP, pszText, iLen + 1); db_set_s(NULL, CHAT_MODULE, "HeaderIncoming", pszText); - } else db_unset(NULL, CHAT_MODULE, "HeaderIncoming"); + } + else db_unset(NULL, CHAT_MODULE, "HeaderIncoming"); iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_OUTSTAMP)); if (iLen > 0) { pszText = (char *)mir_realloc(pszText, iLen + 1); GetDlgItemTextA(hwndDlg, IDC_OUTSTAMP, pszText, iLen + 1); db_set_s(NULL, CHAT_MODULE, "HeaderOutgoing", pszText); - } else db_unset(NULL, CHAT_MODULE, "HeaderOutgoing"); + } + else db_unset(NULL, CHAT_MODULE, "HeaderOutgoing"); iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_GETPOS, 0, 0); db_set_w(NULL, CHAT_MODULE, "LogLimit", (WORD)iLen); diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 70f6a16088..722d902956 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -42,7 +42,6 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT if (hContact != 0 && M.GetByte("limittabs", 0) && !_tcsncmp(pContainer->szName, _T("default"), 6)) { if ((pContainer = FindMatchingContainer(_T("default"), hContact)) == NULL) { TCHAR szName[CONTAINER_NAMELEN + 1]; - mir_sntprintf(szName, CONTAINER_NAMELEN, _T("default")); if ((pContainer = CreateContainer(szName, CNT_CREATEFLAG_CLONED, hContact)) == NULL) return 0; diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 7b23100b3c..8e664f85a0 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -35,33 +35,25 @@ */ void TSAPI DM_SaveLogAsRTF(const TWindowData *dat) { - TCHAR szFilename[MAX_PATH]; - OPENFILENAME ofn = {0}; - EDITSTREAM stream = { 0 }; - TCHAR szFilter[MAX_PATH]; - if (dat && dat->hwndIEView != 0) { - IEVIEWEVENT event = {0}; - - event.cbSize = sizeof(IEVIEWEVENT); + IEVIEWEVENT event = { sizeof(event) }; event.hwnd = dat->hwndIEView; event.hContact = dat->hContact; event.iType = IEE_SAVE_DOCUMENT; - event.dwFlags = 0; - event.count = 0; - event.codepage = 0; CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event); } else if (dat) { - TCHAR szInitialDir[MAX_PATH + 2]; - + TCHAR szFilter[MAX_PATH], szFilename[MAX_PATH]; mir_sntprintf(szFilter, SIZEOF(szFilter), _T("%s%c*.rtf%c%c"), TranslateT("Rich Edit file"), 0, 0, 0); mir_sntprintf(szFilename, MAX_PATH, _T("%s.rtf"), dat->cache->getNick()); Utils::sanitizeFilename(szFilename); + TCHAR szInitialDir[MAX_PATH + 2]; mir_sntprintf(szInitialDir, MAX_PATH, _T("%s%s\\"), M.getDataPath(), _T("\\Saved message logs")); CreateDirectoryTreeT(szInitialDir); + + OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = dat->hwnd; ofn.lpstrFile = szFilename; @@ -71,6 +63,7 @@ void TSAPI DM_SaveLogAsRTF(const TWindowData *dat) ofn.Flags = OFN_HIDEREADONLY; ofn.lpstrDefExt = _T("rtf"); if (GetSaveFileName(&ofn)) { + EDITSTREAM stream = { 0 }; stream.dwCookie = (DWORD_PTR)szFilename; stream.dwError = 0; stream.pfnCallback = Utils::StreamOut; diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 8f06a703b7..d269befbeb 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -515,14 +515,14 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendJob *job = sendQueue->getJobByIndex((int)wParam); ACKDATA ack = {0}; - ack.hContact = job->hOwner; + ack.hContact = job->hContact; ack.hProcess = job->hSendId; ack.type = ACKTYPE_MESSAGE; ack.result = ACKRESULT_SUCCESS; - if (job->hOwner && job->iAcksNeeded && job->hOwner && job->iStatus == SendQueue::SQ_INPROGRESS) { - if (IsWindow(job->hwndOwner)) - ::SendMessage(job->hwndOwner, HM_EVENTSENT, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack); + if (job->hContact && job->iAcksNeeded && job->hContact && job->iStatus == SendQueue::SQ_INPROGRESS) { + if (IsWindow(job->hOwnerWnd)) + ::SendMessage(job->hOwnerWnd, HM_EVENTSENT, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack); else sendQueue->ackMessage(0, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack); } diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 57bae214e2..3df8f93aaa 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -442,13 +442,13 @@ int CMimAPI::ProtoAck(WPARAM wParam, LPARAM lParam) MCONTACT hMeta = db_mc_getMeta(pAck->hContact); for (int j = 0; j < SendQueue::NR_SENDJOBS; j++) { SendJob &p = jobs[j]; - if (pAck->hProcess == p.hSendId && pAck->hContact == p.hOwner) { - TWindowData *dat = p.hwndOwner ? (TWindowData*)GetWindowLongPtr(p.hwndOwner, GWLP_USERDATA) : NULL; + if (pAck->hProcess == p.hSendId && pAck->hContact == p.hContact) { + TWindowData *dat = p.hOwnerWnd ? (TWindowData*)GetWindowLongPtr(p.hOwnerWnd, GWLP_USERDATA) : NULL; if (dat == NULL) { sendQueue->ackMessage(NULL, (WPARAM)MAKELONG(j, i), lParam); return 0; } - if (dat->hContact == p.hOwner || dat->hContact == hMeta) { + if (dat->hContact == p.hContact || dat->hContact == hMeta) { iFound = j; break; } @@ -459,7 +459,7 @@ int CMimAPI::ProtoAck(WPARAM wParam, LPARAM lParam) if (iFound == SendQueue::NR_SENDJOBS) // no matching send info found in the queue sendLater->processAck(pAck); else // try to find the process handle in the list of open send later jobs - SendMessage(jobs[iFound].hwndOwner, HM_EVENTSENT, (WPARAM)MAKELONG(iFound, i), lParam); + SendMessage(jobs[iFound].hOwnerWnd, HM_EVENTSENT, (WPARAM)MAKELONG(iFound, i), lParam); } return 0; } @@ -596,10 +596,9 @@ int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM lParam) bAllowAutoCreate = true; else { char *szProto = GetContactProto(hContact); - if (szProto && !strcmp(szProto, META_PROTO)) { - MCONTACT hSubconttact = db_mc_getMostOnline(hContact); - szProto = GetContactProto(hSubconttact); - } + if (szProto && !strcmp(szProto, META_PROTO)) + szProto = GetContactProto(db_mc_getMostOnline(hContact)); + if (szProto) { DWORD dwStatus = (DWORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); if (dwStatus == 0 || dwStatus <= ID_STATUS_OFFLINE || ((1 << (dwStatus - ID_STATUS_ONLINE)) & dwStatusMask)) // should never happen, but... diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index b3b6ee785e..3de6b4a4cd 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2569,10 +2569,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->cache->saveHistory(0, 0); if (dat->iCurrentQueueError >= 0 && dat->iCurrentQueueError < SendQueue::NR_SENDJOBS) { SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError); - if (job->hSendId == 0 && job->hOwner == 0) + if (job->hSendId == 0 && job->hContact == 0) break; - job->hSendId = (HANDLE)CallContactService(job->hOwner, PSS_MESSAGE, + job->hSendId = (HANDLE)CallContactService(job->hContact, PSS_MESSAGE, (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->szSendBuffer); resent++; } @@ -3435,7 +3435,7 @@ quote_from_last: SendJob *jobs = sendQueue->getJobByIndex(0); for (int i = 0; i < SendQueue::NR_SENDJOBS; i++) { - if (jobs[i].hOwner == dat->hContact) { + if (jobs[i].hContact == dat->hContact) { if (jobs[i].iStatus >(unsigned)SendQueue::SQ_INPROGRESS) sendQueue->clearJob(i); @@ -3443,7 +3443,7 @@ quote_from_last: // the hwndOwner is set to 0 because the window handle is now no longer valid. // Response for such a job is still silently handled by AckMessage() (sendqueue.c) if (jobs[i].iStatus == (unsigned)SendQueue::SQ_INPROGRESS) - jobs[i].hwndOwner = 0; + jobs[i].hOwnerWnd = 0; } } } diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 5bdb343f03..24005d3032 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -72,10 +72,8 @@ BOOL TSAPI IsCustomEvent(int eventType) return TRUE; } -/* - * reorder tabs within a container. fSavePos indicates whether the new position should be saved to the - * contacts db record (if so, the container will try to open the tab at the saved position later) - */ +// reorder tabs within a container. fSavePos indicates whether the new position should be saved to the +// contacts db record (if so, the container will try to open the tab at the saved position later) void TSAPI RearrangeTab(HWND hwndDlg, const TWindowData *dat, int iMode, BOOL fSavePos) { @@ -131,11 +129,9 @@ static UINT_PTR CALLBACK OpenFileSubclass(HWND hwnd, UINT msg, WPARAM wParam, LP return FALSE; } -/* - * saves a contact picture to disk - * takes hbm (bitmap handle) and bool isOwnPic (1 == save the picture as your own avatar) - * requires AVS and ADVAIMG services (Miranda 0.7+) - */ +// saves a contact picture to disk +// takes hbm (bitmap handle) and bool isOwnPic (1 == save the picture as your own avatar) +// requires AVS and ADVAIMG services (Miranda 0.7+) static void SaveAvatarToFile(TWindowData *dat, HBITMAP hbm, int isOwnPic) { @@ -168,21 +164,19 @@ static void SaveAvatarToFile(TWindowData *dat, HBITMAP hbm, int isOwnPic) mir_sntprintf(szBaseName, MAX_PATH, _T("%s_%s"), dat->cache->getNick(), szTimestamp); mir_sntprintf(szFinalFilename, MAX_PATH, _T("%s.png"), szBaseName); - OPENFILENAME ofn = {0}; - ofn.lpstrDefExt = _T("png"); - /* - * do not allow / or \ or % in the filename - */ + // do not allow / or \ or % in the filename Utils::sanitizeFilename(szFinalFilename); TCHAR filter[MAX_PATH]; mir_sntprintf(filter, SIZEOF(filter), _T("%s%c*.bmp;*.png;*.jpg;*.gif%c%c"), TranslateT("Image files"), 0, 0, 0); + + OPENFILENAME ofn = { 0 }; + ofn.lpstrDefExt = _T("png"); ofn.lpstrFilter = filter; ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ENABLESIZING | OFN_ENABLEHOOK; ofn.lpfnHook = OpenFileSubclass; ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = 0; ofn.lpstrFile = szFinalFilename; ofn.lpstrInitialDir = szFinalPath; ofn.nMaxFile = MAX_PATH; @@ -204,10 +198,8 @@ static void SaveAvatarToFile(TWindowData *dat, HBITMAP hbm, int isOwnPic) } } -/* - * flash a tab icon if mode = true, otherwise restore default icon - * store flashing state into bState - */ +// flash a tab icon if mode = true, otherwise restore default icon +// store flashing state into bState void TSAPI FlashTab(TWindowData *dat, HWND hwndTab, int iTabindex, BOOL *bState, BOOL mode, HICON origImage) { @@ -224,10 +216,8 @@ void TSAPI FlashTab(TWindowData *dat, HWND hwndTab, int iTabindex, BOOL *bState, dat->pContainer->SideBar->updateSession(dat); } -/* - * calculates avatar layouting, based on splitter position to find the optimal size - * for the avatar w/o disturbing the toolbar too much. - */ +// calculates avatar layouting, based on splitter position to find the optimal size +// for the avatar w/o disturbing the toolbar too much. void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo) { @@ -253,7 +243,7 @@ void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo) GetClientRect(dat->hwnd, &rc); if (dat->dwFlags & MWF_WASBACKGROUNDCREATE || dat->pContainer->dwFlags & CNT_DEFERREDCONFIGURE || dat->pContainer->dwFlags & CNT_CREATE_MINIMIZED || IsIconic(dat->pContainer->hwnd)) - return; // at this stage, the layout is not yet ready... + return; // at this stage, the layout is not yet ready... if (bminfo->bmWidth == 0 || bminfo->bmHeight == 0) picAspect = 1.0; @@ -2388,11 +2378,11 @@ void TSAPI SendHBitmapAsFile(const TWindowData *dat, HBITMAP hbmp) } } if (filename[0] == 0) { // prompting to save - OPENFILENAME dlg; - dlg.lStructSize = sizeof(dlg); - dlg.hwndOwner = NULL; //dat->hwnd; TCHAR filter[MAX_PATH]; mir_sntprintf(filter, SIZEOF(filter), _T("%s%c*.jpg%c%c"), TranslateT("JPEG-compressed images"), 0, 0, 0); + + OPENFILENAME dlg; + dlg.lStructSize = sizeof(dlg); dlg.lpstrFilter = filter; dlg.nFilterIndex = 1; dlg.lpstrFile = filename; @@ -2402,6 +2392,7 @@ void TSAPI SendHBitmapAsFile(const TWindowData *dat, HBITMAP hbmp) if (!GetSaveFileName(&dlg)) return; } + IMGSRVC_INFO ii; ii.cbSize = sizeof(ii); ii.hbm = hbmp; diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 8e8610bc3a..7a5a5a559c 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -44,7 +44,7 @@ int SendQueue::findNextFailed(const TWindowData *dat) const { if (dat) for (int i=0; i < NR_SENDJOBS; i++) - if (m_jobs[i].hOwner == dat->hContact && m_jobs[i].iStatus == SQ_ERROR) + if (m_jobs[i].hContact == dat->hContact && m_jobs[i].iStatus == SQ_ERROR) return i; return -1; @@ -82,9 +82,9 @@ int SendQueue::addTo(TWindowData *dat, const int iLen, int dwFlags) * find a mir_free entry in the send queue... */ for (i=0; i < NR_SENDJOBS; i++) { - if (m_jobs[i].hOwner != 0 || m_jobs[i].iStatus != 0) { + if (m_jobs[i].hContact != 0 || m_jobs[i].iStatus != 0) { // this entry is used, check if it's orphaned and can be removed... - if (m_jobs[i].hwndOwner && IsWindow(m_jobs[i].hwndOwner)) // window exists, do not reuse it + if (m_jobs[i].hOwnerWnd && IsWindow(m_jobs[i].hOwnerWnd)) // window exists, do not reuse it continue; if (time(NULL) - m_jobs[i].dwTime < 120) // non-acked entry, but not old enough, don't re-use it continue; @@ -152,7 +152,7 @@ static void DoSplitSendW(LPVOID param) WCHAR *wszSaved, savedChar; int iCur = 0, iSavedCur = 0, i; BOOL fSplitting = TRUE; - MCONTACT hContact = job->hOwner; + MCONTACT hContact = job->hContact; DWORD dwFlags = job->dwFlags; int chunkSize = job->chunkSize / 2; char *szProto = GetContactProto(hContact); @@ -227,7 +227,7 @@ static void DoSplitSendA(LPVOID param) char *szBegin, *szTemp, *szSaved, savedChar; int iLen, iCur = 0, iSavedCur = 0, i; BOOL fSplitting = TRUE; - MCONTACT hContact = job->hOwner; + MCONTACT hContact = job->hContact; DWORD dwFlags = job->dwFlags; int chunkSize = job->chunkSize; @@ -318,9 +318,9 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) int iJobs = 0; int iMinLength = 0; - m_jobs[iEntry].hOwner = ccActive->getActiveContact(); m_jobs[iEntry].iStatus = SQ_INPROGRESS; - m_jobs[iEntry].hwndOwner = hwndDlg; + m_jobs[iEntry].hContact = ccActive->getActiveContact(); + m_jobs[iEntry].hOwnerWnd = hwndDlg; int iSendLength = getSendLength(iEntry, dat->sendMode); @@ -374,8 +374,8 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) if (!fSplit) goto send_unsplitted; - m_jobs[iEntry].hOwner = ccActive->getActiveContact(); - m_jobs[iEntry].hwndOwner = hwndDlg; + m_jobs[iEntry].hContact = ccActive->getActiveContact(); + m_jobs[iEntry].hOwnerWnd = hwndDlg; m_jobs[iEntry].iStatus = SQ_INPROGRESS; m_jobs[iEntry].iAcksNeeded = 1; m_jobs[iEntry].chunkSize = dat->nMax; @@ -394,8 +394,8 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) send_unsplitted: - m_jobs[iEntry].hOwner = ccActive->getActiveContact(); - m_jobs[iEntry].hwndOwner = hwndDlg; + m_jobs[iEntry].hContact = ccActive->getActiveContact(); + m_jobs[iEntry].hOwnerWnd = hwndDlg; m_jobs[iEntry].iStatus = SQ_INPROGRESS; m_jobs[iEntry].iAcksNeeded = 1; if (dat->sendMode & SMODE_SENDLATER) { @@ -554,7 +554,7 @@ void SendQueue::showErrorControls(TWindowData *dat, const int showCmd) const SendMessage(hwndDlg, WM_SIZE, 0, 0); DM_ScrollToBottom(dat, 0, 1); - if (m_jobs[0].hOwner != 0) + if (m_jobs[0].hContact != 0) EnableSending(dat, TRUE); } @@ -678,10 +678,8 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam) showErrorControls(dat, FALSE); } } - /* - * we must discard this job, because there is no message window open to handle the - * error properly. But we display a tray notification to inform the user about the problem. - */ + // we must discard this job, because there is no message window open to handle the + // error properly. But we display a tray notification to inform the user about the problem. else goto inform_and_discard; } @@ -689,10 +687,8 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam) if (ack->result == ACKRESULT_FAILED) { if (dat) { - /* - * "hard" errors are handled differently in multisend. There is no option to retry - once failed, they - * are discarded and the user is notified with a small log message. - */ + // "hard" errors are handled differently in multisend. There is no option to retry - once failed, they + // are discarded and the user is notified with a small log message. if (!nen_options.iNoSounds && !(m_pContainer->dwFlags & CNT_NOSOUND)) SkinPlaySound("SendError"); @@ -707,7 +703,7 @@ int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam) } inform_and_discard: - _DebugPopup(job.hOwner, TranslateT("A message delivery has failed after the contacts chat window was closed. You may want to resend the last message")); + _DebugPopup(job.hContact, TranslateT("A message delivery has failed after the contacts chat window was closed. You may want to resend the last message")); clearJob(iFound); return 0; } @@ -715,16 +711,16 @@ inform_and_discard: DBEVENTINFO dbei = { sizeof(dbei) }; dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT; - dbei.szModule = GetContactProto(job.hOwner); + dbei.szModule = GetContactProto(job.hContact); dbei.timestamp = time(NULL); dbei.cbBlob = lstrlenA(job.szSendBuffer) + 1; if (dat) dat->cache->updateStats(TSessionStats::BYTES_SENT, dbei.cbBlob - 1); else { - CContactCache *c = CContactCache::getContactCache(job.hOwner); - if (c) - c->updateStats(TSessionStats::BYTES_SENT, dbei.cbBlob - 1); + CContactCache *cc = CContactCache::getContactCache(job.hContact); + if (cc) + cc->updateStats(TSessionStats::BYTES_SENT, dbei.cbBlob - 1); } if (job.dwFlags & PREF_UNICODE) @@ -735,17 +731,17 @@ inform_and_discard: dbei.flags |= DBEF_UTF; dbei.pBlob = (PBYTE)job.szSendBuffer; - MessageWindowEvent evt = { sizeof(evt), (int)job.hSendId, job.hOwner, &dbei }; + MessageWindowEvent evt = { sizeof(evt), (int)job.hSendId, job.hContact, &dbei }; NotifyEventHooks(PluginConfig.m_event_WriteEvent, 0, (LPARAM)&evt); job.szSendBuffer = (char*)dbei.pBlob; - HANDLE hNewEvent = db_event_add(job.hOwner, &dbei); + HANDLE hNewEvent = db_event_add(job.hContact, &dbei); if (m_pContainer) if (!nen_options.iNoSounds && !(m_pContainer->dwFlags & CNT_NOSOUND)) SkinPlaySound("SendMsg"); - if (dat && (job.hOwner == dat->hContact)) + if (dat && job.hContact == dat->hContact) if (dat->hDbEventFirst == NULL) { dat->hDbEventFirst = hNewEvent; SendMessage(dat->hwnd, DM_REMAKELOG, 0, 0); @@ -770,7 +766,6 @@ inform_and_discard: int iNextFailed = findNextFailed(dat); if (iNextFailed >= 0 && !(dat->dwFlags & MWF_ERRORSTATE)) handleError(dat, iNextFailed); - //MAD: close on send mode else { if (M.GetByte("AutoClose", 0)) { if (M.GetByte("adv_AutoClose_2", 0)) @@ -779,7 +774,6 @@ inform_and_discard: SendMessage(dat->pContainer->hwnd, WM_CLOSE, 0, 0); } } - //MAD_ } return 0; } @@ -861,7 +855,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b if (fIsSendLater) { mir_snprintf(tszMsg, required, "%s%s", job->szSendBuffer, utf_header); - db_set_s(hContact ? hContact : job->hOwner, "SendLater", szKeyName, tszMsg); + db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, tszMsg); } else { mir_snprintf(tszMsg, required, "%s%s", utf_header, job->szSendBuffer); @@ -883,19 +877,19 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, MCONTACT hContact, b mir_sntprintf(tszMsg, required, _T("%s%s"), tszHeader, wszMsg); char *utf = mir_utf8encodeT(tszMsg); if (fIsSendLater) - db_set_s(hContact ? hContact : job->hOwner, "SendLater", szKeyName, utf); + db_set_s(hContact ? hContact : job->hContact, "SendLater", szKeyName, utf); else sendLater->addJob(utf, hContact); mir_free(utf); mir_free(tszMsg); } if (fIsSendLater) { - int iCount = db_get_dw(hContact ? hContact : job->hOwner, "SendLater", "count", 0); + int iCount = db_get_dw(hContact ? hContact : job->hContact, "SendLater", "count", 0); iCount++; - db_set_dw(hContact ? hContact : job->hOwner, "SendLater", "count", iCount); - sendLater->addContact(hContact ? hContact : job->hOwner); + db_set_dw(hContact ? hContact : job->hContact, "SendLater", "count", iCount); + sendLater->addContact(hContact ? hContact : job->hContact); } - return(iJobIndex); + return iJobIndex; } return -1; } diff --git a/plugins/TabSRMM/src/sendqueue.h b/plugins/TabSRMM/src/sendqueue.h index 2cccff76f7..49341f718d 100644 --- a/plugins/TabSRMM/src/sendqueue.h +++ b/plugins/TabSRMM/src/sendqueue.h @@ -44,8 +44,8 @@ struct SendJob char *szSendBuffer; int iSendLength; // length of message in utf-8 octets (used to check maxlen) int sendCount; - MCONTACT hOwner; - HWND hwndOwner; + MCONTACT hContact; + HWND hOwnerWnd; unsigned iStatus; TCHAR szErrorMsg[128]; DWORD dwFlags; diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h index d2edbc9f6e..a3f83f42bc 100644 --- a/plugins/TabSRMM/src/utils.h +++ b/plugins/TabSRMM/src/utils.h @@ -108,8 +108,6 @@ public: template static size_t TSAPI CopyToClipBoard(T* _t, const HWND hwndOwner) { - HGLOBAL hData; - if (!OpenClipboard(hwndOwner) || _t == 0) return 0; @@ -118,7 +116,7 @@ public: size_t i = _s * (s->length() + 1); EmptyClipboard(); - hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, i); + HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, i); CopyMemory((void*)GlobalLock(hData), (void*)_t, i); GlobalUnlock(hData); -- cgit v1.2.3