diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-04 22:23:23 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-04 22:23:23 +0000 |
commit | dc58876a244067b91cd927dad812a8f812a61712 (patch) | |
tree | 9e1a04f5f3fcfc02519f72087c597e63399a6e7b /plugins/Scriver/src/chat | |
parent | ca88cf375915e8da3e9c461bdc4b21ebb383fe05 (diff) |
Scriver suddenly has its own replaceStrA/replaceStrT functions
git-svn-id: http://svn.miranda-ng.org/main/trunk@7505 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Scriver/src/chat')
-rw-r--r-- | plugins/Scriver/src/chat/chat.h | 6 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/manager.cpp | 51 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/options.cpp | 11 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/services.cpp | 14 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/tools.cpp | 219 | ||||
-rw-r--r-- | plugins/Scriver/src/chat/window.cpp | 2 |
6 files changed, 138 insertions, 165 deletions
diff --git a/plugins/Scriver/src/chat/chat.h b/plugins/Scriver/src/chat/chat.h index 0a702cd0f6..e88221baae 100644 --- a/plugins/Scriver/src/chat/chat.h +++ b/plugins/Scriver/src/chat/chat.h @@ -422,16 +422,14 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex); BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem);
BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem);
BOOL IsEventSupported(int eventType);
-BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
// message.c
TCHAR* DoRtfToTags( char* pszRtfText, SESSION_INFO *si);
//////////////////////////////////////////////////////////////////////////////////
-TCHAR* a2tf( const TCHAR* str, int flags );
-TCHAR* replaceStr( TCHAR** dest, const TCHAR* src );
-char* replaceStrA( char** dest, const char* src );
+TCHAR* a2tf(const TCHAR *str, int flags);
#define DEFLOGFILENAME _T("%miranda_logpath%\\%proto%\\%userid%.log")
#endif
diff --git a/plugins/Scriver/src/chat/manager.cpp b/plugins/Scriver/src/chat/manager.cpp index 0c54c89940..02c6854f88 100644 --- a/plugins/Scriver/src/chat/manager.cpp +++ b/plugins/Scriver/src/chat/manager.cpp @@ -39,10 +39,11 @@ void SetActiveSession(const TCHAR* pszID, const char* pszModule) void SetActiveSessionEx(SESSION_INFO *si)
{
- if ( si ) {
- replaceStr( &pszActiveWndID, si->ptszID );
- replaceStrA( &pszActiveWndModule, si->pszModule );
-} }
+ if (si) {
+ replaceStrT(pszActiveWndID, si->ptszID);
+ replaceStr(pszActiveWndModule, si->pszModule);
+ }
+}
SESSION_INFO* GetActiveSession( void )
{
@@ -631,9 +632,9 @@ BOOL SM_ChangeUID(const TCHAR* pszID, const char* pszModule, const TCHAR* pszUID while ( pTemp != NULL ) {
if (( !pszID || !lstrcmpi( pTemp->ptszID, pszID )) && !lstrcmpiA( pTemp->pszModule, pszModule )) {
- USERINFO* ui = UM_FindUser( pTemp->pUsers, pszUID );
- if ( ui )
- replaceStr( &ui->pszUID, pszNewUID );
+ USERINFO *ui = UM_FindUser(pTemp->pUsers, pszUID);
+ if (ui)
+ replaceStrT(ui->pszUID, pszNewUID);
if ( pszID )
return TRUE;
@@ -655,11 +656,11 @@ BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce) while ( pTemp != NULL ) {
if (( !pszID || !lstrcmpi( pTemp->ptszID, pszID )) && !lstrcmpiA( pTemp->pszModule, pszModule )) {
USERINFO* ui = UM_FindUser(pTemp->pUsers, gce->ptszUID );
- if ( ui ) {
- replaceStr( &ui->pszNick, gce->ptszText);
- SM_MoveUser( pTemp->ptszID, pTemp->pszModule, ui->pszUID );
- if ( pTemp->hWnd )
- SendMessage( pTemp->hWnd, GC_UPDATENICKLIST, 0, 0 );
+ if (ui) {
+ replaceStrT(ui->pszNick, gce->ptszText);
+ SM_MoveUser(pTemp->ptszID, pTemp->pszModule, ui->pszUID);
+ if (pTemp->hWnd)
+ SendMessage(pTemp->hWnd, GC_UPDATENICKLIST, 0, 0);
}
if (pszID)
@@ -670,11 +671,11 @@ BOOL SM_ChangeNick(const TCHAR* pszID, const char* pszModule, GCEVENT * gce) }
return TRUE;
}
-BOOL SM_RemoveAll (void)
+
+BOOL SM_RemoveAll(void)
{
- while (m_WndList)
- {
- SESSION_INFO*pLast = m_WndList->next;
+ while (m_WndList) {
+ SESSION_INFO *pLast = m_WndList->next;
if (m_WndList->hWnd)
SendMessage(m_WndList->hWnd, GC_EVENT_CONTROL+WM_USER+500, SESSION_TERMINATE, 0);
@@ -691,12 +692,12 @@ BOOL SM_RemoveAll (void) m_WndList->iStatusCount = 0;
m_WndList->nUsersInNicklist = 0;
- mir_free( m_WndList->pszModule );
- mir_free( m_WndList->ptszID );
- mir_free( m_WndList->ptszName );
- mir_free( m_WndList->ptszStatusbarText );
- mir_free( m_WndList->ptszTopic );
- mir_free( m_WndList->pszHeader);
+ mir_free(m_WndList->pszModule);
+ mir_free(m_WndList->ptszID);
+ mir_free(m_WndList->ptszName);
+ mir_free(m_WndList->ptszStatusbarText);
+ mir_free(m_WndList->ptszTopic);
+ mir_free(m_WndList->pszHeader);
tcmdlist_free(m_WndList->windowData.cmdList);
mir_free(m_WndList);
m_WndList = pLast;
@@ -926,7 +927,7 @@ STATUSINFO * TM_AddStatus(STATUSINFO** ppStatusList, const TCHAR* pszStatus, int if ( !TM_FindStatus(*ppStatusList, pszStatus)) {
STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
- replaceStr( &node->pszGroup, pszStatus );
+ replaceStrT(node->pszGroup, pszStatus);
node->hIcon = (HICON)(*iCount);
while ((INT_PTR)node->hIcon > STATUSICONCOUNT - 1)
node->hIcon--;
@@ -1117,14 +1118,14 @@ USERINFO* UM_AddUser(STATUSINFO* pStatusList, USERINFO** ppUserList, const TCHAR // if (!UM_FindUser(*ppUserList, pszUI, wStatus)
{
USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO));
- replaceStr( &node->pszUID, pszUID );
+ replaceStrT(node->pszUID, pszUID);
if (*ppUserList == NULL) { // list is empty
*ppUserList = node;
node->next = NULL;
}
else {
- if ( pLast ) {
+ if (pLast) {
node->next = pTemp;
pLast->next = node;
}
diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp index 35a34aac4b..2d5370980f 100644 --- a/plugins/Scriver/src/chat/options.cpp +++ b/plugins/Scriver/src/chat/options.cpp @@ -225,21 +225,20 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p void LoadLogFonts(void)
{
- int i;
- for ( i = 0; i<OPTIONS_FONTCOUNT; i++)
+ for (int i = 0; i<OPTIONS_FONTCOUNT; i++)
LoadMsgDlgFont(i, &aFonts[i].lf, &aFonts[i].color, TRUE);
}
-static void InitSetting(TCHAR** ppPointer, char* pszSetting, TCHAR* pszDefault)
+static void InitSetting(TCHAR **ppPointer, char *pszSetting, TCHAR *pszDefault)
{
DBVARIANT dbv;
if ( !db_get_ts(NULL, "Chat", pszSetting, &dbv )) {
- replaceStr( ppPointer, dbv.ptszVal );
+ replaceStrT(*ppPointer, dbv.ptszVal);
db_free(&dbv);
}
- else replaceStr( ppPointer, pszDefault );
- }
+ else replaceStrT(*ppPointer, pszDefault);
+}
#define OPT_FIXHEADINGS (WM_USER+1)
diff --git a/plugins/Scriver/src/chat/services.cpp b/plugins/Scriver/src/chat/services.cpp index aa1b4c5891..30c4d1928b 100644 --- a/plugins/Scriver/src/chat/services.cpp +++ b/plugins/Scriver/src/chat/services.cpp @@ -306,28 +306,24 @@ static INT_PTR DoControl(GCEVENT *gce, WPARAM wp) }
SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
}
-
else if (gce->pDest->iType == GC_EVENT_CHUID && gce->pszText)
{
SM_ChangeUID( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText);
}
-
else if (gce->pDest->iType == GC_EVENT_CHANGESESSIONAME && gce->pszText)
{
SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if ( si ) {
- replaceStr( &si->ptszName, gce->ptszText );
+ if (si) {
+ replaceStrT(si->ptszName, gce->ptszText);
if (si->hWnd)
SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
}
}
-
else if (gce->pDest->iType == GC_EVENT_SETITEMDATA) {
SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
if (si)
si->dwItemData = gce->dwItemData;
}
-
else if (gce->pDest->iType ==GC_EVENT_GETITEMDATA) {
SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
if (si) {
@@ -340,8 +336,8 @@ static INT_PTR DoControl(GCEVENT *gce, WPARAM wp) {
SESSION_INFO *si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
if (si) {
- replaceStr( &si->ptszStatusbarText, gce->ptszText );
- if ( si->ptszStatusbarText )
+ replaceStrT(si->ptszStatusbarText, gce->ptszText);
+ if (si->ptszStatusbarText)
db_set_ts(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
else
db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
@@ -475,7 +471,7 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_TOPIC:
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
if (gce->pszText) {
- replaceStr( &si->ptszTopic, gce->ptszText);
+ replaceStrT(si->ptszTopic, gce->ptszText);
db_set_ts(si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting(si->ptszTopic));
if ( db_get_b( NULL, "Chat", "TopicOnClist", 0 ))
db_set_ts(si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting(si->ptszTopic));
diff --git a/plugins/Scriver/src/chat/tools.cpp b/plugins/Scriver/src/chat/tools.cpp index ea3ce9918a..1f8dcc3389 100644 --- a/plugins/Scriver/src/chat/tools.cpp +++ b/plugins/Scriver/src/chat/tools.cpp @@ -27,12 +27,12 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) int i = 0;
int j = 0;
- if ( pszWord == 0 || lstrlen(pszWord) == 0 )
+ if (pszWord == 0 || lstrlen(pszWord) == 0)
return NULL;
- while(j < 9999 && i <= lstrlen( pszWord )) {
+ while (j < 9999 && i <= lstrlen(pszWord)) {
if (pszWord[i] == '%') {
- switch ( pszWord[i+1] ) {
+ switch (pszWord[i + 1]) {
case '%':
szTemp[j] = '%';
j++;
@@ -60,7 +60,8 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) j++;
i++;
break;
- } }
+ }
+ }
else {
szTemp[j] = pszWord[i];
j++;
@@ -68,7 +69,7 @@ TCHAR* RemoveFormatting(const TCHAR* pszWord) }
}
- return (TCHAR*) &szTemp;
+ return (TCHAR*)&szTemp;
}
static void __stdcall ShowRoomFromPopup(void * pi)
@@ -79,26 +80,22 @@ static void __stdcall ShowRoomFromPopup(void * pi) static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
+ switch (message) {
case WM_COMMAND:
if (HIWORD(wParam) == STN_CLICKED) {
- SESSION_INFO *si = (SESSION_INFO*) PUGetPluginData(hWnd);
-
+ SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd);
CallFunctionAsync(ShowRoomFromPopup, si);
-
PUDeletePopup(hWnd);
return TRUE;
}
break;
case WM_CONTEXTMENU:
- {
- SESSION_INFO *si = (SESSION_INFO*) PUGetPluginData(hWnd);
- if (si->windowData.hContact)
- if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
+ SESSION_INFO *si = (SESSION_INFO*)PUGetPluginData(hWnd);
+ if (si->windowData.hContact)
+ if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->windowData.hContact, 0))
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->windowData.hContact, (LPARAM)"chaticon");
- PUDeletePopup( hWnd );
- }
+ PUDeletePopup( hWnd );
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
@@ -116,20 +113,16 @@ static int ShowPopup (HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszP mir_vsntprintf(szBuf, 4096, fmt, marker);
va_end(marker);
- POPUPDATAT pd = {0};
+ POPUPDATAT pd = { 0 };
pd.lchContact = hContact;
-
- if ( hIcon )
- pd.lchIcon = hIcon ;
- else
- pd.lchIcon = GetCachedIcon("chat_window");
+ pd.lchIcon = (hIcon) ? hIcon : GetCachedIcon("chat_window");
PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
- mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME-1, _T("%s - %s"),
+ mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
(pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
pcli->pfnGetContactDisplayName(hContact, 0));
- lstrcpyn( pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
+ lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
pd.iSeconds = g_Settings.iPopupTimeout;
if (g_Settings.iPopupStyle == 2) {
@@ -154,13 +147,13 @@ static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT * gce) {
int iEvent = gce->pDest->iType;
- if ( iEvent&g_Settings.dwTrayIconFlags ) {
- switch ( iEvent ) {
- case GC_EVENT_MESSAGE|GC_EVENT_HIGHLIGHT :
- case GC_EVENT_ACTION|GC_EVENT_HIGHLIGHT :
+ if (iEvent&g_Settings.dwTrayIconFlags) {
+ switch (iEvent) {
+ case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
CList_AddEvent(si->windowData.hContact, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), "chaticon", 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
break;
- case GC_EVENT_MESSAGE :
+ case GC_EVENT_MESSAGE:
CList_AddEvent(si->windowData.hContact, GetCachedIcon("chat_log_message_in"), "chaticon", CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_ACTION:
@@ -206,16 +199,16 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) {
int iEvent = gce->pDest->iType;
- if ( iEvent & g_Settings.dwPopupFlags ) {
+ if (iEvent & g_Settings.dwPopupFlags) {
switch (iEvent) {
- case GC_EVENT_MESSAGE|GC_EVENT_HIGHLIGHT :
- ShowPopup(si->windowData.hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting( gce->ptszText ));
+ case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
+ ShowPopup(si->windowData.hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
- case GC_EVENT_ACTION|GC_EVENT_HIGHLIGHT :
+ case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
ShowPopup(si->windowData.hContact, si, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, aFonts[16].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
- case GC_EVENT_MESSAGE :
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_message_in"), si->pszModule, si->ptszName, aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting( gce->ptszText));
+ case GC_EVENT_MESSAGE:
+ ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_message_in"), si->pszModule, si->ptszName, aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_action"), si->pszModule, si->ptszName, aFonts[15].color, _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
@@ -233,7 +226,7 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) if (!gce->pszText)
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
else
- ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick,RemoveFormatting(gce->ptszText));
+ ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_quit"), si->pszModule, si->ptszName, aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NICK:
ShowPopup(si->windowData.hContact, si, GetCachedIcon("chat_log_nick"), si->pszModule, si->ptszName, aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
@@ -270,7 +263,7 @@ static BOOL DoPopup(SESSION_INFO *si, GCEVENT * gce) BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighlight, int bManyFix)
{
- if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER)
+ if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER)
return FALSE;
BOOL bInactive = si->hWnd == NULL || GetForegroundWindow() != GetParent(si->hWnd);
@@ -278,7 +271,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh int iEvent = gce->pDest->iType;
- if ( bHighlight ) {
+ if (bHighlight) {
gce->pDest->iType |= GC_EVENT_HIGHLIGHT;
if (bInactive || !g_Settings.SoundsFocus)
SkinPlaySound("ChatHighlight");
@@ -334,9 +327,9 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh if (bInactive && g_Settings.FlashWindow && si->hWnd)
SendMessage(GetParent(si->hWnd), CM_STARTFLASHING, 0, 0);
- if (bInactive && !( si->wState & STATE_TALK )) {
+ if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
- db_set_w(si->windowData.hContact, si->pszModule,"ApparentMode",(LPARAM)(WORD) 40071);
+ db_set_w(si->windowData.hContact, si->pszModule, "ApparentMode", (LPARAM)(WORD)40071);
}
if (bInactive && si->hWnd)
SendMessage(si->hWnd, GC_SETTABHIGHLIGHT, 0, 0);
@@ -365,7 +358,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT * gce, BOOL bHighligh int GetColorIndex(const char* pszModule, COLORREF cr)
{
- MODULEINFO * pMod = MM_FindModule(pszModule);
+ MODULEINFO *pMod = MM_FindModule(pszModule);
if (!pMod || pMod->nColorCount == 0)
return -1;
@@ -383,18 +376,18 @@ int GetColorIndex(const char* pszModule, COLORREF cr) void CheckColorsInModule(const char* pszModule)
{
- MODULEINFO *pMod = MM_FindModule( pszModule );
+ MODULEINFO *pMod = MM_FindModule(pszModule);
COLORREF crFG;
COLORREF crBG = (COLORREF)db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, NULL, &crFG, FALSE);
- if ( !pMod )
+ if (!pMod)
return;
for (int i = 0; i < pMod->nColorCount; i++) {
if (pMod->crColors[i] == crFG || pMod->crColors[i] == crBG) {
- if (pMod->crColors[i] == RGB(255,255,255))
+ if (pMod->crColors[i] == RGB(255, 255, 255))
pMod->crColors[i]--;
else
pMod->crColors[i]++;
@@ -402,19 +395,19 @@ void CheckColorsInModule(const char* pszModule) }
}
-TCHAR* my_strstri( const TCHAR* s1, const TCHAR* s2)
+TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2)
{
- for(int i=0;s1[i];i++)
- for(int j=i,k=0; _totlower(s1[j]) == _totlower(s2[k]);j++,k++)
- if (!s2[k+1])
- return (TCHAR*)(s1+i);
+ for (int i = 0; s1[i]; i++)
+ for (int j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++)
+ if (!s2[k + 1])
+ return (TCHAR*)(s1 + i);
return NULL;
}
BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText)
{
- if ( g_Settings.HighlightEnabled && g_Settings.pszHighlightWords && pszText && si->pMe ) {
+ if (g_Settings.HighlightEnabled && g_Settings.pszHighlightWords && pszText && si->pMe) {
TCHAR* p1 = g_Settings.pszHighlightWords;
TCHAR* p2 = NULL;
const TCHAR* p3 = pszText;
@@ -426,7 +419,7 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) while (*p1 != '\0') {
// find the next/first word in the highlight word string
// skip 'spaces' be4 the word
- while(*p1 == ' ' && *p1 != '\0')
+ while (*p1 == ' ' && *p1 != '\0')
p1 += 1;
//find the end of the word
@@ -437,7 +430,7 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) return FALSE;
// copy the word into szWord1
- lstrcpyn(szWord1, p1, p2-p1>998?999:p2-p1+1);
+ lstrcpyn(szWord1, p1, p2 - p1 > 998 ? 999 : p2 - p1 + 1);
p1 = p2;
// replace %m with the users nickname
@@ -451,10 +444,9 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) }
// time to get the next/first word in the incoming text string
- while(*p3 != '\0')
- {
+ while (*p3 != '\0') {
// skip 'spaces' be4 the word
- while(*p3 == ' ' && *p3 != '\0')
+ while (*p3 == ' ' && *p3 != '\0')
p3 += 1;
//find the end of the word
@@ -465,11 +457,11 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) if (p3 != p2) {
// eliminate ending character if needed
- if (p2-p3 > 1 && _tcschr(szTrimString, p2[-1]))
+ if (p2 - p3 > 1 && _tcschr(szTrimString, p2[-1]))
p2 -= 1;
// copy the word into szWord2 and remove formatting
- lstrcpyn(szWord2, p3, p2-p3>998?999:p2-p3+1);
+ lstrcpyn(szWord2, p3, p2 - p3 > 998 ? 999 : p2 - p3 + 1);
// reset the pointer if it was touched because of an ending character
if (*p2 != '\0' && *p2 != ' ')
@@ -482,10 +474,12 @@ BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText) // compare the words, using wildcards
if (WCCmp(szWord1, RemoveFormatting(szWord2)))
return TRUE;
- } }
+ }
+ }
p3 = pszText;
- } }
+ }
+ }
return FALSE;
}
@@ -503,7 +497,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) return FALSE;
MODULEINFO *mi = MM_FindModule(si->pszModule);
- if ( !mi )
+ if (!mi)
return FALSE;
szBuffer[0] = '\0';
@@ -523,10 +517,10 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) TCHAR* pszNick = NULL;
if (bFileJustCreated)
fputws((const wchar_t*)"\377\376", hFile); //UTF-16 LE BOM == FF FE
- if ( gce->ptszNick ) {
- if ( g_Settings.LogLimitNames && lstrlen(gce->ptszNick) > 20 ) {
+ if (gce->ptszNick) {
+ if (g_Settings.LogLimitNames && lstrlen(gce->ptszNick) > 20) {
lstrcpyn(szTemp2, gce->ptszNick, 20);
- lstrcpyn(szTemp2+20, _T("..."), 4);
+ lstrcpyn(szTemp2 + 20, _T("..."), 4);
}
else lstrcpyn(szTemp2, gce->ptszNick, 511);
@@ -536,15 +530,14 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), szTemp2);
pszNick = szTemp;
}
- switch (gce->pDest->iType)
- {
+ switch (gce->pDest->iType) {
case GC_EVENT_MESSAGE:
- case GC_EVENT_MESSAGE|GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
p = '*';
mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s * %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
- case GC_EVENT_ACTION|GC_EVENT_HIGHLIGHT:
+ case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
p = '*';
mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
@@ -558,14 +551,14 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left"), (char*)pszNick);
else
mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has left (%s)"), (char*)pszNick, RemoveFormatting(gce->ptszText));
- break;
+ break;
case GC_EVENT_QUIT:
p = '<';
if (!gce->pszText)
mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected"), (char*)pszNick);
else
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char*)pszNick,RemoveFormatting(gce->ptszText));
- break;
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s has disconnected (%s)"), (char*)pszNick, RemoveFormatting(gce->ptszText));
+ break;
case GC_EVENT_NICK:
p = '^';
mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
@@ -623,9 +616,9 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) size_t read = 0;
pBuffer = (BYTE *)mir_alloc(g_Settings.LoggingLimit * 1024 + 2);
- pBuffer[g_Settings.LoggingLimit*1024] = '\0';
- pBuffer[g_Settings.LoggingLimit*1024+1] = '\0';
- fseek(hFile, -g_Settings.LoggingLimit*1024, SEEK_END);
+ pBuffer[g_Settings.LoggingLimit * 1024] = '\0';
+ pBuffer[g_Settings.LoggingLimit * 1024 + 1] = '\0';
+ fseek(hFile, -g_Settings.LoggingLimit * 1024, SEEK_END);
read = fread(pBuffer, 1, g_Settings.LoggingLimit * 1024, hFile);
fclose(hFile);
hFile = NULL;
@@ -633,9 +626,10 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) // trim to whole lines, should help with broken log files I hope.
pBufferTemp = (BYTE*)_tcschr((TCHAR*)pBuffer, _T('\n'));
if (pBufferTemp) {
- pBufferTemp+= sizeof(TCHAR);
+ pBufferTemp += sizeof(TCHAR);
read = read - (pBufferTemp - pBuffer);
- } else pBufferTemp = pBuffer;
+ }
+ else pBufferTemp = pBuffer;
if (read > 0) {
hFile = _tfopen(tszFile, _T("wb"));
@@ -644,9 +638,12 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) fwrite(pBufferTemp, 1, read, hFile);
fclose(hFile);
hFile = NULL;
- } }
+ }
+ }
mir_free(pBuffer);
- } } }
+ }
+ }
+ }
if (hFile)
fclose(hFile);
@@ -658,7 +655,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT * gce) UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText)
{
- GCMENUITEMS gcmi = {0};
+ GCMENUITEMS gcmi = { 0 };
HMENU hSubMenu = 0;
*hMenu = GetSubMenu(g_hMenu, iIndex);
@@ -676,17 +673,16 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s EnableMenuItem(*hMenu, IDM_CLEAR, MF_BYCOMMAND | MF_GRAYED);
}
- if ( pszWordText && pszWordText[0] ) {
+ if (pszWordText && pszWordText[0]) {
TCHAR szMenuText[4096];
- mir_sntprintf( szMenuText, 4096, TranslateT("Look up \'%s\':"), pszWordText );
- ModifyMenu( *hMenu, 4, MF_STRING|MF_BYPOSITION, 4, szMenuText );
+ mir_sntprintf(szMenuText, 4096, TranslateT("Look up \'%s\':"), pszWordText);
+ ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText);
SetSearchEngineIcons(*hMenu, g_dat.hSearchEngineIconList);
}
- else ModifyMenu( *hMenu, 4, MF_STRING|MF_GRAYED|MF_BYPOSITION, 4, TranslateT( "No word to look up" ));
+ else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up"));
gcmi.Type = MENU_ON_LOG;
}
- else if (iIndex == 0)
- {
+ else if (iIndex == 0) {
TCHAR szTemp[50];
if (pszWordText)
mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("&Message %s"), pszWordText);
@@ -705,8 +701,8 @@ UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *s AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
for (int i = 0; i < gcmi.nItems; i++) {
- TCHAR* ptszDescr = a2tf(gcmi.Item[i].pszDesc, si->dwFlags);
- TCHAR* ptszText = TranslateTS(ptszDescr);
+ TCHAR *ptszDescr = a2tf(gcmi.Item[i].pszDesc, si->dwFlags);
+ TCHAR *ptszText = TranslateTS(ptszDescr);
DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0;
if (gcmi.Item[i].uType == MENU_NEWPOPUP) {
@@ -750,26 +746,23 @@ void DestroyGCMenu(HMENU *hMenu, int iIndex) BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, DWORD dwItem)
{
- GCHOOK* gch = (GCHOOK*)mir_alloc( sizeof( GCHOOK ));
- GCDEST* gcd = (GCDEST*)mir_alloc( sizeof( GCDEST ));
-
- memset( gch, 0, sizeof( GCHOOK ));
- memset( gcd, 0, sizeof( GCDEST ));
+ GCHOOK *gch = (GCHOOK*)mir_calloc(sizeof(GCHOOK));
+ GCDEST *gcd = (GCDEST*)mir_calloc(sizeof(GCDEST));
- replaceStrA( &gcd->pszModule, pszModule);
+ replaceStr(gcd->pszModule, pszModule);
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si == NULL)
return FALSE;
- if ( !( si->dwFlags & GC_UNICODE )) {
+ if (!(si->dwFlags & GC_UNICODE)) {
gcd->pszID = mir_t2a(pszID);
gch->pszUID = mir_t2a(pszUID);
gch->pszText = mir_t2a(pszText);
}
else {
- replaceStr(&gcd->ptszID, pszID);
- replaceStr(&gch->ptszUID, pszUID);
- replaceStr(&gch->ptszText, pszText);
+ replaceStrT(gcd->ptszID, pszID);
+ replaceStrT(gch->ptszUID, pszUID);
+ replaceStrT(gch->ptszText, pszText);
}
gcd->iType = iType;
@@ -781,15 +774,15 @@ BOOL DoEventHookAsync(HWND hwnd, const TCHAR* pszID, const char* pszModule, int BOOL DoEventHook(const TCHAR* pszID, const char* pszModule, int iType, const TCHAR* pszUID, const TCHAR* pszText, DWORD dwItem)
{
- GCHOOK gch = {0};
- GCDEST gcd = {0};
+ GCHOOK gch = { 0 };
+ GCDEST gcd = { 0 };
gcd.pszModule = (char*)pszModule;
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si == NULL)
return FALSE;
- if ( !(si->dwFlags & GC_UNICODE)) {
+ if (!(si->dwFlags & GC_UNICODE)) {
gcd.pszID = mir_t2a(pszID);
gch.pszUID = mir_t2a(pszUID);
gch.pszText = mir_t2a(pszText);
@@ -845,7 +838,7 @@ BOOL IsEventSupported(int eventType) return FALSE;
}
-TCHAR* a2tf( const TCHAR* str, int flags )
+TCHAR* a2tf(const TCHAR* str, int flags)
{
if (str == NULL)
return NULL;
@@ -856,7 +849,7 @@ TCHAR* a2tf( const TCHAR* str, int flags ) int codepage = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
int cbLen = MultiByteToWideChar(codepage, 0, (char*)str, -1, 0, 0);
- TCHAR *result = (TCHAR*)mir_alloc( sizeof(TCHAR)*( cbLen+1 ));
+ TCHAR *result = (TCHAR*)mir_alloc(sizeof(TCHAR)*(cbLen + 1));
if (result == NULL)
return NULL;
@@ -865,26 +858,12 @@ TCHAR* a2tf( const TCHAR* str, int flags ) return result;
}
-TCHAR* replaceStr( TCHAR** dest, const TCHAR* src )
-{
- mir_free(*dest);
- *dest = mir_tstrdup(src);
- return *dest;
-}
-
-char* replaceStrA( char** dest, const char* src )
-{
- mir_free(*dest);
- *dest = mir_strdup(src);
- return *dest;
-}
-
-TCHAR* GetChatLogsFilename (HANDLE hContact, time_t tTime)
+TCHAR* GetChatLogsFilename(HANDLE hContact, time_t tTime)
{
REPLACEVARSARRAY rva[11];
- TCHAR *p = {0}, *tszParsedName = {0};
+ TCHAR *p = { 0 }, *tszParsedName = { 0 };
- if (g_Settings.pszLogDir[_tcslen(g_Settings.pszLogDir)-1] == '\\')
+ if (g_Settings.pszLogDir[_tcslen(g_Settings.pszLogDir) - 1] == '\\')
_tcscat(g_Settings.pszLogDir, _T("%userid%.log"));
if (!tTime)
time(&tTime);
@@ -933,11 +912,11 @@ TCHAR* GetChatLogsFilename (HANDLE hContact, time_t tTime) _tcsncpy(tszFileName, tszParsedName, MAX_PATH);
mir_free(tszParsedName);
- for (int i=0; i < SIZEOF(rva);i++)
+ for (int i = 0; i < SIZEOF(rva); i++)
mir_free(rva[i].lptzValue);
for (p = tszFileName + 2; *p; ++p)
- if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|' )
+ if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|')
*p = _T('_');
return tszFileName;
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp index 3b699c035a..20ae57859c 100644 --- a/plugins/Scriver/src/chat/window.cpp +++ b/plugins/Scriver/src/chat/window.cpp @@ -1614,7 +1614,7 @@ LABEL_SHOWWINDOW: case GC_FIREHOOK:
if (lParam) {
- GCHOOK* gch = (GCHOOK *) lParam;
+ GCHOOK *gch = (GCHOOK *) lParam;
NotifyEventHooks(hSendEvent,0,(WPARAM)gch);
if ( gch->pDest ) {
mir_free( gch->pDest->pszID );
|