summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/src/chat.cpp15
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h2
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp10
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp6
-rw-r--r--protocols/IRCG/src/input.cpp4
-rw-r--r--protocols/IRCG/src/irc.h3
-rw-r--r--protocols/IRCG/src/scripting.cpp25
-rw-r--r--protocols/IRCG/src/services.cpp559
-rw-r--r--protocols/IRCG/src/tools.cpp55
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp2
-rw-r--r--protocols/JabberG/src/jabber_form.cpp393
-rw-r--r--protocols/MRA/src/MraChat.cpp2
-rw-r--r--protocols/MSN/src/msn.cpp4
-rw-r--r--protocols/MSN/src/msn_chat.cpp4
-rw-r--r--protocols/MSN/src/msn_commands.cpp951
-rw-r--r--protocols/MSN/src/msn_global.h3
-rw-r--r--protocols/MSN/src/msn_proto.cpp26
-rw-r--r--protocols/MSN/src/msn_proto.h2
-rw-r--r--protocols/Omegle/src/chat.cpp18
-rw-r--r--protocols/SkypeClassic/src/gchat.cpp16
-rw-r--r--protocols/SkypeClassic/src/gchat.h6
-rw-r--r--protocols/SkypeClassic/src/skype.cpp2
-rw-r--r--protocols/Twitter/src/chat.cpp12
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp4
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp4
25 files changed, 910 insertions, 1218 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 5315294fe7..b002768851 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -30,7 +30,7 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char
ptrT tnick( mir_a2t_cp(name,CP_UTF8));
ptrT ttext( mir_a2t_cp(message,CP_UTF8));
- GCDEST gcd = { m_szModuleName, (TCHAR*)tchat_id, GC_EVENT_MESSAGE };
+ GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = ttext;
gce.time = timestamp ? timestamp : ::time(NULL);
@@ -146,7 +146,7 @@ void FacebookProto::AddChatContact(const TCHAR *tchat_id, const char *id, const
ptrT tnick( mir_a2t_cp(name, CP_UTF8));
ptrT tid( mir_a2t(id));
- GCDEST gcd = { m_szModuleName, (TCHAR *)tchat_id, GC_EVENT_JOIN };
+ GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN };
GCEVENT gce = { sizeof(gce), &gcd };
gce.pDest = &gcd;
gce.dwFlags = GCEF_ADDTOLOG;
@@ -176,7 +176,7 @@ void FacebookProto::RemoveChatContact(const TCHAR *tchat_id, const char *id)
ptrT tid( mir_a2t(id));
- GCDEST gcd = { m_szModuleName, (TCHAR *)tchat_id, GC_EVENT_PART };
+ GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_PART };
GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszUID = gce.ptszNick = tid;
@@ -222,7 +222,7 @@ void FacebookProto::AddChat(const TCHAR *tid, const TCHAR *tname)
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
// Send setting events
- GCDEST gcd = { m_szModuleName, (TCHAR*)tid, GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, tid, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
// Create a user statuses
@@ -271,7 +271,7 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM wParam,LPARAM suppress)
return 0;
// Create a group
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("Admin");
CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
@@ -302,10 +302,7 @@ INT_PTR FacebookProto::OnLeaveChat(WPARAM,LPARAM)
/*
void FacebookProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index 6f506d6377..cfee1a350f 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -211,7 +211,7 @@ struct GGPROTO : public PROTO<GGPROTO>
void gc_menus_init(HGENMENU hRoot);
int gc_destroy();
TCHAR * gc_getchat(uin_t sender, uin_t *recipients, int recipients_count);
- GGGC *gc_lookup(TCHAR *id);
+ GGGC *gc_lookup(const TCHAR *id);
int gc_changenick(HANDLE hContact, TCHAR *ptszNick);
int __cdecl gc_event(WPARAM wParam, LPARAM lParam);
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index 3ae8ecf309..5fb2027896 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -98,7 +98,7 @@ int GGPROTO::gc_destroy()
return 1;
}
-GGGC* GGPROTO::gc_lookup(TCHAR *id)
+GGGC* GGPROTO::gc_lookup(const TCHAR *id)
{
GGGC *chat;
list_t l;
@@ -152,8 +152,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
}
// Message typed / send only if online
- if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText)
- {
+ if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText) {
TCHAR id[32];
UIN2IDT(uin, id);
DBVARIANT dbv;
@@ -172,7 +171,8 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
// Get rid of CRLF at back
int lc = (int)_tcslen(gch->ptszText) - 1;
- while(lc >= 0 && (gch->ptszText[lc] == '\n' || gch->ptszText[lc] == '\r')) gch->ptszText[lc --] = 0;
+ while(lc >= 0 && (gch->ptszText[lc] == '\n' || gch->ptszText[lc] == '\r'))
+ gch->ptszText[lc --] = 0;
gce.time = time(NULL);
gce.bIsMe = 1;
@@ -219,7 +219,7 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count
GGGC *chat;
TCHAR id[32];
uin_t uin; DBVARIANT dbv;
- GCDEST gcd = {m_szModuleName, 0, GC_EVENT_ADDGROUP};
+ GCDEST gcd = { m_szModuleName, 0, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
debugLogA("gc_getchat(): Count %d.", recipients_count);
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index ae19f64af2..18851cdbf5 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -385,7 +385,7 @@ bool CIrcProto::OnIrc_PART(const CIrcMessage* pmsg)
DoEvent(GC_EVENT_PART, pmsg->parameters[0].c_str(), pmsg->prefix.sNick.c_str(), pmsg->parameters.getCount()>1?pmsg->parameters[1].c_str():NULL, NULL, host.c_str(), NULL, true, false);
if ( pmsg->prefix.sNick == m_info.sNick ) {
CMString S = MakeWndID(pmsg->parameters[0].c_str());
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
}
@@ -404,7 +404,7 @@ bool CIrcProto::OnIrc_KICK(const CIrcMessage* pmsg)
if ( pmsg->parameters[1] == m_info.sNick ) {
CMString S = MakeWndID( pmsg->parameters[0].c_str());
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent(SESSION_OFFLINE, (LPARAM)&gce);
@@ -1257,7 +1257,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg)
gcw.ptszName = sChanName;
if (!CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) {
DBVARIANT dbv;
- GCDEST gcd = { m_szModuleName, (TCHAR*)sID.c_str(), GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, sID.c_str(), GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
PostIrcMessage( _T("/MODE %s"), sChanName );
diff --git a/protocols/IRCG/src/input.cpp b/protocols/IRCG/src/input.cpp
index 674f8e857c..2342aee213 100644
--- a/protocols/IRCG/src/input.cpp
+++ b/protocols/IRCG/src/input.cpp
@@ -255,7 +255,7 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
else
S = MakeWndID( window );
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent(WINDOW_CLEARLOG, (LPARAM)&gce);
return true;
@@ -477,7 +477,7 @@ BOOL CIrcProto::DoHardcodedCommand( CMString text, TCHAR* window, HANDLE hContac
}
CMString S = MakeWndID(window);
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h
index 367b92a905..4e963e743c 100644
--- a/protocols/IRCG/src/irc.h
+++ b/protocols/IRCG/src/irc.h
@@ -358,8 +358,7 @@ struct CIrcProto : public PROTO<CIrcProto>
HANDLE m_evWndCreate;
CMString m_statusMessage;
- bool m_bMbotInstalled;
- int m_iTempCheckTime;
+ int m_iTempCheckTime;
CIrcSessionInfo si;
diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp
index ea63dc16a2..4152ab3a8c 100644
--- a/protocols/IRCG/src/scripting.cpp
+++ b/protocols/IRCG/src/scripting.cpp
@@ -50,27 +50,6 @@ INT_PTR __cdecl CIrcProto::Scripting_InsertRawOut( WPARAM, LPARAM lParam )
INT_PTR __cdecl CIrcProto::Scripting_InsertGuiIn(WPARAM wParam,LPARAM lParam)
{
- GCEVENT* gce = (GCEVENT *) lParam;
- WPARAM_GUI_IN * wgi = (WPARAM_GUI_IN *) wParam;
-
-
- if ( m_bMbotInstalled && m_scriptingEnabled && gce ) {
- TCHAR* p1 = NULL;
- CMString S;
- if ( gce->pDest && gce->pDest->ptszID ) {
- p1 = gce->pDest->ptszID;
- S = MakeWndID(gce->pDest->ptszID);
- gce->pDest->ptszID = ( TCHAR* )S.c_str();
- }
- gce->cbSize = sizeof(GCEVENT);
-
- CallServiceSync( MS_GC_EVENT, wgi?wgi->wParam:0, (LPARAM)gce);
-
- if ( p1 )
- gce->pDest->ptszID = p1;
- return 0;
- }
-
return 1;
}
@@ -80,8 +59,8 @@ static void __stdcall OnHook(void * pi)
GCHOOK* gch = ( GCHOOK* )pi;
free(gch->ptszUID);
free(gch->ptszText);
- free(gch->pDest->ptszID);
- free(gch->pDest->pszModule);
+ free((void*)gch->pDest->ptszID);
+ free((void*)gch->pDest->pszModule);
delete gch->pDest;
delete gch;
}
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index c0f68e43b2..42e6b10536 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -226,7 +226,7 @@ int __cdecl CIrcProto::OnContactDeleted(WPARAM wp, LPARAM)
S = MakeWndID( dbv.ptszVal );
if (type == GCW_SERVER)
S = SERVERWINDOW;
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
int i = CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
if (i && type == GCW_CHATROOM)
@@ -270,7 +270,7 @@ INT_PTR __cdecl CIrcProto::OnLeaveChat(WPARAM wp, LPARAM)
PostIrcMessage( _T("/PART %s %s"), dbv.ptszVal, m_userInfo);
CMString S = MakeWndID(dbv.ptszVal);
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
}
@@ -498,327 +498,290 @@ static void DoChatFormatting( TCHAR* pszText )
int __cdecl CIrcProto::GCEventHook(WPARAM wParam,LPARAM lParam)
{
- GCHOOK *gchook= (GCHOOK*) lParam;
- GCHOOK *gchtemp = NULL;
- GCHOOK *gch = NULL;
+ GCHOOK *gch= (GCHOOK*) lParam;
CMString S = _T("");
EnterCriticalSection(&m_gchook);
// handle the hook
- if ( gchook ) {
- if (!lstrcmpiA(gchook->pDest->pszModule, m_szModuleName)) {
-
- // first see if the scripting module should modify or stop this event
- if (m_bMbotInstalled && m_scriptingEnabled && wParam == NULL) {
- gchtemp = (GCHOOK*)mir_alloc(sizeof(GCHOOK));
- gchtemp->pDest = (GCDEST*)mir_alloc(sizeof(GCDEST));
- gchtemp->pDest->iType = gchook->pDest->iType;
- gchtemp->dwData = gchook->dwData;
-
- if ( gchook->pDest->ptszID ) {
- gchtemp->pDest->ptszID = mir_tstrdup( gchook->pDest->ptszID );
- TCHAR* pTemp = _tcschr(gchtemp->pDest->ptszID, ' ');
- if ( pTemp )
- *pTemp = '\0';
- }
- else gchtemp->pDest->ptszID = NULL;
+ if (gch) {
+ if (!lstrcmpiA(gch->pDest->pszModule, m_szModuleName)) {
+ TCHAR *p1 = mir_tstrdup( gch->pDest->ptszID );
+ TCHAR *p2 = _tcsstr( p1, _T(" - "));
+ if (p2)
+ *p2 = '\0';
+
+ switch( gch->pDest->iType ) {
+ case GC_SESSION_TERMINATE:
+ FreeWindowItemData(p1, (CHANNELINFO*)gch->dwData);
+ break;
- //MBOT CORRECTIONS
- gchook->pDest->pszModule = mir_strdup( gchook->pDest->pszModule );
- gchook->ptszText = mir_tstrdup( gchook->ptszText );
- gchook->ptszUID = mir_tstrdup( gchook->ptszUID );
+ case GC_USER_MESSAGE:
+ if (gch && gch->ptszText && *gch->ptszText) {
+ TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText)+1000];
+ lstrcpy(pszText, gch->ptszText);
+ DoChatFormatting(pszText);
+ PostIrcMessageWnd(p1, NULL, pszText);
+ delete []pszText;
+ }
+ break;
- if ( Scripting_TriggerMSPGuiOut(gchtemp) && gchtemp)
- gch = gchtemp;
- else
- gch = NULL;
- }
- else gch = gchook;
+ case GC_USER_CHANMGR:
+ PostIrcMessageWnd(p1, NULL, _T("/CHANNELMANAGER"));
+ break;
- if ( gch ) {
- TCHAR* p1 = mir_tstrdup( gch->pDest->ptszID );
- TCHAR* p2 = _tcsstr( p1, _T(" - "));
- if ( p2 )
- *p2 = '\0';
+ case GC_USER_PRIVMESS:
+ {
+ TCHAR szTemp[4000];
+ mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/QUERY %s"), gch->ptszUID );
+ PostIrcMessageWnd(p1, NULL, szTemp);
+ }
+ break;
- switch( gch->pDest->iType ) {
- case GC_SESSION_TERMINATE:
- FreeWindowItemData(p1, (CHANNELINFO*)gch->dwData);
+ case GC_USER_LOGMENU:
+ switch( gch->dwData ) {
+ case 1:
+ OnChangeNickMenuCommand(NULL, NULL);
+ break;
+ case 2:
+ PostIrcMessageWnd(p1, NULL, _T("/CHANNELMANAGER"));
break;
- case GC_USER_MESSAGE:
- if (gch && gch->ptszText && *gch->ptszText) {
- TCHAR* pszText = new TCHAR[lstrlen(gch->ptszText)+1000];
- lstrcpy(pszText, gch->ptszText);
- DoChatFormatting(pszText);
- PostIrcMessageWnd(p1, NULL, pszText);
- delete []pszText;
+ case 3:
+ PostIrcMessage( _T("/PART %s %s"), p1, m_userInfo );
+ {
+ S = MakeWndID(p1);
+ GCDEST gcd = { m_szModuleName, S.c_str(), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
}
break;
-
- case GC_USER_CHANMGR:
- PostIrcMessageWnd(p1, NULL, _T("/CHANNELMANAGER"));
+ case 4: // show server window
+ PostIrcMessageWnd(p1, NULL, _T("/SERVERSHOW"));
break;
-
- case GC_USER_PRIVMESS:
+ /* case 5: // nickserv register nick
+ PostIrcMessage( _T("/nickserv REGISTER %%question=\"%s\",\"%s\""),
+ TranslateT("Please enter your authentification code"), TranslateT("Authentificate nick"));
+ break;
+ */
+ case 6: // nickserv Identify
+ 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"));
+ break;
+ case 8: // nickserv Identify
{
- TCHAR szTemp[4000];
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("/QUERY %s"), gch->ptszUID );
- PostIrcMessageWnd(p1, NULL, szTemp);
+ 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 );
+ SetFocus(hEditCtrl);
+ dlg->Activate();
}
break;
-
- case GC_USER_LOGMENU:
- switch( gch->dwData ) {
- case 1:
- OnChangeNickMenuCommand(NULL, NULL);
- break;
- case 2:
- PostIrcMessageWnd(p1, NULL, _T("/CHANNELMANAGER"));
- break;
-
- case 3:
- PostIrcMessage( _T("/PART %s %s"), p1, m_userInfo );
- {
- S = MakeWndID(p1);
- GCDEST gcd = { m_szModuleName, (TCHAR*)S.c_str(), GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- CallChatEvent(SESSION_TERMINATE, (LPARAM)&gce);
- }
- break;
- case 4: // show server window
- PostIrcMessageWnd(p1, NULL, _T("/SERVERSHOW"));
- break;
-/* case 5: // nickserv register nick
- PostIrcMessage( _T("/nickserv REGISTER %%question=\"%s\",\"%s\""),
- TranslateT("Please enter your authentification code"), TranslateT("Authentificate nick"));
- break;
-*/ case 6: // nickserv Identify
- 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"));
- break;
- case 8: // nickserv Identify
- {
- 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 );
- SetFocus(hEditCtrl);
- dlg->Activate();
+ case 9: // nickserv remind password
+ {
+ DBVARIANT dbv;
+ if ( !getTString( "Nick", &dbv )) {
+ PostIrcMessage( _T("/nickserv SENDPASS %s"), dbv.ptszVal);
+ db_free( &dbv );
}
- break;
- case 9: // nickserv remind password
- {
- DBVARIANT 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\""),
- TranslateT("Please enter your new password"), TranslateT("Set new password"));
- break;
- case 11: // nickserv set language
- 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\""),
- 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\""),
- 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\""),
- 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"));
- break;
- case 16: // nickserv kill unauth on
- PostIrcMessage( _T("/nickserv SET KILL ON"));
- break;
- case 17: // nickserv kill unauth quick
- PostIrcMessage( _T("/nickserv SET KILL QUICK"));
- break;
- case 18: // nickserv hide nick from /LIST
- PostIrcMessage( _T("/nickserv SET PRIVATE ON"));
- break;
- case 19: // nickserv show nick to /LIST
- PostIrcMessage( _T("/nickserv SET PRIVATE OFF"));
- break;
- case 20: // nickserv Hide e-mail from info
- PostIrcMessage( _T("/nickserv SET HIDE EMAIL ON"));
- break;
- case 21: // nickserv Show e-mail in info
- PostIrcMessage( _T("/nickserv SET HIDE EMAIL OFF"));
- break;
- case 22: // nickserv Set security for nick
- PostIrcMessage( _T("/nickserv SET SECURE ON"));
- break;
- case 23: // nickserv Remove security for nick
- PostIrcMessage( _T("/nickserv SET SECURE OFF"));
- break;
- case 24: // nickserv Link nick to current
- 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\""),
- 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\""),
- 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"));
- break;
- case 28: // nickserv list all channels owned
- PostIrcMessage( _T("/nickserv LISTCHANS"));
- break;
}
break;
+ case 10: // nickserv set new password
+ 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\""),
+ 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\""),
+ 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\""),
+ 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\""),
+ 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"));
+ break;
+ case 16: // nickserv kill unauth on
+ PostIrcMessage( _T("/nickserv SET KILL ON"));
+ break;
+ case 17: // nickserv kill unauth quick
+ PostIrcMessage( _T("/nickserv SET KILL QUICK"));
+ break;
+ case 18: // nickserv hide nick from /LIST
+ PostIrcMessage( _T("/nickserv SET PRIVATE ON"));
+ break;
+ case 19: // nickserv show nick to /LIST
+ PostIrcMessage( _T("/nickserv SET PRIVATE OFF"));
+ break;
+ case 20: // nickserv Hide e-mail from info
+ PostIrcMessage( _T("/nickserv SET HIDE EMAIL ON"));
+ break;
+ case 21: // nickserv Show e-mail in info
+ PostIrcMessage( _T("/nickserv SET HIDE EMAIL OFF"));
+ break;
+ case 22: // nickserv Set security for nick
+ PostIrcMessage( _T("/nickserv SET SECURE ON"));
+ break;
+ case 23: // nickserv Remove security for nick
+ PostIrcMessage( _T("/nickserv SET SECURE OFF"));
+ break;
+ case 24: // nickserv Link nick to current
+ 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\""),
+ 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\""),
+ 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"));
+ break;
+ case 28: // nickserv list all channels owned
+ PostIrcMessage( _T("/nickserv LISTCHANS"));
+ break;
+ }
+ break;
- case GC_USER_NICKLISTMENU:
- switch(gch->dwData) {
- case 1:
- PostIrcMessage( _T("/MODE %s +o %s"), p1, gch->ptszUID );
- break;
- case 2:
- PostIrcMessage( _T("/MODE %s -o %s"), p1, gch->ptszUID );
- break;
- case 3:
- PostIrcMessage( _T("/MODE %s +v %s"), p1, gch->ptszUID );
- break;
- case 4:
- PostIrcMessage( _T("/MODE %s -v %s"), p1, gch->ptszUID );
- break;
- case 5:
- PostIrcMessage( _T("/KICK %s %s"), p1, gch->ptszUID );
- break;
- case 6:
- 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 );
- break;
- case 8:
- 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 );
- break;
- case 10:
- 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 13:
- PostIrcMessage( _T("/DCC CHAT %s"), gch->ptszUID );
- break;
- case 14:
- PostIrcMessage( _T("/DCC SEND %s"), gch->ptszUID );
- break;
- case 15:
- DoUserhostWithReason(1, _T("I"), true, _T("%s"), gch->ptszUID );
- break;
- case 16:
- PostIrcMessage( _T("/MODE %s +h %s"), p1, gch->ptszUID );
- break;
- case 17:
- PostIrcMessage( _T("/MODE %s -h %s"), p1, gch->ptszUID );
- break;
- case 18:
- PostIrcMessage( _T("/MODE %s +q %s"), p1, gch->ptszUID );
- break;
- case 19:
- PostIrcMessage( _T("/MODE %s -q %s"), p1, gch->ptszUID );
- break;
- case 20:
- PostIrcMessage( _T("/MODE %s +a %s"), p1, gch->ptszUID );
- break;
- case 21:
- PostIrcMessage( _T("/MODE %s -a %s"), p1, gch->ptszUID );
- break;
- case 22:
- 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\""),
- gch->ptszUID, TranslateT("Please enter the channel name to invite to"), TranslateT("Invite to channel"));
- break;
- case 30:
- {
- PROTOSEARCHRESULT psr = { 0 };
- psr.cbSize = sizeof(psr);
- psr.flags = PSR_TCHAR;
- psr.id = gch->ptszUID;
- psr.nick = gch->ptszUID;
-
- ADDCONTACTSTRUCT acs = { 0 };
- acs.handleType = HANDLE_SEARCHRESULT;
- acs.szProto = m_szModuleName;
- acs.psr = &psr;
- CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
- }
- break;
- case 31: //slap
- {
- TCHAR tszTemp[4000];
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/slap %s"), gch->ptszUID);
- PostIrcMessageWnd(p1, NULL, tszTemp);
- }
- break;
- case 32: //nickserv info
- {
- TCHAR tszTemp[4000];
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv INFO %s ALL"), gch->ptszUID);
- PostIrcMessageWnd(p1, NULL, tszTemp);
- }
- break;
- case 33: //nickserv ghost
- {
- TCHAR tszTemp[4000];
- mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv GHOST %s"), gch->ptszUID);
- PostIrcMessageWnd(p1, NULL, tszTemp);
- }
- break;
+ case GC_USER_NICKLISTMENU:
+ switch(gch->dwData) {
+ case 1:
+ PostIrcMessage( _T("/MODE %s +o %s"), p1, gch->ptszUID );
+ break;
+ case 2:
+ PostIrcMessage( _T("/MODE %s -o %s"), p1, gch->ptszUID );
+ break;
+ case 3:
+ PostIrcMessage( _T("/MODE %s +v %s"), p1, gch->ptszUID );
+ break;
+ case 4:
+ PostIrcMessage( _T("/MODE %s -v %s"), p1, gch->ptszUID );
+ break;
+ case 5:
+ PostIrcMessage( _T("/KICK %s %s"), p1, gch->ptszUID );
+ break;
+ case 6:
+ 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 );
+ break;
+ case 8:
+ 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 );
+ break;
+ case 10:
+ 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 13:
+ PostIrcMessage( _T("/DCC CHAT %s"), gch->ptszUID );
+ break;
+ case 14:
+ PostIrcMessage( _T("/DCC SEND %s"), gch->ptszUID );
+ break;
+ case 15:
+ DoUserhostWithReason(1, _T("I"), true, _T("%s"), gch->ptszUID );
+ break;
+ case 16:
+ PostIrcMessage( _T("/MODE %s +h %s"), p1, gch->ptszUID );
+ break;
+ case 17:
+ PostIrcMessage( _T("/MODE %s -h %s"), p1, gch->ptszUID );
+ break;
+ case 18:
+ PostIrcMessage( _T("/MODE %s +q %s"), p1, gch->ptszUID );
+ break;
+ case 19:
+ PostIrcMessage( _T("/MODE %s -q %s"), p1, gch->ptszUID );
+ break;
+ case 20:
+ PostIrcMessage( _T("/MODE %s +a %s"), p1, gch->ptszUID );
+ break;
+ case 21:
+ PostIrcMessage( _T("/MODE %s -a %s"), p1, gch->ptszUID );
+ break;
+ case 22:
+ 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\""),
+ gch->ptszUID, TranslateT("Please enter the channel name to invite to"), TranslateT("Invite to channel"));
+ break;
+ case 30:
+ {
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.id = gch->ptszUID;
+ psr.nick = gch->ptszUID;
+
+ ADDCONTACTSTRUCT acs = { 0 };
+ acs.handleType = HANDLE_SEARCHRESULT;
+ acs.szProto = m_szModuleName;
+ acs.psr = &psr;
+ CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
+ }
+ break;
+ case 31: //slap
+ {
+ TCHAR tszTemp[4000];
+ mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/slap %s"), gch->ptszUID);
+ PostIrcMessageWnd(p1, NULL, tszTemp);
+ }
+ break;
+ case 32: //nickserv info
+ {
+ TCHAR tszTemp[4000];
+ mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv INFO %s ALL"), gch->ptszUID);
+ PostIrcMessageWnd(p1, NULL, tszTemp);
+ }
+ break;
+ case 33: //nickserv ghost
+ {
+ TCHAR tszTemp[4000];
+ mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("/nickserv GHOST %s"), gch->ptszUID);
+ PostIrcMessageWnd(p1, NULL, tszTemp);
}
break;
}
- mir_free( p1 );
- } } }
+ break;
+ }
+ mir_free( p1 );
+ } }
- if ( gchtemp ) {
- mir_free(gchtemp->ptszUID);
- mir_free(gchtemp->ptszText);
- mir_free(gchtemp->pDest->ptszID);
- mir_free(gchtemp->pDest->pszModule);
- mir_free(gchtemp->pDest);
- mir_free(gchtemp);
- }
LeaveCriticalSection(&m_gchook);
return 0;
}
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp
index ee4fcbb51c..9cfcb82137 100644
--- a/protocols/IRCG/src/tools.cpp
+++ b/protocols/IRCG/src/tools.cpp
@@ -406,60 +406,7 @@ TCHAR* __stdcall DoColorCodes(const TCHAR* text, bool bStrip, bool bReplacePerce
INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam)
{
- GCEVENT *gce = (GCEVENT *)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->ptszID == NULL || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID, SERVERWINDOW)))
- {
- GCEVENT *gcevent = (GCEVENT*)lParam;
- WPARAM wp = wParam;
- GCEVENT *gcetemp = (GCEVENT*)mir_alloc(sizeof(GCEVENT));
- gcetemp->pDest = (GCDEST*)mir_alloc(sizeof(GCDEST));
- gcetemp->pDest->iType = gcevent->pDest->iType;
- gcetemp->dwFlags = gcevent->dwFlags;
- gcetemp->bIsMe = gcevent->bIsMe;
- 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) {
- //MBOT CORRECTIONS
- //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);
- }
- iVal = CallServiceSync(MS_GC_EVENT, wp, (LPARAM)gcetemp);
- }
-
- if (gcetemp) {
- mir_free((void*)gcetemp->ptszNick);
- mir_free((void*)gcetemp->ptszUID);
- mir_free((void*)gcetemp->ptszStatus);
- mir_free((void*)gcetemp->ptszUserInfo);
- mir_free((void*)gcetemp->ptszText);
- 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)lParam);
}
INT_PTR CIrcProto::DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick,
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index abc5ac5dcf..8fadba06dc 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -699,7 +699,7 @@ class CGroupchatInviteDlg : public CJabberDlgBase
}
public:
- CGroupchatInviteDlg(CJabberProto *ppro, TCHAR *room) :
+ CGroupchatInviteDlg(CJabberProto *ppro, const TCHAR *room) :
CSuper(ppro, IDD_GROUPCHAT_INVITE, NULL),
m_newJids(1),
m_btnInvite(this, IDC_INVITE),
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp
index 69f79832f8..90d06a099a 100644
--- a/protocols/JabberG/src/jabber_form.cpp
+++ b/protocols/JabberG/src/jabber_form.cpp
@@ -224,7 +224,7 @@ static TJabberFormControlType JabberFormTypeNameToId(const TCHAR *type)
return JFORM_CTYPE_FIXED;
if (!_tcscmp(type, _T("hidden")))
return JFORM_CTYPE_HIDDEN;
- // else
+
return JFORM_CTYPE_TEXT_SINGLE;
}
@@ -252,40 +252,34 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo
int height = layout_info->ctrlHeight;
if ((item->type == JFORM_CTYPE_LIST_MULTI) || (item->type == JFORM_CTYPE_TEXT_MULTI)) height *= 3;
SetRect(&rcCtrl, indent, rcLabel.bottom, layout_info->width, rcLabel.bottom + height);
- } else
- if (item->type == JFORM_CTYPE_BOOLEAN)
- {
- SetRect(&rcCtrl, 0, 0, layout_info->width-20, 0);
+ }
+ else if (item->type == JFORM_CTYPE_BOOLEAN) {
+ SetRect(&rcCtrl, 0, 0, layout_info->width - 20, 0);
HDC hdc = GetDC(item->hCtrl);
HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(item->hCtrl, WM_GETFONT, 0, 0));
- DrawText(hdc, labelStr, -1, &rcCtrl, DT_CALCRECT|DT_RIGHT|DT_WORDBREAK);
+ DrawText(hdc, labelStr, -1, &rcCtrl, DT_CALCRECT | DT_RIGHT | DT_WORDBREAK);
SelectObject(hdc, hfntSave);
ReleaseDC(item->hCtrl, hdc);
rcCtrl.right += 20;
- } else
- if (item->type == JFORM_CTYPE_FIXED)
- {
+ }
+ else if (item->type == JFORM_CTYPE_FIXED) {
SetRect(&rcCtrl, 0, 0, layout_info->width, 0);
HDC hdc = GetDC(item->hCtrl);
HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(item->hCtrl, WM_GETFONT, 0, 0));
- DrawText(hdc, valueStr, -1, &rcCtrl, DT_CALCRECT|DT_EDITCONTROL);
+ DrawText(hdc, valueStr, -1, &rcCtrl, DT_CALCRECT | DT_EDITCONTROL);
rcCtrl.right += 20;
SelectObject(hdc, hfntSave);
ReleaseDC(item->hCtrl, hdc);
- } else
- {
- SetRect(&rcCtrl, rcLabel.right+5, 0, layout_info->width, layout_info->ctrlHeight);
+ }
+ else {
+ SetRect(&rcCtrl, rcLabel.right + 5, 0, layout_info->width, layout_info->ctrlHeight);
rcLabel.bottom = rcCtrl.bottom;
}
if (item->hLabel)
- SetWindowPos(item->hLabel, 0,
- 0, 0, rcLabel.right-rcLabel.left, rcLabel.bottom-rcLabel.top,
- SWP_NOZORDER|SWP_NOMOVE);
+ SetWindowPos(item->hLabel, 0, 0, 0, rcLabel.right - rcLabel.left, rcLabel.bottom - rcLabel.top, SWP_NOZORDER | SWP_NOMOVE);
if (item->hCtrl)
- SetWindowPos(item->hCtrl, 0,
- 0, 0, rcCtrl.right-rcCtrl.left, rcCtrl.bottom-rcCtrl.top,
- SWP_NOZORDER|SWP_NOMOVE);
+ SetWindowPos(item->hCtrl, 0, 0, 0, rcCtrl.right - rcCtrl.left, rcCtrl.bottom - rcCtrl.top, SWP_NOZORDER | SWP_NOMOVE);
item->ptLabel.x = rcLabel.left;
item->ptLabel.y = rcLabel.top;
@@ -302,8 +296,7 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo
TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, TJabberFormControlType type, const TCHAR *labelStr, const TCHAR *valueStr)
{
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
- if (!controls)
- {
+ if (!controls) {
controls = new TJabberFormControlList(5);
SetWindowLongPtr(hwndStatic, GWLP_USERDATA, (LONG_PTR)controls);
}
@@ -312,82 +305,72 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
item->type = type;
item->hLabel = item->hCtrl = NULL;
- switch (type)
- {
- case JFORM_CTYPE_TEXT_PRIVATE:
- {
- item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), valueStr,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL|ES_PASSWORD,
- 0, 0, 0, 0,
- hwndStatic, (HMENU) layout_info->id, hInst, NULL);
- ++layout_info->id;
- break;
- }
- case JFORM_CTYPE_TEXT_MULTI:
- {
- item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), valueStr,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|ES_LEFT|ES_MULTILINE|ES_AUTOVSCROLL|ES_WANTRETURN,
- 0, 0, 0, 0,
- hwndStatic, (HMENU) layout_info->id, hInst, NULL);
- mir_subclassWindow(item->hCtrl, JabberFormMultiLineWndProc);
- ++layout_info->id;
- break;
- }
- case JFORM_CTYPE_BOOLEAN:
- {
- item->hCtrl = CreateWindowEx(0, _T("button"), labelStr,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX|BS_MULTILINE,
- 0, 0, 0, 0,
- hwndStatic, (HMENU) layout_info->id, hInst, NULL);
- if (valueStr && !_tcscmp(valueStr, _T("1")))
- SendMessage(item->hCtrl, BM_SETCHECK, 1, 0);
- ++layout_info->id;
- break;
- }
- case JFORM_CTYPE_LIST_SINGLE:
- {
- item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "combobox", NULL,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,
- 0, 0, 0, 0,
- hwndStatic, (HMENU) layout_info->id, hInst, NULL);
- ++layout_info->id;
- break;
- }
- case JFORM_CTYPE_LIST_MULTI:
- {
- item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "listbox",
- NULL, WS_CHILD|WS_VISIBLE|WS_TABSTOP|LBS_MULTIPLESEL,
- 0, 0, 0, 0,
- hwndStatic, (HMENU) layout_info->id, hInst, NULL);
- ++layout_info->id;
- break;
- }
- case JFORM_CTYPE_FIXED:
- {
- item->hCtrl = CreateWindow(_T("edit"), valueStr,
- WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_READONLY|ES_AUTOHSCROLL,
- 0, 0, 0, 0,
- hwndStatic, (HMENU)-1, hInst, NULL);
- break;
- }
- case JFORM_CTYPE_HIDDEN:
- {
- break;
- }
- case JFORM_CTYPE_TEXT_SINGLE:
- {
- item->hLabel = labelStr ? (JabberFormCreateLabel()) : NULL;
- item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), valueStr,
- WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_LEFT|ES_AUTOHSCROLL,
- 0, 0, 0, 0,
- hwndStatic, (HMENU) layout_info->id, hInst, NULL);
- ++layout_info->id;
- break;
- }
+ switch (type) {
+ case JFORM_CTYPE_TEXT_PRIVATE:
+ item->hLabel = JabberFormCreateLabel();
+ item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), valueStr,
+ WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)layout_info->id, hInst, NULL);
+ ++layout_info->id;
+ break;
+
+ case JFORM_CTYPE_TEXT_MULTI:
+ item->hLabel = JabberFormCreateLabel();
+ item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), valueStr,
+ WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)layout_info->id, hInst, NULL);
+ mir_subclassWindow(item->hCtrl, JabberFormMultiLineWndProc);
+ ++layout_info->id;
+ break;
+
+ case JFORM_CTYPE_BOOLEAN:
+ item->hCtrl = CreateWindowEx(0, _T("button"), labelStr,
+ WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)layout_info->id, hInst, NULL);
+ if (valueStr && !_tcscmp(valueStr, _T("1")))
+ SendMessage(item->hCtrl, BM_SETCHECK, 1, 0);
+ ++layout_info->id;
+ break;
+
+ case JFORM_CTYPE_LIST_SINGLE:
+ item->hLabel = JabberFormCreateLabel();
+ item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "combobox", NULL,
+ WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)layout_info->id, hInst, NULL);
+ ++layout_info->id;
+ break;
+
+ case JFORM_CTYPE_LIST_MULTI:
+ item->hLabel = JabberFormCreateLabel();
+ item->hCtrl = CreateWindowExA(WS_EX_CLIENTEDGE, "listbox",
+ NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | LBS_MULTIPLESEL,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)layout_info->id, hInst, NULL);
+ ++layout_info->id;
+ break;
+
+ case JFORM_CTYPE_FIXED:
+ item->hCtrl = CreateWindow(_T("edit"), valueStr,
+ WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_READONLY | ES_AUTOHSCROLL,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)-1, hInst, NULL);
+ break;
+
+ case JFORM_CTYPE_HIDDEN:
+ break;
+
+ case JFORM_CTYPE_TEXT_SINGLE:
+ item->hLabel = labelStr ? (JabberFormCreateLabel()) : NULL;
+ item->hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, _T("edit"), valueStr,
+ WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL,
+ 0, 0, 0, 0,
+ hwndStatic, (HMENU)layout_info->id, hInst, NULL);
+ ++layout_info->id;
+ break;
}
HFONT hFont = (HFONT)SendMessage(GetParent(hwndStatic), WM_GETFONT, 0, 0);
@@ -400,11 +383,10 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo
return item;
}
-void JabberFormAddListItem(TJabberFormControlInfo *item, TCHAR *text, bool selected)
+void JabberFormAddListItem(TJabberFormControlInfo *item, const TCHAR *text, bool selected)
{
DWORD dwIndex;
- switch (item->type)
- {
+ switch (item->type) {
case JFORM_CTYPE_LIST_MULTI:
dwIndex = SendMessage(item->hCtrl, LB_ADDSTRING, 0, (LPARAM)text);
if (selected) SendMessage(item->hCtrl, LB_SETSEL, TRUE, dwIndex);
@@ -421,16 +403,15 @@ void JabberFormLayoutControls(HWND hwndStatic, TJabberFormLayoutInfo *layout_inf
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
if (!controls) return;
- for (int i=0; i < controls->getCount(); i++)
- {
+ for (int i = 0; i < controls->getCount(); i++) {
if ((*controls)[i]->hLabel)
SetWindowPos((*controls)[i]->hLabel, 0,
- layout_info->offset+(*controls)[i]->ptLabel.x, layout_info->y_pos+(*controls)[i]->ptLabel.y, 0, 0,
- SWP_NOZORDER|SWP_NOSIZE);
+ layout_info->offset + (*controls)[i]->ptLabel.x, layout_info->y_pos + (*controls)[i]->ptLabel.y, 0, 0,
+ SWP_NOZORDER | SWP_NOSIZE);
if ((*controls)[i]->hCtrl)
SetWindowPos((*controls)[i]->hCtrl, 0,
- layout_info->offset+(*controls)[i]->ptCtrl.x, layout_info->y_pos+(*controls)[i]->ptCtrl.y, 0, 0,
- SWP_NOZORDER|SWP_NOSIZE);
+ layout_info->offset + (*controls)[i]->ptCtrl.x, layout_info->y_pos + (*controls)[i]->ptCtrl.y, 0, 0,
+ SWP_NOZORDER | SWP_NOSIZE);
layout_info->y_pos += (*controls)[i]->szBlock.cy;
layout_info->y_pos += layout_info->y_spacing;
@@ -450,7 +431,7 @@ HJFORMLAYOUT JabberFormCreateLayout(HWND hwndStatic)
layout_info->id = 0;
layout_info->width = frameRect.right - frameRect.left - 20 - 10;
layout_info->y_spacing = 5;
- layout_info->maxLabelWidth = layout_info->width*2/5;
+ layout_info->maxLabelWidth = layout_info->width * 2 / 5;
layout_info->offset = 10;
layout_info->y_pos = 14;
return layout_info;
@@ -462,12 +443,12 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp
HXML v, vs;
- int i, j, k;
const TCHAR *label, *typeName, *varStr, *str, *valueText;
- TCHAR *labelStr, *valueStr, *p;
+ TCHAR *labelStr, *valueStr;
RECT frameRect;
- if (xNode == NULL || xmlGetName(xNode) == NULL || lstrcmp(xmlGetName(xNode), _T("x")) || hwndStatic == NULL) return;
+ if (xNode == NULL || xmlGetName(xNode) == NULL || lstrcmp(xmlGetName(xNode), _T("x")) || hwndStatic == NULL)
+ return;
GetClientRect(hwndStatic, &frameRect);
@@ -478,99 +459,110 @@ void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bComp
layout_info.width = frameRect.right - frameRect.left - 20;
if (!bCompact) layout_info.width -= 10;
layout_info.y_spacing = bCompact ? 1 : 5;
- layout_info.maxLabelWidth = layout_info.width*2/5;
+ layout_info.maxLabelWidth = layout_info.width * 2 / 5;
layout_info.offset = 10;
layout_info.y_pos = bCompact ? 0 : 14;
- for (i=0; ; i++) {
- HXML n = xmlGetChild(xNode ,i);
+ for (int i = 0;; i++) {
+ HXML n = xmlGetChild(xNode, i);
if (!n)
break;
- if (xmlGetName(n)) {
- if (!lstrcmp(xmlGetName(n), _T("field"))) {
- varStr = xmlGetAttrValue(n, _T("var"));
- if ((typeName = xmlGetAttrValue(n, _T("type"))) != NULL) {
- if ((label = xmlGetAttrValue(n, _T("label"))) != NULL)
- labelStr = mir_tstrdup(label);
- else
- labelStr = mir_tstrdup(varStr);
-
- TJabberFormControlType type = JabberFormTypeNameToId(typeName);
-
- if ((v = xmlGetChild(n, "value")) != NULL) {
- valueText = xmlGetText(v);
- if (type != JFORM_CTYPE_TEXT_MULTI)
- valueStr = mir_tstrdup(valueText);
- else {
- size_t size = 1;
- for (j=0; ; j++) {
- v = xmlGetChild(n,j);
- if (!v)
- break;
- if (xmlGetName(v) && !lstrcmp(xmlGetName(v), _T("value")) && xmlGetText(v))
- size += _tcslen(xmlGetText(v)) + 2;
- }
- valueStr = (TCHAR*)mir_alloc(sizeof(TCHAR)*size);
- valueStr[0] = '\0';
- for (j=0; ; j++) {
- v = xmlGetChild(n,j);
- if (!v)
- break;
- if (xmlGetName(v) && !lstrcmp(xmlGetName(v), _T("value")) && xmlGetText(v)) {
- if (valueStr[0])
- _tcscat(valueStr, _T("\r\n"));
- _tcscat(valueStr, xmlGetText(v));
- } }
- }
+ if (lstrcmp(xmlGetName(n), _T("field")))
+ continue;
+
+ varStr = xmlGetAttrValue(n, _T("var"));
+ if ((typeName = xmlGetAttrValue(n, _T("type"))) == NULL)
+ continue;
+
+ if ((label = xmlGetAttrValue(n, _T("label"))) != NULL)
+ labelStr = mir_tstrdup(label);
+ else
+ labelStr = mir_tstrdup(varStr);
+
+ TJabberFormControlType type = JabberFormTypeNameToId(typeName);
+
+ if ((v = xmlGetChild(n, "value")) != NULL) {
+ valueText = xmlGetText(v);
+ if (type != JFORM_CTYPE_TEXT_MULTI)
+ valueStr = mir_tstrdup(valueText);
+ else {
+ size_t size = 1;
+ for (int j = 0;; j++) {
+ v = xmlGetChild(n, j);
+ if (!v)
+ break;
+ if (xmlGetName(v) && !lstrcmp(xmlGetName(v), _T("value")) && xmlGetText(v))
+ size += _tcslen(xmlGetText(v)) + 2;
+ }
+ valueStr = (TCHAR*)mir_alloc(sizeof(TCHAR)*size);
+ valueStr[0] = '\0';
+ for (int j = 0;; j++) {
+ v = xmlGetChild(n, j);
+ if (!v)
+ break;
+ if (xmlGetName(v) && !lstrcmp(xmlGetName(v), _T("value")) && xmlGetText(v)) {
+ if (valueStr[0])
+ _tcscat(valueStr, _T("\r\n"));
+ _tcscat(valueStr, xmlGetText(v));
}
- else valueText = valueStr = NULL;
+ }
+ }
+ }
+ else valueText = valueStr = NULL;
- TJabberFormControlInfo *item = JabberFormAppendControl(hwndStatic, &layout_info, type, labelStr, valueStr);
+ TJabberFormControlInfo *item = JabberFormAppendControl(hwndStatic, &layout_info, type, labelStr, valueStr);
- mir_free(labelStr);
- mir_free(valueStr);
+ mir_free(labelStr);
+ mir_free(valueStr);
- if (type == JFORM_CTYPE_LIST_SINGLE) {
- for (j=0; ; j++) {
- HXML o = xmlGetChild(n,j);
- if (o == NULL)
- break;
- if (xmlGetName(o) && !lstrcmp(xmlGetName(o), _T("option"))) {
- if ((v = xmlGetChild(o , "value")) != NULL && xmlGetText(v)) {
- if ((str = xmlGetAttrValue(o, _T("label"))) == NULL)
- str = xmlGetText(v);
- if ((p = mir_tstrdup(str)) != NULL) {
- bool selected = false;
- if (valueText != NULL && !_tcscmp(valueText, xmlGetText(v)))
- selected = true;
- JabberFormAddListItem(item, p, selected);
- mir_free(p);
- } } } }
+ if (type == JFORM_CTYPE_LIST_SINGLE) {
+ for (int j = 0;; j++) {
+ HXML o = xmlGetChild(n, j);
+ if (o == NULL)
+ break;
+
+ if (lstrcmp(xmlGetName(o), _T("option")))
+ continue;
+ if ((v = xmlGetChild(o, "value")) == NULL || xmlGetText(v) == NULL)
+ continue;
+ if ((str = xmlGetAttrValue(o, _T("label"))) == NULL)
+ str = xmlGetText(v);
+ if (str == NULL)
+ continue;
+
+ bool selected = !lstrcmp(valueText, xmlGetText(v));
+ JabberFormAddListItem(item, str, selected);
+ }
+ }
+ else if (type == JFORM_CTYPE_LIST_MULTI) {
+ for (int j = 0;; j++) {
+ HXML o = xmlGetChild(n, j);
+ if (o == NULL)
+ break;
+
+ if (lstrcmp(xmlGetName(o), _T("option")))
+ continue;
+ if ((v = xmlGetChild(o, "value")) == NULL || xmlGetText(v) == NULL)
+ continue;
+ if ((str = xmlGetAttrValue(o, _T("label"))) == NULL)
+ str = xmlGetText(v);
+ if (str == NULL)
+ continue;
+
+ bool selected = false;
+ for (int k = 0;; k++) {
+ vs = xmlGetChild(n, k);
+ if (!vs)
+ break;
+ if (!lstrcmp(xmlGetName(vs), _T("value")) && !lstrcmp(xmlGetText(vs), xmlGetText(v))) {
+ selected = true;
+ break;
}
- else if (type == JFORM_CTYPE_LIST_MULTI) {
- for (j=0; ; j++) {
- HXML o = xmlGetChild(n,j);
- if (o == NULL)
- break;
- if (xmlGetName(o) && !lstrcmp(xmlGetName(o), _T("option"))) {
- if ((v = xmlGetChild(o , "value")) != NULL && xmlGetText(v)) {
- if ((str = xmlGetAttrValue(o, _T("label"))) == NULL)
- str = xmlGetText(v);
- if ((p = mir_tstrdup(str)) != NULL) {
- bool selected = false;
- for (k=0; ; k++) {
- vs = xmlGetChild(n,k);
- if (!vs)
- break;
- if (!lstrcmp(xmlGetName(vs), _T("value")) && xmlGetText(vs) && !_tcscmp(xmlGetText(vs), xmlGetText(v)))
- {
- selected = true;
- break;
- }
- }
- JabberFormAddListItem(item, p, selected);
- mir_free(p);
- } } } } } } } } }
+ }
+ JabberFormAddListItem(item, str, selected);
+ }
+ }
+ }
JabberFormLayoutControls(hwndStatic, &layout_info, formHeight);
}
@@ -720,7 +712,7 @@ struct JABBER_FORM_INFO
static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JABBER_FORM_INFO *jfi;
+ JABBER_FORM_INFO *jfi = (JABBER_FORM_INFO*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
@@ -731,7 +723,7 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
// lParam is (JABBER_FORM_INFO *)
TranslateDialogDefault(hwndDlg);
ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME_TEXT), SW_HIDE);
- jfi = (JABBER_FORM_INFO *) lParam;
+ jfi = (JABBER_FORM_INFO*)lParam;
if (jfi != NULL) {
// Set dialog title
if (jfi->xNode != NULL && (n = xmlGetChild(jfi->xNode , "title")) != NULL && xmlGetText(n) != NULL)
@@ -741,9 +733,8 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
// Set instruction field
if (jfi->xNode != NULL && (n = xmlGetChild(jfi->xNode , "instructions")) != NULL && xmlGetText(n) != NULL)
JabberFormSetInstruction(hwndDlg, xmlGetText(n));
- else
- {
- if (jfi->xNode != NULL && (n = xmlGetChild(jfi->xNode , "title")) != NULL && xmlGetText(n) != NULL)
+ else {
+ if (jfi->xNode != NULL && (n = xmlGetChild(jfi->xNode, "title")) != NULL && xmlGetText(n) != NULL)
JabberFormSetInstruction(hwndDlg, xmlGetText(n));
else if (jfi->defTitle != NULL)
JabberFormSetInstruction(hwndDlg, TranslateTS(jfi->defTitle));
@@ -752,7 +743,6 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
// Create form
if (jfi->xNode != NULL) {
RECT rect;
-
GetClientRect(GetDlgItem(hwndDlg, IDC_FRAME), &(jfi->frameRect));
GetClientRect(GetDlgItem(hwndDlg, IDC_VSCROLL), &rect);
jfi->frameRect.right -= (rect.right - rect.left);
@@ -805,7 +795,6 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
break;
case WM_VSCROLL:
- jfi = (JABBER_FORM_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (jfi != NULL) {
int pos = jfi->curPos;
switch (LOWORD(wParam)) {
@@ -840,7 +829,6 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_SUBMIT:
- jfi = (JABBER_FORM_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (jfi != NULL) {
HXML n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), jfi->xNode);
(jfi->ppro->*(jfi->pfnSubmit))(n, jfi->userdata);
@@ -860,7 +848,6 @@ static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
case WM_DESTROY:
JabberFormDestroyUI(GetDlgItem(hwndDlg, IDC_FRAME));
- jfi = (JABBER_FORM_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
delete jfi;
break;
}
@@ -893,4 +880,4 @@ JABBER_FORM_INFO::~JABBER_FORM_INFO()
{
xi.destroyNode(xNode);
mir_free(userdata);
-} \ No newline at end of file
+}
diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp
index 2622dfe4d5..ac645e11a7 100644
--- a/protocols/MRA/src/MraChat.cpp
+++ b/protocols/MRA/src/MraChat.cpp
@@ -42,7 +42,7 @@ INT_PTR CMraProto::MraChatSessionNew(HANDLE hContact)
gcw.ptszStatusbarText = _T("status bar");
gcw.dwItemData = (DWORD)hContact;
if ( !CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw)) {
- GCDEST gcd = { m_szModuleName, (TCHAR*)wszEMail.c_str(), GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, wszEMail.c_str(), GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
for (int i = 0; i < SIZEOF(lpwszStatuses); i++) {
gce.ptszStatus = TranslateTS(lpwszStatuses[i]);
diff --git a/protocols/MSN/src/msn.cpp b/protocols/MSN/src/msn.cpp
index 77ac325ac5..21e199fb77 100644
--- a/protocols/MSN/src/msn.cpp
+++ b/protocols/MSN/src/msn.cpp
@@ -38,8 +38,7 @@ void MsnLinks_Destroy(void);
/////////////////////////////////////////////////////////////////////////////////////////
// Global variables
-bool msnHaveChatDll;
-int avsPresent = -1;
+int avsPresent = -1;
static const PLUGININFOEX pluginInfo =
{
@@ -86,7 +85,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,LPVOID lpvRes
static int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
avsPresent = ServiceExists(MS_AV_SETMYAVATART) != 0;
- msnHaveChatDll = ServiceExists(MS_GC_REGISTER) != 0;
MsnLinks_Init();
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp
index d5718bb34e..55c9ae5cd3 100644
--- a/protocols/MSN/src/msn_chat.cpp
+++ b/protocols/MSN/src/msn_chat.cpp
@@ -109,7 +109,7 @@ void CMsnProto::MSN_ChatStart(ThreadData* info)
}
}
-void CMsnProto::MSN_KillChatSession(TCHAR* id)
+void CMsnProto::MSN_KillChatSession(const TCHAR* id)
{
GCDEST gcd = { m_szModuleName, id, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
@@ -329,8 +329,8 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam)
ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
if (thread)
{
- rtrimt(gch->ptszText); // remove the ending linebreak
TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText));
+ rtrimt(pszMsg); // remove the ending linebreak
thread->sendMessage('N', NULL, NETID_MSN, UTF8(pszMsg), 0);
DBVARIANT dbv;
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index 63836bea6a..bd5ce999d9 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -36,19 +36,16 @@ void MSN_ConnectionProc(HANDLE hNewConnection, DWORD /* dwRemoteIP */, void* ext
CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hNewConnection, (LPARAM)&connInfo);
ThreadData* T = proto->MSN_GetThreadByPort(connInfo.wPort);
- if (T != NULL && T->s == NULL)
- {
+ if (T != NULL && T->s == NULL) {
T->s = hNewConnection;
ReleaseSemaphore(T->hWaitEvent, 1, NULL);
}
- else
- {
+ else {
proto->debugLogA("There's no registered file transfers for incoming port #%u, connection closed", connInfo.wPort);
Netlib_CloseHandle(hNewConnection);
}
}
-
void CMsnProto::sttSetMirVer(HANDLE hContact, DWORD dwValue, bool always)
{
static const char* MirVerStr[] =
@@ -83,9 +80,8 @@ void CMsnProto::sttSetMirVer(HANDLE hContact, DWORD dwValue, bool always)
setString(hContact, "MirVer", "Miranda IM 0.5.x (MSN v.0.5.x)");
else if (dwValue == 0x30000024)
setString(hContact, "MirVer", "Miranda IM 0.4.x (MSN v.0.4.x)");
- else if (always || getByte(hContact, "StdMirVer", 0))
- {
- unsigned wlmId = min(dwValue >> 28 & 0xff, SIZEOF(MirVerStr)-1);
+ else if (always || getByte(hContact, "StdMirVer", 0)) {
+ unsigned wlmId = min(dwValue >> 28 & 0xff, SIZEOF(MirVerStr) - 1);
setString(hContact, "MirVer", MirVerStr[wlmId]);
}
else
@@ -116,12 +112,10 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
const char* AuthCookie = tFileInfo["AuthCookie"];
const char* SessionID = tFileInfo["Session-ID"];
const char* SessionProtocol = tFileInfo["Session-Protocol"];
-// const char* Connectivity = tFileInfo["Connectivity"];
+ // const char* Connectivity = tFileInfo["Connectivity"];
- if (AppGUID != NULL)
- {
- if (!strcmp(AppGUID, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}"))
- {
+ if (AppGUID != NULL) {
+ if (!strcmp(AppGUID, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) {
MSN_ShowPopup(info->getContactHandle(),
TranslateT("Contact tried to open an audio conference (not currently supported)"),
MSN_ALLOW_MSGBOX);
@@ -129,8 +123,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
}
}
- if (Invcommand && (strcmp(Invcommand, "CANCEL") == 0))
- {
+ if (Invcommand && (strcmp(Invcommand, "CANCEL") == 0)) {
delete info->mMsnFtp;
info->mMsnFtp = NULL;
}
@@ -150,7 +143,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
TCHAR tComment[40];
mir_sntprintf(tComment, SIZEOF(tComment), TranslateT("%I64u bytes"), ft->std.currentFileSize);
- PROTORECVFILET pre = {0};
+ PROTORECVFILET pre = { 0 };
pre.flags = PREF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
@@ -161,8 +154,8 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
return;
}
- if (IPAddress != NULL && Port != NULL && AuthCookie != NULL) // receive Second
- {
+ // receive Second
+ if (IPAddress != NULL && Port != NULL && AuthCookie != NULL) {
ThreadData* newThread = new ThreadData;
if (inet_addr(IPAddress) != MyConnection.extIP || !IPAddressInt)
@@ -172,11 +165,9 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
newThread->mType = SERVER_FILETRANS;
- if (info->mMsnFtp == NULL)
- {
+ if (info->mMsnFtp == NULL) {
ThreadData* otherThread = MSN_GetOtherContactThread(info);
- if (otherThread)
- {
+ if (otherThread) {
info->mMsnFtp = otherThread->mMsnFtp;
otherThread->mMsnFtp = NULL;
}
@@ -189,16 +180,15 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
return;
}
- if (Invcommand != NULL && Invcookie != NULL && Port == NULL && AuthCookie == NULL && SessionID == NULL) // send 1
- {
+ // send 1
+ if (Invcommand != NULL && Invcookie != NULL && Port == NULL && AuthCookie == NULL && SessionID == NULL) {
msnftp_startFileSend(info, Invcommand, Invcookie);
return;
}
- if (Appname == NULL && SessionID != NULL && SessionProtocol != NULL) // netmeeting send 1
- {
- if (!_stricmp(Invcommand,"ACCEPT"))
- {
+ // netmeeting send 1
+ if (Appname == NULL && SessionID != NULL && SessionProtocol != NULL) {
+ if (!_stricmp(Invcommand, "ACCEPT")) {
ShellExecuteA(NULL, "open", "conf.exe", NULL, NULL, SW_SHOW);
Sleep(3000);
@@ -217,8 +207,8 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
return;
}
- if (Appname != NULL && !_stricmp(Appname,"NetMeeting")) // netmeeting receive 1
- {
+ // netmeeting receive 1
+ if (Appname != NULL && !_stricmp(Appname, "NetMeeting")) {
char command[1024];
int nBytes;
@@ -226,8 +216,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
mir_sntprintf(text, SIZEOF(text), TranslateT("Accept NetMeeting request from %s?"), tszEmail);
mir_free(tszEmail);
- if (MessageBox(NULL, text, TranslateT("MSN Protocol"), MB_YESNO | MB_ICONQUESTION) == IDYES)
- {
+ if (MessageBox(NULL, text, TranslateT("MSN Protocol"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
nBytes = mir_snprintf(command, sizeof(command),
"MIME-Version: 1.0\r\n"
"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
@@ -240,8 +229,7 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
"IP-Address: %s\r\n\r\n",
Invcookie, MyConnection.GetMyExtIPStr());
}
- else
- {
+ else {
nBytes = mir_snprintf(command, sizeof(command),
"MIME-Version: 1.0\r\n"
"Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
@@ -258,7 +246,8 @@ void CMsnProto::sttInviteMessage(ThreadData* info, char* msgBody, char* email, c
char ipaddr[256];
mir_snprintf(ipaddr, sizeof(ipaddr), "callto://%s", IPAddress);
ShellExecuteA(NULL, "open", ipaddr, NULL, NULL, SW_SHOW);
-} }
+ }
+}
/////////////////////////////////////////////////////////////////////////////////////////
// Processes custom smiley messages
@@ -276,15 +265,13 @@ void CMsnProto::sttCustomSmiley(const char* msgBody, char* email, char* nick, in
unsigned iCount = 0;
bool parseSmiley = true;
- for (;;)
- {
+ for (;;) {
tok2 = strchr(tok1, '\t');
if (tok2 == NULL) break;
size_t sz = tok2 - tok1;
- if (parseSmiley)
- {
- sz = min(sz, sizeof(lastsml) - 1);
+ if (parseSmiley) {
+ sz = min(sz, sizeof(lastsml)-1);
memcpy(lastsml, tok1, sz);
lastsml[sz] = 0;
@@ -292,8 +279,7 @@ void CMsnProto::sttCustomSmiley(const char* msgBody, char* email, char* nick, in
*(smlp++) = '\n'; *smlp = 0;
++iCount;
}
- else
- {
+ else {
filetransfer* ft = new filetransfer(this);
ft->std.hContact = hContact;
@@ -302,7 +288,7 @@ void CMsnProto::sttCustomSmiley(const char* msgBody, char* email, char* nick, in
ft->p2p_object[sz] = 0;
size_t slen = strlen(lastsml);
- ptrA buf( mir_base64_encode((PBYTE)lastsml, (unsigned)slen));
+ ptrA buf(mir_base64_encode((PBYTE)lastsml, (unsigned)slen));
ptrA smileyName(mir_urlEncode(buf));
int rlen = lstrlenA(buf);
@@ -330,15 +316,13 @@ void CMsnProto::sttCustomSmiley(const char* msgBody, char* email, char* nick, in
void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* params)
{
- union
- {
+ union {
char* tWords[6];
struct { char *fromEmail, *fromNick, *strMsgBytes; } data;
struct { char *fromEmail, *fromNetId, *toEmail, *toNetId, *typeId, *strMsgBytes; } datau;
};
- if (sttDivideWords(params, SIZEOF(tWords), tWords) < 3)
- {
+ if (sttDivideWords(params, SIZEOF(tWords), tWords) < 3) {
debugLogA("Invalid %.3s command, ignoring", cmdString);
return;
}
@@ -348,14 +332,12 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
bool ubmMsg = strncmp(cmdString, "UBM", 3) == 0;
bool sentMsg = false;
- if (ubmMsg)
- {
+ if (ubmMsg) {
msgBytes = atol(datau.strMsgBytes);
nick = datau.fromEmail;
email = datau.fromEmail;
}
- else
- {
+ else {
msgBytes = atol(data.strMsgBytes);
nick = data.fromNick;
email = data.fromEmail;
@@ -382,8 +364,7 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
// Chunked message
char* newbody = NULL;
- if (tMsgId)
- {
+ if (tMsgId) {
int idx;
const char* tChunks = tHeader["Chunks"];
if (tChunks)
@@ -404,54 +385,35 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
if (tContentType == NULL)
return;
- if (!_strnicmp(tContentType, "text/x-clientcaps", 17))
- {
+ if (!_strnicmp(tContentType, "text/x-clientcaps", 17)) {
MimeHeaders tFileInfo;
tFileInfo.readFromBuffer(msgBody);
info->firstMsgRecv = true;
HANDLE hContact = MSN_HContactFromEmail(email);
const char* mirver = tFileInfo["Client-Name"];
- if (hContact != NULL && mirver != NULL)
- {
+ if (hContact != NULL && mirver != NULL) {
setString(hContact, "MirVer", mirver);
delSetting(hContact, "StdMirVer");
}
}
- else if (!ubmMsg && !info->firstMsgRecv)
- {
+ else if (!ubmMsg && !info->firstMsgRecv) {
info->firstMsgRecv = true;
MsnContact *cont = Lists_Get(email);
if (cont && cont->hContact != NULL)
sttSetMirVer(cont->hContact, cont->cap1, true);
}
- if (!_strnicmp(tContentType, "text/plain", 10))
- {
+ if (!_strnicmp(tContentType, "text/plain", 10)) {
HANDLE hContact = MSN_HContactFromEmail(email, nick, true, true);
const char* p = tHeader["X-MMS-IM-Format"];
- bool isRtl = p != NULL && strstr(p, "RL=1") != NULL;
+ bool isRtl = p != NULL && strstr(p, "RL=1") != NULL;
if (info->mJoinedContactsWLID.getCount() > 1)
- {
- if (msnHaveChatDll)
- MSN_ChatStart(info);
- else
- {
- for (int j=0; j < info->mJoinedContactsWLID.getCount(); j++)
- {
- if (_stricmp(info->mJoinedContactsWLID[j], email) == 0 && j != 0)
- {
- hContact = info->getContactHandle();
- break;
- }
- }
- }
- }
- else
- {
- char* szEmail;
+ MSN_ChatStart(info);
+ else {
+ char *szEmail;
parseWLID(NEWSTR_ALLOCA(email), NULL, &szEmail, NULL);
sentMsg = _stricmp(szEmail, MyOptions.szEmail) == 0;
if (sentMsg)
@@ -459,17 +421,15 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
}
const char* tP4Context = tHeader["P4-Context"];
- if (tP4Context)
- {
- size_t newlen = strlen(msgBody) + strlen(tP4Context) + 4;
+ if (tP4Context) {
+ size_t newlen = strlen(msgBody) + strlen(tP4Context) + 4;
char* newMsgBody = (char*)mir_alloc(newlen);
mir_snprintf(newMsgBody, newlen, "[%s] %s", tP4Context, msgBody);
mir_free(newbody);
msgBody = newbody = newMsgBody;
}
- if (info->mChatID[0])
- {
+ if (info->mChatID[0]) {
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
@@ -486,10 +446,8 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
mir_free((void*)gce.ptszText);
mir_free((void*)gce.ptszUID);
}
- else if (hContact)
- {
- if (!sentMsg)
- {
+ else if (hContact) {
+ if (!sentMsg) {
CallService(MS_PROTO_CONTACTISTYPING, WPARAM(hContact), 0);
PROTORECVEVENT pre = { 0 };
@@ -499,11 +457,10 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
pre.lParam = 0;
ProtoChainRecvMsg(hContact, &pre);
}
- else
- {
+ else {
bool haveWnd = MSN_MsgWndExist(hContact);
- DBEVENTINFO dbei = {0};
+ DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_SENT | DBEF_UTF | (haveWnd ? 0 : DBEF_READ) | (isRtl ? DBEF_RTL : 0);
@@ -515,74 +472,63 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
}
}
}
- else if (!_strnicmp(tContentType, "text/x-msmsgsprofile", 20))
- {
+ else if (!_strnicmp(tContentType, "text/x-msmsgsprofile", 20)) {
replaceStr(msnExternalIP, tHeader["ClientIP"]);
abchMigrated = atol(tHeader["ABCHMigrated"]);
langpref = atol(tHeader["lang_preference"]);
emailEnabled = atol(tHeader["EmailEnabled"]);
- if (!MSN_RefreshContactList())
- {
+ if (!MSN_RefreshContactList()) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NOSERVER);
info->sendTerminate();
}
- else
- {
+ else {
MSN_SetServerStatus(m_iDesiredStatus);
MSN_EnableMenuItems(true);
}
}
- else if (!_strnicmp(tContentType, "text/x-msmsgscontrol", 20))
- {
+ else if (!_strnicmp(tContentType, "text/x-msmsgscontrol", 20)) {
const char* tTypingUser = tHeader["TypingUser"];
- if (tTypingUser != NULL && info->mChatID[0] == 0 && _stricmp(email, MyOptions.szEmail))
- {
+ if (tTypingUser != NULL && info->mChatID[0] == 0 && _stricmp(email, MyOptions.szEmail)) {
HANDLE hContact = MSN_HContactFromEmail(tTypingUser, tTypingUser);
- CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, 7);
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, 7);
}
}
- else if (!_strnicmp(tContentType, "text/x-msnmsgr-datacast", 23))
- {
- if (info->mJoinedContactsWLID.getCount())
- {
+ else if (!_strnicmp(tContentType, "text/x-msnmsgr-datacast", 23)) {
+ if (info->mJoinedContactsWLID.getCount()) {
HANDLE tContact;
- if (info->mChatID[0])
- {
- GC_INFO gci = {0};
+ if (info->mChatID[0]) {
+ GC_INFO gci = { 0 };
gci.Flags = HCONTACT;
gci.pszModule = m_szModuleName;
gci.pszID = info->mChatID;
CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci);
tContact = gci.hContact;
}
- else
- tContact = info->getContactHandle();
+ else tContact = info->getContactHandle();
MimeHeaders tFileInfo;
tFileInfo.readFromBuffer(msgBody);
const char* id = tFileInfo["ID"];
- if (id != NULL)
- {
- switch (atol(id))
- {
- case 1: // Nudge
- NotifyEventHooks(hMSNNudge, (WPARAM)tContact, 0);
- break;
+ if (id != NULL) {
+ switch (atol(id)) {
+ case 1: // Nudge
+ NotifyEventHooks(hMSNNudge, (WPARAM)tContact, 0);
+ break;
- case 2: // Wink
- break;
+ case 2: // Wink
+ break;
- case 4: // Action Message
- break;
+ case 4: // Action Message
+ break;
}
}
}
}
- else if (!_strnicmp(tContentType,"text/x-msmsgsemailnotification", 30))
+ else if (!_strnicmp(tContentType, "text/x-msmsgsemailnotification", 30))
sttNotificationMessage(msgBody, false);
else if (!_strnicmp(tContentType, "text/x-msmsgsinitialemailnotification", 37))
sttNotificationMessage(msgBody, true);
@@ -594,16 +540,13 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
sttNotificationMessage(msgBody, false);
else if (!_strnicmp(tContentType, "text/x-msmsgsinvite", 19))
sttInviteMessage(info, msgBody, email, nick);
- else if (!_strnicmp(tContentType, "application/x-msnmsgrp2p", 24))
- {
+ else if (!_strnicmp(tContentType, "application/x-msnmsgrp2p", 24)) {
const char* dest = tHeader["P2P-Dest"];
- if (dest)
- {
+ if (dest) {
char *szEmail, *szInst;
parseWLID(NEWSTR_ALLOCA(dest), NULL, &szEmail, &szInst);
- if (stricmp(szEmail, MyOptions.szEmail) == 0)
- {
+ if (stricmp(szEmail, MyOptions.szEmail) == 0) {
const char* src = tHeader["P2P-Src"];
if (src == NULL) src = email;
@@ -622,7 +565,6 @@ void CMsnProto::MSN_ReceiveMessage(ThreadData* info, char* cmdString, char* para
mir_free(newbody);
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Process Yahoo Find
@@ -631,7 +573,7 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len)
if (buf == NULL) return;
ezxml_t xmli = ezxml_parse_str(buf, len);
- ezxml_t dom = ezxml_child(xmli, "d");
+ ezxml_t dom = ezxml_child(xmli, "d");
const char* szDom = ezxml_attr(dom, "n");
ezxml_t cont = ezxml_child(dom, "c");
@@ -641,12 +583,10 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len)
mir_snprintf(szEmail, sizeof(szEmail), "%s@%s", szCont, szDom);
const char *szNetId = ezxml_attr(cont, "t");
- if (msnSearchId != NULL)
- {
- if (szNetId != NULL)
- {
+ if (msnSearchId != NULL) {
+ if (szNetId != NULL) {
TCHAR* szEmailT = mir_utf8decodeT(szEmail);
- PROTOSEARCHRESULT isr = {0};
+ PROTOSEARCHRESULT isr = { 0 };
isr.cbSize = sizeof(isr);
isr.flags = PSR_TCHAR;
isr.id = szEmailT;
@@ -660,14 +600,11 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len)
msnSearchId = NULL;
}
- else
- {
- if (szNetId != NULL)
- {
+ else {
+ if (szNetId != NULL) {
int netId = atol(szNetId);
HANDLE hContact = MSN_HContactFromEmail(szEmail, szEmail, true, false);
- if (MSN_AddUser(hContact, szEmail, netId, LIST_FL))
- {
+ if (MSN_AddUser(hContact, szEmail, netId, LIST_FL)) {
MSN_AddUser(hContact, szEmail, netId, LIST_PL + LIST_REMOVE);
MSN_AddUser(hContact, szEmail, netId, LIST_BL + LIST_REMOVE);
MSN_AddUser(hContact, szEmail, netId, LIST_AL);
@@ -680,7 +617,6 @@ void CMsnProto::sttProcessYFind(char* buf, size_t len)
ezxml_free(xmli);
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Process user addition
@@ -690,24 +626,21 @@ void CMsnProto::sttProcessAdd(char* buf, size_t len)
ezxml_t xmli = ezxml_parse_str(buf, len);
ezxml_t dom = ezxml_child(xmli, "d");
- while (dom != NULL)
- {
+ while (dom != NULL) {
const char* szDom = ezxml_attr(dom, "n");
ezxml_t cont = ezxml_child(dom, "c");
- while (cont != NULL)
- {
+ while (cont != NULL) {
const char* szCont = ezxml_attr(cont, "n");
const char* szNick = ezxml_attr(cont, "f");
- int listId = atol(ezxml_attr(cont, "l"));
- int netId = atol(ezxml_attr(cont, "t"));
+ int listId = atol(ezxml_attr(cont, "l"));
+ int netId = atol(ezxml_attr(cont, "t"));
char szEmail[128];
mir_snprintf(szEmail, sizeof(szEmail), "%s@%s", szCont, szDom);
UrlDecode((char*)szNick);
- if (listId == LIST_FL)
- {
+ if (listId == LIST_FL) {
HANDLE hContact = MSN_HContactFromEmail(szEmail, szNick, true, false);
MSN_SetContactDb(hContact, szEmail);
}
@@ -718,21 +651,17 @@ void CMsnProto::sttProcessAdd(char* buf, size_t len)
MSN_AddUser(NULL, szEmail, netId, listId);
MsnContact* msc = Lists_Get(szEmail);
- if (msc == NULL)
- {
+ if (msc == NULL) {
Lists_Add(listId, netId, szEmail);
msc = Lists_Get(szEmail);
}
- if (listId == LIST_RL)
- {
- if ((msc->list & (LIST_AL | LIST_BL)) == 0)
- {
+ if (listId == LIST_RL) {
+ if ((msc->list & (LIST_AL | LIST_BL)) == 0) {
MSN_AddAuthRequest(szEmail, szNick, msc->invite);
msc->netId = netId;
}
- else
- MSN_AddUser(NULL, szEmail, netId, LIST_PL + LIST_REMOVE);
+ else MSN_AddUser(NULL, szEmail, netId, LIST_PL + LIST_REMOVE);
}
cont = ezxml_next(cont);
@@ -742,29 +671,24 @@ void CMsnProto::sttProcessAdd(char* buf, size_t len)
ezxml_free(xmli);
}
-
void CMsnProto::sttProcessRemove(char* buf, size_t len)
{
ezxml_t xmli = ezxml_parse_str(buf, len);
ezxml_t dom = ezxml_child(xmli, "d");
- while (dom != NULL)
- {
+ while (dom != NULL) {
const char* szDom = ezxml_attr(dom, "n");
ezxml_t cont = ezxml_child(dom, "c");
- while (cont != NULL)
- {
+ while (cont != NULL) {
const char* szCont = ezxml_attr(cont, "n");
- int listId = atol(ezxml_attr(cont, "l"));
+ int listId = atol(ezxml_attr(cont, "l"));
char szEmail[128];
mir_snprintf(szEmail, sizeof(szEmail), "%s@%s", szCont, szDom);
Lists_Remove(listId, szEmail);
MsnContact* msc = Lists_Get(szEmail);
- if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0)
- {
- if (msc->hContact && _stricmp(szEmail, MyOptions.szEmail))
- {
+ if (msc == NULL || (msc->list & (LIST_RL | LIST_FL | LIST_LL)) == 0) {
+ if (msc->hContact && _stricmp(szEmail, MyOptions.szEmail)) {
CallService(MS_DB_CONTACT_DELETE, (WPARAM)msc->hContact, 0);
msc->hContact = NULL;
}
@@ -777,7 +701,6 @@ void CMsnProto::sttProcessRemove(char* buf, size_t len)
ezxml_free(xmli);
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// MSN_HandleCommands - process commands from the server
/////////////////////////////////////////////////////////////////////////////////////////
@@ -793,8 +716,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
parseWLID(NEWSTR_ALLOCA(wlid), NULL, &szEmail, NULL);
// Add endpoints
- for (ezxml_t endp = ezxml_child(xmli, "EndpointData"); endp; endp = ezxml_next(endp))
- {
+ for (ezxml_t endp = ezxml_child(xmli, "EndpointData"); endp; endp = ezxml_next(endp)) {
const char *id = ezxml_attr(endp, "id");
const char *caps = ezxml_txt(ezxml_child(endp, "Capabilities"));
char* end = NULL;
@@ -806,8 +728,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
// Process status message info
const char* szStatMsg = ezxml_txt(ezxml_child(xmli, "PSM"));
- if (*szStatMsg)
- {
+ if (*szStatMsg) {
stripBBCode((char*)szStatMsg);
stripColorCode((char*)szStatMsg);
db_set_utf(hContact, "CList", "StatusMsg", szStatMsg);
@@ -815,14 +736,13 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
else db_unset(hContact, "CList", "StatusMsg");
{
- ptrT tszStatus( mir_utf8decodeT(szStatMsg));
+ ptrT tszStatus(mir_utf8decodeT(szStatMsg));
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, tszStatus);
}
// Process current media info
const char* szCrntMda = ezxml_txt(ezxml_child(xmli, "CurrentMedia"));
- if (!*szCrntMda)
- {
+ if (!*szCrntMda) {
delSetting(hContact, "ListeningTo");
ezxml_free(xmli);
return;
@@ -833,8 +753,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
unsigned pCount;
char* p = (char*)szCrntMda;
- for (pCount = 0; pCount < SIZEOF(parts); ++pCount)
- {
+ for (pCount = 0; pCount < SIZEOF(parts); ++pCount) {
parts[pCount] = p;
char* p1 = strstr(p, "\\0");
@@ -845,8 +764,7 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
}
// Now let's mount the final string
- if (pCount <= 4)
- {
+ if (pCount <= 4) {
delSetting(hContact, "ListeningTo");
ezxml_free(xmli);
return;
@@ -854,16 +772,13 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
// Check if there is any info in the string
bool foundUsefullInfo = false;
- for (unsigned i = 4; i < pCount; i++)
- {
- if (parts[i][0] != '\0')
- {
+ for (unsigned i = 4; i < pCount; i++) {
+ if (parts[i][0] != '\0') {
foundUsefullInfo = true;
break;
}
}
- if (!foundUsefullInfo)
- {
+ if (!foundUsefullInfo) {
delSetting(hContact, "ListeningTo");
ezxml_free(xmli);
return;
@@ -871,25 +786,22 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
if (!ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT) ||
!ServiceExists(MS_LISTENINGTO_OVERRIDECONTACTOPTION) ||
- !CallService(MS_LISTENINGTO_OVERRIDECONTACTOPTION, 0, (LPARAM) hContact))
+ !CallService(MS_LISTENINGTO_OVERRIDECONTACTOPTION, 0, (LPARAM)hContact))
{
// User contact options
char *format = mir_strdup(parts[3]);
char *unknown = NULL;
if (ServiceExists(MS_LISTENINGTO_GETUNKNOWNTEXT))
- unknown = mir_utf8encodeT((TCHAR *) CallService(MS_LISTENINGTO_GETUNKNOWNTEXT, 0, 0));
+ unknown = mir_utf8encodeT((TCHAR *)CallService(MS_LISTENINGTO_GETUNKNOWNTEXT, 0, 0));
- for (unsigned i = 4; i < pCount; i++)
- {
+ for (unsigned i = 4; i < pCount; i++) {
char part[16];
size_t lenPart = mir_snprintf(part, sizeof(part), "{%d}", i - 4);
if (parts[i][0] == '\0' && unknown != NULL)
parts[i] = unknown;
size_t lenPartsI = strlen(parts[i]);
- for (p = strstr(format, part); p; p = strstr(p + lenPartsI, part))
- {
- if (lenPart < lenPartsI)
- {
+ for (p = strstr(format, part); p; p = strstr(p + lenPartsI, part)) {
+ if (lenPart < lenPartsI) {
int loc = p - format;
format = (char *)mir_realloc(format, strlen(format) + (lenPartsI - lenPart) + 1);
p = format + loc;
@@ -903,25 +815,24 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
mir_free(unknown);
mir_free(format);
}
- else
- {
+ else {
// Use user options
- LISTENINGTOINFO lti = {0};
+ LISTENINGTOINFO lti = { 0 };
lti.cbSize = sizeof(LISTENINGTOINFO);
lti.ptszTitle = mir_utf8decodeT(parts[4]);
- if (pCount > 5) lti.ptszArtist = mir_utf8decodeT(parts[5] );
- if (pCount > 6) lti.ptszAlbum = mir_utf8decodeT(parts[6] );
- if (pCount > 7) lti.ptszTrack = mir_utf8decodeT(parts[7] );
- if (pCount > 8) lti.ptszYear = mir_utf8decodeT(parts[8] );
- if (pCount > 9) lti.ptszGenre = mir_utf8decodeT(parts[9] );
+ if (pCount > 5) lti.ptszArtist = mir_utf8decodeT(parts[5]);
+ if (pCount > 6) lti.ptszAlbum = mir_utf8decodeT(parts[6]);
+ if (pCount > 7) lti.ptszTrack = mir_utf8decodeT(parts[7]);
+ if (pCount > 8) lti.ptszYear = mir_utf8decodeT(parts[8]);
+ if (pCount > 9) lti.ptszGenre = mir_utf8decodeT(parts[9]);
if (pCount > 10) lti.ptszLength = mir_utf8decodeT(parts[10]);
if (pCount > 11) lti.ptszPlayer = mir_utf8decodeT(parts[11]);
else lti.ptszPlayer = mir_utf8decodeT(parts[0]);
if (pCount > 12) lti.ptszType = mir_utf8decodeT(parts[12]);
else lti.ptszType = mir_utf8decodeT(parts[1]);
- TCHAR *cm = (TCHAR *) CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM) _T("%title% - %artist%"), (LPARAM) &lti);
+ TCHAR *cm = (TCHAR *)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)_T("%title% - %artist%"), (LPARAM)&lti);
setTString(hContact, "ListeningTo", cm);
mir_free(cm);
@@ -939,7 +850,6 @@ void CMsnProto::sttProcessStatusMessage(char* buf, unsigned len, const char* wli
ezxml_free(xmli);
}
-
void CMsnProto::sttProcessPage(char* buf, unsigned len)
{
if (buf == NULL) return;
@@ -949,25 +859,22 @@ void CMsnProto::sttProcessPage(char* buf, unsigned len)
const char* szMsg = ezxml_txt(ezxml_child(xmlbdy, "TEXT"));
const char* szTel = ezxml_attr(ezxml_child(xmlnot, "FROM"), "name");
- if (szTel && *szMsg)
- {
- PROTORECVEVENT pre = {0};
+ if (szTel && *szMsg) {
+ PROTORECVEVENT pre = { 0 };
pre.szMessage = (char*)szMsg;
pre.flags = PREF_UTF /*+ ((isRtl) ? PREF_RTL : 0)*/;
pre.timestamp = time(NULL);
- ProtoChainRecvMsg( MSN_HContactFromEmail(szTel, szTel, true, true), &pre);
+ ProtoChainRecvMsg(MSN_HContactFromEmail(szTel, szTel, true, true), &pre);
}
ezxml_free(xmlnot);
}
-
void CMsnProto::sttProcessNotificationMessage(char* buf, unsigned len)
{
if (buf == NULL) return;
ezxml_t xmlnot = ezxml_parse_str(buf, len);
- if (strcmp(ezxml_attr(xmlnot, "siteid"), "0") == 0)
- {
+ if (strcmp(ezxml_attr(xmlnot, "siteid"), "0") == 0) {
ezxml_free(xmlnot);
return;
}
@@ -977,20 +884,19 @@ void CMsnProto::sttProcessNotificationMessage(char* buf, unsigned len)
ezxml_t xmlbdy = ezxml_child(xmlmsg, "BODY");
ezxml_t xmltxt = ezxml_child(xmlbdy, "TEXT");
- if (xmltxt != NULL)
- {
+ if (xmltxt != NULL) {
char fullurl[1024];
size_t sz = 0;
const char* acturl = ezxml_attr(xmlact, "url");
if (acturl == NULL || strstr(acturl, "://") == NULL)
- sz += mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "%s", ezxml_attr(xmlnot, "siteurl"));
+ sz += mir_snprintf(fullurl + sz, sizeof(fullurl)-sz, "%s", ezxml_attr(xmlnot, "siteurl"));
- sz += mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "%s", acturl);
- if (sz != 0 && fullurl[sz-1] != '?')
- sz += mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "?");
+ sz += mir_snprintf(fullurl + sz, sizeof(fullurl)-sz, "%s", acturl);
+ if (sz != 0 && fullurl[sz - 1] != '?')
+ sz += mir_snprintf(fullurl + sz, sizeof(fullurl)-sz, "?");
- mir_snprintf(fullurl+sz, sizeof(fullurl)-sz, "notification_id=%s&message_id=%s",
+ mir_snprintf(fullurl + sz, sizeof(fullurl)-sz, "notification_id=%s&message_id=%s",
ezxml_attr(xmlnot, "id"), ezxml_attr(xmlmsg, "id"));
SkinPlaySound(alertsoundname);
@@ -999,11 +905,9 @@ void CMsnProto::sttProcessNotificationMessage(char* buf, unsigned len)
MSN_ShowPopup(TranslateT("MSN Alert"), alrt, MSN_ALERT_POPUP | MSN_ALLOW_MSGBOX, fullurl);
mir_free(alrt);
}
- else if (xmlbdy)
- {
+ else if (xmlbdy) {
const char *txt = ezxml_txt(xmlbdy);
- if (strstr(txt, "ABCHInternal"))
- {
+ if (strstr(txt, "ABCHInternal")) {
MSN_SharingFindMembership(true);
MSN_ABFind("ABFindContactsPaged", NULL, true);
MSN_StoreGetProfile();
@@ -1021,23 +925,18 @@ void CMsnProto::MSN_InitSB(ThreadData* info, const char* szEmail)
bool typing = false;
- for (int i=3; --i;)
- {
+ for (int i = 3; --i;) {
MsgQueueEntry E;
- while (MsgQueue_GetNext(szEmail, E))
- {
+ while (MsgQueue_GetNext(szEmail, E)) {
if (E.msgType == 'X') ;
else if (E.msgType == 2571)
typing = E.flags != 0;
- else if (E.msgSize == 0)
- {
+ else if (E.msgSize == 0) {
info->sendMessage(E.msgType, NULL, 1, E.message, E.flags);
ProtoBroadcastAck(cont->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)E.seq, 0);
}
- else
- {
- if (E.msgType == 'D' && !info->mBridgeInit /*&& strchr(data.flags, ':')*/)
- {
+ else {
+ if (E.msgType == 'D' && !info->mBridgeInit /*&& strchr(data.flags, ':')*/) {
info->mBridgeInit = true;
// P2PV2_Header hdrdata(E.message);
@@ -1061,12 +960,9 @@ void CMsnProto::MSN_InitSB(ThreadData* info, const char* szEmail)
MSN_StartStopTyping(info, true);
if (getByte("EnableDeliveryPopup", 0))
- {
MSN_ShowPopup(cont->hContact, info->mCaller ?
TranslateT("Chat session established by my request") :
- TranslateT("Chat session established by contact request"),
- 0);
- }
+ TranslateT("Chat session established by contact request"), 0);
PROTO_AVATAR_INFORMATIONT ai = { sizeof(ai), cont->hContact };
GetAvatarInfo(GAIF_FORCE, (LPARAM)&ai);
@@ -1077,81 +973,71 @@ int CMsnProto::MSN_HandleCommands(ThreadData* info, char* cmdString)
char* params = "";
int trid = -1;
- if (cmdString[3])
- {
- if (isdigit((BYTE)cmdString[4]))
- {
- trid = strtol(cmdString+4, &params, 10);
- switch (*params)
- {
- case ' ': case '\0': case '\t': case '\n':
- while (*params == ' ' || *params == '\t')
- params++;
- break;
+ if (cmdString[3]) {
+ if (isdigit((BYTE)cmdString[4])) {
+ trid = strtol(cmdString + 4, &params, 10);
+ switch (*params) {
+ case ' ': case '\0': case '\t': case '\n':
+ while (*params == ' ' || *params == '\t')
+ params++;
+ break;
- default: params = cmdString+4;
+ default:
+ params = cmdString + 4;
}
}
- else params = cmdString+4;
+ else params = cmdString + 4;
}
-// debugLogA("%s", cmdString);
- switch((*(PDWORD)cmdString & 0x00FFFFFF) | 0x20000000)
- {
- case ' KCA': //********* ACK: section 8.7 Instant Messages
- ReleaseSemaphore(info->hWaitEvent, 1, NULL);
-
- if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
- ProtoBroadcastAck(info->getContactHandle(), ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)trid, 0);
- break;
-
- case ' YQF': //********* FQY: Find Yahoo User
- char* tWords[1];
- if (sttDivideWords(params, 1, tWords) != 1)
- {
- debugLogA("Invalid %.3s command, ignoring", cmdString);
- }
- else
- {
- size_t len = atol(tWords[0]);
- sttProcessYFind((char*)HReadBuffer(info, 0).surelyRead(len), len);
- }
- break;
+ switch((*(PDWORD)cmdString & 0x00FFFFFF) | 0x20000000) {
+ case ' KCA': //********* ACK: section 8.7 Instant Messages
+ ReleaseSemaphore(info->hWaitEvent, 1, NULL);
+
+ if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
+ ProtoBroadcastAck(info->getContactHandle(), ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)trid, 0);
+ break;
+
+ case ' YQF': //********* FQY: Find Yahoo User
+ char* tWords[1];
+ if (sttDivideWords(params, 1, tWords) != 1)
+ debugLogA("Invalid %.3s command, ignoring", cmdString);
+ else {
+ size_t len = atol(tWords[0]);
+ sttProcessYFind((char*)HReadBuffer(info, 0).surelyRead(len), len);
+ }
+ break;
- case ' LDA': //********* ADL: Add to the list
+ case ' LDA': //********* ADL: Add to the list
{
char* tWords[1];
- if (sttDivideWords(params, 1, tWords) != 1)
- {
+ if (sttDivideWords(params, 1, tWords) != 1) {
LBL_InvalidCommand:
debugLogA("Invalid %.3s command, ignoring", cmdString);
break;
}
- if (strcmp(tWords[0], "OK") != 0)
- {
+ if (strcmp(tWords[0], "OK") != 0) {
size_t len = atol(tWords[0]);
sttProcessAdd((char*)HReadBuffer(info, 0).surelyRead(len), len);
}
- break;
}
+ break;
- case ' SBS':
- break;
+ case ' SBS':
+ break;
- case ' SNA': //********* ANS: section 8.4 Getting Invited to a Switchboard Session
- break;
+ case ' SNA': //********* ANS: section 8.4 Getting Invited to a Switchboard Session
+ break;
- case ' PRP':
- break;
+ case ' PRP':
+ break;
- case ' PLB': //********* BLP: section 7.6 List Retrieval And Property Management
- break;
+ case ' PLB': //********* BLP: section 7.6 List Retrieval And Property Management
+ break;
- case ' EYB': //********* BYE: section 8.5 Session Participant Changes
+ case ' EYB': //********* BYE: section 8.5 Session Participant Changes
{
- union
- {
+ union {
char* tWords[2];
// modified for chat, orginally param2 = junk
// param 2: quit due to idle = "1", normal quit = nothing
@@ -1161,8 +1047,7 @@ LBL_InvalidCommand:
sttDivideWords(params, 2, tWords);
UrlDecode(data.userEmail);
- if (strchr(data.userEmail, ';'))
- {
+ if (strchr(data.userEmail, ';')) {
if (info->mJoinedContactsWLID.getCount() == 1)
p2p_clearThreadSessions(info->mJoinedContactsWLID[0], info->mType);
info->contactLeft(data.userEmail);
@@ -1175,7 +1060,6 @@ LBL_InvalidCommand:
MSN_ShowPopup(hContact, TranslateT("Contact left channel"), 0);
// modified for chat
- if (msnHaveChatDll)
{
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_QUIT };
GCEVENT gce = { sizeof(gce), &gcd };
@@ -1195,10 +1079,8 @@ LBL_InvalidCommand:
setWord(hContact, "Status", ID_STATUS_OFFLINE);
// see if the session is quit due to idleness
- if (info->mChatID[0] && personleft == 1)
- {
- if (!strcmp(data.isIdle, "1"))
- {
+ if (info->mChatID[0] && personleft == 1) {
+ if (!strcmp(data.isIdle, "1")) {
GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_INFORMATION };
GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
@@ -1209,12 +1091,10 @@ LBL_InvalidCommand:
gce.ptszText = TranslateT("To resume the conversation, please quit this session and start a new chat session.");
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
}
- else
- {
+ else {
if (!Miranda_Terminated() && MessageBox(NULL,
- TranslateT("There is only 1 person left in the chat, do you want to switch back to standard message window?"),
- TranslateT("MSN Chat"), MB_YESNO|MB_ICONQUESTION) == IDYES)
- {
+ TranslateT("There is only 1 person left in the chat, do you want to switch back to standard message window?"),
+ TranslateT("MSN Chat"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
// kill chat dlg and open srmm dialog
MSN_KillChatSession(info->mChatID);
@@ -1228,21 +1108,20 @@ LBL_InvalidCommand:
else if (info->mJoinedContactsWLID.getCount() < 1)
return 1;
- break;
}
- case ' LAC': //********* CAL: section 8.3 Inviting Users to a Switchboard Session
- break;
+ break;
+
+ case ' LAC': //********* CAL: section 8.3 Inviting Users to a Switchboard Session
+ break;
- case ' GHC': //********* CHG: section 7.7 Client States
+ case ' GHC': //********* CHG: section 7.7 Client States
{
int oldStatus = m_iStatus;
int newStatus = MSNStatusToMiranda(params);
- if (oldStatus <= ID_STATUS_OFFLINE)
- {
+ if (oldStatus <= ID_STATUS_OFFLINE) {
isConnectSuccess = true;
int count = -1;
- for (;;)
- {
+ for (;;) {
MsnContact *msc = Lists_GetNext(count);
if (msc == NULL) break;
@@ -1250,17 +1129,16 @@ LBL_InvalidCommand:
setWord(msc->hContact, "Status", ID_STATUS_ONTHEPHONE);
}
}
- if (newStatus != ID_STATUS_IDLE)
- {
+ if (newStatus != ID_STATUS_IDLE) {
m_iStatus = newStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, newStatus);
debugLogA("Status change acknowledged: %s", params);
MSN_RemoveEmptyGroups();
}
if (newStatus == ID_STATUS_OFFLINE) return 1;
- break;
}
- case ' LHC': //********* CHL: Query from Server on MSNP7
+ break;
+ case ' LHC': //********* CHL: Query from Server on MSNP7
{
char* authChallengeInfo;
if (sttDivideWords(params, 1, &authChallengeInfo) != 1)
@@ -1269,15 +1147,14 @@ LBL_InvalidCommand:
char dgst[64];
MSN_MakeDigest(authChallengeInfo, dgst);
info->sendPacket("QRY", "%s 32\r\n%s", msnProductID, dgst);
- break;
}
- case ' RVC': //********* CVR: MSNP8
- break;
+ break;
+ case ' RVC': //********* CVR: MSNP8
+ break;
- case ' NLF': //********* FLN: section 7.9 Notification Messages
+ case ' NLF': //********* FLN: section 7.9 Notification Messages
{
- union
- {
+ union {
char* tWords[2];
struct { char *userEmail, *netId; } data;
};
@@ -1287,20 +1164,17 @@ LBL_InvalidCommand:
goto LBL_InvalidCommand;
HANDLE hContact = MSN_HContactFromEmail(data.userEmail);
- if (hContact != NULL)
- {
- setWord(hContact, "Status", MSN_GetThreadByContact(data.userEmail) ?
- ID_STATUS_INVISIBLE : ID_STATUS_OFFLINE);
+ if (hContact != NULL) {
+ setWord(hContact, "Status", MSN_GetThreadByContact(data.userEmail) ? ID_STATUS_INVISIBLE : ID_STATUS_OFFLINE);
setDword(hContact, "IdleTS", 0);
ForkThread(&CMsnProto::MsgQueue_AllClearThread, mir_strdup(data.userEmail));
}
- break;
}
- case ' NLI':
- case ' NLN': //********* ILN/NLN: section 7.9 Notification Messages
+ break;
+ case ' NLI':
+ case ' NLN': //********* ILN/NLN: section 7.9 Notification Messages
{
- union
- {
+ union {
char* tWords[5];
struct { char *userStatus, *wlid, *userNick, *objid, *cmdstring; } data;
};
@@ -1316,12 +1190,10 @@ LBL_InvalidCommand:
bool isMe = false;
char* szEmail, *szNet;
parseWLID(NEWSTR_ALLOCA(data.wlid), &szNet, &szEmail, NULL);
- if (!stricmp(szEmail, MyOptions.szEmail) && !strcmp(szNet, "1"))
- {
+ if (!stricmp(szEmail, MyOptions.szEmail) && !strcmp(szNet, "1")) {
isMe = true;
int newStatus = MSNStatusToMiranda(params);
- if (newStatus != m_iStatus && newStatus != ID_STATUS_IDLE)
- {
+ if (newStatus != m_iStatus && newStatus != ID_STATUS_IDLE) {
int oldMode = m_iStatus;
m_iDesiredStatus = m_iStatus = newStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus);
@@ -1333,22 +1205,20 @@ LBL_InvalidCommand:
MsnContact *cont = Lists_Get(szEmail);
HANDLE hContact = NULL;
- if (!cont && !isMe)
- {
+ if (!cont && !isMe) {
hContact = MSN_HContactFromEmail(data.wlid, data.userNick, true, true);
cont = Lists_Get(szEmail);
}
if (cont) hContact = cont->hContact;
- if (hContact != NULL)
- {
+ if (hContact != NULL) {
setStringUtf(hContact, "Nick", data.userNick);
lastStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
if (lastStatus == ID_STATUS_OFFLINE || lastStatus == ID_STATUS_INVISIBLE)
db_unset(hContact, "CList", "StatusMsg");
int newStatus = MSNStatusToMiranda(params);
- setWord(hContact, "Status", newStatus != ID_STATUS_IDLE ? newStatus : ID_STATUS_AWAY);
+ setWord(hContact, "Status", newStatus != ID_STATUS_IDLE ? newStatus : ID_STATUS_AWAY);
setDword(hContact, "IdleTS", newStatus != ID_STATUS_IDLE ? 0 : time(NULL));
}
@@ -1407,12 +1277,11 @@ remove:
else if (lastStatus == ID_STATUS_OFFLINE)
delSetting(hContact, "MirVer");
- break;
}
- case ' ORI': //********* IRO: section 8.4 Getting Invited to a Switchboard Session
+ break;
+ case ' ORI': //********* IRO: section 8.4 Getting Invited to a Switchboard Session
{
- union
- {
+ union {
char* tWords[5];
struct { char *strThisContact, *totalContacts, *userEmail, *userNick, *flags; } data;
};
@@ -1423,16 +1292,13 @@ remove:
info->contactJoined(data.userEmail);
- if (!strchr(data.userEmail, ';'))
- {
+ if (!strchr(data.userEmail, ';')) {
UrlDecode(data.userNick);
HANDLE hContact = MSN_HContactFromEmail(data.userEmail, data.userNick, true, true);
- if (tNumTokens == 5 && strcmp(data.flags, "0:0"))
- {
+ if (tNumTokens == 5 && strcmp(data.flags, "0:0")) {
MsnContact *cont = Lists_Get(data.userEmail);
- if (cont)
- {
+ if (cont) {
char* end = NULL;
cont->cap1 = strtoul(data.flags, &end, 10);
cont->cap2 = end && *end == ':' ? strtoul(end + 1, NULL, 10) : 0;
@@ -1444,12 +1310,13 @@ remove:
setWord(hContact, "Status", ID_STATUS_INVISIBLE);
// only start the chat session after all the IRO messages has been recieved
- if (msnHaveChatDll && info->mJoinedContactsWLID.getCount() > 1 && !strcmp(data.strThisContact, data.totalContacts))
+ if (info->mJoinedContactsWLID.getCount() > 1 && !strcmp(data.strThisContact, data.totalContacts))
MSN_ChatStart(info);
}
- break;
}
- case ' IOJ': //********* JOI: section 8.5 Session Participant Changes
+ break;
+
+ case ' IOJ': //********* JOI: section 8.5 Session Participant Changes
{
union {
char* tWords[3];
@@ -1462,22 +1329,17 @@ remove:
UrlDecode(data.userEmail);
- if (strchr(data.userEmail, ';'))
- {
+ if (strchr(data.userEmail, ';')) {
info->contactJoined(data.userEmail);
break;
}
- if (_stricmp(MyOptions.szEmail, data.userEmail) == 0)
- {
- if (!info->mCaller)
- {
- if (info->mJoinedContactsWLID.getCount() == 1)
- {
+ if (_stricmp(MyOptions.szEmail, data.userEmail) == 0) {
+ if (!info->mCaller) {
+ if (info->mJoinedContactsWLID.getCount() == 1) {
MSN_InitSB(info, info->mJoinedContactsWLID[0]);
}
- else
- {
+ else {
info->sendCaps();
if (info->mInitialContactWLID && MsgQueue_CheckContact(info->mInitialContactWLID))
msnNsThread->sendPacket("XFR", "SB");
@@ -1489,16 +1351,16 @@ remove:
const char* wlid;
do {
wlid = MsgQueue_GetNextRecipient();
- } while (wlid != NULL && MSN_GetUnconnectedThread(wlid) != NULL);
+ }
+ while (wlid != NULL && MSN_GetUnconnectedThread(wlid) != NULL);
- if (wlid == NULL) //can happen if both parties send first message at the same time
- {
+ //can happen if both parties send first message at the same time
+ if (wlid == NULL) {
debugLogA("USR (SB) internal: thread created for no reason");
return 1;
}
- if (strcmp(wlid, "chat") == 0)
- {
+ if (strcmp(wlid, "chat") == 0) {
MsgQueueEntry E;
MsgQueue_GetNext(wlid, E);
@@ -1525,11 +1387,9 @@ remove:
stripColorCode(data.userNick);
HANDLE hContact = MSN_HContactFromEmail(data.userEmail, data.userNick, true, true);
- if (tNumTokens == 3)
- {
+ if (tNumTokens == 3) {
MsnContact *cont = Lists_Get(data.userEmail);
- if (cont)
- {
+ if (cont) {
char* end = NULL;
cont->cap1 = strtoul(data.flags, &end, 10);
cont->cap2 = end && *end == ':' ? strtoul(end + 1, NULL, 10) : 0;
@@ -1540,106 +1400,97 @@ remove:
debugLogA("New contact in channel %s %s", data.userEmail, data.userNick);
if (info->contactJoined(data.userEmail) <= 1)
- {
MSN_InitSB(info, data.userEmail);
- }
- else
- {
+ else {
bool chatCreated = info->mChatID[0] != 0;
info->sendCaps();
- if (msnHaveChatDll)
- {
- if (chatCreated)
- {
- GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszNick = GetContactNameT(hContact);
- gce.ptszUID = mir_a2t(data.userEmail);
- gce.ptszStatus = TranslateT("Others");
- gce.time = time(NULL);
- gce.bIsMe = FALSE;
- CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
- mir_free((void*)gce.ptszUID);
- }
- else MSN_ChatStart(info);
+ if (chatCreated) {
+ GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszNick = GetContactNameT(hContact);
+ gce.ptszUID = mir_a2t(data.userEmail);
+ gce.ptszStatus = TranslateT("Others");
+ gce.time = time(NULL);
+ gce.bIsMe = FALSE;
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+ mir_free((void*)gce.ptszUID);
}
+ else MSN_ChatStart(info);
}
- break;
+ }
+ break;
+
+ case ' GSM': //********* MSG: sections 8.7 Instant Messages, 8.8 Receiving an Instant Message
+ MSN_ReceiveMessage(info, cmdString, params);
+ break;
+
+ case ' MBU':
+ MSN_ReceiveMessage(info, cmdString, params);
+ break;
+
+ case ' KAN': //********* NAK: section 8.7 Instant Messages
+ if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
+ ProtoBroadcastAck(info->getContactHandle(),
+ ACKTYPE_MESSAGE, ACKRESULT_FAILED,
+ (HANDLE)trid, (LPARAM)Translate("Message delivery failed"));
+ debugLogA("Message send failed (trid=%d)", trid);
+ break;
+
+ case ' TON': //********* NOT: notification message
+ sttProcessNotificationMessage((char*)HReadBuffer(info, 0).surelyRead(trid), trid);
+ break;
+
+ case ' GPI': //********* IPG: mobile page
+ sttProcessPage((char*)HReadBuffer(info, 0).surelyRead(trid), trid);
+ break;
+
+ case ' FCG': //********* GCF:
+ HReadBuffer(info, 0).surelyRead(atol(params));
+ break;
+
+ case ' TUO': //********* OUT: sections 7.10 Connection Close, 8.6 Leaving a Switchboard Session
+ if (!_stricmp(params, "OTH")) {
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION);
+ debugLogA("You have been disconnected from the MSN server because you logged on from another location using the same MSN passport.");
}
- case ' GSM': //********* MSG: sections 8.7 Instant Messages, 8.8 Receiving an Instant Message
- MSN_ReceiveMessage(info, cmdString, params);
- break;
-
- case ' MBU':
- MSN_ReceiveMessage(info, cmdString, params);
- break;
-
- case ' KAN': //********* NAK: section 8.7 Instant Messages
- if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
- ProtoBroadcastAck(info->getContactHandle(),
- ACKTYPE_MESSAGE, ACKRESULT_FAILED,
- (HANDLE)trid, (LPARAM)Translate("Message delivery failed"));
- debugLogA("Message send failed (trid=%d)", trid);
- break;
-
- case ' TON': //********* NOT: notification message
- sttProcessNotificationMessage((char*)HReadBuffer(info, 0).surelyRead(trid), trid);
- break;
-
- case ' GPI': //********* IPG: mobile page
- sttProcessPage((char*)HReadBuffer(info, 0).surelyRead(trid), trid);
- break;
-
- case ' FCG': //********* GCF:
- HReadBuffer(info, 0).surelyRead(atol(params));
+ if (!_stricmp(params, "MIG")) // ignore it
break;
- case ' TUO': //********* OUT: sections 7.10 Connection Close, 8.6 Leaving a Switchboard Session
- if (!_stricmp(params, "OTH"))
- {
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION);
- debugLogA("You have been disconnected from the MSN server because you logged on from another location using the same MSN passport.");
- }
-
- if (!_stricmp(params, "MIG")) // ignore it
- break;
-
- return 1;
+ return 1;
- case ' YRQ': //********* QRY:
- break;
+ case ' YRQ': //********* QRY:
+ break;
- case ' GNQ': //********* QNG: reply to PNG
- msnPingTimeout = trid;
- if (info->mType == SERVER_NOTIFICATION && hKeepAliveThreadEvt != NULL)
- SetEvent(hKeepAliveThreadEvt);
- break;
+ case ' GNQ': //********* QNG: reply to PNG
+ msnPingTimeout = trid;
+ if (info->mType == SERVER_NOTIFICATION && hKeepAliveThreadEvt != NULL)
+ SetEvent(hKeepAliveThreadEvt);
+ break;
- case ' LMR': //********* RML: Remove from the list
+ case ' LMR': //********* RML: Remove from the list
{
char* tWords[1];
if (sttDivideWords(params, 1, tWords) != 1)
goto LBL_InvalidCommand;
- if (strcmp(tWords[0], "OK") != 0)
- {
+ if (strcmp(tWords[0], "OK") != 0) {
size_t len = atol(tWords[0]);
sttProcessRemove((char*)HReadBuffer(info, 0).surelyRead(len), len);
}
- break;
}
+ break;
- case ' GNR': //********* RNG: section 8.4 Getting Invited to a Switchboard Session
- //note: unusual message encoding: trid==sessionid
+ case ' GNR': //********* RNG: section 8.4 Getting Invited to a Switchboard Session
+ //note: unusual message encoding: trid==sessionid
{
union {
char* tWords[8];
struct { char *newServer, *security, *authChallengeInfo, *callerEmail, *callerNick,
- *type, *srcUrl, *genGateway; } data;
+ *type, *srcUrl, *genGateway; } data;
};
if (sttDivideWords(params, 8, tWords) != 8)
@@ -1667,13 +1518,12 @@ remove:
debugLogA("Opening caller's switchboard server '%s'...", data.newServer);
newThread->startThread(&CMsnProto::MSNServerThread, this);
- break;
}
+ break;
- case ' XBU': // UBX : MSNP11+ User Status Message
+ case ' XBU': // UBX : MSNP11+ User Status Message
{
- union
- {
+ union {
char* tWords[2];
struct { char *wlid, *datalen; } data;
};
@@ -1686,13 +1536,12 @@ remove:
goto LBL_InvalidCommand;
sttProcessStatusMessage((char*)HReadBuffer(info, 0).surelyRead(len), len, data.wlid);
- break;
}
+ break;
- case ' NBU': // UBN : MSNP13+ File sharing, P2P Bootstrap, TURN setup.
+ case ' NBU': // UBN : MSNP13+ File sharing, P2P Bootstrap, TURN setup.
{
- union
- {
+ union {
char* tWords[3];
struct { char *email, *typeId, *datalen; } data;
};
@@ -1711,115 +1560,102 @@ remove:
if (strstr(data.email, sttVoidUid))
parseWLID(NEWSTR_ALLOCA(data.email), NULL, &szEmail, NULL);
- switch (atol(data.typeId))
- {
- case 1:
- // File sharing stuff
- // sttProcessFileSharing(msgBody, len, hContact);
- break;
+ switch (atol(data.typeId)) {
+ case 1:
+ // File sharing stuff
+ // sttProcessFileSharing(msgBody, len, hContact);
+ break;
- case 3:
- // P2P Bootstrap
- p2p_processSIP(info, msgBody, NULL, szEmail);
- break;
+ case 3:
+ // P2P Bootstrap
+ p2p_processSIP(info, msgBody, NULL, szEmail);
+ break;
- case 4:
- case 8:
- ProtoBroadcastAck( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION );
- debugLogA( "You have been disconnected from the MSN server because you logged on from another location using the same MSN passport." );
- break;
+ case 4:
+ case 8:
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION);
+ debugLogA("You have been disconnected from the MSN server because you logged on from another location using the same MSN passport.");
+ break;
- case 6:
- MSN_SharingFindMembership(true);
- MSN_ABFind("ABFindContactsPaged", NULL, true);
- break;
+ case 6:
+ MSN_SharingFindMembership(true);
+ MSN_ABFind("ABFindContactsPaged", NULL, true);
+ break;
- case 10:
- // TURN setup
- p2p_processSIP(info, msgBody, NULL, szEmail);
- break;
+ case 10:
+ // TURN setup
+ p2p_processSIP(info, msgBody, NULL, szEmail);
+ break;
}
- break;
}
+ break;
- case ' NUU': // UUN : MSNP13+ File sharing, P2P Bootstrap, TURN setup.
- break;
-
- case ' RSU': //********* USR: sections 7.3 Authentication, 8.2 Switchboard Connections and Authentication
- if (info->mType == SERVER_SWITCHBOARD) //(section 8.2)
- {
- union {
- char* tWords[3];
- struct { char *status, *userHandle, *friendlyName; } data;
- };
+ case ' NUU': // UUN : MSNP13+ File sharing, P2P Bootstrap, TURN setup.
+ break;
- if (sttDivideWords(params, 3, tWords) != 3)
- goto LBL_InvalidCommand;
+ case ' RSU': //********* USR: sections 7.3 Authentication, 8.2 Switchboard Connections and Authentication
+ if (info->mType == SERVER_SWITCHBOARD) { //(section 8.2)
+ union {
+ char* tWords[3];
+ struct { char *status, *userHandle, *friendlyName; } data;
+ };
- UrlDecode(data.userHandle); UrlDecode(data.friendlyName);
+ if (sttDivideWords(params, 3, tWords) != 3)
+ goto LBL_InvalidCommand;
- if (strcmp(data.status, "OK"))
- {
- debugLogA("Unknown status to USR command (SB): '%s'", data.status);
- break;
- }
+ UrlDecode(data.userHandle); UrlDecode(data.friendlyName);
- info->sendPacket("CAL", MyOptions.szEmail);
+ if (strcmp(data.status, "OK")) {
+ debugLogA("Unknown status to USR command (SB): '%s'", data.status);
+ break;
}
- else //dispatch or notification server (section 7.3)
- {
- union
- {
- char* tWords[4];
- struct { char *security, *sequence, *authChallengeInfo, *nonce; } data;
- };
-
- if (sttDivideWords(params, 4, tWords) != 4)
- goto LBL_InvalidCommand;
-
- if (!strcmp(data.security, "SSO"))
- {
- if (MSN_GetPassportAuth())
- {
- m_iDesiredStatus = ID_STATUS_OFFLINE;
- return 1;
- }
- char* sec = GenerateLoginBlob(data.nonce);
- info->sendPacket("USR", "SSO S %s %s %s", authStrToken ? authStrToken : "", sec, MyOptions.szMachineGuid);
- mir_free(sec);
+ info->sendPacket("CAL", MyOptions.szEmail);
+ }
+ else { //dispatch or notification server (section 7.3)
+ union {
+ char* tWords[4];
+ struct { char *security, *sequence, *authChallengeInfo, *nonce; } data;
+ };
- ForkThread(&CMsnProto::msn_keepAliveThread, NULL);
- ForkThread(&CMsnProto::MSNConnDetectThread, NULL);
- }
- else if (!strcmp(data.security, "OK"))
- {
- }
- else
- {
- debugLogA("Unknown security package '%s'", data.security);
+ if (sttDivideWords(params, 4, tWords) != 4)
+ goto LBL_InvalidCommand;
- if (info->mType == SERVER_NOTIFICATION)
- {
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPROTOCOL);
- }
+ if (!strcmp(data.security, "SSO")) {
+ if (MSN_GetPassportAuth()) {
+ m_iDesiredStatus = ID_STATUS_OFFLINE;
return 1;
}
+
+ char* sec = GenerateLoginBlob(data.nonce);
+ info->sendPacket("USR", "SSO S %s %s %s", authStrToken ? authStrToken : "", sec, MyOptions.szMachineGuid);
+ mir_free(sec);
+
+ ForkThread(&CMsnProto::msn_keepAliveThread, NULL);
+ ForkThread(&CMsnProto::MSNConnDetectThread, NULL);
}
- break;
+ else if (!strcmp(data.security, "OK")) {
+ }
+ else {
+ debugLogA("Unknown security package '%s'", data.security);
- case ' SFR': // RFS: Refresh Contact List
- if (!MSN_RefreshContactList())
- {
- MSN_ShowError("Cannot retrieve contact list");
+ if (info->mType == SERVER_NOTIFICATION)
+ ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPROTOCOL);
return 1;
}
- break;
+ }
+ break;
- case ' XUU': // UUX: MSNP11 addition
+ case ' SFR': // RFS: Refresh Contact List
+ if (!MSN_RefreshContactList()) {
+ MSN_ShowError("Cannot retrieve contact list");
+ return 1;
+ }
+ break;
+
+ case ' XUU': // UUX: MSNP11 addition
{
char* tWords[1];
-
if (sttDivideWords(params, SIZEOF(tWords), tWords) != SIZEOF(tWords))
goto LBL_InvalidCommand;
@@ -1828,31 +1664,20 @@ remove:
goto LBL_InvalidCommand;
HReadBuffer(info, 0).surelyRead(len);
- break;
}
- case ' REV': //******** VER: section 7.1 Protocol Versioning
+ break;
+
+ case ' REV': //******** VER: section 7.1 Protocol Versioning
{
char* protocol1;
if (sttDivideWords(params, 1, &protocol1) != 1)
goto LBL_InvalidCommand;
- if (MyOptions.szEmail[0] == 0)
- {
+ if (MyOptions.szEmail[0] == 0) {
MSN_ShowError("You must specify your e-mail in Options/Network/MSN");
return 1;
}
-/*
- if (strcmp(protocol1, msnProtID))
- {
- MSN_ShowError("Server has requested an unknown protocol set (%s)", params);
- if (info->mType == SERVER_NOTIFICATION)
- {
- ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPROTOCOL);
- }
- return 1;
- }
-*/
OSVERSIONINFOEX osvi = {0};
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx((LPOSVERSIONINFO)&osvi);
@@ -1863,23 +1688,21 @@ remove:
msnProductVer, MyOptions.szEmail);
info->sendPacket("USR", "SSO I %s", MyOptions.szEmail);
- break;
}
- case ' RFX': //******** XFR: sections 7.4 Referral, 8.1 Referral to Switchboard
+ break;
+ case ' RFX': //******** XFR: sections 7.4 Referral, 8.1 Referral to Switchboard
{
- union
- {
+ union {
char* tWords[7];
struct { char *type, *newServer, *security, *authChallengeInfo,
- *type2, *srcUrl, *genGateway; } data;
+ *type2, *srcUrl, *genGateway; } data;
};
int numWords = sttDivideWords(params, 7, tWords);
if (numWords < 3)
goto LBL_InvalidCommand;
- if (!strcmp(data.type, "NS")) //notification server
- {
+ if (!strcmp(data.type, "NS")) { //notification server
UrlDecode(data.newServer);
ThreadData* newThread = new ThreadData;
strcpy(newThread->mServer, data.newServer);
@@ -1894,15 +1717,13 @@ remove:
return 1; //kill the old thread
}
- if (!strcmp(data.type, "SB")) //switchboard server
- {
+ if (!strcmp(data.type, "SB")) { //switchboard server
UrlDecode(data.newServer);
if (numWords < 4)
goto LBL_InvalidCommand;
- if (strcmp(data.security, "CKI"))
- {
+ if (strcmp(data.security, "CKI")) {
debugLogA("Unknown XFR SB security package '%s'", data.security);
break;
}
@@ -1918,12 +1739,12 @@ remove:
newThread->startThread(&CMsnProto::MSNServerThread, this);
}
else debugLogA("Unknown referral server: %s", data.type);
- break;
}
+ break;
- default:
- debugLogA("Unrecognised message: %s", cmdString);
- break;
+ default:
+ debugLogA("Unrecognised message: %s", cmdString);
+ break;
}
return 0;
diff --git a/protocols/MSN/src/msn_global.h b/protocols/MSN/src/msn_global.h
index 327ce5b39d..9c97843e95 100644
--- a/protocols/MSN/src/msn_global.h
+++ b/protocols/MSN/src/msn_global.h
@@ -776,8 +776,7 @@ const char msnStoreAppId[] = "Messenger Client 9.0";
const char msnProductVer[] = "14.0.8117.0416";
const char msnProtID[] = "MSNP18";
-extern HINSTANCE hInst;
-extern bool msnHaveChatDll;
+extern HINSTANCE hInst;
///////////////////////////////////////////////////////////////////////////////
// UTF8 encode helper
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 63191ab22f..46e40adbef 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -181,20 +181,18 @@ CMsnProto::~CMsnProto()
int CMsnProto::OnModulesLoaded(WPARAM, LPARAM)
{
- if (msnHaveChatDll) {
- GCREGISTER gcr = {0};
- gcr.cbSize = sizeof(GCREGISTER);
- gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
- gcr.iMaxText = 0;
- gcr.nColors = 16;
- gcr.pColors = (COLORREF*)crCols;
- gcr.ptszDispName = m_tszUserName;
- gcr.pszModule = m_szModuleName;
- CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
-
- HookProtoEvent(ME_GC_EVENT, &CMsnProto::MSN_GCEventHook);
- HookProtoEvent(ME_GC_BUILDMENU, &CMsnProto::MSN_GCMenuHook);
- }
+ GCREGISTER gcr = {0};
+ gcr.cbSize = sizeof(GCREGISTER);
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR;
+ gcr.iMaxText = 0;
+ gcr.nColors = 16;
+ gcr.pColors = (COLORREF*)crCols;
+ gcr.ptszDispName = m_tszUserName;
+ gcr.pszModule = m_szModuleName;
+ CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
+
+ HookProtoEvent(ME_GC_EVENT, &CMsnProto::MSN_GCEventHook);
+ HookProtoEvent(ME_GC_BUILDMENU, &CMsnProto::MSN_GCMenuHook);
HookProtoEvent(ME_IDLE_CHANGED, &CMsnProto::OnIdleChanged);
InitPopups();
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h
index d581560dcd..d738dca64c 100644
--- a/protocols/MSN/src/msn_proto.h
+++ b/protocols/MSN/src/msn_proto.h
@@ -411,7 +411,7 @@ struct CMsnProto : public PROTO<CMsnProto>
int MSN_ChatInit(ThreadData* info);
void MSN_ChatStart(ThreadData* info);
- void MSN_KillChatSession(TCHAR* id);
+ void MSN_KillChatSession(const TCHAR* id);
HANDLE MSN_GetChatInernalHandle(HANDLE hContact);
diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp
index 88f6874c71..30ba9e2192 100644
--- a/protocols/Omegle/src/chat.cpp
+++ b/protocols/Omegle/src/chat.cpp
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void OmegleProto::UpdateChat(const TCHAR *name, const TCHAR *message, bool addtolog)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
gce.ptszText = message;
@@ -207,14 +207,14 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam)
/*void OmegleProto::SendChatEvent(int type)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallServiceSync(MS_GC_EVENT,WINDOW_CLEARLOG,reinterpret_cast<LPARAM>(&gce));
}*/
void OmegleProto::AddChatContact(const TCHAR *name)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = DWORD(time(0));
gce.dwFlags = GCEF_ADDTOLOG;
@@ -236,7 +236,7 @@ void OmegleProto::AddChatContact(const TCHAR *name)
void OmegleProto::DeleteChatContact(const TCHAR *name)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_PART };
GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = name;
@@ -264,7 +264,7 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress)
return 0;
// Create a group
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("Admin");
@@ -284,7 +284,7 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress)
void OmegleProto::SetTopic(const TCHAR *topic)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_TOPIC };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
@@ -298,7 +298,7 @@ void OmegleProto::SetTopic(const TCHAR *topic)
INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
@@ -310,7 +310,7 @@ INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM)
void OmegleProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
@@ -347,7 +347,7 @@ void OmegleProto::ClearChat()
if (getByte(OMEGLE_KEY_NO_CLEAR, 0))
return;
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, reinterpret_cast<LPARAM>(&gce));
}
diff --git a/protocols/SkypeClassic/src/gchat.cpp b/protocols/SkypeClassic/src/gchat.cpp
index 815521e699..0a1ea0441b 100644
--- a/protocols/SkypeClassic/src/gchat.cpp
+++ b/protocols/SkypeClassic/src/gchat.cpp
@@ -48,7 +48,7 @@ static CRITICAL_SECTION m_GCMutex;
Returns: Pointer to the gchat_contacts entry for the given id.
NULL on failure (not enough memory)
*/
-gchat_contacts *GetChat(TCHAR *szChatId) {
+gchat_contacts *GetChat(const TCHAR *szChatId) {
int i;
for (i=0;i<chatcount;i++)
@@ -165,7 +165,7 @@ void RemChatContact(gchat_contacts *gc, const TCHAR *who) {
}
}
-HANDLE find_chat(TCHAR *chatname) {
+HANDLE find_chat(LPCTSTR chatname) {
char *szProto;
int tCompareResult;
HANDLE hContact;
@@ -390,7 +390,7 @@ int __cdecl ChatInit(WPARAM wParam, LPARAM lParam)
if (!CallService(MS_GC_NEWSESSION, 0, (LPARAM)&gcw)) {
char *szChatRole;
- GCDEST gcd = { SKYPE_PROTONAME, (TCHAR*)gcw.ptszID, GC_EVENT_ADDGROUP };
+ GCDEST gcd = { SKYPE_PROTONAME, gcw.ptszID, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("CREATOR");
// BUG: Groupchat returns nonzero on success here in earlier versions, so we don't check
@@ -476,7 +476,7 @@ void KillChatSession(GCDEST *gcd)
LeaveCriticalSection(&m_GCMutex);
}
-void InviteUser(TCHAR *szChatId)
+void InviteUser(const TCHAR *szChatId)
{
HMENU tMenu = CreatePopupMenu();
HANDLE hContact = db_find_first(), hInvitedUser;
@@ -535,7 +535,7 @@ static void KickUser (HANDLE hContact, GCHOOK *gch)
if (SkypeSend ("ALTER CHAT "STR" KICK "STR, gch->pDest->ptszID, gch->ptszUID)!=-1) {
if (ptr=SkypeRcv("ALTER CHAT KICK", 2000)) {
if (strncmp(ptr, "ERROR", 5)) {
- GCDEST gcd = { SKYPE_PROTONAME, (TCHAR*)gch->pDest->ptszID, GC_EVENT_KICK };
+ GCDEST gcd = { SKYPE_PROTONAME, gch->pDest->ptszID, GC_EVENT_KICK };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = (DWORD)time(NULL);
gce.dwFlags = GCEF_ADDTOLOG;
@@ -564,7 +564,7 @@ static void KickUser (HANDLE hContact, GCHOOK *gch)
LeaveCriticalSection(&m_GCMutex);
}
-void SetChatTopic (TCHAR *szChatId, TCHAR *szTopic, BOOL bSet)
+void SetChatTopic(const TCHAR *szChatId, TCHAR *szTopic, BOOL bSet)
{
HANDLE hContact = find_chat (szChatId);
char *szUTFTopic;
@@ -704,11 +704,11 @@ int GCEventHook(WPARAM wParam,LPARAM lParam) {
{
TCHAR *ptr, buf[MAX_BUF];
- ptr = SkypeGetT ("CHAT", gch->pDest->ptszID, "TOPIC");
+ ptr = SkypeGetT ("CHAT", (TCHAR*)gch->pDest->ptszID, "TOPIC");
_tcscpy(buf, ptr);
free(ptr);
if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INPUTBOX), NULL, InputBoxDlgProc, (LPARAM)&buf))
- SetChatTopic (gch->pDest->ptszID, buf, TRUE);
+ SetChatTopic(gch->pDest->ptszID, buf, TRUE);
break;
}
}
diff --git a/protocols/SkypeClassic/src/gchat.h b/protocols/SkypeClassic/src/gchat.h
index f9bd283320..1b3cfcbe73 100644
--- a/protocols/SkypeClassic/src/gchat.h
+++ b/protocols/SkypeClassic/src/gchat.h
@@ -25,8 +25,8 @@ typedef struct {
int ChatInit(WPARAM, LPARAM);
int __cdecl ChatStart(char *szChatId, BOOL bJustCreate);
-gchat_contacts *GetChat(TCHAR *szChatId);
-HANDLE find_chat(TCHAR *chatname);
+gchat_contacts *GetChat(LPCTSTR szChatId);
+HANDLE find_chat(LPCTSTR chatname);
#ifdef _UNICODE
HANDLE find_chatA(char *chatname);
#else
@@ -44,4 +44,4 @@ INT_PTR GCOnLeaveChat(WPARAM wParam,LPARAM lParam);
INT_PTR GCOnJoinChat(WPARAM wParam,LPARAM lParam);
void GCInit(void);
void GCExit(void);
-void SetChatTopic (TCHAR *szChatId, TCHAR *szTopic, BOOL bSet);
+void SetChatTopic (const TCHAR *szChatId, TCHAR *szTopic, BOOL bSet);
diff --git a/protocols/SkypeClassic/src/skype.cpp b/protocols/SkypeClassic/src/skype.cpp
index 2c2d6ef737..20a75aaea5 100644
--- a/protocols/SkypeClassic/src/skype.cpp
+++ b/protocols/SkypeClassic/src/skype.cpp
@@ -1259,7 +1259,7 @@ void FetchMessageThread(fetchmsg_arg *pargs) {
MsgList_Add (pre.lParam, INVALID_HANDLE_VALUE); // Mark as groupchat
if (ci.pszVal) mir_free (ci.pszVal);
free_nonutf_tchar_string((void*)gce.ptszUID);
- free_nonutf_tchar_string(gcd.ptszID);
+ free_nonutf_tchar_string((void*)gcd.ptszID);
// Yes, we have successfully read the msg
if (!args.bDontMarkSeen)
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index cddcbcefca..6867783ea0 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void TwitterProto::UpdateChat(const twitter_user &update)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
gce.pDest = &gcd;
gce.bIsMe = (update.username == twit_.get_username());
@@ -89,7 +89,7 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
// TODO: remove nick?
void TwitterProto::AddChatContact(const char *name,const char *nick)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = DWORD(time(0));
gce.ptszNick = mir_a2t(nick ? nick:name);
@@ -103,7 +103,7 @@ void TwitterProto::AddChatContact(const char *name,const char *nick)
void TwitterProto::DeleteChatContact(const char *name)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_PART };
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = DWORD(time(0));
gce.ptszNick = mir_a2t(name);
@@ -127,7 +127,7 @@ INT_PTR TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
return 0;
// ***** Create a group
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("Normal");
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
@@ -147,7 +147,7 @@ INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM)
{
in_chat_ = false;
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
@@ -157,7 +157,7 @@ INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM)
void TwitterProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
GCEVENT gce = { sizeof(gce), &gcd };
if(status == ID_STATUS_ONLINE)
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 1935fb7b73..4fac52e913 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -59,7 +59,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg)
c->m_hContact = gci.hContact;
m_chats.insert(c);
- GCDEST gcd = { m_szModuleName, sid.GetBuffer(), GC_EVENT_ADDGROUP };
+ GCDEST gcd = { m_szModuleName, sid, GC_EVENT_ADDGROUP };
GCEVENT gce = { sizeof(gce), &gcd };
for (int i = SIZEOF(sttStatuses)-1; i >= 0; i--) {
gce.ptszStatus = TranslateTS(sttStatuses[i]);
@@ -88,7 +88,7 @@ void CVkProto::RetrieveChatInfo(CVkChatInfo *cc)
szQuery.AppendFormat("\"users\": API.messages.getChatUsers({\"chat_id\":%d, \"fields\":\"uid,first_name,last_name\"})", cc->m_chatid);
if (!cc->m_bHistoryRead)
- szQuery.AppendFormat(",\"msgs\": API.messages.getHistory({\"chat_id\":%d, \"count\":\"20\", \"rev\":\"1\"})", cc->m_chatid);
+ szQuery.AppendFormat(",\"msgs\": API.messages.getHistory({\"chat_id\":%d, \"count\":\"20\", \"rev\":\"0\"})", cc->m_chatid);
szQuery.Append("};");
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 69f9e54c63..9a0c122eaf 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+static COLORREF sttColors[] = { 0, 1, 2, 3, 4, 5, 6 };
+
CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
PROTO<CVkProto>(szModuleName, ptszUserName),
m_arRequestsQueue(10),
@@ -57,6 +59,8 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
GCREGISTER gcr = { sizeof(gcr) };
gcr.ptszDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
+ gcr.nColors = SIZEOF(sttColors);
+ gcr.pColors = sttColors;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
// Set all contacts offline -- in case we crashed