diff options
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 56 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msglog.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendlater.cpp | 9 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendqueue.cpp | 194 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendqueue.h | 1 |
5 files changed, 103 insertions, 160 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 29891b4142..96e2477eb1 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2698,40 +2698,38 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP sendQueue->handleError(dat, iNextFailed);
break;
}
- case MSGERROR_RETRY: {
- int resent = 0;;
-
- if (!(dat->dwFlags & MWF_ERRORSTATE))
- break;
-
- 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)
- break;
- job->hSendId = (HANDLE) CallContactService(job->hOwner,
- SendQueue::MsgServiceName(job->hOwner, dat, job->dwFlags), (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->sendBuffer);
- resent++;
- }
+ case MSGERROR_RETRY:
+ if (dat->dwFlags & MWF_ERRORSTATE) {
+ int resent = 0;
+
+ 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)
+ break;
- if (resent) {
- int iNextFailed;
- SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError);
+ job->hSendId = (HANDLE) CallContactService(job->hOwner, PSS_MESSAGE,
+ (dat->sendMode & SMODE_FORCEANSI) ? (job->dwFlags & ~PREF_UNICODE) : job->dwFlags, (LPARAM)job->sendBuffer);
+ resent++;
+ }
- SetTimer(hwndDlg, TIMERID_MSGSEND + dat->iCurrentQueueError, PluginConfig.m_MsgTimeout, NULL);
- job->iStatus = SendQueue::SQ_INPROGRESS;
- dat->iCurrentQueueError = -1;
- sendQueue->showErrorControls(dat, FALSE);
- SetDlgItemText(hwndDlg, IDC_MESSAGE, _T(""));
- sendQueue->checkQueue(dat);
- if ((iNextFailed = sendQueue->findNextFailed(dat)) >= 0)
- sendQueue->handleError(dat, iNextFailed);
+ if (resent) {
+ int iNextFailed;
+ SendJob *job = sendQueue->getJobByIndex(dat->iCurrentQueueError);
+
+ SetTimer(hwndDlg, TIMERID_MSGSEND + dat->iCurrentQueueError, PluginConfig.m_MsgTimeout, NULL);
+ job->iStatus = SendQueue::SQ_INPROGRESS;
+ dat->iCurrentQueueError = -1;
+ sendQueue->showErrorControls(dat, FALSE);
+ SetDlgItemText(hwndDlg, IDC_MESSAGE, _T(""));
+ sendQueue->checkQueue(dat);
+ if ((iNextFailed = sendQueue->findNextFailed(dat)) >= 0)
+ sendQueue->handleError(dat, iNextFailed);
+ }
}
- }
- break;
}
break;
+
case DM_SELECTTAB:
SendMessage(hwndContainer, DM_SELECTTAB, wParam, lParam); // pass the msg to our container
return 0;
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index f8a35f26cd..75784e1987 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -1388,8 +1388,7 @@ void TSAPI StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAp if (streamData.dbei != 0)
isSent = (streamData.dbei->flags & DBEF_SENT) != 0;
else {
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDbEventFirst, &dbei);
isSent = (dbei.flags & DBEF_SENT) != 0;
}
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 596ce729d3..634f26042e 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -33,7 +33,6 @@ CSendLater *sendLater = 0;
-#define U_PREF_UNICODE PREF_UNICODE
/*
* implementation of the CSendLaterJob class
*/
@@ -461,9 +460,7 @@ int CSendLater::sendIt(CSendLaterJob *job) return 0;
}
- dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : U_PREF_UNICODE;
-
- char *svcName = SendQueue::MsgServiceName(hContact, 0, dwFlags);
+ dwFlags = IsUtfSendAvailable(hContact) ? PREF_UTF : PREF_UNICODE;
job->lastSent = now;
job->iSendCount++;
@@ -471,9 +468,9 @@ int CSendLater::sendIt(CSendLaterJob *job) job->bCode = CSendLaterJob::JOB_WAITACK;
if (dwFlags & PREF_UTF)
- job->hProcess = (HANDLE)CallContactService(hContact, svcName, dwFlags, (LPARAM)job->sendBuffer);
+ job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->sendBuffer);
else
- job->hProcess = (HANDLE)CallContactService(hContact, svcName, dwFlags, (LPARAM)job->pBuf);
+ job->hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)job->pBuf);
return 0;
}
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 3f78cf8c32..2713cd1470 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -34,38 +34,6 @@ SendQueue *sendQueue = 0;
-static char *pss_msg = "/SendMsg";
-static char *pss_msgw = "/SendMsgW";
-
-/**
- * get the service name to send a message
- *
- * @param hContact (HANDLE) contact's handle
- * @param dat _MessageWindowData
- * @param dwFlags
- *
- * @return (char *) name of the service to send a message to this contact
- */
-char *SendQueue::MsgServiceName(const HANDLE hContact = 0, const TWindowData *dat = 0, int dwFlags = 0)
-{
- char szServiceName[100];
- char *szProto = GetContactProto(hContact);
-
- if (szProto == NULL)
- return pss_msg;
-
- if (dat) {
- if (dat->sendMode & SMODE_FORCEANSI || !(dwFlags & PREF_UNICODE))
- return pss_msg;
- }
-
- _snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- if (ServiceExists(szServiceName))
- return pss_msgw;
-
- return pss_msg;
-}
-
/*
* searches the queue for a message belonging to the given contact which has been marked
* as "failed" by either the ACKRESULT_FAILED or a timeout handler
@@ -169,21 +137,19 @@ entry_found: #define SPLIT_WORD_CUTOFF 20
-static int SendChunkW(WCHAR *chunk, HANDLE hContact, char *szSvc, DWORD dwFlags)
+static int SendChunkW(WCHAR *chunk, HANDLE hContact, DWORD dwFlags)
{
- BYTE *pBuf = NULL;
- int wLen = lstrlenW(chunk), id;
+ int wLen = lstrlenW(chunk);
DWORD memRequired = (wLen + 1) * sizeof(WCHAR);
DWORD codePage = db_get_dw(hContact, SRMSGMOD_T, "ANSIcodepage", CP_ACP);
- int mbcsSize = WideCharToMultiByte(codePage, 0, chunk, -1, (char *)pBuf, 0, 0, 0);
+ int mbcsSize = WideCharToMultiByte(codePage, 0, chunk, -1, NULL, 0, 0, 0);
memRequired += mbcsSize;
- pBuf = (BYTE *)mir_alloc(memRequired);
- WideCharToMultiByte(codePage, 0, chunk, -1, (char *)pBuf, mbcsSize, 0, 0);
- CopyMemory(&pBuf[mbcsSize], chunk, (wLen + 1) * sizeof(WCHAR));
- id = CallContactService(hContact, szSvc, dwFlags, (LPARAM)pBuf);
- mir_free(pBuf);
- return id;
+
+ mir_ptr<char> pBuf((char*)mir_alloc(memRequired));
+ WideCharToMultiByte(codePage, 0, chunk, -1, pBuf, mbcsSize, 0, 0);
+ CopyMemory(&pBuf[mbcsSize], chunk, (wLen+1) * sizeof(WCHAR));
+ return CallContactService(hContact, PSS_MESSAGE, dwFlags, (LPARAM)pBuf);
}
static int SendChunkA(char *chunk, HANDLE hContact, char *szSvc, DWORD dwFlags)
@@ -199,22 +165,11 @@ static void DoSplitSendW(LPVOID param) WCHAR *wszBegin, *wszTemp, *wszSaved, savedChar;
int iLen, iCur = 0, iSavedCur = 0, i;
BOOL fSplitting = TRUE;
- char szServiceName[100], *svcName;
HANDLE hContact = job->hOwner;
DWORD dwFlags = job->dwFlags;
int chunkSize = job->chunkSize / 2;
char *szProto = GetContactProto(hContact);
- if (szProto == NULL)
- svcName = pss_msg;
- else {
- _snprintf(szServiceName, sizeof(szServiceName), "%s%sW", szProto, PSS_MESSAGE);
- if (ServiceExists(szServiceName))
- svcName = pss_msgw;
- else
- svcName = pss_msg;
- }
-
iLen = lstrlenA(job->sendBuffer);
wszBegin = (WCHAR *) & job->sendBuffer[iLen + 1];
wszTemp = (WCHAR *)mir_alloc(sizeof(WCHAR) * (lstrlenW(wszBegin) + 1));
@@ -250,7 +205,7 @@ static void DoSplitSendW(LPVOID param) }
savedChar = *wszSaved;
*wszSaved = 0;
- id = SendChunkW(wszTemp, hContact, svcName, dwFlags);
+ id = SendChunkW(wszTemp, hContact, dwFlags);
if (!fFirstSend) {
job->hSendId = (HANDLE)id;
fFirstSend = TRUE;
@@ -264,7 +219,7 @@ static void DoSplitSendW(LPVOID param) }
}
else {
- id = SendChunkW(wszTemp, hContact, svcName, dwFlags);
+ id = SendChunkW(wszTemp, hContact, dwFlags);
if (!fFirstSend) {
job->hSendId = (HANDLE)id;
fFirstSend = TRUE;
@@ -285,13 +240,10 @@ static void DoSplitSendA(LPVOID param) char *szBegin, *szTemp, *szSaved, savedChar;
int iLen, iCur = 0, iSavedCur = 0, i;
BOOL fSplitting = TRUE;
- char *svcName;
HANDLE hContact = job->hOwner;
DWORD dwFlags = job->dwFlags;
int chunkSize = job->chunkSize;
- svcName = pss_msg;
-
iLen = lstrlenA(job->sendBuffer);
szTemp = (char *)mir_alloc(iLen + 1);
CopyMemory(szTemp, job->sendBuffer, iLen + 1);
@@ -414,82 +366,82 @@ int SendQueue::sendQueued(TWindowData *dat, const int iEntry) sendLater->flushQueue(); // force queue processing
return 0;
}
- else {
- if (dat->hContact == NULL)
- return 0; //never happens
- dat->nMax = dat->cache->getMaxMessageLength(); // refresh length info
+ if (dat->hContact == NULL)
+ return 0; //never happens
- if (dat->sendMode & SMODE_FORCEANSI && M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1))
- M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0);
- else if (!(dat->sendMode & SMODE_FORCEANSI) && !M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0))
- M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1);
+ dat->nMax = dat->cache->getMaxMessageLength(); // refresh length info
- if (M->GetByte("autosplit", 0) && !(dat->sendMode & SMODE_SENDLATER)) {
- BOOL fSplit = FALSE;
- DWORD dwOldFlags;
+ if (dat->sendMode & SMODE_FORCEANSI && M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1))
+ M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0);
+ else if (!(dat->sendMode & SMODE_FORCEANSI) && !M->GetByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 0))
+ M->WriteByte(dat->cache->getActiveContact(), dat->cache->getActiveProto(), "UnicodeSend", 1);
- /*
- * determine send buffer length
- */
- if (getSendLength(iEntry, dat->sendMode) >= dat->nMax)
- fSplit = true;
+ if (M->GetByte("autosplit", 0) && !(dat->sendMode & SMODE_SENDLATER)) {
+ BOOL fSplit = FALSE;
+ DWORD dwOldFlags;
- if (!fSplit)
- goto send_unsplitted;
+ /*
+ * determine send buffer length
+ */
+ if (getSendLength(iEntry, dat->sendMode) >= dat->nMax)
+ fSplit = true;
- m_jobs[iEntry].hOwner = dat->hContact;
- m_jobs[iEntry].hwndOwner = hwndDlg;
- m_jobs[iEntry].iStatus = SQ_INPROGRESS;
- m_jobs[iEntry].iAcksNeeded = 1;
- m_jobs[iEntry].chunkSize = dat->nMax;
+ if (!fSplit)
+ goto send_unsplitted;
- dwOldFlags = m_jobs[iEntry].dwFlags;
- if (dat->sendMode & SMODE_FORCEANSI)
- m_jobs[iEntry].dwFlags &= ~PREF_UNICODE;
+ m_jobs[iEntry].hOwner = dat->hContact;
+ m_jobs[iEntry].hwndOwner = hwndDlg;
+ m_jobs[iEntry].iStatus = SQ_INPROGRESS;
+ m_jobs[iEntry].iAcksNeeded = 1;
+ m_jobs[iEntry].chunkSize = dat->nMax;
- if (!(m_jobs[iEntry].dwFlags & PREF_UNICODE) || dat->sendMode & SMODE_FORCEANSI)
- mir_forkthread(DoSplitSendA, (LPVOID)iEntry);
- else
- mir_forkthread(DoSplitSendW, (LPVOID)iEntry);
- m_jobs[iEntry].dwFlags = dwOldFlags;
- }
- else {
+ dwOldFlags = m_jobs[iEntry].dwFlags;
+ if (dat->sendMode & SMODE_FORCEANSI)
+ m_jobs[iEntry].dwFlags &= ~PREF_UNICODE;
+
+ if (!(m_jobs[iEntry].dwFlags & PREF_UNICODE) || dat->sendMode & SMODE_FORCEANSI)
+ mir_forkthread(DoSplitSendA, (LPVOID)iEntry);
+ else
+ mir_forkthread(DoSplitSendW, (LPVOID)iEntry);
+ m_jobs[iEntry].dwFlags = dwOldFlags;
+ }
+ else {
send_unsplitted:
- m_jobs[iEntry].hOwner = dat->hContact;
- m_jobs[iEntry].hwndOwner = hwndDlg;
- m_jobs[iEntry].iStatus = SQ_INPROGRESS;
- m_jobs[iEntry].iAcksNeeded = 1;
- if (dat->sendMode & SMODE_SENDLATER) {
- TCHAR tszError[256];
-
- 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<LPARAM>(tszError));
- clearJob(iEntry);
- return 0;
- }
- doSendLater(iEntry, dat);
+ m_jobs[iEntry].hOwner = dat->hContact;
+ m_jobs[iEntry].hwndOwner = hwndDlg;
+ m_jobs[iEntry].iStatus = SQ_INPROGRESS;
+ m_jobs[iEntry].iAcksNeeded = 1;
+ if (dat->sendMode & SMODE_SENDLATER) {
+ TCHAR tszError[256];
+
+ 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<LPARAM>(tszError));
clearJob(iEntry);
return 0;
}
- m_jobs[iEntry].hSendId = (HANDLE) CallContactService(dat->hContact, MsgServiceName(dat->hContact, dat, m_jobs[iEntry].dwFlags), (dat->sendMode & SMODE_FORCEANSI) ? (m_jobs[iEntry].dwFlags & ~PREF_UNICODE) : m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].sendBuffer);
-
- if (dat->sendMode & SMODE_NOACK) { // fake the ack if we are not interested in receiving real acks
- ACKDATA ack = {0};
- ack.hContact = dat->hContact;
- ack.hProcess = m_jobs[iEntry].hSendId;
- ack.type = ACKTYPE_MESSAGE;
- ack.result = ACKRESULT_SUCCESS;
- SendMessage(hwndDlg, HM_EVENTSENT, (WPARAM)MAKELONG(iEntry, 0), (LPARAM)&ack);
- }
- else
- SetTimer(hwndDlg, TIMERID_MSGSEND + iEntry, PluginConfig.m_MsgTimeout, NULL);
+ doSendLater(iEntry, dat);
+ clearJob(iEntry);
+ return 0;
}
+ m_jobs[iEntry].hSendId = (HANDLE) CallContactService(dat->hContact, PSS_MESSAGE,
+ (dat->sendMode & SMODE_FORCEANSI) ? (m_jobs[iEntry].dwFlags & ~PREF_UNICODE) : m_jobs[iEntry].dwFlags, (LPARAM)m_jobs[iEntry].sendBuffer);
+
+ if (dat->sendMode & SMODE_NOACK) { // fake the ack if we are not interested in receiving real acks
+ ACKDATA ack = {0};
+ ack.hContact = dat->hContact;
+ ack.hProcess = m_jobs[iEntry].hSendId;
+ ack.type = ACKTYPE_MESSAGE;
+ ack.result = ACKRESULT_SUCCESS;
+ SendMessage(hwndDlg, HM_EVENTSENT, (WPARAM)MAKELONG(iEntry, 0), (LPARAM)&ack);
+ }
+ else SetTimer(hwndDlg, TIMERID_MSGSEND + iEntry, PluginConfig.m_MsgTimeout, NULL);
}
+
dat->iOpenJobs++;
m_currentIndex++;
@@ -550,14 +502,13 @@ void SendQueue::checkQueue(const TWindowData *dat) const void SendQueue::logError(const TWindowData *dat, int iSendJobIndex, const TCHAR *szErrMsg) const
{
- DBEVENTINFO dbei = {0};
int iMsgLen;
if (dat == 0)
return;
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_ERRMSG;
- dbei.cbSize = sizeof(dbei);
if (iSendJobIndex >= 0) {
dbei.pBlob = (BYTE *)m_jobs[iSendJobIndex].sendBuffer;
iMsgLen = lstrlenA(m_jobs[iSendJobIndex].sendBuffer) + 1;
@@ -738,7 +689,6 @@ int SendQueue::RTL_Detect(const WCHAR *pszwText) int SendQueue::ackMessage(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
ACKDATA *ack = (ACKDATA *) lParam;
- DBEVENTINFO dbei = { 0};
HANDLE hNewEvent;
int iFound = SendQueue::NR_SENDJOBS, iNextFailed;
TContainerData *m_pContainer = 0;
@@ -792,7 +742,7 @@ inform_and_discard: }
}
- dbei.cbSize = sizeof(dbei);
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT;
dbei.szModule = GetContactProto(m_jobs[iFound].hOwner);
diff --git a/plugins/TabSRMM/src/sendqueue.h b/plugins/TabSRMM/src/sendqueue.h index 428ee49b32..1eac7f557d 100644 --- a/plugins/TabSRMM/src/sendqueue.h +++ b/plugins/TabSRMM/src/sendqueue.h @@ -100,7 +100,6 @@ public: * static members
*/
static int TSAPI RTL_Detect (const wchar_t *pszwText);
- static char* TSAPI MsgServiceName (const HANDLE hContact, const TWindowData *dat, int isUnicode);
static int TSAPI GetProtoIconFromList (const char *szProto, int iStatus);
static LRESULT TSAPI WarnPendingJobs (unsigned int uNrMessages);
static void TSAPI NotifyDeliveryFailure (const TWindowData *dat);
|