From e5a52db1e9acd0dc80c7581f20bacf63e1d08722 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Mar 2014 12:30:35 +0000 Subject: fix for tabSRMM send queue git-svn-id: http://svn.miranda-ng.org/main/trunk@8555 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/contactcache.h | 2 +- plugins/TabSRMM/src/container.cpp | 2 +- plugins/TabSRMM/src/mim.cpp | 29 ++-- plugins/TabSRMM/src/sendlater.cpp | 344 +++++++++++++++---------------------- plugins/TabSRMM/src/sendqueue.cpp | 16 +- plugins/TabSRMM/src/sidebar.cpp | 2 +- plugins/TabSRMM/src/taskbar.cpp | 6 +- plugins/TabSRMM/src/utils.cpp | 8 +- 8 files changed, 170 insertions(+), 239 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/contactcache.h b/plugins/TabSRMM/src/contactcache.h index 141f93e52c..b0dc12e78e 100644 --- a/plugins/TabSRMM/src/contactcache.h +++ b/plugins/TabSRMM/src/contactcache.h @@ -77,7 +77,7 @@ struct CContactCache : public MZeroedObject const WORD getOldStatus() const { return m_wOldStatus; } const TCHAR* getNick() const { return m_szNick; } const MCONTACT getContact() const { return m_hContact; } - const MCONTACT getActiveContact() const { return m_isMeta ? cc->nDefault : m_hContact; } + const MCONTACT getActiveContact() const { return m_isMeta ? db_mc_getDefault(m_hContact) : m_hContact; } const DWORD getIdleTS() const { return m_idleTS; } const char* getProto() const { return cc->szProto; } const char* getActiveProto() const { return m_isMeta ? (m_szMetaProto ? m_szMetaProto : cc->szProto) : cc->szProto; } diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 8a630c4549..a3350ecc8d 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -1764,7 +1764,7 @@ panel_found: } SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, lParam); if (0 != hIconBig && reinterpret_cast(CALLSERVICE_NOTFOUND) != hIconBig) - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, reinterpret_cast(hIconBig)); + SendMessage(hwndDlg, WM_SETICON, ICON_BIG, LPARAM(hIconBig)); pContainer->hIcon = (lParam == (LPARAM)hIconMsg) ? STICK_ICON_MSG : 0; } return 0; diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index e858d37ff3..d7fc9f7b20 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -435,30 +435,25 @@ int CMimAPI::ProtoAck(WPARAM wParam, LPARAM lParam) return 0; HWND hwndDlg = 0; - int i=0, j, iFound = SendQueue::NR_SENDJOBS; + int i=0, iFound = SendQueue::NR_SENDJOBS; SendJob *jobs = sendQueue->getJobByIndex(0); if (pAck->type == ACKTYPE_MESSAGE) { - MCONTACT hOwner = db_mc_getMeta(pAck->hContact); - if (hOwner == 0) - hOwner = pAck->hContact; - - for (j = 0; j < SendQueue::NR_SENDJOBS; j++) { - if (pAck->hProcess == jobs[j].hSendId && hOwner == jobs[j].hOwner) { - TWindowData *dat = jobs[j].hwndOwner ? (TWindowData*)GetWindowLongPtr(jobs[j].hwndOwner, GWLP_USERDATA) : NULL; - if (dat) { - if (dat->hContact == jobs[j].hOwner) { - iFound = j; - break; - } - } else { // ack message w/o an open window... + 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 (dat == NULL) { sendQueue->ackMessage(NULL, (WPARAM)MAKELONG(j, i), lParam); return 0; } + if (dat->hContact == p.hOwner || dat->hContact == hMeta) { + iFound = j; + break; + } } - if (iFound == SendQueue::NR_SENDJOBS) // no mathing entry found in this queue entry.. continue - continue; - else + if (iFound != SendQueue::NR_SENDJOBS) // no mathing entry found in this queue entry.. continue break; } if (iFound == SendQueue::NR_SENDJOBS) // no matching send info found in the queue diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 9845968dbc..be92ccc2ce 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -33,28 +33,24 @@ CSendLater *sendLater = 0; -/* - * implementation of the CSendLaterJob class - */ - +// implementation of the CSendLaterJob class +// CSendLaterJob::CSendLaterJob() { ZeroMemory(this, sizeof(CSendLaterJob)); fSuccess = false; } -/** - * return true if this job is persistent (saved to the database). - * such a job will survive a restart of Miranda - */ +// return true if this job is persistent (saved to the database). +// such a job will survive a restart of Miranda +// bool CSendLaterJob::isPersistentJob() { return(szId[0] == 'S' ? true : false); } -/** - * check conditions for deletion - */ +// check conditions for deletion +// bool CSendLaterJob::mustDelete() { if (fSuccess) @@ -66,9 +62,8 @@ bool CSendLaterJob::mustDelete() return false; } -/** - * clean database entries for a persistent job (currently: manual send later jobs) - */ +// clean database entries for a persistent job (currently: manual send later jobs) +// void CSendLaterJob::cleanDB() { if (isPersistentJob()) { @@ -79,18 +74,16 @@ void CSendLaterJob::cleanDB() if (iCount) iCount--; db_set_dw(hContact, "SendLater", "count", iCount); - /* - * delete flags - */ + + // delete flags mir_snprintf(szKey, 100, "$%s", szId); db_unset(hContact, "SendLater", szKey); } } -/** - * read flags for a persistent jobs from the db - * flag key name is the job id with a "$" prefix. - */ +// read flags for a persistent jobs from the db +// flag key name is the job id with a "$" prefix. +// void CSendLaterJob::readFlags() { if (isPersistentJob()) { @@ -105,10 +98,9 @@ void CSendLaterJob::readFlags() } } -/** - * write flags for a persistent jobs from the db - * flag key name is the job id with a "$" prefix. - */ +// write flags for a persistent jobs from the db +// flag key name is the job id with a "$" prefix. +// void CSendLaterJob::writeFlags() { if (isPersistentJob()) { @@ -120,9 +112,8 @@ void CSendLaterJob::writeFlags() } } -/** - * delete a send later job - */ +// delete a send later job +// CSendLaterJob::~CSendLaterJob() { if (fSuccess || fFailed) { @@ -183,11 +174,10 @@ CSendLater::CSendLater() : m_fSuccessPopups = M.GetByte("qmgrSuccessPopups", 0) != 0; } -/** - * clear all open send jobs. Only called on system shutdown to remove - * the jobs from memory. Must _NOT_ delete any sendlater related stuff from - * the database (only successful sends may do this). - */ +// clear all open send jobs. Only called on system shutdown to remove +// the jobs from memory. Must _NOT_ delete any sendlater related stuff from +// the database (only successful sends may do this). +// CSendLater::~CSendLater() { if (m_hwndDlg) @@ -213,18 +203,16 @@ void CSendLater::startJobListProcess() Utils::enableDlgControl(m_hwndDlg, IDC_QMGR_LIST, false); } -/** - * checks if the current job in the timer-based process queue is subject - * for deletion (that is, it has failed or succeeded) - * - * if not, it will send the job and increment the list iterator. - * - * this method is called once per tick from the timer based scheduler in - * hotkeyhandler.cpp. - * - * returns true if more jobs are awaiting processing, false otherwise. - */ - +// checks if the current job in the timer-based process queue is subject +// for deletion (that is, it has failed or succeeded) +// +// if not, it will send the job and increment the list iterator. +// +// this method is called once per tick from the timer based scheduler in +// hotkeyhandler.cpp. +// +// returns true if more jobs are awaiting processing, false otherwise. +// bool CSendLater::processCurrentJob() { if (!m_sendLaterJobList.getCount() || m_currJob == -1) @@ -253,22 +241,20 @@ bool CSendLater::processCurrentJob() return true; } -/** - * stub used as enum proc for the database enumeration, collecting - * all entries in the SendLater module - * (static function) - */ +// stub used as enum proc for the database enumeration, collecting +// all entries in the SendLater module +// (static function) +// int _cdecl CSendLater::addStub(const char *szSetting, LPARAM lParam) { return(sendLater->addJob(szSetting, lParam)); } -/** - * Process a single contact from the list of contacts with open send later jobs - * enum the "SendLater" module and add all jobs to the list of open jobs. - * addJob() will deal with possible duplicates - * @param hContact HANDLE: contact's handle - */ +// Process a single contact from the list of contacts with open send later jobs +// enum the "SendLater" module and add all jobs to the list of open jobs. +// addJob() will deal with possible duplicates +// @param hContact HANDLE: contact's handle +// void CSendLater::processSingleContact(const MCONTACT hContact) { int iCount = db_get_dw(hContact, "SendLater", "count", 0); @@ -283,10 +269,9 @@ void CSendLater::processSingleContact(const MCONTACT hContact) } } -/** - * called periodically from a timer, check if new contacts were added - * and process them - */ +// called periodically from a timer, check if new contacts were added +// and process them +// void CSendLater::processContacts() { if (m_fAvail && m_sendLaterContactList.getCount() != 0) { @@ -297,17 +282,16 @@ void CSendLater::processContacts() } } -/** - * This function adds a new job to the list of messages to send unattended - * used by the send later feature and multisend - * - * @param szSetting is either the name of the database key for a send later - * job OR the utf-8 encoded message for a multisend job prefixed with - * a 'M+timestamp'. Send later job ids start with "S". - * - * @param lParam: a contact handle for which the job should be scheduled - * @return 0 on failure, 1 otherwise - */ +// This function adds a new job to the list of messages to send unattended +// used by the send later feature and multisend +// +// @param szSetting is either the name of the database key for a send later +// job OR the utf-8 encoded message for a multisend job prefixed with +// a 'M+timestamp'. Send later job ids start with "S". +// +// @param lParam: a contact handle for which the job should be scheduled +// @return 0 on failure, 1 otherwise +// int CSendLater::addJob(const char *szSetting, LPARAM lParam) { MCONTACT hContact = lParam; @@ -320,9 +304,7 @@ int CSendLater::addJob(const char *szSetting, LPARAM lParam) if (szSetting[0] != 'S' && szSetting[0] != 'M') return 0; - /* - * check for possible dupes - */ + // check for possible dupes for (int i=0; i < m_sendLaterJobList.getCount(); i++) { CSendLaterJob *p = m_sendLaterJobList[i]; if (p->hContact == hContact && !strcmp(p->szId, szSetting)) @@ -351,25 +333,18 @@ int CSendLater::addJob(const char *szSetting, LPARAM lParam) job->hContact = hContact; job->created = atol(&szSetting[1]); - char *szAnsi = 0; - wchar_t *szWchar = 0; - UINT required = 0; - int iLen = lstrlenA(szOrig_Utf); job->sendBuffer = reinterpret_cast(mir_alloc(iLen + 1)); strncpy(job->sendBuffer, szOrig_Utf, iLen); job->sendBuffer[iLen] = 0; - /* - * construct conventional send buffer - */ - - szAnsi = mir_utf8decodecp(szOrig_Utf, CP_ACP, &szWchar); + // construct conventional send buffer + wchar_t *szWchar = 0; + char *szAnsi = mir_utf8decodecp(szOrig_Utf, CP_ACP, &szWchar); iLen = lstrlenA(szAnsi); + UINT required = iLen + 1; if (szWchar) - required = iLen + 1 + ((lstrlenW(szWchar) + 1) * sizeof(wchar_t)); - else - required = iLen + 1; + required += ((lstrlenW(szWchar) + 1) * sizeof(wchar_t)); job->pBuf = (PBYTE)mir_calloc(required); @@ -388,19 +363,11 @@ int CSendLater::addJob(const char *szSetting, LPARAM lParam) return 1; } -/** - * Try to send an open job from the job list - * this is ONLY called from the WM_TIMER handler and should never be executed - * directly. - */ +// Try to send an open job from the job list +// this is ONLY called from the WM_TIMER handler and should never be executed directly. int CSendLater::sendIt(CSendLaterJob *job) { - MCONTACT hContact = job->hContact; time_t now = time(0); - DWORD dwFlags = 0; - DBVARIANT dbv = {0}; - const char *szProto = 0; - if (job->bCode == CSendLaterJob::JOB_HOLD || job->bCode == CSendLaterJob::JOB_DEFERRED || job->fSuccess || job->fFailed || job->lastSent > now) return 0; // this one is frozen or done (will be removed soon), don't process it now. @@ -410,10 +377,8 @@ int CSendLater::sendIt(CSendLaterJob *job) return 0; } - /* - * mark job as deferred (5 unsuccessful sends). Job will not be removed, but - * the user must manually reset it in order to trigger a new send attempt. - */ + // mark job as deferred (5 unsuccessful sends). Job will not be removed, but + // the user must manually reset it in order to trigger a new send attempt. if (job->iSendCount == 5) { job->bCode = CSendLaterJob::JOB_DEFERRED; return 0; @@ -422,8 +387,8 @@ int CSendLater::sendIt(CSendLaterJob *job) if (job->iSendCount > 0 && (now - job->lastSent < SENDLATER_RESEND_THRESHOLD)) return 0; // this one was sent, but probably failed. Resend it after a while - CContactCache *c = CContactCache::getContactCache(hContact); - if (!c) + CContactCache *c = CContactCache::getContactCache(job->hContact); + if (c == NULL) return 0; // should not happen if (!c->isValid()) { @@ -432,18 +397,15 @@ int CSendLater::sendIt(CSendLaterJob *job) return 0; // can happen (contact has been deleted). mark the job as failed } - hContact = c->getActiveContact(); - szProto = c->getActiveProto(); - + MCONTACT hContact = c->getActiveContact(); + const char *szProto = c->getActiveProto(); if (!hContact || szProto == 0) return 0; WORD wMyStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); WORD wContactStatus = c->getActiveStatus(); - /* - * status mode checks - */ + // status mode checks if (wMyStatus == ID_STATUS_OFFLINE) { job->bCode = CSendLaterJob::JOB_MYSTATUS; return 0; @@ -455,23 +417,12 @@ int CSendLater::sendIt(CSendLaterJob *job) } } - // RM: use offline only for protocols which doesn't support offline sending - // - but no protocol except facebook supports PF4_IMSENDOFFLINE so disabled at all - /*if (wContactStatus == ID_STATUS_OFFLINE) { - int pcaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0); - if (!(pcaps & PF4_IMSENDOFFLINE)) { - job->bCode = CSendLaterJob::JOB_STATUS; - return 0; - } - }*/ - - dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : PREF_UNICODE; - job->lastSent = now; job->iSendCount++; job->hTargetContact = hContact; job->bCode = CSendLaterJob::JOB_WAITACK; + DWORD dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : PREF_UNICODE; if (dwFlags & PREF_UTF) job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->sendBuffer); else @@ -479,12 +430,9 @@ int CSendLater::sendIt(CSendLaterJob *job) return 0; } -/* - * add a contact to the list of contacts having open send later jobs. - * This ist is periodically checked for new additions (processContacts()) - * and new jobs are created. - */ - +// add a contact to the list of contacts having open send later jobs. +// This is is periodically checked for new additions (processContacts()) +// and new jobs are created. void CSendLater::addContact(const MCONTACT hContact) { if (!m_fAvail) @@ -492,7 +440,7 @@ void CSendLater::addContact(const MCONTACT hContact) if (m_sendLaterContactList.getCount() == 0) { m_sendLaterContactList.insert((HANDLE)hContact); - m_last_sendlater_processed = 0; // force processing at next tick + m_last_sendlater_processed = 0; // force processing at next tick return; } @@ -504,16 +452,15 @@ void CSendLater::addContact(const MCONTACT hContact) return; m_sendLaterContactList.insert((HANDLE)hContact); - m_last_sendlater_processed = 0; // force processing at next tick + m_last_sendlater_processed = 0; // force processing at next tick } -/** - * process ACK messages for the send later job list. Called from the proto ack - * handler when it does not find a match in the normal send queue - * - * Add the message to the database and mark it as successful. The job will be - * removed later by the job list processing code. - */ +// process ACK messages for the send later job list. Called from the proto ack +// handler when it does not find a match in the normal send queue +// +// Add the message to the database and mark it as successful. The job will be +// removed later by the job list processing code. +// HANDLE CSendLater::processAck(const ACKDATA *ack) { if (m_sendLaterJobList.getCount() == 0 || !m_fAvail) @@ -545,48 +492,34 @@ HANDLE CSendLater::processAck(const ACKDATA *ack) return 0; } -/* - * UI stuff (dialog procedures for the queue manager dialog - */ - +// UI stuff (dialog procedures for the queue manager dialog void CSendLater::qMgrUpdate(bool fReEnable) { if (m_hwndDlg) { if (fReEnable) Utils::enableDlgControl(m_hwndDlg, IDC_QMGR_LIST, true); - ::SendMessage(m_hwndDlg, WM_USER + 100, 0, 0); // if qmgr is open, tell it to update + ::SendMessage(m_hwndDlg, WM_USER + 100, 0, 0); // if qmgr is open, tell it to update } } LRESULT CSendLater::qMgrAddFilter(const MCONTACT hContact, const TCHAR* tszNick) { - LRESULT lr; - - lr = ::SendMessage(m_hwndFilter, CB_FINDSTRING, 0, reinterpret_cast(tszNick)); + LRESULT lr = ::SendMessage(m_hwndFilter, CB_FINDSTRING, 0, LPARAM(tszNick)); if (lr == CB_ERR) { - lr = ::SendMessage(m_hwndFilter, CB_INSERTSTRING, -1, reinterpret_cast(tszNick)); + lr = ::SendMessage(m_hwndFilter, CB_INSERTSTRING, -1, LPARAM(tszNick)); ::SendMessage(m_hwndFilter, CB_SETITEMDATA, lr, hContact); if (hContact == m_hFilter) m_sel = lr; } - return(m_sel); + return m_sel; } -/** - * fills the list of jobs with current contents of the job queue - * filters by m_hFilter (contact handle) - * - */ +// fills the list of jobs with current contents of the job queue +// filters by m_hFilter (contact handle) +// void CSendLater::qMgrFillList(bool fClear) { - LVITEM lvItem = {0}; - unsigned uIndex = 0; - CContactCache* c = 0; - TCHAR* formatTime = _T("%Y.%m.%d - %H:%M"); - TCHAR tszTimestamp[30]; - TCHAR tszStatus[20]; - const TCHAR* tszStatusText = 0; - BYTE bCode = '-'; + TCHAR *formatTime = _T("%Y.%m.%d - %H:%M"); if (fClear) { ::SendMessage(m_hwndList, LVM_DELETEALLITEMS, 0, 0); @@ -595,46 +528,51 @@ void CSendLater::qMgrFillList(bool fClear) m_sel = 0; ::SendMessage(m_hwndFilter, CB_INSERTSTRING, -1, - reinterpret_cast(TranslateT(""))); + LPARAM(TranslateT(""))); ::SendMessage(m_hwndFilter, CB_SETITEMDATA, 0, 0); + LVITEM lvItem = { 0 }; lvItem.cchTextMax = 255; - for (int i=0; i < m_sendLaterJobList.getCount(); i++) { + BYTE bCode = '-'; + unsigned uIndex = 0; + for (int i = 0; i < m_sendLaterJobList.getCount(); i++) { CSendLaterJob *p = m_sendLaterJobList[i]; - c = CContactCache::getContactCache(p->hContact); + CContactCache *c = CContactCache::getContactCache(p->hContact); if (c) { - const TCHAR* tszNick = c->getNick(); - TCHAR tszBuf[255]; - + const TCHAR *tszNick = c->getNick(); if (m_hFilter && m_hFilter != p->hContact) { qMgrAddFilter(c->getContact(), tszNick); continue; } + lvItem.mask = LVIF_TEXT|LVIF_PARAM; + TCHAR tszBuf[255]; mir_sntprintf(tszBuf, 255, _T("%s [%s]"), tszNick, c->getRealAccount()); lvItem.pszText = tszBuf; lvItem.iItem = uIndex++; lvItem.iSubItem = 0; lvItem.lParam = LPARAM(p); - ::SendMessage(m_hwndList, LVM_INSERTITEM, 0, reinterpret_cast(&lvItem)); + ::SendMessage(m_hwndList, LVM_INSERTITEM, 0, LPARAM(&lvItem)); qMgrAddFilter(c->getContact(), tszNick); lvItem.mask = LVIF_TEXT; + TCHAR tszTimestamp[30]; _tcsftime(tszTimestamp, 30, formatTime, _localtime32((__time32_t *)&p->created)); tszTimestamp[29] = 0; lvItem.pszText = tszTimestamp; lvItem.iSubItem = 1; - ::SendMessage(m_hwndList, LVM_SETITEM, 0, reinterpret_cast(&lvItem)); + ::SendMessage(m_hwndList, LVM_SETITEM, 0, LPARAM(&lvItem)); - TCHAR* msg = mir_utf8decodeT(p->sendBuffer); - TCHAR* preview = Utils::GetPreviewWithEllipsis(msg, 255); + TCHAR *msg = mir_utf8decodeT(p->sendBuffer); + TCHAR *preview = Utils::GetPreviewWithEllipsis(msg, 255); lvItem.pszText = preview; lvItem.iSubItem = 2; - ::SendMessage(m_hwndList, LVM_SETITEM, 0, reinterpret_cast(&lvItem)); + ::SendMessage(m_hwndList, LVM_SETITEM, 0, LPARAM(&lvItem)); mir_free(preview); mir_free(msg); + const TCHAR *tszStatusText = 0; if (p->fFailed) { tszStatusText = p->bCode == CSendLaterJob::JOB_REMOVABLE ? TranslateT("Removed") : TranslateT("Failed"); @@ -659,11 +597,13 @@ void CSendLater::qMgrFillList(bool fClear) } if (p->bCode) bCode = p->bCode; + + TCHAR tszStatus[20]; mir_sntprintf(tszStatus, 20, _T("X/%s[%c] (%d)"), tszStatusText, bCode, p->iSendCount); - tszStatus[0] = static_cast(p->szId[0]); + tszStatus[0] = p->szId[0]; lvItem.pszText = tszStatus; lvItem.iSubItem = 3; - ::SendMessage(m_hwndList, LVM_SETITEM, 0, reinterpret_cast(&lvItem)); + ::SendMessage(m_hwndList, LVM_SETITEM, 0, LPARAM(&lvItem)); if (p->lastSent == 0) mir_sntprintf(tszTimestamp, 30, _T("%s"), _T("Never")); @@ -673,7 +613,7 @@ void CSendLater::qMgrFillList(bool fClear) } lvItem.pszText = tszTimestamp; lvItem.iSubItem = 4; - ::SendMessage(m_hwndList, LVM_SETITEM, 0, reinterpret_cast(&lvItem)); + ::SendMessage(m_hwndList, LVM_SETITEM, 0, LPARAM(&lvItem)); } } @@ -683,9 +623,8 @@ void CSendLater::qMgrFillList(bool fClear) ::SendMessage(m_hwndFilter, CB_SETCURSEL, m_sel, 0); } -/* - * set the column headers - */ +// set the column headers +// #define QMGR_LIST_NRCOLUMNS 5 static char* szColFormat = "%d;%d;%d;%d;%d"; @@ -713,29 +652,28 @@ void CSendLater::qMgrSetupColumns() col.cx = max(nWidths[0], 10); col.pszText = TranslateT("Contact"); - ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 0, reinterpret_cast(&col)); + ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 0, LPARAM(&col)); col.pszText = TranslateT("Original timestamp"); col.cx = max(nWidths[1], 10); - ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 1, reinterpret_cast(&col)); + ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 1, LPARAM(&col)); col.pszText = TranslateT("Message text"); col.cx = max((cxList - nWidths[0] - nWidths[1] - nWidths[3] - nWidths[4] - 10), 10); - ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 2, reinterpret_cast(&col)); + ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 2, LPARAM(&col)); col.pszText = TranslateT("Status"); col.cx = max(nWidths[3], 10); - ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 3, reinterpret_cast(&col)); + ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 3, LPARAM(&col)); col.pszText = TranslateT("Last send info"); col.cx = max(nWidths[4], 10); - ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 4, reinterpret_cast(&col)); + ::SendMessage(m_hwndList, LVM_INSERTCOLUMN, 4, LPARAM(&col)); } -/** - * save user defined column widths to the database - */ +// save user defined column widths to the database +// void CSendLater::qMgrSaveColumns() { char szColFormatNew[100]; @@ -744,7 +682,7 @@ void CSendLater::qMgrSaveColumns() col.mask = LVCF_WIDTH; for (i=0; i < QMGR_LIST_NRCOLUMNS; i++) { - ::SendMessage(m_hwndList, LVM_GETCOLUMN, i, reinterpret_cast(&col)); + ::SendMessage(m_hwndList, LVM_GETCOLUMN, i, LPARAM(&col)); nWidths[i] = max(col.cx, 10); } mir_snprintf(szColFormatNew, 100, "%d;%d;%d;%d;%d", nWidths[0], nWidths[1], nWidths[2], nWidths[3], nWidths[4]); @@ -753,13 +691,13 @@ void CSendLater::qMgrSaveColumns() INT_PTR CALLBACK CSendLater::DlgProcStub(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - CSendLater *s = reinterpret_cast(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); + CSendLater *s = (CSendLater*)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (s) return s->DlgProc(hwnd, msg, wParam, lParam); if (msg == WM_INITDIALOG) { ::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); - s = reinterpret_cast(lParam); + s = (CSendLater*)(lParam); return s->DlgProc(hwnd, msg, wParam, lParam); } return FALSE; @@ -800,9 +738,8 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM POINT pt; ::GetCursorPos(&pt); - /* - * copy to clipboard only allowed with a single selection - */ + + // copy to clipboard only allowed with a single selection if (::SendMessage(m_hwndList, LVM_GETSELECTEDCOUNT, 0, 0) == 1) ::EnableMenuItem(hSubMenu, ID_QUEUEMANAGER_COPYMESSAGETOCLIPBOARD, MF_ENABLED); @@ -855,13 +792,12 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; case IDC_QMGR_HELP: - CallService(MS_UTILS_OPENURL, 0, reinterpret_cast("http://wiki.miranda.or.at/TabSRMM/SendLater")); + CallService(MS_UTILS_OPENURL, 0, LPARAM("http://wiki.miranda.or.at/TabSRMM/SendLater")); break; - /* - * this handles all commands sent by the context menu - * mark jobs for removal/reset/hold/unhold - * exception: kill all open multisend jobs is directly handled from the context menu - */ + + // this handles all commands sent by the context menu + // mark jobs for removal/reset/hold/unhold + // exception: kill all open multisend jobs is directly handled from the context menu case IDC_QMGR_REMOVE: if (::SendMessage(m_hwndList, LVM_GETSELECTEDCOUNT, 0, 0) != 0) { LVITEM item = {0}; @@ -876,9 +812,9 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } for (LRESULT i = 0; i < items; i++) { item.iItem = i; - ::SendMessage(m_hwndList, LVM_GETITEM, 0, reinterpret_cast(&item)); + ::SendMessage(m_hwndList, LVM_GETITEM, 0, LPARAM(&item)); if (item.state & LVIS_SELECTED) { - CSendLaterJob* job = reinterpret_cast(item.lParam); + CSendLaterJob* job = (CSendLaterJob*)item.lParam; if (!job) continue; @@ -929,20 +865,16 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return FALSE; } -/** - * invoke queue manager dialog - do nothing if this dialog is already open - */ +// invoke queue manager dialog - do nothing if this dialog is already open +// void CSendLater::invokeQueueMgrDlg() { if (m_hwndDlg == 0) - m_hwndDlg = ::CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_SENDLATER_QMGR), 0, CSendLater::DlgProcStub, - reinterpret_cast(this)); + m_hwndDlg = ::CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_SENDLATER_QMGR), 0, CSendLater::DlgProcStub, LPARAM(this)); } -/* - * service function to invoke the queue manager - */ - +// service function to invoke the queue manager +// INT_PTR CSendLater::svcQMgr(WPARAM wParam, LPARAM lParam) { sendLater->invokeQueueMgrDlg(); diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index bf0ef923e9..8e8610bc3a 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -308,13 +308,17 @@ int SendQueue::getSendLength(const int iEntry, int sendMode) int SendQueue::sendQueued(TWindowData *dat, const int iEntry) { + CContactCache *ccActive = CContactCache::getContactCache(dat->hContact); + if (ccActive == NULL) + return 0; + HWND hwndDlg = dat->hwnd; if (dat->sendMode & SMODE_MULTIPLE) { int iJobs = 0; int iMinLength = 0; - m_jobs[iEntry].hOwner = dat->hContact; + m_jobs[iEntry].hOwner = ccActive->getActiveContact(); m_jobs[iEntry].iStatus = SQ_INPROGRESS; m_jobs[iEntry].hwndOwner = hwndDlg; @@ -332,7 +336,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) if (iSendLength >= iMinLength) { TCHAR tszError[256]; mir_sntprintf(tszError, 256, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), iMinLength); - ::SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, reinterpret_cast(tszError)); + ::SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, LPARAM(tszError)); sendQueue->clearJob(iEntry); return 0; } @@ -347,7 +351,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) sendQueue->clearJob(iEntry); if (iJobs) - sendLater->flushQueue(); // force queue processing + sendLater->flushQueue(); // force queue processing return 0; } @@ -370,7 +374,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) if (!fSplit) goto send_unsplitted; - m_jobs[iEntry].hOwner = dat->hContact; + m_jobs[iEntry].hOwner = ccActive->getActiveContact(); m_jobs[iEntry].hwndOwner = hwndDlg; m_jobs[iEntry].iStatus = SQ_INPROGRESS; m_jobs[iEntry].iAcksNeeded = 1; @@ -390,7 +394,7 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) send_unsplitted: - m_jobs[iEntry].hOwner = dat->hContact; + m_jobs[iEntry].hOwner = ccActive->getActiveContact(); m_jobs[iEntry].hwndOwner = hwndDlg; m_jobs[iEntry].iStatus = SQ_INPROGRESS; m_jobs[iEntry].iAcksNeeded = 1; @@ -400,7 +404,7 @@ send_unsplitted: int iSendLength = getSendLength(iEntry, dat->sendMode); if (iSendLength >= dat->nMax) { mir_sntprintf(tszError, 256, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), dat->nMax); - SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, reinterpret_cast(tszError)); + SendMessage(dat->hwnd, DM_ACTIVATETOOLTIP, IDC_MESSAGE, LPARAM(tszError)); clearJob(iEntry); return 0; } diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp index 2855d35281..b55e905536 100644 --- a/plugins/TabSRMM/src/sidebar.cpp +++ b/plugins/TabSRMM/src/sidebar.cpp @@ -356,7 +356,7 @@ void CSideBarButton::invokeContextMenu() tsn.nmHdr.idFrom = 5000; tsn.nmHdr.hwndFrom = ::GetDlgItem(pContainer->hwnd, 5000); tsn.dat = m_dat; - ::SendMessage(pContainer->hwnd, WM_NOTIFY, 0, reinterpret_cast(&tsn)); + ::SendMessage(pContainer->hwnd, WM_NOTIFY, 0, LPARAM(&tsn)); } } diff --git a/plugins/TabSRMM/src/taskbar.cpp b/plugins/TabSRMM/src/taskbar.cpp index 06acd7a1e5..0303771b77 100644 --- a/plugins/TabSRMM/src/taskbar.cpp +++ b/plugins/TabSRMM/src/taskbar.cpp @@ -382,7 +382,7 @@ void CProxyWindow::sendPreview() ::DeleteObject(brb); CImageItem::SetBitmap32Alpha(hbm, 100); - LRESULT first = ::SendMessage(hwndRich, EM_CHARFROMPOS, 0, reinterpret_cast(&ptOrigin)); + LRESULT first = ::SendMessage(hwndRich, EM_CHARFROMPOS, 0, LPARAM(&ptOrigin)); /* * paint the content of the message log control into a separate bitmap without @@ -414,7 +414,7 @@ void CProxyWindow::sendPreview() fr.chrg.cpMax = -1; fr.chrg.cpMin = first; - ::SendMessage(hwndRich, EM_FORMATRANGE, 1, reinterpret_cast(&fr)); + ::SendMessage(hwndRich, EM_FORMATRANGE, 1, LPARAM(&fr)); } ::SelectObject(hdcRich, hbmRichOld); @@ -478,7 +478,7 @@ void CProxyWindow::setOverlayIcon(const HICON hIcon, bool fInvalidate) void CProxyWindow::updateIcon(const HICON hIcon) const { if (m_hwndProxy && hIcon) - ::SendMessage(m_hwndProxy, WM_SETICON, ICON_SMALL, reinterpret_cast(hIcon)); + ::SendMessage(m_hwndProxy, WM_SETICON, ICON_SMALL, LPARAM(hIcon)); } /** diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 776afac70b..d4fac96cb2 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -1125,11 +1125,11 @@ CWarning::~CWarning() LRESULT CWarning::ShowDialog() const { if (!m_fIsModal) { - ::CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_WARNING), 0, stubDlgProc, reinterpret_cast(this)); + ::CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_WARNING), 0, stubDlgProc, LPARAM(this)); return 0; } - return ::DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_WARNING), 0, stubDlgProc, reinterpret_cast(this)); + return ::DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_WARNING), 0, stubDlgProc, LPARAM(this)); } __int64 CWarning::getMask() @@ -1278,8 +1278,8 @@ INT_PTR CALLBACK CWarning::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP m_hwnd = hwnd; ::SetWindowTextW(hwnd, TranslateT("TabSRMM warning message")); - ::SendMessage(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast(::LoadSkinnedIconBig(SKINICON_OTHER_MIRANDA))); - ::SendMessage(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast(::LoadSkinnedIcon(SKINICON_OTHER_MIRANDA))); + ::SendMessage(hwnd, WM_SETICON, ICON_BIG, LPARAM(::LoadSkinnedIconBig(SKINICON_OTHER_MIRANDA))); + ::SendMessage(hwnd, WM_SETICON, ICON_SMALL, LPARAM(::LoadSkinnedIcon(SKINICON_OTHER_MIRANDA))); ::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_AUTOURLDETECT, TRUE, 0); ::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_SETEVENTMASK, 0, ENM_LINK); -- cgit v1.2.3