Beispiel #1
0
void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char* szErr)
{
	MCONTACT hMeta = db_mc_getMeta(hContact);

	mir_cslockfull lck(csMsgQueue);
	for (int i = 0; i < msgQueue.getCount(); i++) {
		TMsgQueue *item = msgQueue[i];
		if ((item->hContact == hContact || item->hContact == hMeta) && item->id == id) {
			msgQueue.remove(i); i--;

			if (!msgQueue.getCount() && timerId) {
				KillTimer(NULL, timerId);
				timerId = 0;
			}
			lck.unlock();

			if (success) {
				mir_free(item->szMsg);
				mir_free(item);
			}
			else MessageFailureProcess(item, szErr);
			break;
		}
	}
}
Beispiel #2
0
void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *szErr)
{
    TMsgQueue *p = msgQueue_find(hContact, id);
    if (p == NULL)
        return;

    if (!success) {
        MessageFailureProcess(p, szErr);
        return;
    }

    DBEVENTINFO dbei = { sizeof(dbei) };
    dbei.eventType = EVENTTYPE_MESSAGE;
    dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & PREF_RTL ? DBEF_RTL : 0);
    dbei.szModule = GetContactProto(hContact);
    dbei.timestamp = time(0);
    dbei.cbBlob = (DWORD)(mir_strlen(p->szMsg) + 1);
    dbei.pBlob = (PBYTE)p->szMsg;

    MessageWindowEvent evt = { sizeof(evt), id, hContact, &dbei };
    NotifyEventHooks(hHookWinWrite, 0, (LPARAM)&evt);

    p->szMsg = (char*)dbei.pBlob;

    db_event_add(hContact, &dbei);

    mir_free(p->szMsg);
    mir_free(p);
}
Beispiel #3
0
static VOID CALLBACK MsgTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
	LIST<TMsgQueue> arTimedOut(1);
	{
		mir_cslock lck(csMsgQueue);
		for (int i = msgQueue.getCount() - 1; i >= 0; i--) {
			TMsgQueue *item = msgQueue[i];
			if (dwTime - item->ts > g_dat.msgTimeout) {
				arTimedOut.insert(item);
				msgQueue.remove(i);
			}
		}
	}

	for (int i = 0; i < arTimedOut.getCount(); ++i)
		MessageFailureProcess(arTimedOut[i], LPGEN("The message send timed out."));
}