summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_groupchat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src/jabber_groupchat.cpp')
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp672
1 files changed, 336 insertions, 336 deletions
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index b442588fc0..fa0e961db3 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -1,13 +1,13 @@
/*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
-of the License, or ( at your option ) any later version.
+of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,24 +34,24 @@ struct JabberGcRecentInfo
TCHAR *room, *server, *nick, *password;
CJabberProto* ppro;
- JabberGcRecentInfo( CJabberProto* proto )
+ JabberGcRecentInfo(CJabberProto* proto)
{
ppro = proto;
room = server = nick = password = NULL;
}
- JabberGcRecentInfo( CJabberProto* proto, const TCHAR *_room, const TCHAR *_server, const TCHAR *_nick = NULL, const TCHAR *_password = NULL)
+ JabberGcRecentInfo(CJabberProto* proto, const TCHAR *_room, const TCHAR *_server, const TCHAR *_nick = NULL, const TCHAR *_password = NULL)
{
ppro = proto;
room = server = nick = password = NULL;
fillData(_room, _server, _nick, _password);
}
- JabberGcRecentInfo( CJabberProto* proto, const TCHAR *jid)
+ JabberGcRecentInfo(CJabberProto* proto, const TCHAR *jid)
{
ppro = proto;
room = server = nick = password = NULL;
fillData(jid);
}
- JabberGcRecentInfo( CJabberProto* proto, int iRecent)
+ JabberGcRecentInfo(CJabberProto* proto, int iRecent)
{
ppro = proto;
room = server = nick = password = NULL;
@@ -133,21 +133,21 @@ struct JabberGcRecentInfo
cleanup();
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_server", iRecent);
- if ( !ppro->JGetStringT( NULL, setting, &dbv )) {
- server = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !ppro->JGetStringT(NULL, setting, &dbv)) {
+ server = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_room", iRecent);
- if ( !ppro->JGetStringT( NULL, setting, &dbv )) {
+ if ( !ppro->JGetStringT(NULL, setting, &dbv)) {
room = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_nick", iRecent);
- if ( !ppro->JGetStringT( NULL, setting, &dbv )) {
+ if ( !ppro->JGetStringT(NULL, setting, &dbv)) {
nick = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_passwordW", iRecent);
@@ -188,12 +188,12 @@ struct JabberGcRecentInfo
private:
BOOL null_strequals(const TCHAR *str1, const TCHAR *str2)
{
- if (!str1 && !str2) return TRUE;
- if (!str1 && str2 && !*str2) return TRUE;
- if (!str2 && str1 && !*str1) return TRUE;
+ if ( !str1 && !str2) return TRUE;
+ if ( !str1 && str2 && !*str2) return TRUE;
+ if ( !str2 && str1 && !*str1) return TRUE;
- if (!str1 && str2) return FALSE;
- if (!str2 && str1) return FALSE;
+ if ( !str1 && str2) return FALSE;
+ if ( !str2 && str1) return FALSE;
return !lstrcmp(str1, str2);
}
@@ -203,85 +203,85 @@ JABBER_RESOURCE_STATUS* CJabberProto::GcFindResource(JABBER_LIST_ITEM *item, con
{
JABBER_RESOURCE_STATUS *res = NULL;
- EnterCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
JABBER_RESOURCE_STATUS *r = item->resource;
- for ( int i=0; i<item->resourceCount; i++ ) {
- if ( !_tcscmp( r[i].resourceName, resource )) {
+ for (int i=0; i<item->resourceCount; i++) {
+ if ( !_tcscmp(r[i].resourceName, resource)) {
res = &r[i];
break;
}
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return res;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleJoinGroupchat( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleJoinGroupchat(WPARAM, LPARAM)
{
- if ( jabberChatDllPresent )
- GroupchatJoinRoomByJid( NULL, NULL );
+ if (jabberChatDllPresent)
+ GroupchatJoinRoomByJid(NULL, NULL);
else
JabberChatDllError();
return 0;
}
-INT_PTR __cdecl CJabberProto::OnJoinChat( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM wParam, LPARAM)
{
DBVARIANT nick, jid;
- HANDLE hContact = ( HANDLE )wParam;
- if ( JGetStringT( hContact, "ChatRoomID", &jid ))
+ HANDLE hContact = (HANDLE)wParam;
+ if (JGetStringT(hContact, "ChatRoomID", &jid))
return 0;
- if ( JGetStringT( hContact, "MyNick", &nick ))
- if ( JGetStringT( NULL, "Nick", &nick )) {
- JFreeVariant( &jid );
+ if (JGetStringT(hContact, "MyNick", &nick))
+ if (JGetStringT(NULL, "Nick", &nick)) {
+ db_free(&jid);
return 0;
}
- TCHAR *password = JGetStringCrypt( hContact, "LoginPassword" );
+ TCHAR *password = JGetStringCrypt(hContact, "LoginPassword");
- if ( JGetWord( hContact, "Status", 0 ) != ID_STATUS_ONLINE ) {
- if ( !jabberChatDllPresent )
+ if (JGetWord(hContact, "Status", 0) != ID_STATUS_ONLINE) {
+ if ( !jabberChatDllPresent)
JabberChatDllError();
else {
- TCHAR* p = _tcschr( jid.ptszVal, '@' );
- if ( p != NULL ) {
+ TCHAR* p = _tcschr(jid.ptszVal, '@');
+ if (p != NULL) {
*p++ = 0;
- GroupchatJoinRoom( p, jid.ptszVal, nick.ptszVal, password );
+ GroupchatJoinRoom(p, jid.ptszVal, nick.ptszVal, password);
} } }
- mir_free( password );
- JFreeVariant( &nick );
- JFreeVariant( &jid );
+ mir_free(password);
+ db_free(&nick);
+ db_free(&jid);
return 0;
}
-INT_PTR __cdecl CJabberProto::OnLeaveChat( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnLeaveChat(WPARAM wParam, LPARAM)
{
DBVARIANT jid;
- HANDLE hContact = ( HANDLE )wParam;
- if ( JGetStringT( hContact, "ChatRoomID", &jid ))
+ HANDLE hContact = (HANDLE)wParam;
+ if (JGetStringT(hContact, "ChatRoomID", &jid))
return 0;
- if ( JGetWord( hContact, "Status", 0 ) != ID_STATUS_OFFLINE ) {
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, jid.ptszVal );
- if ( item != NULL )
- GcQuit( item, 0, NULL );
+ if (JGetWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) {
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, jid.ptszVal);
+ if (item != NULL)
+ GcQuit(item, 0, NULL);
}
- JFreeVariant( &jid );
+ db_free(&jid);
return 0;
}
-void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, const TCHAR* nick, const TCHAR* password, bool autojoin )
+void CJabberProto::GroupchatJoinRoom(const TCHAR *server, const TCHAR *room, const TCHAR *nick, const TCHAR *password, bool autojoin)
{
- JabberGcRecentInfo info( this );
+ JabberGcRecentInfo info(this);
int i = 0;
bool found = false;
for (i = 0 ; i < 5; ++i)
{
- if (!info.loadRecent(i))
+ if ( !info.loadRecent(i))
continue;
if (info.equals(room, server, nick, password))
@@ -291,9 +291,9 @@ void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, co
}
}
- if (!found)
+ if ( !found)
{
- for (int i = 4; i--; )
+ for (int i = 4; i--;)
{
if (info.loadRecent(i))
info.saveRecent(i + 1);
@@ -304,34 +304,34 @@ void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, co
}
TCHAR text[512];
- mir_sntprintf( text, SIZEOF(text), _T("%s@%s/%s"), room, server, nick );
+ mir_sntprintf(text, SIZEOF(text), _T("%s@%s/%s"), room, server, nick);
- JABBER_LIST_ITEM* item = ListAdd( LIST_CHATROOM, text );
+ JABBER_LIST_ITEM* item = ListAdd(LIST_CHATROOM, text);
item->bAutoJoin = autojoin;
- replaceStrT( item->nick, nick );
- replaceStrT( item->password, info.password );
+ replaceStrT(item->nick, nick);
+ replaceStrT(item->password, info.password);
- int status = ( m_iStatus == ID_STATUS_INVISIBLE ) ? ID_STATUS_ONLINE : m_iStatus;
- XmlNode x( _T("x")); x << XATTR( _T("xmlns"), _T(JABBER_FEAT_MUC));
- if ( info.password && info.password[0] )
- x << XCHILD( _T("password"), info.password );
+ int status = (m_iStatus == ID_STATUS_INVISIBLE) ? ID_STATUS_ONLINE : m_iStatus;
+ XmlNode x(_T("x")); x << XATTR(_T("xmlns"), _T(JABBER_FEAT_MUC));
+ if (info.password && info.password[0])
+ x << XCHILD(_T("password"), info.password);
if (m_options.GcLogChatHistory) {
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, SIZEOF(setting), "muc_%s@%s_lastevent", _T2A(room), _T2A(server));
- time_t lasteventtime = this->JGetDword( NULL, setting, 0 );
- if ( lasteventtime > 0 ) {
+ time_t lasteventtime = this->JGetDword(NULL, setting, 0);
+ if (lasteventtime > 0) {
_tzset();
lasteventtime += _timezone + 1;
struct tm* time = localtime(&lasteventtime);
TCHAR lasteventdate[40];
mir_sntprintf(lasteventdate, SIZEOF(lasteventdate), _T("%04d-%02d-%02dT%02d:%02d:%02dZ"),
time->tm_year+1900, time->tm_mon+1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec);
- x << XCHILD( _T("history")) << XATTR( _T("since"), lasteventdate);
+ x << XCHILD(_T("history")) << XATTR(_T("since"), lasteventdate);
}
}
- SendPresenceTo( status, text, x );
+ SendPresenceTo(status, text, x);
}
////////////////////////////////////////////////////////////////////////////////
@@ -361,17 +361,17 @@ static int sttRoomListAppend(HWND hwndList, RoomInfo::Overlay overlay, const TCH
void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
{
- if (!iqNode || !pInfo)
+ if ( !iqNode || !pInfo)
return;
HWND hwndList = (HWND)pInfo->GetUserData();
SendMessage(hwndList, CB_SHOWDROPDOWN, FALSE, 0);
SendMessage(hwndList, CB_RESETCONTENT, 0, 0);
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT )
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
{
- HXML query = xmlGetChild( iqNode , "query" );
- if ( !query )
+ HXML query = xmlGetChild(iqNode , "query");
+ if ( !query)
{
sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL,
TranslateT("Jabber Error"),
@@ -381,9 +381,9 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
{
bool found = false;
HXML item;
- for ( int i = 1; item = xmlGetNthChild( query, _T("item"), i ); i++ )
+ for (int i = 1; item = xmlGetNthChild(query, _T("item"), i); i++)
{
- const TCHAR *jid = xmlGetAttrValue( item, _T("jid"));
+ const TCHAR *jid = xmlGetAttrValue(item, _T("jid"));
TCHAR *name = NEWTSTR_ALLOCA(jid);
if (name)
{
@@ -396,13 +396,13 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
sttRoomListAppend(hwndList,
ListGetItemPtr(LIST_BOOKMARK, jid) ? RoomInfo::ROOM_BOOKMARK : RoomInfo::ROOM_DEFAULT,
- xmlGetAttrValue( item, _T("name")),
+ xmlGetAttrValue(item, _T("name")),
jid, name);
found = true;
}
- if (!found)
+ if ( !found)
{
sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL,
TranslateT("Jabber Error"),
@@ -411,15 +411,15 @@ void CJabberProto::OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo)
}
}
} else
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR )
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR)
{
- HXML errorNode = xmlGetChild( iqNode , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
+ HXML errorNode = xmlGetChild(iqNode , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL,
TranslateT("Jabber Error"),
str,
_T(""));
- mir_free( str );
+ mir_free(str);
} else
{
sttRoomListAppend(hwndList, RoomInfo::ROOM_FAIL,
@@ -445,7 +445,7 @@ static void sttJoinDlgShowRecentItems(HWND hwndDlg, int newCount)
int curRecentHeight = rcLastItem.bottom - rcTitle.top - (5 - oldCount) * (rcLastItem.bottom - rcLastItem.top);
int newRecentHeight = rcLastItem.bottom - rcTitle.top - (5 - newCount) * (rcLastItem.bottom - rcLastItem.top);
- if (!newCount) newRecentHeight = 0;
+ if ( !newCount) newRecentHeight = 0;
int offset = newRecentHeight - curRecentHeight;
RECT rc;
@@ -488,11 +488,11 @@ void CJabberDlgGcJoin::OnInitDialog()
{
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "group" );
+ WindowSetIcon(m_hwnd, m_proto, "group");
JabberGcRecentInfo *info = NULL;
- if ( m_jid )
- info = new JabberGcRecentInfo( m_proto, m_jid );
+ if (m_jid)
+ info = new JabberGcRecentInfo(m_proto, m_jid);
else
{
OpenClipboard(m_hwnd);
@@ -502,7 +502,7 @@ void CJabberDlgGcJoin::OnInitDialog()
{
TCHAR *buf = (TCHAR *)GlobalLock(hData);
if (buf && _tcschr(buf, _T('@')) && !_tcschr(buf, _T(' ')))
- info = new JabberGcRecentInfo( m_proto, buf );
+ info = new JabberGcRecentInfo(m_proto, buf);
GlobalUnlock(hData);
}
CloseClipboard();
@@ -515,14 +515,14 @@ void CJabberDlgGcJoin::OnInitDialog()
}
DBVARIANT dbv;
- if ( !m_proto->JGetStringT( NULL, "Nick", &dbv )) {
- SetDlgItemText( m_hwnd, IDC_NICK, dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !m_proto->JGetStringT(NULL, "Nick", &dbv)) {
+ SetDlgItemText(m_hwnd, IDC_NICK, dbv.ptszVal);
+ db_free(&dbv);
}
else {
- TCHAR* nick = JabberNickFromJID( m_proto->m_szJabberJID );
- SetDlgItemText( m_hwnd, IDC_NICK, nick );
- mir_free( nick );
+ TCHAR* nick = JabberNickFromJID(m_proto->m_szJabberJID);
+ SetDlgItemText(m_hwnd, IDC_NICK, nick);
+ mir_free(nick);
}
{
@@ -550,10 +550,10 @@ void CJabberDlgGcJoin::OnInitDialog()
m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr");
int i = 0;
- for ( ; i < 5; ++i)
+ for (; i < 5; ++i)
{
TCHAR jid[JABBER_MAX_JID_LEN];
- JabberGcRecentInfo info( m_proto );
+ JabberGcRecentInfo info(m_proto);
if (info.loadRecent(i))
{
mir_sntprintf(jid, SIZEOF(jid), _T("%s@%s (%s)"),
@@ -575,20 +575,20 @@ void CJabberDlgGcJoin::OnClose()
void CJabberDlgGcJoin::OnDestroy()
{
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0 ));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, 0));
m_proto->m_pDlgJabberJoinGroupchat = NULL;
DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0));
CSuper::OnDestroy();
- mir_free( m_jid ); m_jid = NULL;
+ mir_free(m_jid); m_jid = NULL;
}
INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
TCHAR text[128];
- switch ( msg ) {
+ switch (msg) {
case WM_DELETEITEM:
{
LPDELETEITEMSTRUCT lpdis = (LPDELETEITEMSTRUCT)lParam;
@@ -676,7 +676,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDC_SERVER:
switch (HIWORD(wParam)) {
case CBN_EDITCHANGE:
@@ -697,7 +697,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_ROOM:
switch (HIWORD(wParam)) {
case CBN_DROPDOWN:
- if (!SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETCOUNT, 0, 0))
+ if ( !SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_GETCOUNT, 0, 0))
{
int iqid = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA);
if (iqid)
@@ -716,10 +716,10 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_WAIT, TranslateT("Loading..."), TranslateT("Please wait for room list to download."), _T(""));
- CJabberIqInfo *pInfo = m_proto->m_iqManager.AddHandler( &CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void *)GetDlgItem(m_hwnd, IDC_ROOM));
+ CJabberIqInfo *pInfo = m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, server, 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM));
pInfo->SetTimeout(30000);
XmlNodeIq iq(pInfo);
- iq << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS));
+ iq << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS));
m_proto->m_ThreadInfo->send(iq);
SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ROOM), GWLP_USERDATA, pInfo->GetIqId());
@@ -743,7 +743,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
JABBER_LIST_ITEM *item = 0;
if (item = m_proto->ListGetItemPtrFromIndex(i))
- if (!lstrcmp(item->type, _T("conference")))
+ if ( !lstrcmp(item->type, _T("conference")))
AppendMenu(hMenu, MF_STRING, (UINT_PTR)item, item->name);
}
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
@@ -756,8 +756,8 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
CheckDlgButton(m_hwnd, IDC_BOOKMARKS, FALSE);
DestroyMenu(hMenu);
- if ( res == -1 )
- m_proto->OnMenuHandleBookmarks( 0, 0 );
+ if (res == -1)
+ m_proto->OnMenuHandleBookmarks(0, 0);
else if (res) {
JABBER_LIST_ITEM *item = (JABBER_LIST_ITEM *)res;
TCHAR *room = NEWTSTR_ALLOCA(item->jid);
@@ -781,7 +781,7 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_RECENT4:
case IDC_RECENT5:
{
- JabberGcRecentInfo info( m_proto, LOWORD( wParam ) - IDC_RECENT1);
+ JabberGcRecentInfo info(m_proto, LOWORD(wParam) - IDC_RECENT1);
info.fillForm(m_hwnd);
if (GetAsyncKeyState(VK_CONTROL))
break;
@@ -790,20 +790,20 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case IDOK:
{
- GetDlgItemText( m_hwnd, IDC_SERVER, text, SIZEOF( text ));
- TCHAR* server = NEWTSTR_ALLOCA( text ), *room;
+ GetDlgItemText(m_hwnd, IDC_SERVER, text, SIZEOF(text));
+ TCHAR* server = NEWTSTR_ALLOCA(text), *room;
m_proto->ComboAddRecentString(m_hwnd, IDC_SERVER, "joinWnd_rcSvr", server);
- GetDlgItemText( m_hwnd, IDC_ROOM, text, SIZEOF( text ));
- room = NEWTSTR_ALLOCA( text );
+ GetDlgItemText(m_hwnd, IDC_ROOM, text, SIZEOF(text));
+ room = NEWTSTR_ALLOCA(text);
- GetDlgItemText( m_hwnd, IDC_NICK, text, SIZEOF( text ));
- TCHAR* nick = NEWTSTR_ALLOCA( text );
+ GetDlgItemText(m_hwnd, IDC_NICK, text, SIZEOF(text));
+ TCHAR* nick = NEWTSTR_ALLOCA(text);
- GetDlgItemText( m_hwnd, IDC_PASSWORD, text, SIZEOF( text ));
- TCHAR* password = NEWTSTR_ALLOCA( text );
- m_proto->GroupchatJoinRoom( server, room, nick, password );
+ GetDlgItemText(m_hwnd, IDC_PASSWORD, text, SIZEOF(text));
+ TCHAR* password = NEWTSTR_ALLOCA(text);
+ m_proto->GroupchatJoinRoom(server, room, nick, password);
}
// fall through
case IDCANCEL:
@@ -812,15 +812,15 @@ INT_PTR CJabberDlgGcJoin::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
case WM_JABBER_CHECK_ONLINE:
- if ( !m_proto->m_bJabberOnline )
- EndDialog( m_hwnd, 0 );
+ if ( !m_proto->m_bJabberOnline)
+ EndDialog(m_hwnd, 0);
break;
}
return CSuper::DlgProc(msg, wParam, lParam);
}
-void CJabberProto::GroupchatJoinRoomByJid( HWND, TCHAR *jid )
+void CJabberProto::GroupchatJoinRoomByJid(HWND, TCHAR *jid)
{
if (m_pDlgJabberJoinGroupchat)
SetForegroundWindow(m_pDlgJabberJoinGroupchat->GetHwnd());
@@ -835,77 +835,77 @@ void CJabberProto::GroupchatJoinRoomByJid( HWND, TCHAR *jid )
struct JabberGroupchatChangeNicknameParam
{
- JabberGroupchatChangeNicknameParam( CJabberProto* ppro_, const TCHAR* jid_ ) :
- ppro( ppro_ ),
- jid( mir_tstrdup( jid_ ))
+ JabberGroupchatChangeNicknameParam(CJabberProto* ppro_, const TCHAR *jid_) :
+ ppro(ppro_),
+ jid(mir_tstrdup(jid_))
{}
~JabberGroupchatChangeNicknameParam()
- { mir_free( jid );
+ { mir_free(jid);
}
CJabberProto* ppro;
TCHAR* jid;
};
-static VOID CALLBACK JabberGroupchatChangeNickname( void* arg )
+static VOID CALLBACK JabberGroupchatChangeNickname(void* arg)
{
- JabberGroupchatChangeNicknameParam* param = ( JabberGroupchatChangeNicknameParam* )arg;
- if ( param == NULL )
+ JabberGroupchatChangeNicknameParam* param = (JabberGroupchatChangeNicknameParam*)arg;
+ if (param == NULL)
return;
- JABBER_LIST_ITEM* item = param->ppro->ListGetItemPtr( LIST_CHATROOM, param->jid );
- if ( item != NULL ) {
+ JABBER_LIST_ITEM* item = param->ppro->ListGetItemPtr(LIST_CHATROOM, param->jid);
+ if (item != NULL) {
TCHAR szBuffer[ 1024 ];
TCHAR szCaption[ 1024 ];
szBuffer[ 0 ] = _T('\0');
TCHAR* roomName = item->name ? item->name : item->jid;
- mir_sntprintf( szCaption, SIZEOF(szCaption), _T("%s <%s>"), TranslateT( "Change nickname in" ), roomName );
- if ( item->nick )
- mir_sntprintf( szBuffer, SIZEOF(szBuffer), _T("%s"), item->nick );
+ mir_sntprintf(szCaption, SIZEOF(szCaption), _T("%s <%s>"), TranslateT("Change nickname in"), roomName);
+ if (item->nick)
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), item->nick);
- if ( param->ppro->EnterString( szBuffer, SIZEOF(szBuffer), szCaption, JES_COMBO, "gcNick_" )) {
+ if (param->ppro->EnterString(szBuffer, SIZEOF(szBuffer), szCaption, JES_COMBO, "gcNick_")) {
TCHAR text[ 1024 ];
- replaceStrT( item->nick, szBuffer );
- mir_sntprintf( text, SIZEOF( text ), _T("%s/%s"), item->jid, szBuffer );
- param->ppro->SendPresenceTo( param->ppro->m_iStatus, text, NULL );
+ replaceStrT(item->nick, szBuffer);
+ mir_sntprintf(text, SIZEOF(text), _T("%s/%s"), item->jid, szBuffer);
+ param->ppro->SendPresenceTo(param->ppro->m_iStatus, text, NULL);
} }
delete param;
}
-static int sttGetStatusCode( HXML node )
+static int sttGetStatusCode(HXML node)
{
- HXML statusNode = xmlGetChild( node , "status" );
- if ( statusNode == NULL )
+ HXML statusNode = xmlGetChild(node , "status");
+ if (statusNode == NULL)
return -1;
- const TCHAR* statusCode = xmlGetAttrValue( statusNode, _T("code"));
- if ( statusCode == NULL )
+ const TCHAR *statusCode = xmlGetAttrValue(statusNode, _T("code"));
+ if (statusCode == NULL)
return -1;
- return _ttol( statusCode );
+ return _ttol(statusCode);
}
-void CJabberProto::RenameParticipantNick( JABBER_LIST_ITEM* item, const TCHAR* oldNick, HXML itemNode )
+void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM* item, const TCHAR *oldNick, HXML itemNode)
{
- const TCHAR* newNick = xmlGetAttrValue( itemNode, _T("nick"));
- const TCHAR* jid = xmlGetAttrValue( itemNode, _T("jid"));
- if ( newNick == NULL )
+ const TCHAR *newNick = xmlGetAttrValue(itemNode, _T("nick"));
+ const TCHAR *jid = xmlGetAttrValue(itemNode, _T("jid"));
+ if (newNick == NULL)
return;
- for ( int i=0; i < item->resourceCount; i++ ) {
+ for (int i=0; i < item->resourceCount; i++) {
JABBER_RESOURCE_STATUS& RS = item->resource[i];
- if ( !lstrcmp( RS.resourceName, oldNick )) {
- replaceStrT( RS.resourceName, newNick );
+ if ( !lstrcmp(RS.resourceName, oldNick)) {
+ replaceStrT(RS.resourceName, newNick);
- if ( !lstrcmp( item->nick, oldNick )) {
- replaceStrT( item->nick, newNick );
+ if ( !lstrcmp(item->nick, oldNick)) {
+ replaceStrT(item->nick, newNick);
- HANDLE hContact = HContactFromJID( item->jid );
- if ( hContact != NULL )
- JSetStringT( hContact, "MyNick", newNick );
+ HANDLE hContact = HContactFromJID(item->jid);
+ if (hContact != NULL)
+ JSetStringT(hContact, "MyNick", newNick);
}
GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CHUID };
@@ -920,91 +920,91 @@ void CJabberProto::RenameParticipantNick( JABBER_LIST_ITEM* item, const TCHAR* o
gce.ptszUserInfo = jid;
gce.time = time(0);
gce.dwFlags = GC_TCHAR;
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
gcd.iType = GC_EVENT_NICK;
gce.ptszNick = oldNick;
gce.ptszUID = newNick;
gce.ptszText = newNick;
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
break;
} } }
-void CJabberProto::GroupchatProcessPresence( HXML node )
+void CJabberProto::GroupchatProcessPresence(HXML node)
{
HXML showNode, statusNode, itemNode, n, priorityNode;
- const TCHAR* from;
+ const TCHAR *from;
int status, newRes = 0;
bool bStatusChanged = false;
BOOL roomCreated;
- if ( !node || !xmlGetName( node ) || lstrcmp( xmlGetName( node ), _T("presence"))) return;
- if (( from = xmlGetAttrValue( node, _T("from"))) == NULL ) return;
+ if ( !node || !xmlGetName(node) || lstrcmp(xmlGetName(node), _T("presence"))) return;
+ if ((from = xmlGetAttrValue(node, _T("from"))) == NULL) return;
- const TCHAR* resource = _tcschr( from, '/' );
- if ( resource == NULL || *++resource == '\0' )
+ const TCHAR *resource = _tcschr(from, '/');
+ if (resource == NULL || *++resource == '\0')
return;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, from );
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, from);
+ if (item == NULL)
return;
JABBER_RESOURCE_STATUS* r = GcFindResource(item, resource);
- HXML nNode = xmlGetChildByTag( node, "nick", "xmlns", _T(JABBER_FEAT_NICK));
- if ( nNode == NULL )
- nNode = xmlGetChildByTag( node, "nick:nick", "xmlns:nick", _T(JABBER_FEAT_NICK));
+ HXML nNode = xmlGetChildByTag(node, "nick", "xmlns", _T(JABBER_FEAT_NICK));
+ if (nNode == NULL)
+ nNode = xmlGetChildByTag(node, "nick:nick", "xmlns:nick", _T(JABBER_FEAT_NICK));
- const TCHAR* cnick = nNode ? xmlGetText( nNode ) : NULL;
- const TCHAR* nick = cnick ? cnick : (r && r->nick ? r->nick : resource);
+ const TCHAR *cnick = nNode ? xmlGetText(nNode) : NULL;
+ const TCHAR *nick = cnick ? cnick : (r && r->nick ? r->nick : resource);
// process custom nick change
- if ( cnick && r && r->nick && _tcscmp( cnick, r->nick ))
- replaceStrT( r->nick, cnick );
+ if (cnick && r && r->nick && _tcscmp(cnick, r->nick))
+ replaceStrT(r->nick, cnick);
- HXML xNode = xmlGetChildByTag( node, "x", "xmlns", _T(JABBER_FEAT_MUC_USER));
- HXML xUserNode = xmlGetChildByTag( node, "user:x", "xmlns:user", _T(JABBER_FEAT_MUC_USER));
+ HXML xNode = xmlGetChildByTag(node, "x", "xmlns", _T(JABBER_FEAT_MUC_USER));
+ HXML xUserNode = xmlGetChildByTag(node, "user:x", "xmlns:user", _T(JABBER_FEAT_MUC_USER));
- itemNode = xmlGetChild( xNode , "item" );
- if ( itemNode == NULL )
- itemNode = xmlGetChild( xUserNode , "user:item" );
+ itemNode = xmlGetChild(xNode , "item");
+ if (itemNode == NULL)
+ itemNode = xmlGetChild(xUserNode , "user:item");
- const TCHAR* type = xmlGetAttrValue( node, _T("type"));
+ const TCHAR *type = xmlGetAttrValue(node, _T("type"));
// entering room or a usual room presence
- if ( type == NULL || !_tcscmp( type, _T("available"))) {
- TCHAR* room = JabberNickFromJID( from );
- if ( room == NULL )
+ if (type == NULL || !_tcscmp(type, _T("available"))) {
+ TCHAR* room = JabberNickFromJID(from);
+ if (room == NULL)
return;
- GcLogCreate( item );
+ GcLogCreate(item);
item->iChatState = 0;
// Update status of room participant
status = ID_STATUS_ONLINE;
- if (( showNode = xmlGetChild( node , "show" )) != NULL ) {
- if ( xmlGetText( showNode ) != NULL ) {
- if ( !_tcscmp( xmlGetText( showNode ) , _T("away"))) status = ID_STATUS_AWAY;
- else if ( !_tcscmp( xmlGetText( showNode ) , _T("xa"))) status = ID_STATUS_NA;
- else if ( !_tcscmp( xmlGetText( showNode ) , _T("dnd"))) status = ID_STATUS_DND;
- else if ( !_tcscmp( xmlGetText( showNode ) , _T("chat"))) status = ID_STATUS_FREECHAT;
+ if ((showNode = xmlGetChild(node , "show")) != NULL) {
+ if (xmlGetText(showNode) != NULL) {
+ if ( !_tcscmp(xmlGetText(showNode) , _T("away"))) status = ID_STATUS_AWAY;
+ else if ( !_tcscmp(xmlGetText(showNode) , _T("xa"))) status = ID_STATUS_NA;
+ else if ( !_tcscmp(xmlGetText(showNode) , _T("dnd"))) status = ID_STATUS_DND;
+ else if ( !_tcscmp(xmlGetText(showNode) , _T("chat"))) status = ID_STATUS_FREECHAT;
} }
- statusNode = xmlGetChild( node , "status" );
- if ( statusNode == NULL )
- statusNode = xmlGetChild( node , "user:status" );
+ statusNode = xmlGetChild(node , "status");
+ if (statusNode == NULL)
+ statusNode = xmlGetChild(node , "user:status");
- const TCHAR* str = statusNode ? xmlGetText( statusNode ) : NULL;
+ const TCHAR *str = statusNode ? xmlGetText(statusNode) : NULL;
char priority = 0;
- if (( priorityNode = xmlGetChild( node , "priority" )) != NULL && xmlGetText( priorityNode ) != NULL )
- priority = (char)_ttoi( xmlGetText( priorityNode ));
+ if ((priorityNode = xmlGetChild(node , "priority")) != NULL && xmlGetText(priorityNode) != NULL)
+ priority = (char)_ttoi(xmlGetText(priorityNode));
if (JABBER_RESOURCE_STATUS *oldRes = ListFindResource(LIST_CHATROOM, from))
if ((oldRes->status != status) || lstrcmp_null(oldRes->statusMessage, str))
bStatusChanged = true;
- newRes = ( ListAddResource( LIST_CHATROOM, from, status, str, priority, cnick ) == 0 ) ? 0 : GC_EVENT_JOIN;
+ newRes = (ListAddResource(LIST_CHATROOM, from, status, str, priority, cnick) == 0) ? 0 : GC_EVENT_JOIN;
roomCreated = FALSE;
@@ -1012,30 +1012,30 @@ void CJabberProto::GroupchatProcessPresence( HXML node )
bool bRoleChanged = false;
// Check additional MUC info for this user
- if ( itemNode != NULL ) {
- if ( r == NULL )
+ if (itemNode != NULL) {
+ if (r == NULL)
r = GcFindResource(item, resource);
- if ( r != NULL ) {
+ if (r != NULL) {
JABBER_GC_AFFILIATION affiliation = r->affiliation;
JABBER_GC_ROLE role = r->role;
- if (( str = xmlGetAttrValue( itemNode, _T("affiliation"))) != NULL ) {
- if ( !_tcscmp( str, _T("owner"))) affiliation = AFFILIATION_OWNER;
- else if ( !_tcscmp( str, _T("admin"))) affiliation = AFFILIATION_ADMIN;
- else if ( !_tcscmp( str, _T("member"))) affiliation = AFFILIATION_MEMBER;
- else if ( !_tcscmp( str, _T("none"))) affiliation = AFFILIATION_NONE;
- else if ( !_tcscmp( str, _T("outcast"))) affiliation = AFFILIATION_OUTCAST;
+ if ((str = xmlGetAttrValue(itemNode, _T("affiliation"))) != NULL) {
+ if ( !_tcscmp(str, _T("owner"))) affiliation = AFFILIATION_OWNER;
+ else if ( !_tcscmp(str, _T("admin"))) affiliation = AFFILIATION_ADMIN;
+ else if ( !_tcscmp(str, _T("member"))) affiliation = AFFILIATION_MEMBER;
+ else if ( !_tcscmp(str, _T("none"))) affiliation = AFFILIATION_NONE;
+ else if ( !_tcscmp(str, _T("outcast"))) affiliation = AFFILIATION_OUTCAST;
}
- if (( str = xmlGetAttrValue( itemNode, _T("role"))) != NULL ) {
- if ( !_tcscmp( str, _T("moderator"))) role = ROLE_MODERATOR;
- else if ( !_tcscmp( str, _T("participant"))) role = ROLE_PARTICIPANT;
- else if ( !_tcscmp( str, _T("visitor"))) role = ROLE_VISITOR;
+ if ((str = xmlGetAttrValue(itemNode, _T("role"))) != NULL) {
+ if ( !_tcscmp(str, _T("moderator"))) role = ROLE_MODERATOR;
+ else if ( !_tcscmp(str, _T("participant"))) role = ROLE_PARTICIPANT;
+ else if ( !_tcscmp(str, _T("visitor"))) role = ROLE_VISITOR;
else role = ROLE_NONE;
}
- if ( (role != ROLE_NONE) && (JabberGcGetStatus(r) != JabberGcGetStatus(affiliation, role))) {
- GcLogUpdateMemberStatus( item, resource, nick, NULL, GC_EVENT_REMOVESTATUS, NULL );
- if (!newRes) newRes = GC_EVENT_ADDSTATUS;
+ if ((role != ROLE_NONE) && (JabberGcGetStatus(r) != JabberGcGetStatus(affiliation, role))) {
+ GcLogUpdateMemberStatus(item, resource, nick, NULL, GC_EVENT_REMOVESTATUS, NULL);
+ if ( !newRes) newRes = GC_EVENT_ADDSTATUS;
}
if (affiliation != r->affiliation) {
@@ -1049,12 +1049,12 @@ void CJabberProto::GroupchatProcessPresence( HXML node )
bRoleChanged = true;
}
- if ( str = xmlGetAttrValue( itemNode, _T("jid")))
- replaceStrT( r->szRealJid, str );
+ if (str = xmlGetAttrValue(itemNode, _T("jid")))
+ replaceStrT(r->szRealJid, str);
}
}
- if ( sttGetStatusCode( xNode ) == 201 )
+ if (sttGetStatusCode(xNode) == 201)
roomCreated = TRUE;
// show status change if needed
@@ -1063,89 +1063,89 @@ void CJabberProto::GroupchatProcessPresence( HXML node )
GcLogShowInformation(item, res, INFO_STATUS);
// Update groupchat log window
- GcLogUpdateMemberStatus( item, resource, nick, str, newRes, NULL );
+ GcLogUpdateMemberStatus(item, resource, nick, str, newRes, NULL);
if (r && bAffiliationChanged) GcLogShowInformation(item, r, INFO_AFFILIATION);
if (r && bRoleChanged) GcLogShowInformation(item, r, INFO_ROLE);
// update clist status
- HANDLE hContact = HContactFromJID( from );
- if ( hContact != NULL )
- JSetWord( hContact, "Status", status );
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact != NULL)
+ JSetWord(hContact, "Status", status);
// Update room status
- //if ( item->status != ID_STATUS_ONLINE ) {
+ //if (item->status != ID_STATUS_ONLINE) {
// item->status = ID_STATUS_ONLINE;
- // JSetWord( hContact, "Status", ( WORD )ID_STATUS_ONLINE );
- // JabberLog( "Room %s online", from );
+ // JSetWord(hContact, "Status", (WORD)ID_STATUS_ONLINE);
+ // JabberLog("Room %s online", from);
//}
// Check <created/>
- if ( roomCreated ||
- (( n = xmlGetChild( node , "created" ))!=NULL &&
- ( str = xmlGetAttrValue( n, _T("xmlns")))!=NULL &&
- !_tcscmp( str, _T("http://jabber.org/protocol/muc#owner")))) {
+ if (roomCreated ||
+ ((n = xmlGetChild(node , "created"))!=NULL &&
+ (str = xmlGetAttrValue(n, _T("xmlns")))!=NULL &&
+ !_tcscmp(str, _T("http://jabber.org/protocol/muc#owner")))) {
// A new room just created by me
// Request room config
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc );
- m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId, item->jid ) << XQUERY( xmlnsOwner ));
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc);
+ m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId, item->jid) << XQUERY(xmlnsOwner));
}
- mir_free( room );
+ mir_free(room);
}
// leaving room
- else if ( !_tcscmp( type, _T("unavailable"))) {
- const TCHAR* str = 0;
- if ( xNode != NULL && item->nick != NULL ) {
- HXML reasonNode = xmlGetChild( itemNode , "reason" );
- str = xmlGetAttrValue( itemNode, _T( "jid" ));
+ else if ( !_tcscmp(type, _T("unavailable"))) {
+ const TCHAR *str = 0;
+ if (xNode != NULL && item->nick != NULL) {
+ HXML reasonNode = xmlGetChild(itemNode , "reason");
+ str = xmlGetAttrValue(itemNode, _T("jid"));
- int iStatus = sttGetStatusCode( xNode );
+ int iStatus = sttGetStatusCode(xNode);
if (iStatus == 301 && r != NULL)
GcLogShowInformation(item, r, INFO_BAN);
- if ( !lstrcmp( resource, item->nick )) {
- switch( iStatus ) {
+ if ( !lstrcmp(resource, item->nick)) {
+ switch(iStatus) {
case 301:
case 307:
- GcQuit( item, iStatus, reasonNode );
+ GcQuit(item, iStatus, reasonNode);
return;
case 303:
- RenameParticipantNick( item, resource, itemNode );
+ RenameParticipantNick(item, resource, itemNode);
return;
} }
else {
- switch( iStatus ) {
+ switch(iStatus) {
case 303:
- RenameParticipantNick( item, resource, itemNode );
+ RenameParticipantNick(item, resource, itemNode);
return;
case 301:
case 307:
case 322:
- ListRemoveResource( LIST_CHATROOM, from );
- GcLogUpdateMemberStatus( item, resource, nick, str, GC_EVENT_KICK, reasonNode, iStatus );
+ ListRemoveResource(LIST_CHATROOM, from);
+ GcLogUpdateMemberStatus(item, resource, nick, str, GC_EVENT_KICK, reasonNode, iStatus);
return;
} } }
- statusNode = xmlGetChild( node , "status" );
- GcLogUpdateMemberStatus( item, resource, nick, str, GC_EVENT_PART, statusNode );
- ListRemoveResource( LIST_CHATROOM, from );
+ statusNode = xmlGetChild(node , "status");
+ GcLogUpdateMemberStatus(item, resource, nick, str, GC_EVENT_PART, statusNode);
+ ListRemoveResource(LIST_CHATROOM, from);
- HANDLE hContact = HContactFromJID( from );
- if ( hContact != NULL )
- JSetWord( hContact, "Status", ID_STATUS_OFFLINE );
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact != NULL)
+ JSetWord(hContact, "Status", ID_STATUS_OFFLINE);
}
// processing room errors
- else if ( !_tcscmp( type, _T("error"))) {
+ else if ( !_tcscmp(type, _T("error"))) {
int errorCode = 0;
- HXML errorNode = xmlGetChild( node , "error" );
- TCHAR* str = JabberErrorMsg( errorNode, &errorCode );
+ HXML errorNode = xmlGetChild(node , "error");
+ TCHAR* str = JabberErrorMsg(errorNode, &errorCode);
- if ( errorCode == JABBER_ERROR_CONFLICT ) {
+ if (errorCode == JABBER_ERROR_CONFLICT) {
TCHAR newNick[256] = { 0 };
if (++item->iChatState == 1 &&
JGetStringT(NULL, "GcAltNick", newNick, SIZEOF(newNick)) != NULL &&
@@ -1157,103 +1157,103 @@ void CJabberProto::GroupchatProcessPresence( HXML node )
SendPresenceTo(m_iStatus, text, NULL);
}
else {
- CallFunctionAsync( JabberGroupchatChangeNickname, new JabberGroupchatChangeNicknameParam( this, from ));
+ CallFunctionAsync(JabberGroupchatChangeNickname, new JabberGroupchatChangeNicknameParam(this, from));
item->iChatState = 0;
}
- mir_free( str );
+ mir_free(str);
return;
}
- MsgPopup( NULL, str, TranslateT( "Jabber Error" ));
+ MsgPopup(NULL, str, TranslateT("Jabber Error"));
- if ( item != NULL)
- if ( !item->bChatActive ) ListRemove( LIST_CHATROOM, from );
- mir_free( str );
+ if (item != NULL)
+ if ( !item->bChatActive) ListRemove(LIST_CHATROOM, from);
+ mir_free(str);
} }
-void CJabberProto::GroupchatProcessMessage( HXML node )
+void CJabberProto::GroupchatProcessMessage(HXML node)
{
HXML n, xNode, m;
- const TCHAR* from, *type, *p, *nick, *resource;
+ const TCHAR *from, *type, *p, *nick, *resource;
JABBER_LIST_ITEM *item;
- if ( !xmlGetName( node ) || lstrcmp( xmlGetName( node ), _T("message"))) return;
- if (( from = xmlGetAttrValue( node, _T("from"))) == NULL ) return;
- if (( item = ListGetItemPtr( LIST_CHATROOM, from )) == NULL ) return;
+ if ( !xmlGetName(node) || lstrcmp(xmlGetName(node), _T("message"))) return;
+ if ((from = xmlGetAttrValue(node, _T("from"))) == NULL) return;
+ if ((item = ListGetItemPtr(LIST_CHATROOM, from)) == NULL) return;
- if (( type = xmlGetAttrValue( node, _T("type"))) == NULL ) return;
- if ( !lstrcmp( type, _T("error")))
+ if ((type = xmlGetAttrValue(node, _T("type"))) == NULL) return;
+ if ( !lstrcmp(type, _T("error")))
return;
GCDEST gcd = { m_szModuleName, NULL, 0 };
gcd.ptszID = item->jid;
- const TCHAR* msgText = NULL;
+ const TCHAR *msgText = NULL;
- resource = _tcschr( from, '/' );
- if ( resource != NULL && *++resource == '\0' )
+ resource = _tcschr(from, '/');
+ if (resource != NULL && *++resource == '\0')
resource = NULL;
- if (( n = xmlGetChild( node , "subject" )) != NULL ) {
- msgText = xmlGetText( n );
+ if ((n = xmlGetChild(node , "subject")) != NULL) {
+ msgText = xmlGetText(n);
- if ( msgText == NULL || msgText[0] == '\0' )
+ if (msgText == NULL || msgText[0] == '\0')
return;
gcd.iType = GC_EVENT_TOPIC;
- if ( resource == NULL && ( m = xmlGetChild( node, "body" )) != NULL ) {
- const TCHAR* tmpnick = xmlGetText( m );
- if ( tmpnick == NULL || *tmpnick == 0 )
+ if (resource == NULL && (m = xmlGetChild(node, "body")) != NULL) {
+ const TCHAR *tmpnick = xmlGetText(m);
+ if (tmpnick == NULL || *tmpnick == 0)
return;
- const TCHAR* tmptr = _tcsstr( tmpnick, _T("has set the subject to:")); //ejabberd
- if ( tmptr == NULL )
- tmptr = _tcsstr( tmpnick, TranslateT("has set the subject to:")); //ejabberd
- if ( tmptr != NULL && *tmptr != 0 ) {
+ const TCHAR *tmptr = _tcsstr(tmpnick, _T("has set the subject to:")); //ejabberd
+ if (tmptr == NULL)
+ tmptr = _tcsstr(tmpnick, TranslateT("has set the subject to:")); //ejabberd
+ if (tmptr != NULL && *tmptr != 0) {
*(TCHAR*)(--tmptr) = 0;
resource = tmpnick;
} }
- replaceStrT( item->itemResource.statusMessage, msgText );
+ replaceStrT(item->itemResource.statusMessage, msgText);
}
else {
- if (( n = xmlGetChildByTag( node , "body", "xml:lang", m_tszSelectedLang )) == NULL )
- if (( n = xmlGetChild( node , "body" )) == NULL )
+ if ((n = xmlGetChildByTag(node , "body", "xml:lang", m_tszSelectedLang)) == NULL)
+ if ((n = xmlGetChild(node , "body")) == NULL)
return;
- msgText = xmlGetText( n );
+ msgText = xmlGetText(n);
- if ( msgText == NULL )
+ if (msgText == NULL)
return;
- if ( resource == NULL)
+ if (resource == NULL)
gcd.iType = GC_EVENT_INFORMATION;
- else if ( _tcsncmp( msgText, _T("/me "), 4 ) == 0 && _tcslen( msgText ) > 4 ) {
+ else if (_tcsncmp(msgText, _T("/me "), 4) == 0 && _tcslen(msgText) > 4) {
msgText += 4;
gcd.iType = GC_EVENT_ACTION;
}
else gcd.iType = GC_EVENT_MESSAGE;
}
- GcLogCreate( item );
+ GcLogCreate(item);
time_t msgTime = 0;
- for ( int i = 1; ( xNode = xmlGetNthChild( node, _T("x"), i )) != NULL; i++ )
- if (( p = xmlGetAttrValue( xNode, _T("xmlns"))) != NULL )
- if ( !_tcscmp( p, _T("jabber:x:delay")) && msgTime==0 )
- if (( p = xmlGetAttrValue( xNode, _T("stamp"))) != NULL ) {
- msgTime = JabberIsoToUnixTime( p );
- if (m_options.GcLogChatHistory && msgTime > 0 ) {
+ for (int i = 1; (xNode = xmlGetNthChild(node, _T("x"), i)) != NULL; i++)
+ if ((p = xmlGetAttrValue(xNode, _T("xmlns"))) != NULL)
+ if ( !_tcscmp(p, _T("jabber:x:delay")) && msgTime==0)
+ if ((p = xmlGetAttrValue(xNode, _T("stamp"))) != NULL) {
+ msgTime = JabberIsoToUnixTime(p);
+ if (m_options.GcLogChatHistory && msgTime > 0) {
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "muc_%s_lastevent", _T2A(gcd.ptszID));
this->JSetDword(NULL, setting, msgTime);
} }
- time_t now = time( NULL );
- if ( msgTime == 0 || msgTime > now )
+ time_t now = time(NULL);
+ if (msgTime == 0 || msgTime > now)
msgTime = now;
- if ( resource != NULL ) {
+ if (resource != NULL) {
JABBER_RESOURCE_STATUS* r = GcFindResource(item, resource);
nick = r && r->nick ? r->nick : resource;
}
@@ -1266,20 +1266,20 @@ void CJabberProto::GroupchatProcessMessage( HXML node )
gce.ptszUID = resource;
gce.ptszNick = nick;
gce.time = msgTime;
- gce.ptszText = EscapeChatTags( (TCHAR*)msgText );
- gce.bIsMe = nick == NULL ? FALSE : (lstrcmp( resource, item->nick ) == 0);
+ gce.ptszText = EscapeChatTags((TCHAR*)msgText);
+ gce.bIsMe = nick == NULL ? FALSE : (lstrcmp(resource, item->nick) == 0);
gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- CallServiceSync( MS_GC_EVENT, NULL, (LPARAM)&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
item->bChatActive = 2;
- if ( gcd.iType == GC_EVENT_TOPIC ) {
+ if (gcd.iType == GC_EVENT_TOPIC) {
gce.dwFlags &= ~GCEF_ADDTOLOG;
gcd.iType = GC_EVENT_SETSBTEXT;
- CallServiceSync( MS_GC_EVENT, NULL, (LPARAM)&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
- mir_free( (void*)gce.pszText ); // Since we processed msgText and created a new string
+ mir_free((void*)gce.pszText); // Since we processed msgText and created a new string
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1292,12 +1292,12 @@ class CGroupchatInviteAcceptDlg : public CJabberDlgBase
JABBER_GROUPCHAT_INVITE_INFO* m_info;
public:
- CGroupchatInviteAcceptDlg( CJabberProto* ppro, JABBER_GROUPCHAT_INVITE_INFO* pInfo ) :
- CSuper( ppro, IDD_GROUPCHAT_INVITE_ACCEPT, NULL ),
- m_info( pInfo ),
- m_accept( this, IDC_ACCEPT )
+ CGroupchatInviteAcceptDlg(CJabberProto* ppro, JABBER_GROUPCHAT_INVITE_INFO* pInfo) :
+ CSuper(ppro, IDD_GROUPCHAT_INVITE_ACCEPT, NULL),
+ m_info(pInfo),
+ m_accept(this, IDC_ACCEPT)
{
- m_accept.OnClick = Callback( this, &CGroupchatInviteAcceptDlg::OnCommand_Accept );
+ m_accept.OnClick = Callback(this, &CGroupchatInviteAcceptDlg::OnCommand_Accept);
}
void OnInitDialog()
@@ -1306,69 +1306,69 @@ public:
TCHAR buf[256];
mir_sntprintf(buf, SIZEOF(buf), _T("%s\n%s"), m_info->roomJid, TranslateT("Incoming groupchat invitation."));
- SetDlgItemText( m_hwnd, IDC_HEADERBAR, buf );
+ SetDlgItemText(m_hwnd, IDC_HEADERBAR, buf);
- SetDlgItemText( m_hwnd, IDC_FROM, m_info->from );
+ SetDlgItemText(m_hwnd, IDC_FROM, m_info->from);
- if ( m_info->reason != NULL )
- SetDlgItemText( m_hwnd, IDC_REASON, m_info->reason );
+ if (m_info->reason != NULL)
+ SetDlgItemText(m_hwnd, IDC_REASON, m_info->reason);
- TCHAR* myNick = JabberNickFromJID( m_proto->m_szJabberJID );
- SetDlgItemText( m_hwnd, IDC_NICK, myNick );
- mir_free( myNick );
+ TCHAR* myNick = JabberNickFromJID(m_proto->m_szJabberJID);
+ SetDlgItemText(m_hwnd, IDC_NICK, myNick);
+ mir_free(myNick);
- WindowSetIcon( m_hwnd, m_proto, "group" );
+ WindowSetIcon(m_hwnd, m_proto, "group");
SetFocus(GetDlgItem(m_hwnd, IDC_NICK));
}
- void OnCommand_Accept( CCtrlButton* )
+ void OnCommand_Accept(CCtrlButton*)
{
TCHAR text[128];
- GetDlgItemText( m_hwnd, IDC_NICK, text, SIZEOF( text ));
- m_proto->AcceptGroupchatInvite( m_info->roomJid, text, m_info->password );
- EndDialog( m_hwnd, 0 );
+ GetDlgItemText(m_hwnd, IDC_NICK, text, SIZEOF(text));
+ m_proto->AcceptGroupchatInvite(m_info->roomJid, text, m_info->password);
+ EndDialog(m_hwnd, 0);
}
};
-void __cdecl CJabberProto::GroupchatInviteAcceptThread( JABBER_GROUPCHAT_INVITE_INFO *inviteInfo )
+void __cdecl CJabberProto::GroupchatInviteAcceptThread(JABBER_GROUPCHAT_INVITE_INFO *inviteInfo)
{
- CGroupchatInviteAcceptDlg( this, inviteInfo ).DoModal();
+ CGroupchatInviteAcceptDlg(this, inviteInfo).DoModal();
- mir_free( inviteInfo->roomJid );
- mir_free( inviteInfo->from );
- mir_free( inviteInfo->reason );
- mir_free( inviteInfo->password );
- mir_free( inviteInfo );
+ mir_free(inviteInfo->roomJid);
+ mir_free(inviteInfo->from);
+ mir_free(inviteInfo->reason);
+ mir_free(inviteInfo->password);
+ mir_free(inviteInfo);
}
-void CJabberProto::GroupchatProcessInvite( const TCHAR* roomJid, const TCHAR* from, const TCHAR* reason, const TCHAR* password )
+void CJabberProto::GroupchatProcessInvite(const TCHAR *roomJid, const TCHAR *from, const TCHAR *reason, const TCHAR *password)
{
- if ( roomJid == NULL )
+ if (roomJid == NULL)
return;
- if (ListGetItemPtr( LIST_CHATROOM, roomJid ))
+ if (ListGetItemPtr(LIST_CHATROOM, roomJid))
return;
- if ( m_options.AutoAcceptMUC == FALSE ) {
- JABBER_GROUPCHAT_INVITE_INFO* inviteInfo = ( JABBER_GROUPCHAT_INVITE_INFO * ) mir_alloc( sizeof( JABBER_GROUPCHAT_INVITE_INFO ));
- inviteInfo->roomJid = mir_tstrdup( roomJid );
- inviteInfo->from = mir_tstrdup( from );
- inviteInfo->reason = mir_tstrdup( reason );
- inviteInfo->password = mir_tstrdup( password );
- JForkThread(( JThreadFunc )&CJabberProto::GroupchatInviteAcceptThread, inviteInfo );
+ if (m_options.AutoAcceptMUC == FALSE) {
+ JABBER_GROUPCHAT_INVITE_INFO* inviteInfo = (JABBER_GROUPCHAT_INVITE_INFO *) mir_alloc(sizeof(JABBER_GROUPCHAT_INVITE_INFO));
+ inviteInfo->roomJid = mir_tstrdup(roomJid);
+ inviteInfo->from = mir_tstrdup(from);
+ inviteInfo->reason = mir_tstrdup(reason);
+ inviteInfo->password = mir_tstrdup(password);
+ JForkThread((JThreadFunc)&CJabberProto::GroupchatInviteAcceptThread, inviteInfo);
}
else {
- TCHAR* myNick = JabberNickFromJID( m_szJabberJID );
- AcceptGroupchatInvite( roomJid, myNick, password );
- mir_free( myNick );
+ TCHAR* myNick = JabberNickFromJID(m_szJabberJID);
+ AcceptGroupchatInvite(roomJid, myNick, password);
+ mir_free(myNick);
} }
-void CJabberProto::AcceptGroupchatInvite( const TCHAR* roomJid, const TCHAR* reason, const TCHAR* password )
+void CJabberProto::AcceptGroupchatInvite(const TCHAR *roomJid, const TCHAR *reason, const TCHAR *password)
{
TCHAR room[256], *server, *p;
- _tcsncpy( room, roomJid, SIZEOF( room ));
- p = _tcstok( room, _T( "@" ));
- server = _tcstok( NULL, _T( "@" ));
- GroupchatJoinRoom( server, p, reason, password );
+ _tcsncpy(room, roomJid, SIZEOF(room));
+ p = _tcstok(room, _T("@"));
+ server = _tcstok(NULL, _T("@"));
+ GroupchatJoinRoom(server, p, reason, password);
}