diff options
author | George Hazan <george.hazan@gmail.com> | 2014-04-02 18:52:46 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-04-02 18:52:46 +0000 |
commit | c76a072915bed0c625aea31cc38029b97dcb4157 (patch) | |
tree | beeb20cd919344a0f3da49d88b5491e1a4e49a38 /plugins/TabSRMM | |
parent | 1c14e99dd57b0ccea99d8efa4ce94ab5c6077276 (diff) |
minor cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@8828 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/hotkeyhandler.cpp | 82 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msglog.cpp | 69 |
2 files changed, 57 insertions, 94 deletions
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index fdaaa532b8..ec934bbf2a 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -77,11 +77,9 @@ LRESULT ProcessHotkeysByMsgFilter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa mf.nmhdr.code = EN_MSGFILTER;
mf.nmhdr.hwndFrom = hwnd;
mf.nmhdr.idFrom = ctrlId;
-
mf.lParam = lParam;
mf.wParam = wParam;
mf.msg = msg;
-
return SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&mf);
}
@@ -110,7 +108,7 @@ void TSAPI HandleMenuEntryFromhContact(MCONTACT hContact) else CallService(MS_MSG_SENDMESSAGE, hContact, 0);
return;
}
-
+
SESSION_INFO *si = SM_FindSessionByHCONTACT(hContact);
if (si != NULL) {
// session does exist, but no window is open for it
@@ -180,10 +178,8 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
break;
- /*
- * handle the popup menus (session list, favorites, recents...
- * just draw some icons, nothing more :)
- */
+ // handle the popup menus (session list, favorites, recents...
+ // just draw some icons, nothing more :)
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT) lParam;
@@ -361,16 +357,12 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
break;
- /*
- * handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message
- * is posted to our invisible hotkey handler which does always run within the main thread.
- * wParam is the hContact
- * lParam the event handle
- */
+ // handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message
+ // is posted to our invisible hotkey handler which does always run within the main thread.
+ // wParam is the hContact
+ // lParam the event handle
case DM_HANDLECLISTEVENT:
- /*
- * if lParam == NULL, don't consider clist events, just open the message tab
- */
+ // if lParam == NULL, don't consider clist events, just open the message tab
if (lParam == 0)
HandleMenuEntryFromhContact(wParam);
else {
@@ -436,9 +428,7 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP mir_free((void*)lParam);
return 0;
- /*
- * sent from the popup to "dismiss" the event. we should do this in the main thread
- */
+ // sent from the popup to "dismiss" the event. we should do this in the main thread
case DM_REMOVECLISTEVENT:
CallService(MS_CLIST_REMOVEEVENT, wParam, lParam);
db_event_markRead(wParam, (HANDLE)lParam);
@@ -468,11 +458,10 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
}
return 0;
- /*
- * react to changes in the desktop composition state
- * (enable/disable DWM, change to a non-aero visual style
- * or classic Windows theme
- */
+
+ // react to changes in the desktop composition state
+ // (enable/disable DWM, change to a non-aero visual style
+ // or classic Windows theme
case WM_DWMCOMPOSITIONCHANGED:
{
bool fNewAero = M.getAeroState(); // refresh dwm state
@@ -494,22 +483,18 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP M.BroadcastMessage(WM_DWMCOMPOSITIONCHANGED, 0, 0);
break;
- /*
- * this message is fired when the user changes desktop color
- * settings (Desktop->personalize)
- * the handler reconfigures the aero-related skin images for
- * tabs and buttons to match the new desktop color theme.
- */
+ // this message is fired when the user changes desktop color
+ // settings (Desktop->personalize)
+ // the handler reconfigures the aero-related skin images for
+ // tabs and buttons to match the new desktop color theme.
case WM_DWMCOLORIZATIONCOLORCHANGED:
M.getAeroState();
Skin->setupAeroSkins();
CSkin::initAeroEffect();
break;
- /*
- * user has changed the visual style or switched to/from
- * classic Windows theme
- */
+ // user has changed the visual style or switched to/from
+ // classic Windows theme
case WM_THEMECHANGED:
M.getAeroState();
Skin->setupTabCloseBitmap();
@@ -591,28 +576,20 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_TIMER:
if (wParam == TIMERID_SENDLATER) {
- /*
- * send heartbeat to each container, they use this to update
- * dynamic content (i.e. local time in the info panel).
- */
+ // send heartbeat to each container, they use this to update
+ // dynamic content (i.e. local time in the info panel).
for (p = pFirstContainer; p; p = p->pNext)
SendMessage(p->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0);
- /*
- * process send later contacts and jobs, if enough time has elapsed
- */
+ // process send later contacts and jobs, if enough time has elapsed
if (sendLater->isAvail() && !sendLater->isInteractive() && (time(0) - sendLater->lastProcessed()) > CSendLater::SENDLATER_PROCESS_INTERVAL) {
sendLater->setLastProcessed(time(0));
- /*
- * check the list of contacts that may have new send later jobs
- * (added on user's request)
- */
+ // check the list of contacts that may have new send later jobs
+ // (added on user's request)
sendLater->processContacts();
- /*
- * start processing the job list
- */
+ // start processing the job list
if (!sendLater->isJobListEmpty()) {
KillTimer(hwndDlg, wParam);
sendLater->startJobListProcess();
@@ -620,11 +597,10 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP }
}
}
- /*
- * process one entry per tick (default: 200ms)
- * TODO better timings, possibly slow down when many jobs are in the
- * queue.
- */
+
+ // process one entry per tick (default: 200ms)
+ // TODO better timings, possibly slow down when many jobs are in the
+ // queue.
else if (wParam == TIMERID_SENDLATER_TICK) {
if ( !sendLater->haveJobs()) {
KillTimer(hwndDlg, wParam);
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index e416f923e8..bbb8709a21 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -552,31 +552,17 @@ int DbEventIsForMsgWindow(DBEVENTINFO *dbei) static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, HANDLE hDbEvent, int prefixParaBreak, LogStreamData *streamData)
{
- char *buffer, c;
- TCHAR ci, cc;
- TCHAR *szFinalTimestamp;
- int bufferAlloced, bufferEnd;
- size_t iTemplateLen, i = 0;
- DBEVENTINFO dbei = { 0 };
- int isSent = 0;
- int iFontIDOffset = 0;
- TCHAR *szTemplate;
HANDLE hTimeZone;
- BOOL skipToNext = FALSE, showTime = TRUE, showDate = TRUE, skipFont = FALSE;
+ BOOL skipToNext = FALSE, skipFont = FALSE;
struct tm event_time;
- TTemplateSet *this_templateset;
BOOL isBold = FALSE, isItalic = FALSE, isUnderline = FALSE;
- DWORD dwEffectiveFlags;
DWORD dwFormattingParams = MAKELONG(PluginConfig.m_FormatWholeWordsOnly, 0);
- BOOL bIsStatusChangeEvent = FALSE;
- TCHAR *msg, *formatted = NULL;
char *rtfMessage = NULL;
- bufferEnd = 0;
- bufferAlloced = 1024;
- buffer = (char *) mir_alloc(bufferAlloced);
- buffer[0] = '\0';
+ int bufferEnd = 0, bufferAlloced = 1024;
+ char *buffer = (char *)mir_alloc(bufferAlloced); buffer[0] = '\0';
+ DBEVENTINFO dbei = { 0 };
if (streamData->dbei != 0)
dbei = *(streamData->dbei);
else {
@@ -598,19 +584,20 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, if (dbei.eventType == EVENTTYPE_MESSAGE && !dbei.markedRead())
dat->cache->updateStats(TSessionStats::SET_LAST_RCV, lstrlenA((char *) dbei.pBlob));
+ TCHAR *formatted = NULL;
if (rtfMessage == NULL) {
- msg = DbGetEventTextT(&dbei, dat->codePage);
+ TCHAR *msg = DbGetEventTextT(&dbei, dat->codePage);
if (!msg) {
mir_free(dbei.pBlob);
mir_free(buffer);
return NULL;
}
TrimMessage(msg);
- formatted = const_cast<TCHAR *>(Utils::FormatRaw(dat, msg, dwFormattingParams, isSent));
+ formatted = const_cast<TCHAR *>(Utils::FormatRaw(dat, msg, dwFormattingParams, FALSE));
mir_free(msg);
}
- bIsStatusChangeEvent = IsStatusEvent(dbei.eventType);
+ BOOL bIsStatusChangeEvent = IsStatusEvent(dbei.eventType);
if (dat->isAutoRTL & 2) { // means: last \\par was deleted to avoid new line at end of log
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\par");
@@ -623,11 +610,11 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, if (dbei.flags & DBEF_RTL)
dat->isAutoRTL |= 1;
- dwEffectiveFlags = dat->dwFlags;
+ DWORD dwEffectiveFlags = dat->dwFlags;
dat->isHistory = (dbei.timestamp < dat->cache->getSessionStart() && dbei.markedRead());
- iFontIDOffset = dat->isHistory ? 8 : 0; // offset into the font table for either history (old) or new events... (# of fonts per configuration set)
- isSent = (dbei.flags & DBEF_SENT);
+ int iFontIDOffset = dat->isHistory ? 8 : 0; // offset into the font table for either history (old) or new events... (# of fonts per configuration set)
+ BOOL isSent = (dbei.flags & DBEF_SENT);
if (!isSent && (bIsStatusChangeEvent || dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
db_event_markRead(hContact, hDbEvent);
@@ -666,23 +653,22 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, streamData->isEmpty = FALSE;
if (dat->isAutoRTL & 1) {
- if (dbei.flags & DBEF_RTL) {
+ if (dbei.flags & DBEF_RTL)
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ltrch\\rtlch");
- } else {
+ else
AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\rtlch\\ltrch");
- }
}
- /*
- * templated code starts here
- */
+ // templated code starts here
if (dwEffectiveFlags & MWF_LOG_SHOWTIME) {
hTimeZone = ((dat->dwFlags & MWF_LOG_LOCALTIME) && !isSent) ? dat->hTimeZone : NULL;
time_t local_time = tmi.timeStampToTimeZoneTimeStamp(hTimeZone, dbei.timestamp);
event_time = *gmtime(&local_time);
}
- this_templateset = dbei.flags & DBEF_RTL ? dat->pContainer->rtl_templates : dat->pContainer->ltr_templates;
+
+ TTemplateSet *this_templateset = dbei.flags & DBEF_RTL ? dat->pContainer->rtl_templates : dat->pContainer->ltr_templates;
+ TCHAR *szTemplate;
if (bIsStatusChangeEvent)
szTemplate = this_templateset->szTemplates[TMPL_STATUSCHG];
else if (dbei.eventType == EVENTTYPE_ERRMSG)
@@ -695,9 +681,9 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, szTemplate = isSent ? this_templateset->szTemplates[TMPL_MSGOUT] : this_templateset->szTemplates[TMPL_MSGIN];
}
- iTemplateLen = lstrlen(szTemplate);
- showTime = dwEffectiveFlags & MWF_LOG_SHOWTIME;
- showDate = dwEffectiveFlags & MWF_LOG_SHOWDATES;
+ size_t iTemplateLen = lstrlen(szTemplate);
+ BOOL showTime = dwEffectiveFlags & MWF_LOG_SHOWTIME;
+ BOOL showDate = dwEffectiveFlags & MWF_LOG_SHOWDATES;
if (dat->hHistoryEvents) {
if (dat->curHistory == dat->maxHistory) {
@@ -709,10 +695,10 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, "\\ul0\\b0\\i0 ");
- while (i < iTemplateLen) {
- ci = szTemplate[i];
+ for (size_t i = 0; i < iTemplateLen; ) {
+ TCHAR ci = szTemplate[i];
if (ci == '%') {
- cc = szTemplate[i + 1];
+ TCHAR cc = szTemplate[i + 1];
skipToNext = FALSE;
skipFont = FALSE;
/*
@@ -797,14 +783,14 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, break;
case 'D': // long date
if (showTime && showDate) {
- szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, (TCHAR)'D');
+ TCHAR *szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, (TCHAR)'D');
AppendTimeStamp(szFinalTimestamp, isSent, &buffer, &bufferEnd, &bufferAlloced, skipFont, dat, iFontIDOffset);
}
else skipToNext = TRUE;
break;
case 'E': // short date...
if (showTime && showDate) {
- szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, (TCHAR)'E');
+ TCHAR *szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, (TCHAR)'E');
AppendTimeStamp(szFinalTimestamp, isSent, &buffer, &bufferEnd, &bufferAlloced, skipFont, dat, iFontIDOffset);
}
else skipToNext = TRUE;
@@ -898,7 +884,7 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, case 'R':
case 'r': // long date
if (showTime && showDate) {
- szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, cc);
+ TCHAR *szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, cc);
AppendTimeStamp(szFinalTimestamp, isSent, &buffer, &bufferEnd, &bufferAlloced, skipFont, dat, iFontIDOffset);
}
else skipToNext = TRUE;
@@ -906,13 +892,14 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, MCONTACT hContact, case 't':
case 'T':
if (showTime) {
- szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, (TCHAR)((dwEffectiveFlags & MWF_LOG_SHOWSECONDS) ? cc : (TCHAR)'t'));
+ TCHAR *szFinalTimestamp = Template_MakeRelativeDate(dat, hTimeZone, dbei.timestamp, g_groupBreak, (TCHAR)((dwEffectiveFlags & MWF_LOG_SHOWSECONDS) ? cc : (TCHAR)'t'));
AppendTimeStamp(szFinalTimestamp, isSent, &buffer, &bufferEnd, &bufferAlloced, skipFont, dat, iFontIDOffset);
}
else skipToNext = TRUE;
break;
case 'S': // symbol
if (dwEffectiveFlags & MWF_LOG_SYMBOLS) {
+ char c;
if ((dwEffectiveFlags & MWF_LOG_INOUTICONS) && dbei.eventType == EVENTTYPE_MESSAGE)
c = isSent ? 0x37 : 0x38;
else {
|