summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp10
-rw-r--r--protocols/IRCG/src/input.cpp4
-rw-r--r--protocols/IRCG/src/services.cpp2
-rw-r--r--protocols/IRCG/src/tools.cpp530
-rw-r--r--protocols/IRCG/src/windows.cpp4
5 files changed, 280 insertions, 270 deletions
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index 27b60e0076..fa9a38b2a4 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -372,7 +372,7 @@ bool CIrcProto::OnIrc_QUIT(const CIrcMessage* pmsg)
GCEVENT gce = {0};
gce.cbSize = sizeof(GCEVENT);
- gcd.pszID = NULL;
+ gcd.ptszID = NULL;
gcd.pszModule = m_szModuleName;
gcd.iType = GC_EVENT_CONTROL;
gce.pDest = &gcd;
@@ -429,7 +429,7 @@ bool CIrcProto::OnIrc_KICK(const CIrcMessage* pmsg)
CallChatEvent( SESSION_OFFLINE, (LPARAM)&gce);
if ( m_rejoinIfKicked ) {
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
if ( wi && wi->pszPassword )
PostIrcMessage( _T("/JOIN %s %s"), pmsg->parameters[0].c_str(), wi->pszPassword);
else
@@ -512,7 +512,7 @@ bool CIrcProto::OnIrc_MODE(const CIrcMessage* pmsg)
if (( int )pmsg->parameters.getCount() > iParametercount ) {
if ( !_tcscmp(pmsg->parameters[2].c_str(), m_info.sNick.c_str())) {
char cModeBit = -1;
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent( GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, false, false, 0 );
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent( GC_EVENT_GETITEMDATA, pmsg->parameters[0].c_str(), NULL, NULL, NULL, NULL, NULL, false, false, 0 );
switch (*p1) {
case 'v': cModeBit = 0; break;
case 'h': cModeBit = 1; break;
@@ -1361,7 +1361,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
//Set the item data for the window
{
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, sChanName, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, sChanName, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
if (!wi)
wi = new CHANNELINFO;
wi->OwnMode = btOwnMode;
@@ -2386,7 +2386,7 @@ bool CIrcProto::DoOnConnect( const CIrcMessage* )
gci.iItem = i;
gci.pszModule = m_szModuleName;
if ( !CallServiceSync( MS_GC_GETINFO, 0, (LPARAM)&gci) && gci.iType == GCW_CHATROOM ) {
- CHANNELINFO* wi = ( CHANNELINFO* )gci.dwItemData;
+ CHANNELINFO *wi = ( CHANNELINFO* )gci.dwItemData;
if ( wi && wi->pszPassword )
PostIrcMessage( _T("/JOIN %s %s"), gci.pszName, wi->pszPassword);
else
diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp
index 01bccf2925..eb8125a351 100644
--- a/protocols/IRCG/src/input.cpp
+++ b/protocols/IRCG/src/input.cpp
@@ -480,7 +480,7 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
PostIrcMessage( _T("/PART %s"), window );
if (( one.IsEmpty() || !IsChannel( one ))) {
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
if ( wi && wi->pszPassword )
PostIrcMessage( _T("/JOIN %s %s"), window, wi->pszPassword);
else
@@ -857,7 +857,7 @@ bool CIrcProto::PostIrcMessageWnd( TCHAR* window, HANDLE hContact, const TCHAR*
if ( Message.IsEmpty())
return 0;
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, windowname, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, windowname, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
int codepage = ( wi ) ? wi->codepage : getCodepage();
// process the message
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index ff75157663..211e9e0dc1 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -954,7 +954,7 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
int len = min((( temp == NULL ) ? lstrlen( gcmi->pszID ) : ( int )( temp - gcmi->pszID + 1 )), SIZEOF(stzChanName)-1 );
lstrcpyn( stzChanName, gcmi->pszID, len );
stzChanName[ len ] = 0;
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA,stzChanName, NULL, NULL, NULL, NULL, NULL, false, false, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA,stzChanName, NULL, NULL, NULL, NULL, NULL, false, false, 0);
BOOL bServOwner = strchr(sUserModes.c_str(), 'q') == NULL?FALSE:TRUE;
BOOL bServAdmin = strchr(sUserModes.c_str(), 'a') == NULL?FALSE:TRUE;
BOOL bOwner = bServOwner?((wi->OwnMode>>4)&01):FALSE;
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp
index f477221510..8489a2557a 100644
--- a/protocols/IRCG/src/tools.cpp
+++ b/protocols/IRCG/src/tools.cpp
@@ -25,25 +25,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void CIrcProto::AddToJTemp(TCHAR op, CMString& sCommand)
{
- CMString res;
+ CMString res;
int pos = 0;
- for ( ;; ) {
- CMString tmp = sCommand.Tokenize( _T(","), pos );
- if ( pos == -1 )
+ for (;;) {
+ CMString tmp = sCommand.Tokenize(_T(","), pos);
+ if (pos == -1)
break;
tmp = op + tmp;
- if ( res.IsEmpty())
+ if (res.IsEmpty())
res = tmp;
else
res += _T(" ") + tmp;
}
DBVARIANT dbv;
- if ( !getTString( "JTemp", &dbv )) {
+ if (!getTString("JTemp", &dbv)) {
res = CMString(dbv.ptszVal) + _T(" ") + res;
- db_free( &dbv );
+ db_free(&dbv);
}
setTString("JTemp", res.c_str());
@@ -51,7 +51,7 @@ void CIrcProto::AddToJTemp(TCHAR op, CMString& sCommand)
CMString __stdcall GetWord(const TCHAR* text, int index)
{
- if ( text && *text ) {
+ if (text && *text) {
TCHAR* p1 = (TCHAR*)text;
TCHAR* p2 = NULL;
@@ -59,31 +59,32 @@ CMString __stdcall GetWord(const TCHAR* text, int index)
p1++;
if (*p1 != '\0') {
- for (int i =0; i < index; i++) {
- p2 = _tcschr( p1, ' ' );
- if ( !p2 )
- p2 = _tcschr( p1, '\0' );
+ for (int i = 0; i < index; i++) {
+ p2 = _tcschr(p1, ' ');
+ if (!p2)
+ p2 = _tcschr(p1, '\0');
else
- while ( *p2 == ' ' )
- p2++;
+ while (*p2 == ' ')
+ p2++;
p1 = p2;
}
p2 = _tcschr(p1, ' ');
- if ( !p2 )
+ if (!p2)
p2 = _tcschr(p1, '\0');
if (p1 != p2)
- return CMString( p1, p2-p1 );
- } }
+ return CMString(p1, p2 - p1);
+ }
+ }
return CMString();
}
const TCHAR* __stdcall GetWordAddress(const TCHAR* text, int index)
{
- if ( !text || !lstrlen(text))
+ if (!text || !lstrlen(text))
return text;
const TCHAR* temp = text;
@@ -96,66 +97,67 @@ const TCHAR* __stdcall GetWordAddress(const TCHAR* text, int index)
for (int i = 0; i < index; i++) {
temp = _tcschr(temp, ' ');
- if ( !temp )
- temp = ( TCHAR* )_tcschr(text, '\0');
+ if (!temp)
+ temp = (TCHAR*)_tcschr(text, '\0');
else
- while (*temp == ' ')
- temp++;
+ while (*temp == ' ')
+ temp++;
text = temp;
}
return temp;
}
-void __stdcall RemoveLinebreaks( CMString& Message )
+void __stdcall RemoveLinebreaks(CMString& Message)
{
- while ( Message.Find( _T("\r\n\r\n"), 0) != -1 )
- ReplaceString( Message, _T("\r\n\r\n"), _T("\r\n"));
+ while (Message.Find(_T("\r\n\r\n"), 0) != -1)
+ ReplaceString(Message, _T("\r\n\r\n"), _T("\r\n"));
- if (Message.Find( _T("\r\n"), 0) == 0)
- Message.Delete(0,2);
+ if (Message.Find(_T("\r\n"), 0) == 0)
+ Message.Delete(0, 2);
- if ( (Message.GetLength() > 1) && (Message.Find(_T("\r\n"), Message.GetLength()-2) == 0))
- Message.Delete(Message.GetLength()-2, 2);
+ if ((Message.GetLength() > 1) && (Message.Find(_T("\r\n"), Message.GetLength() - 2) == 0))
+ Message.Delete(Message.GetLength() - 2, 2);
}
-String& __stdcall ReplaceString ( String& text, const char* replaceme, const char* newword )
+String& __stdcall ReplaceString(String& text, const char* replaceme, const char* newword)
{
- if ( !text.IsEmpty() && replaceme != NULL) {
+ if (!text.IsEmpty() && replaceme != NULL) {
int i = 0;
- while (( i = text.Find(replaceme, i)) != -1 ) {
- text.Delete(i,lstrlenA(replaceme));
+ while ((i = text.Find(replaceme, i)) != -1) {
+ text.Delete(i, lstrlenA(replaceme));
text.Insert(i, newword);
i = i + lstrlenA(newword);
- } }
+ }
+ }
return text;
}
-CMString& __stdcall ReplaceString ( CMString& text, const TCHAR* replaceme, const TCHAR* newword)
+CMString& __stdcall ReplaceString(CMString& text, const TCHAR* replaceme, const TCHAR* newword)
{
- if ( !text.IsEmpty() && replaceme != NULL) {
+ if (!text.IsEmpty() && replaceme != NULL) {
int i = 0;
- while (( i = text.Find(replaceme, i)) != -1 ) {
- text.Delete(i,lstrlen(replaceme));
+ while ((i = text.Find(replaceme, i)) != -1) {
+ text.Delete(i, lstrlen(replaceme));
text.Insert(i, newword);
i = i + lstrlen(newword);
- } }
+ }
+ }
return text;
}
-char* __stdcall IrcLoadFile( TCHAR* szPath)
+char* __stdcall IrcLoadFile(TCHAR* szPath)
{
char * szContainer = NULL;
DWORD dwSiz = 0;
- FILE *hFile = _tfopen(szPath, _T("rb"));
- if ( hFile != NULL )
- {
- fseek(hFile,0,SEEK_END); // seek to end
+ FILE *hFile = _tfopen(szPath, _T("rb"));
+ if (hFile != NULL) {
+ fseek(hFile, 0, SEEK_END); // seek to end
dwSiz = ftell(hFile); // size
- fseek(hFile,0,SEEK_SET); // seek back to original pos
- szContainer = new char [dwSiz+1];
+ fseek(hFile, 0, SEEK_SET); // seek back to original pos
+ szContainer = new char[dwSiz + 1];
fread(szContainer, 1, dwSiz, hFile);
szContainer[dwSiz] = '\0';
fclose(hFile);
@@ -165,9 +167,9 @@ char* __stdcall IrcLoadFile( TCHAR* szPath)
return 0;
}
-int __stdcall WCCmp( const TCHAR* wild, const TCHAR* string )
+int __stdcall WCCmp(const TCHAR* wild, const TCHAR* string)
{
- if ( wild == NULL || !lstrlen(wild) || string == NULL || !lstrlen(string))
+ if (wild == NULL || !lstrlen(wild) || string == NULL || !lstrlen(string))
return 1;
const TCHAR *cp = NULL, *mp = NULL;
@@ -178,14 +180,14 @@ int __stdcall WCCmp( const TCHAR* wild, const TCHAR* string )
wild++;
string++;
}
-
+
while (*string) {
if (*wild == '*') {
if (!*++wild)
return 1;
mp = wild;
- cp = string+1;
+ cp = string + 1;
}
else if ((*wild == *string) || (*wild == '?')) {
wild++;
@@ -194,22 +196,23 @@ int __stdcall WCCmp( const TCHAR* wild, const TCHAR* string )
else {
wild = mp;
string = cp++;
- } }
-
+ }
+ }
+
while (*wild == '*')
wild++;
return !*wild;
-}
+}
-bool CIrcProto::IsChannel(const TCHAR* sName)
+bool CIrcProto::IsChannel(const TCHAR* sName)
{
- return ( sChannelPrefixes.Find( sName[0] ) != -1 );
+ return (sChannelPrefixes.Find(sName[0]) != -1);
}
String __stdcall GetWord(const char* text, int index)
{
- if ( text && text[0] ) {
+ if (text && text[0]) {
char* p1 = (char*)text;
char* p2 = NULL;
@@ -217,13 +220,13 @@ String __stdcall GetWord(const char* text, int index)
p1++;
if (*p1 != '\0') {
- for (int i =0; i < index; i++) {
- p2 = strchr( p1, ' ' );
- if ( !p2 )
- p2 = strchr( p1, '\0' );
+ for (int i = 0; i < index; i++) {
+ p2 = strchr(p1, ' ');
+ if (!p2)
+ p2 = strchr(p1, '\0');
else
- while ( *p2 == ' ' )
- p2++;
+ while (*p2 == ' ')
+ p2++;
p1 = p2;
}
@@ -233,29 +236,30 @@ String __stdcall GetWord(const char* text, int index)
p2 = strchr(p1, '\0');
if (p1 != p2)
- return String( p1, p2-p1+1 );
- } }
+ return String(p1, p2 - p1 + 1);
+ }
+ }
return String();
}
-bool CIrcProto::IsChannel(const char* sName)
+bool CIrcProto::IsChannel(const char* sName)
{
- return ( sChannelPrefixes.Find( sName[0] ) != -1 );
+ return (sChannelPrefixes.Find(sName[0]) != -1);
}
-TCHAR* __stdcall my_strstri(const TCHAR* s1, const TCHAR* s2)
-{
- int i,j,k;
- for(i=0;s1[i];i++)
- for(j=i,k=0; _totlower(s1[j]) == _totlower(s2[k]);j++,k++)
- if (!s2[k+1])
- return ( TCHAR* )(s1+i);
+TCHAR* __stdcall my_strstri(const TCHAR* s1, const TCHAR* s2)
+{
+ int i, j, k;
+ for (i = 0; s1[i]; i++)
+ for (j = i, k = 0; _totlower(s1[j]) == _totlower(s2[k]); j++, k++)
+ if (!s2[k + 1])
+ return (TCHAR*)(s1 + i);
- return NULL;
-}
+ return NULL;
+}
-TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePercent)
+TCHAR* __stdcall DoColorCodes(const TCHAR* text, bool bStrip, bool bReplacePercent)
{
static TCHAR szTemp[4000]; szTemp[0] = '\0';
TCHAR* p = szTemp;
@@ -263,34 +267,34 @@ TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePerc
bool bUnderline = false;
bool bItalics = false;
- if ( !text )
+ if (!text)
return szTemp;
- while ( *text != '\0' ) {
+ while (*text != '\0') {
int iFG = -1;
int iBG = -1;
- switch( *text ) {
+ switch (*text) {
case '%': //escape
- *p++ = '%';
- if ( bReplacePercent )
- *p++ = '%';
+ *p++ = '%';
+ if (bReplacePercent)
+ *p++ = '%';
text++;
break;
case 2: //bold
- if ( !bStrip ) {
- *p++ = '%';
- *p++ = bBold ? 'B' : 'b';
+ if (!bStrip) {
+ *p++ = '%';
+ *p++ = bBold ? 'B' : 'b';
}
bBold = !bBold;
text++;
break;
case 15: //reset
- if ( !bStrip ) {
- *p++ = '%';
- *p++ = 'r';
+ if (!bStrip) {
+ *p++ = '%';
+ *p++ = 'r';
}
bUnderline = false;
bBold = false;
@@ -298,18 +302,18 @@ TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePerc
break;
case 22: //italics
- if ( !bStrip ) {
- *p++ = '%';
- *p++ = bItalics ? 'I' : 'i';
+ if (!bStrip) {
+ *p++ = '%';
+ *p++ = bItalics ? 'I' : 'i';
}
bItalics = !bItalics;
text++;
break;
case 31: //underlined
- if ( !bStrip ) {
- *p++ = '%';
- *p++ = bUnderline ? 'U' : 'u';
+ if (!bStrip) {
+ *p++ = '%';
+ *p++ = bUnderline ? 'U' : 'u';
}
bUnderline = !bUnderline;
text++;
@@ -319,8 +323,8 @@ TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePerc
text++;
// do this if the colors should be reset to default
- if ( *text <= 47 || *text >= 58 || *text == '\0' ) {
- if ( !bStrip ) {
+ if (*text <= 47 || *text >= 58 || *text == '\0') {
+ if (!bStrip) {
*p++ = '%';
*p++ = 'C';
*p++ = '%';
@@ -332,67 +336,70 @@ TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePerc
TCHAR buf[3];
// fix foreground index
- if ( text[1] > 47 && text[1] < 58 && text[1] != '\0')
- lstrcpyn( buf, text, 3 );
+ if (text[1] > 47 && text[1] < 58 && text[1] != '\0')
+ lstrcpyn(buf, text, 3);
else
- lstrcpyn( buf, text, 2 );
- text += lstrlen( buf );
- iFG = _ttoi( buf );
+ lstrcpyn(buf, text, 2);
+ text += lstrlen(buf);
+ iFG = _ttoi(buf);
// fix background color
- if ( *text == ',' && text[1] > 47 && text[1] < 58 && text[1] != '\0' ) {
+ if (*text == ',' && text[1] > 47 && text[1] < 58 && text[1] != '\0') {
text++;
- if ( text[1] > 47 && text[1] < 58 && text[1] != '\0' )
- lstrcpyn( buf, text, 3 );
+ if (text[1] > 47 && text[1] < 58 && text[1] != '\0')
+ lstrcpyn(buf, text, 3);
else
- lstrcpyn( buf, text, 2 );
- text += lstrlen( buf );
- iBG = _ttoi( buf );
- } }
-
- if ( iFG >= 0 && iFG != 99 )
- while( iFG > 15 )
- iFG -= 16;
- if ( iBG >= 0 && iBG != 99 )
- while( iBG > 15 )
- iBG -= 16;
+ lstrcpyn(buf, text, 2);
+ text += lstrlen(buf);
+ iBG = _ttoi(buf);
+ }
+ }
+
+ if (iFG >= 0 && iFG != 99)
+ while (iFG > 15)
+ iFG -= 16;
+ if (iBG >= 0 && iBG != 99)
+ while (iBG > 15)
+ iBG -= 16;
// create tag for chat.dll
- if ( !bStrip ) {
+ if (!bStrip) {
TCHAR buf[10];
- if ( iFG >= 0 && iFG != 99 ) {
+ if (iFG >= 0 && iFG != 99) {
*p++ = '%';
*p++ = 'c';
- mir_sntprintf( buf, SIZEOF(buf), _T("%02u"), iFG );
- for (int i = 0; i<2; i++)
+ mir_sntprintf(buf, SIZEOF(buf), _T("%02u"), iFG);
+ for (int i = 0; i < 2; i++)
*p++ = buf[i];
}
else if (iFG == 99) {
*p++ = '%';
*p++ = 'C';
}
-
- if ( iBG >= 0 && iBG != 99 ) {
+
+ if (iBG >= 0 && iBG != 99) {
*p++ = '%';
*p++ = 'f';
- mir_sntprintf( buf, SIZEOF(buf), _T("%02u"), iBG );
- for ( int i = 0; i<2; i++ )
+ mir_sntprintf(buf, SIZEOF(buf), _T("%02u"), iBG);
+ for (int i = 0; i < 2; i++)
*p++ = buf[i];
}
- else if ( iBG == 99 ) {
+ else if (iBG == 99) {
*p++ = '%';
*p++ = 'F';
- } }
+ }
+ }
break;
default:
*p++ = *text++;
break;
- } }
-
+ }
+ }
+
*p = '\0';
return szTemp;
}
@@ -403,11 +410,10 @@ INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam)
INT_PTR iVal = 0;
// first see if the scripting module should modify or stop this event
- if ( m_bMbotInstalled && m_scriptingEnabled && gce
- && gce->time != 0 && (gce->pDest->pszID == NULL
- || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID , SERVERWINDOW)))
- {
- GCEVENT *gcevent= (GCEVENT*) lParam;
+ if (m_bMbotInstalled && m_scriptingEnabled && gce
+ && gce->time != 0 && (gce->pDest->ptszID == NULL
+ || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID, SERVERWINDOW))) {
+ GCEVENT *gcevent = (GCEVENT*)lParam;
GCEVENT *gcetemp = NULL;
WPARAM wp = wParam;
gcetemp = (GCEVENT *)mir_alloc(sizeof(GCEVENT));
@@ -418,66 +424,66 @@ INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam)
gcetemp->cbSize = sizeof(GCEVENT);
gcetemp->dwItemData = gcevent->dwItemData;
gcetemp->time = gcevent->time;
- gcetemp->pDest->ptszID = mir_tstrdup( gcevent->pDest->ptszID );
- gcetemp->pDest->pszModule = mir_strdup( gcevent->pDest->pszModule );
- gcetemp->ptszText = mir_tstrdup( gcevent->ptszText );
- gcetemp->ptszUID = mir_tstrdup( gcevent->ptszUID );
- gcetemp->ptszNick = mir_tstrdup( gcevent->ptszNick );
- gcetemp->ptszStatus = mir_tstrdup( gcevent->ptszStatus );
- gcetemp->ptszUserInfo = mir_tstrdup( gcevent->ptszUserInfo );
-
- if ( Scripting_TriggerMSPGuiIn( &wp, gcetemp ) && gcetemp ) {
+ gcetemp->pDest->ptszID = mir_tstrdup(gcevent->pDest->ptszID);
+ gcetemp->pDest->pszModule = mir_strdup(gcevent->pDest->pszModule);
+ gcetemp->ptszText = mir_tstrdup(gcevent->ptszText);
+ gcetemp->ptszUID = mir_tstrdup(gcevent->ptszUID);
+ gcetemp->ptszNick = mir_tstrdup(gcevent->ptszNick);
+ gcetemp->ptszStatus = mir_tstrdup(gcevent->ptszStatus);
+ gcetemp->ptszUserInfo = mir_tstrdup(gcevent->ptszUserInfo);
+
+ if (Scripting_TriggerMSPGuiIn(&wp, gcetemp) && gcetemp) {
//MBOT CORRECTIONS
//if ( gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID ) {
- if ( gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID &&
+ if (gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID &&
!my_strstri(gcetemp->pDest->ptszID, (IsConnected()) ? m_info.sNetwork.c_str() : TranslateT("Offline"))) {
- CMString sTempId = MakeWndID( gcetemp->pDest->ptszID );
- mir_realloc( gcetemp->pDest->ptszID, sizeof(TCHAR)*(sTempId.GetLength() + 1));
- lstrcpyn(gcetemp->pDest->ptszID, sTempId.c_str(), sTempId.GetLength()+1);
+ CMString sTempId = MakeWndID(gcetemp->pDest->ptszID);
+ mir_realloc(gcetemp->pDest->ptszID, sizeof(TCHAR)*(sTempId.GetLength() + 1));
+ lstrcpyn(gcetemp->pDest->ptszID, sTempId.c_str(), sTempId.GetLength() + 1);
}
- iVal = CallServiceSync(MS_GC_EVENT, wp, (LPARAM) gcetemp);
+ iVal = CallServiceSync(MS_GC_EVENT, wp, (LPARAM)gcetemp);
}
- if ( gcetemp ) {
- mir_free(( void* )gcetemp->pszNick);
- mir_free(( void* )gcetemp->pszUID);
- mir_free(( void* )gcetemp->pszStatus);
- mir_free(( void* )gcetemp->pszUserInfo);
- mir_free(( void* )gcetemp->pszText);
- mir_free(( void* )gcetemp->pDest->pszID);
- mir_free(( void* )gcetemp->pDest->pszModule);
- mir_free(( void* )gcetemp->pDest);
- mir_free(( void* )gcetemp);
+ if (gcetemp) {
+ mir_free((void*)gcetemp->pszNick);
+ mir_free((void*)gcetemp->pszUID);
+ mir_free((void*)gcetemp->pszStatus);
+ mir_free((void*)gcetemp->pszUserInfo);
+ mir_free((void*)gcetemp->pszText);
+ mir_free((void*)gcetemp->pDest->ptszID);
+ mir_free((void*)gcetemp->pDest->pszModule);
+ mir_free((void*)gcetemp->pDest);
+ mir_free((void*)gcetemp);
}
return iVal;
}
- return CallServiceSync( MS_GC_EVENT, wParam, ( LPARAM )gce );
+ return CallServiceSync(MS_GC_EVENT, wParam, (LPARAM)gce);
}
-INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick,
- const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo,
- DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe, time_t timestamp)
-{
- GCDEST gcd = {0};
- GCEVENT gce = {0};
+INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick,
+ const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo,
+ DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe, time_t timestamp)
+{
+ GCDEST gcd = { 0 };
+ GCEVENT gce = { 0 };
CMString sID;
CMString sText = _T("");
- if ( iEvent == GC_EVENT_INFORMATION && bIsMe && !bEcho )
+ if (iEvent == GC_EVENT_INFORMATION && bIsMe && !bEcho)
return false;
- if ( pszText ) {
+ if (pszText) {
if (iEvent != GC_EVENT_SENDMESSAGE)
sText = DoColorCodes(pszText, FALSE, TRUE);
else
sText = pszText;
}
- if ( pszWindow ) {
- if ( lstrcmpi( pszWindow, SERVERWINDOW))
+ if (pszWindow) {
+ if (lstrcmpi(pszWindow, SERVERWINDOW))
sID = pszWindow + (CMString)_T(" - ") + m_info.sNetwork;
else
sID = pszWindow;
@@ -495,15 +501,15 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszN
gce.ptszNick = pszNick;
gce.ptszUID = pszNick;
if (iEvent == GC_EVENT_TOPIC)
- gce.ptszUserInfo = pszUserInfo;
+ gce.ptszUserInfo = pszUserInfo;
else
- gce.ptszUserInfo = m_showAddresses ? pszUserInfo : NULL;
+ gce.ptszUserInfo = m_showAddresses ? pszUserInfo : NULL;
- if ( !sText.IsEmpty())
+ if (!sText.IsEmpty())
gce.ptszText = sText.c_str();
gce.dwItemData = dwItemData;
- if(timestamp == 1)
+ if (timestamp == 1)
gce.time = time(NULL);
else
gce.time = timestamp;
@@ -511,10 +517,10 @@ INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszN
return CallChatEvent(0, (LPARAM)&gce);
}
-CMString CIrcProto::ModeToStatus(int sMode)
+CMString CIrcProto::ModeToStatus(int sMode)
{
- if ( sUserModes.Find( sMode ) != -1 ) {
- switch( sMode ) {
+ if (sUserModes.Find(sMode) != -1) {
+ switch (sMode) {
case 'q':
return (CMString)_T("Owner");
case 'o':
@@ -527,17 +533,18 @@ CMString CIrcProto::ModeToStatus(int sMode)
return (CMString)_T("Admin");
default:
return (CMString)_T("Unknown");
- } }
+ }
+ }
return (CMString)_T("Normal");
}
-CMString CIrcProto::PrefixToStatus(int cPrefix)
+CMString CIrcProto::PrefixToStatus(int cPrefix)
{
- const TCHAR* p = _tcschr( sUserModePrefixes.c_str(), cPrefix );
- if ( p ) {
- int index = int( p - sUserModePrefixes.c_str());
- return ModeToStatus( sUserModes[index] );
+ const TCHAR* p = _tcschr(sUserModePrefixes.c_str(), cPrefix);
+ if (p) {
+ int index = int(p - sUserModePrefixes.c_str());
+ return ModeToStatus(sUserModes[index]);
}
return (CMString)_T("Normal");
@@ -548,92 +555,93 @@ CMString CIrcProto::PrefixToStatus(int cPrefix)
struct TimerPair
{
- TimerPair( CIrcProto* _pro, UINT_PTR _id ) :
- ppro( _pro ),
- idEvent( _id )
- {}
+ TimerPair(CIrcProto* _pro, UINT_PTR _id) :
+ ppro(_pro),
+ idEvent(_id)
+ {
+ }
UINT_PTR idEvent;
CIrcProto *ppro;
};
-static int CompareTimers( const TimerPair* p1, const TimerPair* p2 )
+static int CompareTimers(const TimerPair* p1, const TimerPair* p2)
{
- if ( p1->idEvent < p2->idEvent )
+ if (p1->idEvent < p2->idEvent)
return -1;
- return ( p1->idEvent == p2->idEvent ) ? 0 : 1;
+ return (p1->idEvent == p2->idEvent) ? 0 : 1;
}
-static OBJLIST<TimerPair> timers( 10, CompareTimers );
+static OBJLIST<TimerPair> timers(10, CompareTimers);
static CRITICAL_SECTION timers_cs;
-void InitTimers( void )
+void InitTimers(void)
{
- InitializeCriticalSection( &timers_cs );
+ InitializeCriticalSection(&timers_cs);
}
-void UninitTimers( void )
+void UninitTimers(void)
{
- EnterCriticalSection( &timers_cs );
+ EnterCriticalSection(&timers_cs);
timers.destroy();
- LeaveCriticalSection( &timers_cs );
- DeleteCriticalSection( &timers_cs );
+ LeaveCriticalSection(&timers_cs);
+ DeleteCriticalSection(&timers_cs);
}
-CIrcProto* GetTimerOwner( UINT_PTR nIDEvent )
+CIrcProto* GetTimerOwner(UINT_PTR nIDEvent)
{
CIrcProto* result;
- EnterCriticalSection( &timers_cs );
- TimerPair temp( NULL, nIDEvent );
- int idx = timers.getIndex( &temp );
- if ( idx == -1 )
+ EnterCriticalSection(&timers_cs);
+ TimerPair temp(NULL, nIDEvent);
+ int idx = timers.getIndex(&temp);
+ if (idx == -1)
result = NULL;
else
- result = timers[ idx ].ppro;
- LeaveCriticalSection( &timers_cs );
+ result = timers[idx].ppro;
+ LeaveCriticalSection(&timers_cs);
return result;
}
-void CIrcProto::SetChatTimer(UINT_PTR &nIDEvent,UINT uElapse, TIMERPROC lpTimerFunc)
+void CIrcProto::SetChatTimer(UINT_PTR &nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
{
if (nIDEvent)
KillChatTimer(nIDEvent);
- nIDEvent = SetTimer( NULL, NULL, uElapse, lpTimerFunc);
+ nIDEvent = SetTimer(NULL, NULL, uElapse, lpTimerFunc);
- EnterCriticalSection( &timers_cs );
- timers.insert( new TimerPair( this, nIDEvent ));
- LeaveCriticalSection( &timers_cs );
+ EnterCriticalSection(&timers_cs);
+ timers.insert(new TimerPair(this, nIDEvent));
+ LeaveCriticalSection(&timers_cs);
}
void CIrcProto::KillChatTimer(UINT_PTR &nIDEvent)
{
- if ( nIDEvent ) {
- EnterCriticalSection( &timers_cs );
- TimerPair temp( this, nIDEvent );
- int idx = timers.getIndex( &temp );
- if ( idx != -1 )
- timers.remove( idx );
+ if (nIDEvent) {
+ EnterCriticalSection(&timers_cs);
+ TimerPair temp(this, nIDEvent);
+ int idx = timers.getIndex(&temp);
+ if (idx != -1)
+ timers.remove(idx);
- LeaveCriticalSection( &timers_cs );
+ LeaveCriticalSection(&timers_cs);
KillTimer(NULL, nIDEvent);
nIDEvent = NULL;
-} }
+ }
+}
/////////////////////////////////////////////////////////////////////////////////////////
int CIrcProto::SetChannelSBText(CMString sWindow, CHANNELINFO * wi)
{
CMString sTemp = _T("");
- if(wi->pszMode)
- {
+ if (wi->pszMode) {
sTemp += _T("[");
sTemp += wi->pszMode;
sTemp += _T("] ");
}
- if(wi->pszTopic)
+ if (wi->pszTopic)
sTemp += wi->pszTopic;
sTemp = DoColorCodes(sTemp.c_str(), TRUE, FALSE);
return DoEvent(GC_EVENT_SETSBTEXT, sWindow.c_str(), NULL, sTemp.c_str(), NULL, NULL, NULL, FALSE, FALSE, 0);
@@ -642,22 +650,22 @@ int CIrcProto::SetChannelSBText(CMString sWindow, CHANNELINFO * wi)
CMString CIrcProto::MakeWndID(const TCHAR* sWindow)
{
TCHAR buf[200];
- mir_sntprintf( buf, SIZEOF(buf), _T("%s - %s"), sWindow, (IsConnected()) ? m_info.sNetwork.c_str() : TranslateT("Offline"));
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s - %s"), sWindow, (IsConnected()) ? m_info.sNetwork.c_str() : TranslateT("Offline"));
return CMString(buf);
}
bool CIrcProto::FreeWindowItemData(CMString window, CHANNELINFO* wis)
{
- CHANNELINFO* wi;
- if ( !wis )
+ CHANNELINFO *wi;
+ if (!wis)
wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
else
wi = wis;
- if ( wi ) {
+ if (wi) {
delete[] wi->pszLimit;
- delete[]wi->pszMode;
- delete[]wi->pszPassword;
- delete[]wi->pszTopic;
+ delete[] wi->pszMode;
+ delete[] wi->pszPassword;
+ delete[] wi->pszTopic;
delete wi;
return true;
}
@@ -666,23 +674,23 @@ bool CIrcProto::FreeWindowItemData(CMString window, CHANNELINFO* wis)
bool CIrcProto::AddWindowItemData(CMString window, const TCHAR* pszLimit, const TCHAR* pszMode, const TCHAR* pszPassword, const TCHAR* pszTopic)
{
- CHANNELINFO* wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
- if ( wi ) {
- if ( pszLimit ) {
- wi->pszLimit = ( TCHAR* )realloc( wi->pszLimit, sizeof(TCHAR)*(lstrlen(pszLimit)+1));
- lstrcpy( wi->pszLimit, pszLimit );
+ CHANNELINFO *wi = (CHANNELINFO *)DoEvent(GC_EVENT_GETITEMDATA, window.c_str(), NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ if (wi) {
+ if (pszLimit) {
+ wi->pszLimit = (TCHAR*)realloc(wi->pszLimit, sizeof(TCHAR)*(lstrlen(pszLimit) + 1));
+ lstrcpy(wi->pszLimit, pszLimit);
}
- if ( pszMode ) {
- wi->pszMode = ( TCHAR* )realloc( wi->pszMode, sizeof(TCHAR)*(lstrlen(pszMode)+1));
- lstrcpy( wi->pszMode, pszMode );
+ if (pszMode) {
+ wi->pszMode = (TCHAR*)realloc(wi->pszMode, sizeof(TCHAR)*(lstrlen(pszMode) + 1));
+ lstrcpy(wi->pszMode, pszMode);
}
- if ( pszPassword ) {
- wi->pszPassword = ( TCHAR* )realloc( wi->pszPassword, sizeof(TCHAR)*(lstrlen(pszPassword)+1));
- lstrcpy( wi->pszPassword, pszPassword );
+ if (pszPassword) {
+ wi->pszPassword = (TCHAR*)realloc(wi->pszPassword, sizeof(TCHAR)*(lstrlen(pszPassword) + 1));
+ lstrcpy(wi->pszPassword, pszPassword);
}
- if ( pszTopic ) {
- wi->pszTopic = ( TCHAR* )realloc( wi->pszTopic, sizeof(TCHAR)*(lstrlen(pszTopic)+1));
- lstrcpy( wi->pszTopic, pszTopic );
+ if (pszTopic) {
+ wi->pszTopic = (TCHAR*)realloc(wi->pszTopic, sizeof(TCHAR)*(lstrlen(pszTopic) + 1));
+ lstrcpy(wi->pszTopic, pszTopic);
}
SetChannelSBText(window, wi);
@@ -694,20 +702,21 @@ bool CIrcProto::AddWindowItemData(CMString window, const TCHAR* pszLimit, const
void CIrcProto::FindLocalIP(HANDLE con) // inspiration from jabber
{
// Determine local IP
- int socket = CallService(MS_NETLIB_GETSOCKET, (WPARAM) con, 0);
- if ( socket != INVALID_SOCKET ) {
+ int socket = CallService(MS_NETLIB_GETSOCKET, (WPARAM)con, 0);
+ if (socket != INVALID_SOCKET) {
struct sockaddr_in saddr;
int len = sizeof(saddr);
getsockname(socket, (struct sockaddr *) &saddr, &len);
lstrcpynA(m_myLocalHost, inet_ntoa(saddr.sin_addr), 49);
- m_myLocalPort = ntohs(saddr.sin_port );
-} }
+ m_myLocalPort = ntohs(saddr.sin_port);
+ }
+}
void CIrcProto::DoUserhostWithReason(int type, CMString reason, bool bSendCommand, CMString userhostparams, ...)
{
TCHAR temp[4096];
CMString S = _T("");
- switch( type ) {
+ switch (type) {
case 1:
S = _T("USERHOST");
break;
@@ -725,44 +734,44 @@ void CIrcProto::DoUserhostWithReason(int type, CMString reason, bool bSendComman
va_end(ap);
// Add reason
- if ( type == 1 )
- vUserhostReasons.insert( new CMString( reason ));
- else if ( type == 2 )
- vWhoInProgress.insert( new CMString( reason));
+ if (type == 1)
+ vUserhostReasons.insert(new CMString(reason));
+ else if (type == 2)
+ vWhoInProgress.insert(new CMString(reason));
// Do command
- if ( IsConnected() && bSendCommand )
- SendIrcMessage( temp, false );
+ if (IsConnected() && bSendCommand)
+ SendIrcMessage(temp, false);
}
CMString CIrcProto::GetNextUserhostReason(int type)
{
CMString reason = _T("");
- switch( type ) {
+ switch (type) {
case 1:
- if ( !vUserhostReasons.getCount())
+ if (!vUserhostReasons.getCount())
return CMString();
// Get reason
reason = vUserhostReasons[0];
- vUserhostReasons.remove( 0 );
+ vUserhostReasons.remove(0);
break;
case 2:
- if ( !vWhoInProgress.getCount())
+ if (!vWhoInProgress.getCount())
return CMString();
// Get reason
reason = vWhoInProgress[0];
- vWhoInProgress.remove( 0 );
+ vWhoInProgress.remove(0);
break;
}
return reason;
}
-CMString CIrcProto::PeekAtReasons( int type )
+CMString CIrcProto::PeekAtReasons(int type)
{
- switch ( type ) {
+ switch (type) {
case 1:
if (!vUserhostReasons.getCount())
return CMString();
@@ -786,13 +795,14 @@ void CIrcProto::ClearUserhostReasons(int type)
case 2:
vWhoInProgress.destroy();
break;
-} }
+ }
+}
////////////////////////////////////////////////////////////////////
SERVER_INFO::~SERVER_INFO()
{
- mir_free( m_name );
- mir_free( m_address );
- mir_free( m_group );
+ mir_free(m_name);
+ mir_free(m_address);
+ mir_free(m_group);
}
diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp
index 78f2f3fe7a..a2973e3c99 100644
--- a/protocols/IRCG/src/windows.cpp
+++ b/protocols/IRCG/src/windows.cpp
@@ -1075,7 +1075,7 @@ void CManagerDlg::OnApplyModes( CCtrlButton* )
{
TCHAR window[256];
GetDlgItemText( m_hwnd, IDC_CAPTION, window, SIZEOF(window));
- CHANNELINFO* wi = (CHANNELINFO *)m_proto->DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)m_proto->DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
if ( wi ) {
TCHAR toadd[10]; *toadd = '\0';
TCHAR toremove[10]; *toremove = '\0';
@@ -1266,7 +1266,7 @@ void CManagerDlg::InitManager( int mode, const TCHAR* window )
{
SetWindowText( GetDlgItem( m_hwnd, IDC_CAPTION ), window );
- CHANNELINFO* wi = (CHANNELINFO *)m_proto->DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
+ CHANNELINFO *wi = (CHANNELINFO *)m_proto->DoEvent(GC_EVENT_GETITEMDATA, window, NULL, NULL, NULL, NULL, NULL, FALSE, FALSE, 0);
if ( wi ) {
if ( m_proto->IsConnected()) {
TCHAR temp[1000];