summaryrefslogtreecommitdiff
path: root/protocols/IRCG/src/services.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/IRCG/src/services.cpp')
-rw-r--r--protocols/IRCG/src/services.cpp491
1 files changed, 243 insertions, 248 deletions
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 42e6b10536..2fe0fd2c81 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -25,15 +25,15 @@ BOOL bChatInstalled = FALSE, m_bMbotInstalled = FALSE;
void CIrcProto::InitMainMenus(void)
{
- char temp[ MAXMODULELABELLENGTH ];
+ char temp[MAXMODULELABELLENGTH];
char *d = temp + mir_snprintf(temp, SIZEOF(temp), m_szModuleName);
CLISTMENUITEM mi = { sizeof(mi) };
mi.pszService = temp;
- if ( bChatInstalled ) {
- HGENMENU hRoot = MO_GetProtoRootMenu( m_szModuleName );
- if ( hRoot == NULL ) {
+ if (bChatInstalled) {
+ HGENMENU hRoot = MO_GetProtoRootMenu(m_szModuleName);
+ if (hRoot == NULL) {
// Root popupmenuitem
mi.ptszName = m_tszUserName;
mi.position = -1999901010;
@@ -51,7 +51,7 @@ void CIrcProto::InitMainMenus(void)
mi.flags = CMIF_CHILDPOPUP;
mi.pszName = LPGEN("&Quick connect");
mi.icolibItem = GetIconHandle(IDI_QUICK);
- strcpy( d, IRC_QUICKCONNECT );
+ strcpy(d, IRC_QUICKCONNECT);
mi.position = 201001;
mi.hParentMenu = hRoot;
hMenuQuick = Menu_AddProtoMenuItem(&mi);
@@ -60,26 +60,26 @@ void CIrcProto::InitMainMenus(void)
mi.pszName = LPGEN("&Join channel");
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_JOIN);//GetIconHandle(IDI_JOIN);
- strcpy( d, IRC_JOINCHANNEL );
+ strcpy(d, IRC_JOINCHANNEL);
mi.position = 201002;
hMenuJoin = Menu_AddProtoMenuItem(&mi);
mi.pszName = LPGEN("&Change your nickname");
mi.icolibItem = GetIconHandle(IDI_RENAME);
- strcpy( d, IRC_CHANGENICK );
+ strcpy(d, IRC_CHANGENICK);
mi.position = 201003;
hMenuNick = Menu_AddProtoMenuItem(&mi);
mi.pszName = LPGEN("Show the &list of available channels");
mi.icolibItem = GetIconHandle(IDI_LIST);
- strcpy( d, IRC_SHOWLIST );
+ strcpy(d, IRC_SHOWLIST);
mi.position = 201004;
hMenuList = Menu_AddProtoMenuItem(&mi);
if (m_useServer) mi.flags &= ~CMIF_GRAYED;
mi.pszName = LPGEN("&Show the server window");
mi.icolibItem = GetIconHandle(IDI_SERVER);
- strcpy( d, IRC_SHOWSERVER );
+ strcpy(d, IRC_SHOWSERVER);
mi.position = 201005;
hMenuServer = Menu_AddProtoMenuItem(&mi);
}
@@ -97,8 +97,8 @@ static CIrcProto* IrcGetInstanceByHContact(HANDLE hContact)
return NULL;
for (int i = 0; i < g_Instances.getCount(); i++)
- if (!strcmp(szProto, g_Instances[i]->m_szModuleName))
- return g_Instances[i];
+ if (!strcmp(szProto, g_Instances[i]->m_szModuleName))
+ return g_Instances[i];
return NULL;
}
@@ -127,7 +127,7 @@ static INT_PTR IrcMenuIgnore(WPARAM wParam, LPARAM lParam)
return (ppro) ? ppro->OnMenuIgnore(wParam, lParam) : 0;
}
-int IrcPrebuildContactMenu( WPARAM wParam, LPARAM lParam )
+int IrcPrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
Menu_ShowItem(hUMenuChanSettings, false);
Menu_ShowItem(hUMenuWhois, false);
@@ -172,7 +172,7 @@ void InitContactMenus(void)
strcpy(d, IRC_UM_IGNORE);
mi.popupPosition = 500090002;
hUMenuIgnore = Menu_AddContactMenuItem(&mi);
- hMenuIgnore = CreateServiceFunction( temp, IrcMenuIgnore );
+ hMenuIgnore = CreateServiceFunction(temp, IrcMenuIgnore);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, IrcPrebuildContactMenu);
}
@@ -196,16 +196,16 @@ INT_PTR __cdecl CIrcProto::OnDoubleclicked(WPARAM, LPARAM lParam)
CLISTEVENT* pcle = (CLISTEVENT*)lParam;
- if ( getByte((HANDLE) pcle->hContact, "DCC", 0) != 0) {
- DCCINFO* pdci = ( DCCINFO* )pcle->lParam;
- CMessageBoxDlg* dlg = new CMessageBoxDlg( this, pdci );
+ if (getByte((HANDLE)pcle->hContact, "DCC", 0) != 0) {
+ DCCINFO* pdci = (DCCINFO*)pcle->lParam;
+ CMessageBoxDlg* dlg = new CMessageBoxDlg(this, pdci);
dlg->Show();
HWND hWnd = dlg->GetHwnd();
TCHAR szTemp[500];
mir_sntprintf(szTemp, SIZEOF(szTemp), TranslateT("%s (%s) is requesting a client-to-client chat connection."),
pdci->sContactName.c_str(), pdci->sHostmask.c_str());
- SetDlgItemText( hWnd, IDC_TEXT, szTemp );
- ShowWindow( hWnd, SW_SHOW );
+ SetDlgItemText(hWnd, IDC_TEXT, szTemp);
+ ShowWindow(hWnd, SW_SHOW);
return 1;
}
return 0;
@@ -213,32 +213,33 @@ INT_PTR __cdecl CIrcProto::OnDoubleclicked(WPARAM, LPARAM lParam)
int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM)
{
- HANDLE hContact = ( HANDLE )wp;
- if ( !hContact )
+ HANDLE hContact = (HANDLE)wp;
+ if (!hContact)
return 0;
DBVARIANT dbv;
- if ( !getTString( hContact, "Nick", &dbv )) {
+ if (!getTString(hContact, "Nick", &dbv)) {
int type = getByte(hContact, "ChatRoom", 0);
- if ( type != 0 ) {
+ if (type != 0) {
CMString S = _T("");
if (type == GCW_CHATROOM)
- S = MakeWndID( dbv.ptszVal );
+ S = MakeWndID(dbv.ptszVal);
if (type == GCW_SERVER)
S = SERVERWINDOW;
GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
- int i = CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
+ int i = CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
if (i && type == GCW_CHATROOM)
- PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
+ PostIrcMessage(_T("/PART %s %s"), dbv.ptszVal, m_userInfo);
}
else {
- BYTE bDCC = getByte(( HANDLE )wp, "DCC", 0) ;
- if ( bDCC ) {
+ BYTE bDCC = getByte((HANDLE)wp, "DCC", 0);
+ if (bDCC) {
CDccSession* dcc = FindDCCSession((HANDLE)wp);
- if ( dcc )
+ if (dcc)
dcc->Disconnect();
- } }
+ }
+ }
db_free(&dbv);
}
@@ -247,13 +248,13 @@ int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM)
INT_PTR __cdecl CIrcProto::OnJoinChat(WPARAM wp, LPARAM)
{
- if (!wp )
+ if (!wp)
return 0;
DBVARIANT dbv;
- if ( !getTString(( HANDLE )wp, "Nick", &dbv)) {
- if ( getByte(( HANDLE )wp, "ChatRoom", 0) == GCW_CHATROOM)
- PostIrcMessage( _T("/JOIN %s"), dbv.ptszVal);
+ if (!getTString((HANDLE)wp, "Nick", &dbv)) {
+ if (getByte((HANDLE)wp, "ChatRoom", 0) == GCW_CHATROOM)
+ PostIrcMessage(_T("/JOIN %s"), dbv.ptszVal);
db_free(&dbv);
}
return 0;
@@ -261,13 +262,13 @@ INT_PTR __cdecl CIrcProto::OnJoinChat(WPARAM wp, LPARAM)
INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM)
{
- if (!wp )
+ if (!wp)
return 0;
DBVARIANT dbv;
- if ( !getTString(( HANDLE )wp, "Nick", &dbv)) {
- if ( getByte(( HANDLE )wp, "ChatRoom", 0) == GCW_CHATROOM) {
- PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
+ if (!getTString((HANDLE)wp, "Nick", &dbv)) {
+ if (getByte((HANDLE)wp, "ChatRoom", 0) == GCW_CHATROOM) {
+ PostIrcMessage(_T("/PART %s %s"), dbv.ptszVal, m_userInfo);
CMString S = MakeWndID(dbv.ptszVal);
GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
@@ -281,12 +282,12 @@ INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM)
INT_PTR __cdecl CIrcProto::OnMenuChanSettings(WPARAM wp, LPARAM)
{
- if (!wp )
+ if (!wp)
return 0;
- HANDLE hContact = (HANDLE) wp;
+ HANDLE hContact = (HANDLE)wp;
DBVARIANT dbv;
- if ( !getTString( hContact, "Nick", &dbv )) {
+ if (!getTString(hContact, "Nick", &dbv)) {
PostIrcMessageWnd(dbv.ptszVal, NULL, _T("/CHANNELMANAGER"));
db_free(&dbv);
}
@@ -295,13 +296,13 @@ INT_PTR __cdecl CIrcProto::OnMenuChanSettings(WPARAM wp, LPARAM)
INT_PTR __cdecl CIrcProto::OnMenuWhois(WPARAM wp, LPARAM)
{
- if ( !wp )
+ if (!wp)
return 0;
DBVARIANT dbv;
- if ( !getTString(( HANDLE )wp, "Nick", &dbv)) {
- PostIrcMessage( _T("/WHOIS %s %s"), dbv.ptszVal, dbv.ptszVal);
+ if (!getTString((HANDLE)wp, "Nick", &dbv)) {
+ PostIrcMessage(_T("/WHOIS %s %s"), dbv.ptszVal, dbv.ptszVal);
db_free(&dbv);
}
return 0;
@@ -310,7 +311,7 @@ INT_PTR __cdecl CIrcProto::OnMenuWhois(WPARAM wp, LPARAM)
INT_PTR __cdecl CIrcProto::OnMenuDisconnect(WPARAM wp, LPARAM)
{
CDccSession* dcc = FindDCCSession((HANDLE)wp);
- if ( dcc )
+ if (dcc)
dcc->Disconnect();
return 0;
}
@@ -322,20 +323,20 @@ INT_PTR __cdecl CIrcProto::OnMenuIgnore(WPARAM wp, LPARAM)
HANDLE hContact = (HANDLE)wp;
DBVARIANT dbv;
- if ( !getTString(hContact, "Nick", &dbv )) {
- if ( !isChatRoom(hContact)) {
+ if (!getTString(hContact, "Nick", &dbv)) {
+ if (!isChatRoom(hContact)) {
char* host = NULL;
DBVARIANT dbv1;
- if ( !getString(hContact, "Host", &dbv1))
+ if (!getString(hContact, "Host", &dbv1))
host = dbv1.pszVal;
- if ( host ) {
+ if (host) {
String S;
if (m_ignoreChannelDefault)
S = "+qnidcm";
else
S = "+qnidc";
- PostIrcMessage( _T("/IGNORE %%question=\"%s\",\"%s\",\"*!*@%S\" %s"),
+ PostIrcMessage(_T("/IGNORE %%question=\"%s\",\"%s\",\"*!*@%S\" %s"),
TranslateT("Please enter the hostmask (nick!user@host) \nNOTE! Contacts on your contact list are never ignored"),
TranslateT("Ignore"), host, S.c_str());
db_free(&dbv1);
@@ -348,39 +349,39 @@ INT_PTR __cdecl CIrcProto::OnMenuIgnore(WPARAM wp, LPARAM)
INT_PTR __cdecl CIrcProto::OnJoinMenuCommand(WPARAM, LPARAM)
{
- if ( !m_joinDlg ) {
- m_joinDlg = new CJoinDlg( this );
+ if (!m_joinDlg) {
+ m_joinDlg = new CJoinDlg(this);
m_joinDlg->Show();
}
- SetDlgItemText( m_joinDlg->GetHwnd(), IDC_CAPTION, TranslateT("Join channel"));
- SetWindowText( GetDlgItem( m_joinDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a channel to join"));
- SendMessage( GetDlgItem( m_joinDlg->GetHwnd(), IDC_ENICK), EM_SETSEL, 0,MAKELPARAM(0,-1));
- ShowWindow( m_joinDlg->GetHwnd(), SW_SHOW);
- SetActiveWindow( m_joinDlg->GetHwnd());
+ SetDlgItemText(m_joinDlg->GetHwnd(), IDC_CAPTION, TranslateT("Join channel"));
+ SetWindowText(GetDlgItem(m_joinDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a channel to join"));
+ SendMessage(GetDlgItem(m_joinDlg->GetHwnd(), IDC_ENICK), EM_SETSEL, 0, MAKELPARAM(0, -1));
+ ShowWindow(m_joinDlg->GetHwnd(), SW_SHOW);
+ SetActiveWindow(m_joinDlg->GetHwnd());
return 0;
}
INT_PTR __cdecl CIrcProto::OnQuickConnectMenuCommand(WPARAM, LPARAM)
{
- if ( !m_quickDlg ) {
- m_quickDlg = new CQuickDlg( this );
+ if (!m_quickDlg) {
+ m_quickDlg = new CQuickDlg(this);
m_quickDlg->Show();
- SetWindowText( m_quickDlg->GetHwnd(), TranslateT( "Quick connect" ));
- SetDlgItemText( m_quickDlg->GetHwnd(), IDC_TEXT, TranslateT( "Please select IRC network and enter the password if needed" ));
- SetDlgItemText( m_quickDlg->GetHwnd(), IDC_CAPTION, TranslateT( "Quick connect" ));
- WindowSetIcon( m_quickDlg->GetHwnd(), IDI_QUICK );
+ SetWindowText(m_quickDlg->GetHwnd(), TranslateT("Quick connect"));
+ SetDlgItemText(m_quickDlg->GetHwnd(), IDC_TEXT, TranslateT("Please select IRC network and enter the password if needed"));
+ SetDlgItemText(m_quickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Quick connect"));
+ WindowSetIcon(m_quickDlg->GetHwnd(), IDI_QUICK);
}
- ShowWindow( m_quickDlg->GetHwnd(), SW_SHOW );
- SetActiveWindow( m_quickDlg->GetHwnd());
+ ShowWindow(m_quickDlg->GetHwnd(), SW_SHOW);
+ SetActiveWindow(m_quickDlg->GetHwnd());
return 0;
}
INT_PTR __cdecl CIrcProto::OnShowListMenuCommand(WPARAM, LPARAM)
{
- PostIrcMessage( _T("/LIST"));
+ PostIrcMessage(_T("/LIST"));
return 0;
}
@@ -388,27 +389,27 @@ INT_PTR __cdecl CIrcProto::OnShowServerMenuCommand(WPARAM, LPARAM)
{
GCDEST gcd = { m_szModuleName, SERVERWINDOW, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
- CallChatEvent( WINDOW_VISIBLE, (LPARAM)&gce);
+ CallChatEvent(WINDOW_VISIBLE, (LPARAM)&gce);
return 0;
}
INT_PTR __cdecl CIrcProto::OnChangeNickMenuCommand(WPARAM, LPARAM)
{
- if ( !m_nickDlg ) {
- m_nickDlg = new CNickDlg( this );
+ if (!m_nickDlg) {
+ m_nickDlg = new CNickDlg(this);
m_nickDlg->Show();
}
- SetDlgItemText( m_nickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Change nickname"));
- SetWindowText( GetDlgItem( m_nickDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a unique nickname"));
- m_nickDlg->m_Enick.SetText( m_info.sNick.c_str());
- m_nickDlg->m_Enick.SendMsg( CB_SETEDITSEL, 0, MAKELPARAM(0,-1));
- ShowWindow( m_nickDlg->GetHwnd(), SW_SHOW);
- SetActiveWindow( m_nickDlg->GetHwnd());
+ SetDlgItemText(m_nickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Change nickname"));
+ SetWindowText(GetDlgItem(m_nickDlg->GetHwnd(), IDC_TEXT), TranslateT("Please enter a unique nickname"));
+ m_nickDlg->m_Enick.SetText(m_info.sNick.c_str());
+ m_nickDlg->m_Enick.SendMsg(CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
+ ShowWindow(m_nickDlg->GetHwnd(), SW_SHOW);
+ SetActiveWindow(m_nickDlg->GetHwnd());
return 0;
}
-static void DoChatFormatting( TCHAR* pszText )
+static void DoChatFormatting(TCHAR* pszText)
{
TCHAR* p1 = pszText;
int iFG = -1;
@@ -419,8 +420,8 @@ static void DoChatFormatting( TCHAR* pszText )
iRemoveChars = 0;
InsertThis[0] = 0;
- if ( *p1 == '%' ) {
- switch ( p1[1] ) {
+ if (*p1 == '%') {
+ switch (p1[1]) {
case 'B':
case 'b':
lstrcpy(InsertThis, _T("\002"));
@@ -437,17 +438,17 @@ static void DoChatFormatting( TCHAR* pszText )
iRemoveChars = 2;
break;
case 'c':
- {
- lstrcpy(InsertThis, _T("\003"));
- iRemoveChars = 2;
+ {
+ lstrcpy(InsertThis, _T("\003"));
+ iRemoveChars = 2;
- TCHAR szTemp[3];
- lstrcpyn(szTemp, p1 + 2, 3);
- iFG = _ttoi(szTemp);
- }
+ TCHAR szTemp[3];
+ lstrcpyn(szTemp, p1 + 2, 3);
+ iFG = _ttoi(szTemp);
+ }
break;
case 'C':
- if ( p1[2] == '%' && p1[3] == 'F') {
+ if (p1[2] == '%' && p1[3] == 'F') {
lstrcpy(InsertThis, _T("\00399,99"));
iRemoveChars = 4;
}
@@ -460,7 +461,7 @@ static void DoChatFormatting( TCHAR* pszText )
case 'f':
if (p1 - 3 >= pszText && p1[-3] == '\003')
lstrcpy(InsertThis, _T(","));
- else if ( iFG >= 0 )
+ else if (iFG >= 0)
mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\003%u,"), iFG);
else
lstrcpy(InsertThis, _T("\00399,"));
@@ -494,11 +495,12 @@ static void DoChatFormatting( TCHAR* pszText )
p1++;
}
else p1++;
-} }
+ }
+}
-int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
+int __cdecl CIrcProto::GCEventHook(WPARAM wParam, LPARAM lParam)
{
- GCHOOK *gch= (GCHOOK*) lParam;
+ GCHOOK *gch = (GCHOOK*)lParam;
CMString S = _T("");
EnterCriticalSection(&m_gchook);
@@ -506,23 +508,23 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
// handle the hook
if (gch) {
if (!lstrcmpiA(gch->pDest->pszModule, m_szModuleName)) {
- TCHAR *p1 = mir_tstrdup( gch->pDest->ptszID );
- TCHAR *p2 = _tcsstr( p1, _T(" - "));
+ TCHAR *p1 = mir_tstrdup(gch->pDest->ptszID);
+ TCHAR *p2 = _tcsstr(p1, _T(" - "));
if (p2)
*p2 = '\0';
- switch( gch->pDest->iType ) {
+ switch (gch->pDest->iType) {
case GC_SESSION_TERMINATE:
FreeWindowItemData(p1, (CHANNELINFO*)gch->dwData);
break;
case GC_USER_MESSAGE:
if (gch && gch->ptszText && *gch->ptszText) {
- TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText)+1000];
+ TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText) + 1000];
lstrcpy(pszText, gch->ptszText);
DoChatFormatting(pszText);
PostIrcMessageWnd(p1, NULL, pszText);
- delete []pszText;
+ delete[]pszText;
}
break;
@@ -531,15 +533,15 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
break;
case GC_USER_PRIVMESS:
- {
- TCHAR szTemp[4000];
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/QUERY %s"), gch->ptszUID );
- PostIrcMessageWnd(p1, NULL, szTemp);
- }
+ {
+ TCHAR szTemp[4000];
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/QUERY %s"), gch->ptszUID);
+ PostIrcMessageWnd(p1, NULL, szTemp);
+ }
break;
case GC_USER_LOGMENU:
- switch( gch->dwData ) {
+ switch (gch->dwData) {
case 1:
OnChangeNickMenuCommand(NULL, NULL);
break;
@@ -548,7 +550,7 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
break;
case 3:
- PostIrcMessage( _T("/PART %s %s"), p1, m_userInfo );
+ PostIrcMessage(_T("/PART %s %s"), p1, m_userInfo);
{
S = MakeWndID(p1);
GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
@@ -565,26 +567,26 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
break;
*/
case 6: // nickserv Identify
- PostIrcMessage( _T("/nickserv AUTH %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv AUTH %%question=\"%s\",\"%s\""),
TranslateT("Please enter your authentification code"), TranslateT("Authentificate nick"));
break;
case 7: // nickserv drop nick
if (MessageBox(0, TranslateT("Are you sure you want to unregister your current nick?"), TranslateT("Delete nick"),
MB_ICONERROR + MB_YESNO + MB_DEFBUTTON2) == IDYES)
- PostIrcMessage( _T("/nickserv DROP"));
+ PostIrcMessage(_T("/nickserv DROP"));
break;
case 8: // nickserv Identify
{
- CQuestionDlg* dlg = new CQuestionDlg( this );
+ CQuestionDlg* dlg = new CQuestionDlg(this);
dlg->Show();
HWND question_hWnd = dlg->GetHwnd();
- HWND hEditCtrl = GetDlgItem( question_hWnd, IDC_EDIT);
- SetDlgItemText( question_hWnd, IDC_CAPTION, TranslateT("Identify nick"));
- SetWindowText( GetDlgItem( question_hWnd, IDC_TEXT), TranslateT("Please enter your password"));
- SetDlgItemText( question_hWnd, IDC_HIDDENEDIT, _T("/nickserv IDENTIFY %question=\"%s\",\"%s\""));
- SetWindowLongPtr(GetDlgItem( question_hWnd, IDC_EDIT), GWL_STYLE,
- (LONG)GetWindowLongPtr(GetDlgItem( question_hWnd, IDC_EDIT), GWL_STYLE) | ES_PASSWORD);
- SendMessage(hEditCtrl, EM_SETPASSWORDCHAR,(WPARAM)_T('*'),0 );
+ HWND hEditCtrl = GetDlgItem(question_hWnd, IDC_EDIT);
+ SetDlgItemText(question_hWnd, IDC_CAPTION, TranslateT("Identify nick"));
+ SetWindowText(GetDlgItem(question_hWnd, IDC_TEXT), TranslateT("Please enter your password"));
+ SetDlgItemText(question_hWnd, IDC_HIDDENEDIT, _T("/nickserv IDENTIFY %question=\"%s\",\"%s\""));
+ SetWindowLongPtr(GetDlgItem(question_hWnd, IDC_EDIT), GWL_STYLE,
+ (LONG)GetWindowLongPtr(GetDlgItem(question_hWnd, IDC_EDIT), GWL_STYLE) | ES_PASSWORD);
+ SendMessage(hEditCtrl, EM_SETPASSWORDCHAR, (WPARAM)_T('*'), 0);
SetFocus(hEditCtrl);
dlg->Activate();
}
@@ -592,152 +594,152 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
case 9: // nickserv remind password
{
DBVARIANT dbv;
- if ( !getTString( "Nick", &dbv )) {
- PostIrcMessage( _T("/nickserv SENDPASS %s"), dbv.ptszVal);
- db_free( &dbv );
+ if (!getTString("Nick", &dbv)) {
+ PostIrcMessage(_T("/nickserv SENDPASS %s"), dbv.ptszVal);
+ db_free(&dbv);
}
}
break;
case 10: // nickserv set new password
- PostIrcMessage( _T("/nickserv SET PASSWORD %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv SET PASSWORD %%question=\"%s\",\"%s\""),
TranslateT("Please enter your new password"), TranslateT("Set new password"));
break;
case 11: // nickserv set language
- PostIrcMessage( _T("/nickserv SET LANGUAGE %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv SET LANGUAGE %%question=\"%s\",\"%s\""),
TranslateT("Please enter desired language ID (numeric value, depends on server)"), TranslateT("Change language of NickServ messages"));
break;
case 12: // nickserv set homepage
- PostIrcMessage( _T("/nickserv SET URL %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv SET URL %%question=\"%s\",\"%s\""),
TranslateT("Please enter URL that will be linked to your nick"), TranslateT("Set URL, linked to nick"));
break;
case 13: // nickserv set email
- PostIrcMessage( _T("/nickserv SET EMAIL %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv SET EMAIL %%question=\"%s\",\"%s\""),
TranslateT("Please enter your e-mail, that will be linked to your nick"), TranslateT("Set e-mail, linked to nick"));
break;
case 14: // nickserv set info
- PostIrcMessage( _T("/nickserv SET INFO %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv SET INFO %%question=\"%s\",\"%s\""),
TranslateT("Please enter some information about your nick"), TranslateT("Set information for nick"));
break;
case 15: // nickserv kill unauth off
- PostIrcMessage( _T("/nickserv SET KILL OFF"));
+ PostIrcMessage(_T("/nickserv SET KILL OFF"));
break;
case 16: // nickserv kill unauth on
- PostIrcMessage( _T("/nickserv SET KILL ON"));
+ PostIrcMessage(_T("/nickserv SET KILL ON"));
break;
case 17: // nickserv kill unauth quick
- PostIrcMessage( _T("/nickserv SET KILL QUICK"));
+ PostIrcMessage(_T("/nickserv SET KILL QUICK"));
break;
case 18: // nickserv hide nick from /LIST
- PostIrcMessage( _T("/nickserv SET PRIVATE ON"));
+ PostIrcMessage(_T("/nickserv SET PRIVATE ON"));
break;
case 19: // nickserv show nick to /LIST
- PostIrcMessage( _T("/nickserv SET PRIVATE OFF"));
+ PostIrcMessage(_T("/nickserv SET PRIVATE OFF"));
break;
case 20: // nickserv Hide e-mail from info
- PostIrcMessage( _T("/nickserv SET HIDE EMAIL ON"));
+ PostIrcMessage(_T("/nickserv SET HIDE EMAIL ON"));
break;
case 21: // nickserv Show e-mail in info
- PostIrcMessage( _T("/nickserv SET HIDE EMAIL OFF"));
+ PostIrcMessage(_T("/nickserv SET HIDE EMAIL OFF"));
break;
case 22: // nickserv Set security for nick
- PostIrcMessage( _T("/nickserv SET SECURE ON"));
+ PostIrcMessage(_T("/nickserv SET SECURE ON"));
break;
case 23: // nickserv Remove security for nick
- PostIrcMessage( _T("/nickserv SET SECURE OFF"));
+ PostIrcMessage(_T("/nickserv SET SECURE OFF"));
break;
case 24: // nickserv Link nick to current
- PostIrcMessage( _T("/nickserv LINK %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv LINK %%question=\"%s\",\"%s\""),
TranslateT("Please enter nick you want to link to your current nick"), TranslateT("Link another nick to current nick"));
break;
case 25: // nickserv Unlink nick from current
- PostIrcMessage( _T("/nickserv LINK %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv LINK %%question=\"%s\",\"%s\""),
TranslateT("Please enter nick you want to unlink from your current nick"), TranslateT("Unlink another nick from current nick"));
break;
case 26: // nickserv Set main nick
- PostIrcMessage( _T("/nickserv LINK %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/nickserv LINK %%question=\"%s\",\"%s\""),
TranslateT("Please enter nick you want to set as your main nick"), TranslateT("Set main nick"));
break;
case 27: // nickserv list all linked nicks
- PostIrcMessage( _T("/nickserv LISTLINKS"));
+ PostIrcMessage(_T("/nickserv LISTLINKS"));
break;
case 28: // nickserv list all channels owned
- PostIrcMessage( _T("/nickserv LISTCHANS"));
+ PostIrcMessage(_T("/nickserv LISTCHANS"));
break;
}
break;
case GC_USER_NICKLISTMENU:
- switch(gch->dwData) {
+ switch (gch->dwData) {
case 1:
- PostIrcMessage( _T("/MODE %s +o %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s +o %s"), p1, gch->ptszUID);
break;
case 2:
- PostIrcMessage( _T("/MODE %s -o %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s -o %s"), p1, gch->ptszUID);
break;
case 3:
- PostIrcMessage( _T("/MODE %s +v %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s +v %s"), p1, gch->ptszUID);
break;
case 4:
- PostIrcMessage( _T("/MODE %s -v %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s -v %s"), p1, gch->ptszUID);
break;
case 5:
- PostIrcMessage( _T("/KICK %s %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/KICK %s %s"), p1, gch->ptszUID);
break;
case 6:
- PostIrcMessage( _T("/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""),
+ PostIrcMessage(_T("/KICK %s %s %%question=\"%s\",\"%s\",\"%s\""),
p1, gch->ptszUID, TranslateT("Please enter the reason"), TranslateT("Kick"), TranslateT("Jerk"));
break;
case 7:
- DoUserhostWithReason(1, _T("B") + (CMString)p1, true, _T("%s"), gch->ptszUID );
+ DoUserhostWithReason(1, _T("B") + (CMString)p1, true, _T("%s"), gch->ptszUID);
break;
case 8:
- DoUserhostWithReason(1, _T("K") + (CMString)p1, true, _T("%s"), gch->ptszUID );
+ DoUserhostWithReason(1, _T("K") + (CMString)p1, true, _T("%s"), gch->ptszUID);
break;
case 9:
- DoUserhostWithReason(1, _T("L") + (CMString)p1, true, _T("%s"), gch->ptszUID );
+ DoUserhostWithReason(1, _T("L") + (CMString)p1, true, _T("%s"), gch->ptszUID);
break;
case 10:
- PostIrcMessage( _T("/WHOIS %s %s"), gch->ptszUID, gch->ptszUID );
+ PostIrcMessage(_T("/WHOIS %s %s"), gch->ptszUID, gch->ptszUID);
break;
- // case 11:
- // DoUserhostWithReason(1, "I", true, "%s", gch->ptszUID );
- // break;
- // case 12:
- // DoUserhostWithReason(1, "J", true, "%s", gch->ptszUID );
- // break;
+ // case 11:
+ // DoUserhostWithReason(1, "I", true, "%s", gch->ptszUID );
+ // break;
+ // case 12:
+ // DoUserhostWithReason(1, "J", true, "%s", gch->ptszUID );
+ // break;
case 13:
- PostIrcMessage( _T("/DCC CHAT %s"), gch->ptszUID );
+ PostIrcMessage(_T("/DCC CHAT %s"), gch->ptszUID);
break;
case 14:
- PostIrcMessage( _T("/DCC SEND %s"), gch->ptszUID );
+ PostIrcMessage(_T("/DCC SEND %s"), gch->ptszUID);
break;
case 15:
- DoUserhostWithReason(1, _T("I"), true, _T("%s"), gch->ptszUID );
+ DoUserhostWithReason(1, _T("I"), true, _T("%s"), gch->ptszUID);
break;
case 16:
- PostIrcMessage( _T("/MODE %s +h %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s +h %s"), p1, gch->ptszUID);
break;
case 17:
- PostIrcMessage( _T("/MODE %s -h %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s -h %s"), p1, gch->ptszUID);
break;
case 18:
- PostIrcMessage( _T("/MODE %s +q %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s +q %s"), p1, gch->ptszUID);
break;
case 19:
- PostIrcMessage( _T("/MODE %s -q %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s -q %s"), p1, gch->ptszUID);
break;
case 20:
- PostIrcMessage( _T("/MODE %s +a %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s +a %s"), p1, gch->ptszUID);
break;
case 21:
- PostIrcMessage( _T("/MODE %s -a %s"), p1, gch->ptszUID );
+ PostIrcMessage(_T("/MODE %s -a %s"), p1, gch->ptszUID);
break;
case 22:
- PostIrcMessage( _T("/NOTICE %s %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/NOTICE %s %%question=\"%s\",\"%s\""),
gch->ptszUID, TranslateT("Please enter the notice text"), TranslateT("Send notice"));
break;
case 23:
- PostIrcMessage( _T("/INVITE %s %%question=\"%s\",\"%s\""),
+ PostIrcMessage(_T("/INVITE %s %%question=\"%s\",\"%s\""),
gch->ptszUID, TranslateT("Please enter the channel name to invite to"), TranslateT("Invite to channel"));
break;
case 30:
@@ -756,31 +758,20 @@ int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
}
break;
case 31: //slap
- {
- TCHAR tszTemp[4000];
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/slap %s"), gch->ptszUID);
- PostIrcMessageWnd(p1, NULL, tszTemp);
- }
+ PostIrcMessageWnd(p1, NULL, CMString(FORMAT, _T("/slap %s"), gch->ptszUID));
break;
case 32: //nickserv info
- {
- TCHAR tszTemp[4000];
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv INFO %s ALL"), gch->ptszUID);
- PostIrcMessageWnd(p1, NULL, tszTemp);
- }
+ PostIrcMessageWnd(p1, NULL, CMString(FORMAT, _T("/nickserv INFO %s ALL"), gch->ptszUID));
break;
case 33: //nickserv ghost
- {
- TCHAR tszTemp[4000];
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv GHOST %s"), gch->ptszUID);
- PostIrcMessageWnd(p1, NULL, tszTemp);
- }
+ PostIrcMessageWnd(p1, NULL, CMString(FORMAT, _T("/nickserv GHOST %s"), gch->ptszUID));
break;
}
break;
}
- mir_free( p1 );
- } }
+ mir_free(p1);
+ }
+ }
LeaveCriticalSection(&m_gchook);
return 0;
@@ -861,11 +852,11 @@ static gc_item nickItems[] = {
int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
{
- GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam;
- if ( gcmi ) {
- if ( !lstrcmpiA( gcmi->pszModule, m_szModuleName )) {
- if ( gcmi->Type == MENU_ON_LOG ) {
- if ( lstrcmpi( gcmi->pszID, SERVERWINDOW)) {
+ GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
+ if (gcmi) {
+ if (!lstrcmpiA(gcmi->pszModule, m_szModuleName)) {
+ if (gcmi->Type == MENU_ON_LOG) {
+ if (lstrcmpi(gcmi->pszID, SERVERWINDOW)) {
gcmi->nItems = SIZEOF(logItems);
gcmi->Item = logItems;
}
@@ -873,44 +864,46 @@ int __cdecl CIrcProto::GCMenuHook(WPARAM, LPARAM lParam)
}
if (gcmi->Type == MENU_ON_NICKLIST) {
- CONTACT user ={ (TCHAR*)gcmi->pszUID, NULL, NULL, false, false, false};
+ CONTACT user = { (TCHAR*)gcmi->pszUID, NULL, NULL, false, false, false };
HANDLE hContact = CList_FindContact(&user);
gcmi->nItems = SIZEOF(nickItems);
gcmi->Item = nickItems;
BOOL bIsInList = (hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 0);
- gcmi->Item[gcmi->nItems-1].bDisabled = bIsInList;
+ gcmi->Item[gcmi->nItems - 1].bDisabled = bIsInList;
unsigned long ulAdr = 0;
if (m_manualHost)
ulAdr = ConvertIPToInteger(m_mySpecifiedHostIP);
else
- ulAdr = ConvertIPToInteger(m_IPFromServer?m_myHost:m_myLocalHost);
- gcmi->Item[23].bDisabled = ulAdr == 0?TRUE:FALSE; //DCC submenu
+ ulAdr = ConvertIPToInteger(m_IPFromServer ? m_myHost : m_myLocalHost);
+ gcmi->Item[23].bDisabled = ulAdr == 0 ? TRUE : FALSE; //DCC submenu
TCHAR stzChanName[100];
- const TCHAR* temp = _tcschr( gcmi->pszID, ' ' );
- 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);
- 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;
- BOOL bAdmin = bServAdmin?((wi->OwnMode>>3)&01):FALSE;
- BOOL bOp = strchr(sUserModes.c_str(), 'o') == NULL?FALSE:((wi->OwnMode>>2)&01);
- BOOL bHalfop = strchr(sUserModes.c_str(), 'h') == NULL?FALSE:((wi->OwnMode>>1)&01);
+ const TCHAR* temp = _tcschr(gcmi->pszID, ' ');
+ 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);
+ 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;
+ BOOL bAdmin = bServAdmin ? ((wi->OwnMode >> 3) & 01) : FALSE;
+ BOOL bOp = strchr(sUserModes.c_str(), 'o') == NULL ? FALSE : ((wi->OwnMode >> 2) & 01);
+ BOOL bHalfop = strchr(sUserModes.c_str(), 'h') == NULL ? FALSE : ((wi->OwnMode >> 1) & 01);
BOOL bForceEnable = GetAsyncKeyState(VK_CONTROL);
- gcmi->Item[6].bDisabled /* "Control" submenu */ = !(bForceEnable|| bHalfop || bOp || bAdmin || bOwner);
- gcmi->Item[7].uType = gcmi->Item[8].uType = /* +/- Owner */ bServOwner?MENU_POPUPITEM:0;
- gcmi->Item[9].uType = gcmi->Item[10].uType = /* +/- Admin */ bServAdmin?MENU_POPUPITEM:0;
- gcmi->Item[7].bDisabled = gcmi->Item[8].bDisabled = gcmi->Item[9].bDisabled = gcmi->Item[10].bDisabled = /* +/- Owner/Admin */
+ gcmi->Item[6].bDisabled /* "Control" submenu */ = !(bForceEnable || bHalfop || bOp || bAdmin || bOwner);
+ gcmi->Item[7].uType = gcmi->Item[8].uType = /* +/- Owner */ bServOwner ? MENU_POPUPITEM : 0;
+ gcmi->Item[9].uType = gcmi->Item[10].uType = /* +/- Admin */ bServAdmin ? MENU_POPUPITEM : 0;
+ gcmi->Item[7].bDisabled = gcmi->Item[8].bDisabled = gcmi->Item[9].bDisabled = gcmi->Item[10].bDisabled = /* +/- Owner/Admin */
!(bForceEnable || bOwner);
gcmi->Item[11].bDisabled = gcmi->Item[12].bDisabled = gcmi->Item[13].bDisabled = gcmi->Item[14].bDisabled = /* +/- Op/hop */
!(bForceEnable || bOp || bAdmin || bOwner);
- } } }
+ }
+ }
+ }
return 0;
}
@@ -919,19 +912,19 @@ int __cdecl CIrcProto::OnPreShutdown(WPARAM, LPARAM)
{
EnterCriticalSection(&cs);
- if ( m_perform && IsConnected())
- if ( DoPerform( "Event: Disconnect" ))
- Sleep( 200 );
+ if (m_perform && IsConnected())
+ if (DoPerform("Event: Disconnect"))
+ Sleep(200);
- DisconnectAllDCCSessions( true );
+ DisconnectAllDCCSessions(true);
- if ( IsConnected())
+ if (IsConnected())
Disconnect();
- if ( m_listDlg )
+ if (m_listDlg)
m_listDlg->Close();
- if ( m_nickDlg )
+ if (m_nickDlg)
m_nickDlg->Close();
- if ( m_joinDlg )
+ if (m_joinDlg)
m_joinDlg->Close();
LeaveCriticalSection(&cs);
@@ -954,11 +947,11 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
Menu_ShowItem(hUMenuChanSettings, true);
// context menu for contact
- else if ( !getTString( hContact, "Default", &dbv )) {
+ else if (!getTString(hContact, "Default", &dbv)) {
Menu_ShowItem(hUMenuChanSettings, false);
// for DCC contact
- BYTE bDcc = getByte( hContact, "DCC", 0) ;
+ BYTE bDcc = getByte(hContact, "DCC", 0);
if (bDcc)
Menu_ShowItem(hUMenuDisconnect, true);
else {
@@ -968,7 +961,7 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
bool bEnabled = true;
if (bIsOnline) {
DBVARIANT dbv3;
- if ( !getString( hContact, "Host", &dbv3)) {
+ if (!getString(hContact, "Host", &dbv3)) {
if (dbv3.pszVal[0] == 0)
bEnabled = false;
db_free(&dbv3);
@@ -976,7 +969,7 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
}
Menu_ShowItem(hUMenuIgnore, bEnabled);
}
- db_free( &dbv );
+ db_free(&dbv);
}
}
@@ -985,33 +978,34 @@ int __cdecl CIrcProto::OnMenuPreBuild(WPARAM wParam, LPARAM)
int __cdecl CIrcProto::OnDbSettingChanged(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact = ( HANDLE ) wParam;
- if ( hContact == NULL || !IsConnected())
+ HANDLE hContact = (HANDLE)wParam;
+ if (hContact == NULL || !IsConnected())
return 0;
- DBCONTACTWRITESETTING* cws = ( DBCONTACTWRITESETTING* )lParam;
- if ( strcmp( cws->szModule, "CList" ))
+ DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam;
+ if (strcmp(cws->szModule, "CList"))
return 0;
- if ( cws->value.type != DBVT_DELETED && !( cws->value.type==DBVT_BYTE && cws->value.bVal==0 ))
+ if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0))
return 0;
- if ( !strcmp( cws->szSetting, "NotOnList" )) {
+ if (!strcmp(cws->szSetting, "NotOnList")) {
DBVARIANT dbv;
- if ( !getTString( hContact, "Nick", &dbv )) {
- if ( getByte( "MirVerAutoRequest", 1))
- PostIrcMessage( _T("/PRIVMSG %s \001VERSION\001"), dbv.ptszVal );
- db_free( &dbv );
- } }
+ if (!getTString(hContact, "Nick", &dbv)) {
+ if (getByte("MirVerAutoRequest", 1))
+ PostIrcMessage(_T("/PRIVMSG %s \001VERSION\001"), dbv.ptszVal);
+ db_free(&dbv);
+ }
+ }
return 0;
}
-void __cdecl CIrcProto::ConnectServerThread( void* )
+void __cdecl CIrcProto::ConnectServerThread(void*)
{
- InterlockedIncrement((long *) &m_bConnectThreadRunning);
- InterlockedIncrement((long *) &m_bConnectRequested);
- while ( !Miranda_Terminated() && m_bConnectRequested > 0 ) {
- while(m_bConnectRequested > 0)
- InterlockedDecrement((long *) &m_bConnectRequested);
+ InterlockedIncrement((long *)&m_bConnectThreadRunning);
+ InterlockedIncrement((long *)&m_bConnectRequested);
+ while (!Miranda_Terminated() && m_bConnectRequested > 0) {
+ while (m_bConnectRequested > 0)
+ InterlockedDecrement((long *)&m_bConnectRequested);
if (IsConnected()) {
Sleep(200);
Disconnect();
@@ -1021,29 +1015,30 @@ void __cdecl CIrcProto::ConnectServerThread( void* )
int Temp = m_iStatus;
m_iStatus = ID_STATUS_CONNECTING;
nickflag = true;
- ProtoBroadcastAck(NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)Temp,ID_STATUS_CONNECTING);
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_CONNECTING);
Sleep(100);
EnterCriticalSection(&cs);
Connect(si);
LeaveCriticalSection(&cs);
if (IsConnected()) {
- if ( m_mySpecifiedHost[0] )
- ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( m_mySpecifiedHost, IP_MANUAL ));
+ if (m_mySpecifiedHost[0])
+ ForkThread(&CIrcProto::ResolveIPThread, new IPRESOLVE(m_mySpecifiedHost, IP_MANUAL));
DoEvent(GC_EVENT_CHANGESESSIONAME, SERVERWINDOW, NULL, m_info.sNetwork.c_str(), NULL, NULL, NULL, FALSE, TRUE);
}
else {
Temp = m_iDesiredStatus;
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK );
- ProtoBroadcastAck(NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)Temp,ID_STATUS_OFFLINE);
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)Temp, ID_STATUS_OFFLINE);
Sleep(100);
- } }
+ }
+ }
InterlockedDecrement((long *)&m_bConnectThreadRunning);
}
-void __cdecl CIrcProto::DisconnectServerThread( void* )
+void __cdecl CIrcProto::DisconnectServerThread(void*)
{
mir_cslock lck(cs);
if (IsConnected())
@@ -1060,7 +1055,7 @@ void CIrcProto::ConnectToServer(void)
si.sUserID = m_userID;
si.sFullName = m_name;
si.sPassword = m_password;
- si.bIdentServer = ((m_ident) ? (true) : (false));
+ si.bIdentServer = ((m_ident) ? (true) : (false));
si.iIdentServerPort = StrToInt(m_identPort);
si.sIdentServerType = m_identSystem;
si.m_iSSL = m_iSSL;
@@ -1076,9 +1071,9 @@ void CIrcProto::ConnectToServer(void)
sChannelModes = "btnimklps";
if (!m_bConnectThreadRunning)
- ForkThread( &CIrcProto::ConnectServerThread, 0 );
+ ForkThread(&CIrcProto::ConnectServerThread, 0);
else if (m_bConnectRequested < 1)
- InterlockedIncrement((long *) &m_bConnectRequested);
+ InterlockedIncrement((long *)&m_bConnectRequested);
TCHAR szTemp[300];
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("\0033%s \002%s\002 (%S: %u)"),
@@ -1088,21 +1083,21 @@ void CIrcProto::ConnectToServer(void)
void CIrcProto::DisconnectFromServer(void)
{
- if ( m_perform && IsConnected())
- DoPerform( "Event: Disconnect" );
+ if (m_perform && IsConnected())
+ DoPerform("Event: Disconnect");
GCDEST gcd = { m_szModuleName, 0, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
- CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
- ForkThread( &CIrcProto::DisconnectServerThread, 0 );
+ CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
+ ForkThread(&CIrcProto::DisconnectServerThread, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
// GetMyAwayMsg - obtain the current away message
-INT_PTR __cdecl CIrcProto::GetMyAwayMsg(WPARAM wParam,LPARAM lParam)
+INT_PTR __cdecl CIrcProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
{
- if (( int )wParam != m_iStatus )
+ if ((int)wParam != m_iStatus)
return 0;
const TCHAR* p = m_statusMessage.c_str();