diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-15 21:18:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-15 21:18:48 +0000 |
commit | 7ebaebba8520e457bf374ca245f52332fbb008be (patch) | |
tree | 55cf960e4981d9413befb1bf275a3fd067bf2534 /protocols | |
parent | 8353de363fc22940685b334cbb38c0378e9c1b71 (diff) |
bye-bye old coding style in Jabber
git-svn-id: http://svn.miranda-ng.org/main/trunk@2322 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
77 files changed, 12586 insertions, 12606 deletions
diff --git a/protocols/JabberG/res/version.rc b/protocols/JabberG/res/version.rc index d50daca899..905ea6666b 100644 --- a/protocols/JabberG/res/version.rc +++ b/protocols/JabberG/res/version.rc @@ -7,7 +7,7 @@ #ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page( 1252)
+#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
@@ -37,7 +37,7 @@ BEGIN VALUE "FileDescription", "Jabber Protocol Plugin for Miranda NG\0"
VALUE "FileVersion", __VERSION_STRING
VALUE "InternalName", "jabber\0"
- VALUE "LegalCopyright", "Copyright ( c) 2002-04 Santithorn Bunchua, 2005 George Hazan \0"
+ VALUE "LegalCopyright", "Copyright (c) 2002-04 Santithorn Bunchua, 2005 George Hazan \0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "jabber.dll\0"
VALUE "PrivateBuild", "\0"
diff --git a/protocols/JabberG/src/MString.cpp b/protocols/JabberG/src/MString.cpp index 773871d1a5..2e11348425 100644 --- a/protocols/JabberG/src/MString.cpp +++ b/protocols/JabberG/src/MString.cpp @@ -6,7 +6,7 @@ CNilMStringData CMBaseString::m_nil;
-CMStringData* CMBaseString::Allocate( int nChars, int nCharSize )
+CMStringData* CMBaseString::Allocate(int nChars, int nCharSize)
{
CMStringData* pData;
nChars++; // nil char
@@ -75,7 +75,7 @@ bool CMStringData::IsShared() const void CMStringData::Lock()
{
nRefs--; // Locked buffers can't be shared, so no interlocked operation necessary
- if ( nRefs == 0 )
+ if (nRefs == 0)
nRefs = -1;
}
@@ -110,92 +110,92 @@ CNilMStringData::CNilMStringData() #if _MSC_VER < 1400
static HINSTANCE hCrt = NULL;
-typedef int ( __cdecl *_vscprintf_func )( LPCSTR pszFormat, va_list args );
+typedef int (__cdecl *_vscprintf_func)(LPCSTR pszFormat, va_list args);
static _vscprintf_func _vscprintf_ptr = NULL;
-typedef int ( __cdecl *_vscwprintf_func )( LPCWSTR pszFormat, va_list args );
+typedef int (__cdecl *_vscwprintf_func)(LPCWSTR pszFormat, va_list args);
static _vscwprintf_func _vscwprintf_ptr = NULL;
-typedef int ( __cdecl *_vsnprintf_func )( char*, size_t, const char*, va_list );
+typedef int (__cdecl *_vsnprintf_func)(char*, size_t, const char*, va_list);
static _vsnprintf_func _vsnprintf_ptr = NULL;
-typedef int ( __cdecl *_vsnwprintf_func )( wchar_t *, size_t, const wchar_t *, va_list );
+typedef int (__cdecl *_vsnwprintf_func)(wchar_t *, size_t, const wchar_t *, va_list);
static _vsnwprintf_func _vsnwprintf_ptr = NULL;
-typedef int ( __cdecl *vswprintf_func )( wchar_t *, size_t, const wchar_t *, va_list );
+typedef int (__cdecl *vswprintf_func)(wchar_t *, size_t, const wchar_t *, va_list);
static vswprintf_func vswprintf_ptr = NULL;
-typedef int ( __cdecl *vsprintf_func )( char*, size_t, const char*, va_list );
+typedef int (__cdecl *vsprintf_func)(char*, size_t, const char*, va_list);
static vsprintf_func vsprintf_ptr = NULL;
-static void checkCrt( void )
+static void checkCrt(void)
{
- if ( hCrt == NULL ) {
- hCrt = GetModuleHandleA( "msvcrt.dll" );
- _vscprintf_ptr = (_vscprintf_func)GetProcAddress( hCrt, "_vscprintf" );
- _vscwprintf_ptr = (_vscwprintf_func)GetProcAddress( hCrt, "_vscwprintf" );
- _vsnprintf_ptr = (_vsnprintf_func)GetProcAddress( hCrt, "_vsnprintf" );
- _vsnwprintf_ptr = (_vsnwprintf_func)GetProcAddress( hCrt, "_vsnwprintf" );
- vswprintf_ptr = (vswprintf_func)GetProcAddress( hCrt, "vswprintf" );
- vsprintf_ptr = (vsprintf_func)GetProcAddress( hCrt, "vsprintf" );
+ if (hCrt == NULL) {
+ hCrt = GetModuleHandleA("msvcrt.dll");
+ _vscprintf_ptr = (_vscprintf_func)GetProcAddress(hCrt, "_vscprintf");
+ _vscwprintf_ptr = (_vscwprintf_func)GetProcAddress(hCrt, "_vscwprintf");
+ _vsnprintf_ptr = (_vsnprintf_func)GetProcAddress(hCrt, "_vsnprintf");
+ _vsnwprintf_ptr = (_vsnwprintf_func)GetProcAddress(hCrt, "_vsnwprintf");
+ vswprintf_ptr = (vswprintf_func)GetProcAddress(hCrt, "vswprintf");
+ vsprintf_ptr = (vsprintf_func)GetProcAddress(hCrt, "vsprintf");
} }
#endif
-int __stdcall ChTraitsCRT<wchar_t>::GetFormattedLength( LPCWSTR pszFormat, va_list args )
+int __stdcall ChTraitsCRT<wchar_t>::GetFormattedLength(LPCWSTR pszFormat, va_list args)
{
#if _MSC_VER < 1400
checkCrt();
- if ( _vscwprintf_ptr != NULL )
- return _vscwprintf_ptr( pszFormat, args );
+ if (_vscwprintf_ptr != NULL)
+ return _vscwprintf_ptr(pszFormat, args);
WCHAR buf[ 4000 ];
- return vswprintf_ptr( buf, SIZEOF(buf), pszFormat, args );
+ return vswprintf_ptr(buf, SIZEOF(buf), pszFormat, args);
#else
- return _vscwprintf( pszFormat, args );
+ return _vscwprintf(pszFormat, args);
#endif
}
-int __stdcall ChTraitsCRT<wchar_t>::Format( LPWSTR pszBuffer, size_t nLength, LPCWSTR pszFormat, va_list args)
+int __stdcall ChTraitsCRT<wchar_t>::Format(LPWSTR pszBuffer, size_t nLength, LPCWSTR pszFormat, va_list args)
{
#if _MSC_VER < 1400
checkCrt();
- if ( _vsnwprintf_ptr != NULL )
- return _vsnwprintf_ptr( pszBuffer, nLength, pszFormat, args );
+ if (_vsnwprintf_ptr != NULL)
+ return _vsnwprintf_ptr(pszBuffer, nLength, pszFormat, args);
- return vswprintf_ptr( pszBuffer, nLength, pszFormat, args );
+ return vswprintf_ptr(pszBuffer, nLength, pszFormat, args);
#else
- return _vsnwprintf( pszBuffer, nLength, pszFormat, args );
+ return _vsnwprintf(pszBuffer, nLength, pszFormat, args);
#endif
}
/////////////////////////////////////////////////////////////////////////////////////////
// ChTraitsCRT<char>
-int __stdcall ChTraitsCRT<char>::GetFormattedLength( LPCSTR pszFormat, va_list args )
+int __stdcall ChTraitsCRT<char>::GetFormattedLength(LPCSTR pszFormat, va_list args)
{
#if _MSC_VER < 1400
checkCrt();
- if ( _vscprintf_ptr != NULL )
- return _vscprintf_ptr( pszFormat, args );
+ if (_vscprintf_ptr != NULL)
+ return _vscprintf_ptr(pszFormat, args);
char buf[4000];
- return vsprintf_ptr( buf, sizeof(buf), pszFormat, args );
+ return vsprintf_ptr(buf, sizeof(buf), pszFormat, args);
#else
- return _vscprintf( pszFormat, args );
+ return _vscprintf(pszFormat, args);
#endif
}
-int __stdcall ChTraitsCRT<char>::Format( LPSTR pszBuffer, size_t nlength, LPCSTR pszFormat, va_list args )
+int __stdcall ChTraitsCRT<char>::Format(LPSTR pszBuffer, size_t nlength, LPCSTR pszFormat, va_list args)
{
#if _MSC_VER < 1400
checkCrt();
- return _vsnprintf( pszBuffer, nlength, pszFormat, args );
+ return _vsnprintf(pszBuffer, nlength, pszFormat, args);
#else
- return vsprintf_s( pszBuffer, nlength, pszFormat, args );
+ return vsprintf_s(pszBuffer, nlength, pszFormat, args);
#endif
}
diff --git a/protocols/JabberG/src/MString.h b/protocols/JabberG/src/MString.h index 7cc16ff4a3..5864b13327 100644 --- a/protocols/JabberG/src/MString.h +++ b/protocols/JabberG/src/MString.h @@ -108,29 +108,29 @@ public: CMSimpleStringT(const CMSimpleStringT& strSrc)
{
CMStringData* pSrcData = strSrc.GetData();
- CMStringData* pNewData = CloneData( pSrcData );
- Attach( pNewData );
+ CMStringData* pNewData = CloneData(pSrcData);
+ Attach(pNewData);
}
CMSimpleStringT(PCXSTR pszSrc)
{
- int nLength = StringLength( pszSrc );
- CMStringData* pData = Allocate( nLength, sizeof( XCHAR ));
+ int nLength = StringLength(pszSrc);
+ CMStringData* pData = Allocate(nLength, sizeof(XCHAR));
if (pData != NULL)
{
- Attach( pData );
- SetLength( nLength );
- CopyChars( m_pszData, nLength, pszSrc, nLength );
+ Attach(pData);
+ SetLength(nLength);
+ CopyChars(m_pszData, nLength, pszSrc, nLength);
}
}
CMSimpleStringT(const XCHAR* pchSrc, int nLength)
{
- CMStringData* pData = Allocate( nLength, sizeof( XCHAR ));
- if ( pData != NULL )
+ CMStringData* pData = Allocate(nLength, sizeof(XCHAR));
+ if (pData != NULL)
{
- Attach( pData );
- SetLength( nLength );
- CopyChars( m_pszData, nLength, pchSrc, nLength );
+ Attach(pData);
+ SetLength(nLength);
+ CopyChars(m_pszData, nLength, pchSrc, nLength);
}
}
~CMSimpleStringT()
@@ -144,19 +144,19 @@ public: return *(CMSimpleStringT<BaseType>*)this;
}
- CMSimpleStringT& operator=(const CMSimpleStringT& strSrc )
+ CMSimpleStringT& operator=(const CMSimpleStringT& strSrc)
{
CMStringData* pSrcData = strSrc.GetData();
CMStringData* pOldData = GetData();
- if ( pSrcData != pOldData)
+ if (pSrcData != pOldData)
{
- if ( pOldData->IsLocked())
- SetString( strSrc.GetString(), strSrc.GetLength());
+ if (pOldData->IsLocked())
+ SetString(strSrc.GetString(), strSrc.GetLength());
else
{
- CMStringData* pNewData = CloneData( pSrcData );
+ CMStringData* pNewData = CloneData(pSrcData);
pOldData->Release();
- Attach( pNewData );
+ Attach(pNewData);
}
}
@@ -165,43 +165,43 @@ public: CMSimpleStringT& operator=(PCXSTR pszSrc)
{
- SetString( pszSrc );
+ SetString(pszSrc);
return *this;
}
- CMSimpleStringT& operator+=( const CMSimpleStringT& strSrc )
+ CMSimpleStringT& operator+=(const CMSimpleStringT& strSrc)
{
- Append( strSrc );
+ Append(strSrc);
return *this;
}
- CMSimpleStringT& operator+=( PCXSTR pszSrc )
+ CMSimpleStringT& operator+=(PCXSTR pszSrc)
{
- Append( pszSrc );
+ Append(pszSrc);
return *this;
}
- CMSimpleStringT& operator+=( char ch )
+ CMSimpleStringT& operator+=(char ch)
{
AppendChar(XCHAR(ch));
return *this;
}
- CMSimpleStringT& operator+=( unsigned char ch )
+ CMSimpleStringT& operator+=(unsigned char ch)
{
AppendChar(XCHAR(ch));
return *this;
}
- CMSimpleStringT& operator+=( wchar_t ch )
+ CMSimpleStringT& operator+=(wchar_t ch)
{
AppendChar(XCHAR(ch));
return *this;
}
- XCHAR operator[]( int iChar ) const
+ XCHAR operator[](int iChar) const
{
return m_pszData[iChar];
}
@@ -216,11 +216,11 @@ public: return m_pszData;
}
- void Append( PCXSTR pszSrc )
+ void Append(PCXSTR pszSrc)
{
- Append( pszSrc, StringLength( pszSrc ));
+ Append(pszSrc, StringLength(pszSrc));
}
- void Append( PCXSTR pszSrc, int nLength )
+ void Append(PCXSTR pszSrc, int nLength)
{
// See comment in SetString() about why we do this
UINT_PTR nOffset = pszSrc - GetString();
@@ -237,66 +237,66 @@ public: nLength = nLength > nSrcLength ? nSrcLength: nLength;
int nNewLength = nOldLength+nLength;
- PXSTR pszBuffer = GetBuffer( nNewLength );
- if ( nOffset <= nOldLength )
+ PXSTR pszBuffer = GetBuffer(nNewLength);
+ if (nOffset <= nOldLength)
{
pszSrc = pszBuffer+nOffset;
// No need to call CopyCharsOverlapped, since the destination is
// beyond the end of the original buffer
}
- CopyChars( pszBuffer+nOldLength, nLength, pszSrc, nLength );
- ReleaseBufferSetLength( nNewLength );
+ CopyChars(pszBuffer+nOldLength, nLength, pszSrc, nLength);
+ ReleaseBufferSetLength(nNewLength);
}
- void AppendChar( XCHAR ch )
+ void AppendChar(XCHAR ch)
{
UINT nOldLength = GetLength();
int nNewLength = nOldLength+1;
- PXSTR pszBuffer = GetBuffer( nNewLength );
+ PXSTR pszBuffer = GetBuffer(nNewLength);
pszBuffer[nOldLength] = ch;
- ReleaseBufferSetLength( nNewLength );
+ ReleaseBufferSetLength(nNewLength);
}
- void Append( const CMSimpleStringT& strSrc )
+ void Append(const CMSimpleStringT& strSrc)
{
- Append( strSrc.GetString(), strSrc.GetLength());
+ Append(strSrc.GetString(), strSrc.GetLength());
}
void Empty()
{
CMStringData* pOldData = GetData();
- if ( pOldData->nDataLength == 0 )
+ if (pOldData->nDataLength == 0)
return;
- if ( pOldData->IsLocked())
+ if (pOldData->IsLocked())
{
// Don't reallocate a locked buffer that's shrinking
- SetLength( 0 );
+ SetLength(0);
}
else
{
pOldData->Release();
CMStringData* pNewData = GetNilString();
- Attach( pNewData );
+ Attach(pNewData);
}
}
void FreeExtra()
{
CMStringData* pOldData = GetData();
int nLength = pOldData->nDataLength;
- if ( pOldData->nAllocLength == nLength )
+ if (pOldData->nAllocLength == nLength)
return;
if ( !pOldData->IsLocked()) // Don't reallocate a locked buffer that's shrinking
{
- CMStringData* pNewData = Allocate( nLength, sizeof( XCHAR ));
- if ( pNewData == NULL ) {
- SetLength( nLength );
+ CMStringData* pNewData = Allocate(nLength, sizeof(XCHAR));
+ if (pNewData == NULL) {
+ SetLength(nLength);
return;
}
- CopyChars( PXSTR( pNewData->data()), nLength, PCXSTR( pOldData->data()), nLength );
+ CopyChars(PXSTR(pNewData->data()), nLength, PCXSTR(pOldData->data()), nLength);
pOldData->Release();
- Attach( pNewData );
- SetLength( nLength );
+ Attach(pNewData);
+ SetLength(nLength);
}
}
@@ -304,26 +304,26 @@ public: {
return GetData()->nAllocLength;
}
- XCHAR GetAt( int iChar ) const
+ XCHAR GetAt(int iChar) const
{
return m_pszData[iChar];
}
PXSTR GetBuffer()
{
CMStringData* pData = GetData();
- if ( pData->IsShared())
- Fork( pData->nDataLength );
+ if (pData->IsShared())
+ Fork(pData->nDataLength);
return m_pszData;
}
- PXSTR GetBuffer( int nMinBufferLength )
+ PXSTR GetBuffer(int nMinBufferLength)
{
- return PrepareWrite( nMinBufferLength );
+ return PrepareWrite(nMinBufferLength);
}
- PXSTR GetBufferSetLength( int nLength )
+ PXSTR GetBufferSetLength(int nLength)
{
- PXSTR pszBuffer = GetBuffer( nLength );
- SetLength( nLength );
+ PXSTR pszBuffer = GetBuffer(nLength);
+ SetLength(nLength);
return pszBuffer;
}
@@ -343,9 +343,9 @@ public: PXSTR LockBuffer()
{
CMStringData* pData = GetData();
- if ( pData->IsShared())
+ if (pData->IsShared())
{
- Fork( pData->nDataLength );
+ Fork(pData->nDataLength);
pData = GetData(); // Do it again, because the fork might have changed it
}
pData->Lock();
@@ -357,43 +357,43 @@ public: CMStringData* pData = GetData();
pData->Unlock();
}
- void Preallocate( int nLength )
+ void Preallocate(int nLength)
{
- PrepareWrite( nLength );
+ PrepareWrite(nLength);
}
- void ReleaseBuffer( int nNewLength = -1 )
+ void ReleaseBuffer(int nNewLength = -1)
{
- if ( nNewLength == -1 )
+ if (nNewLength == -1)
{
int nAlloc = GetData()->nAllocLength;
- nNewLength = StringLengthN( m_pszData, nAlloc);
+ nNewLength = StringLengthN(m_pszData, nAlloc);
}
- SetLength( nNewLength );
+ SetLength(nNewLength);
}
- void ReleaseBufferSetLength( int nNewLength )
+ void ReleaseBufferSetLength(int nNewLength)
{
- SetLength( nNewLength );
+ SetLength(nNewLength);
}
- void Truncate( int nNewLength )
+ void Truncate(int nNewLength)
{
- GetBuffer( nNewLength );
- ReleaseBufferSetLength( nNewLength );
+ GetBuffer(nNewLength);
+ ReleaseBufferSetLength(nNewLength);
}
- void SetAt( int iChar, XCHAR ch )
+ void SetAt(int iChar, XCHAR ch)
{
int nLength = GetLength();
PXSTR pszBuffer = GetBuffer();
pszBuffer[iChar] = ch;
- ReleaseBufferSetLength( nLength );
+ ReleaseBufferSetLength(nLength);
}
- void SetString( PCXSTR pszSrc )
+ void SetString(PCXSTR pszSrc)
{
- SetString( pszSrc, StringLength( pszSrc ));
+ SetString(pszSrc, StringLength(pszSrc));
}
- void SetString( PCXSTR pszSrc, int nLength )
+ void SetString(PCXSTR pszSrc, int nLength)
{
- if ( nLength == 0 )
+ if (nLength == 0)
{
Empty();
}
@@ -403,17 +403,17 @@ public: UINT nOldLength = GetLength();
UINT_PTR nOffset = pszSrc - GetString();
- PXSTR pszBuffer = GetBuffer( nLength );
- if ( nOffset <= nOldLength )
+ PXSTR pszBuffer = GetBuffer(nLength);
+ if (nOffset <= nOldLength)
{
- CopyCharsOverlapped( pszBuffer, GetAllocLength(),
- pszBuffer+nOffset, nLength );
+ CopyCharsOverlapped(pszBuffer, GetAllocLength(),
+ pszBuffer+nOffset, nLength);
}
else
{
- CopyChars( pszBuffer, GetAllocLength(), pszSrc, nLength );
+ CopyChars(pszBuffer, GetAllocLength(), pszSrc, nLength);
}
- ReleaseBufferSetLength( nLength );
+ ReleaseBufferSetLength(nLength);
}
}
public:
@@ -421,7 +421,7 @@ public: {
CMSimpleStringT s;
- Concatenate( s, str1, str1.GetLength(), str2, str2.GetLength());
+ Concatenate(s, str1, str1.GetLength(), str2, str2.GetLength());
return s;
}
@@ -430,7 +430,7 @@ public: {
CMSimpleStringT s;
- Concatenate( s, str1, str1.GetLength(), psz2, StringLength( psz2 ));
+ Concatenate(s, str1, str1.GetLength(), psz2, StringLength(psz2));
return s;
}
@@ -439,19 +439,19 @@ public: {
CMSimpleStringT s;
- Concatenate( s, psz1, StringLength( psz1 ), str2, str2.GetLength());
+ Concatenate(s, psz1, StringLength(psz1), str2, str2.GetLength());
return s;
}
- static void __stdcall CopyChars(XCHAR* pchDest, const XCHAR* pchSrc, int nChars )
+ static void __stdcall CopyChars(XCHAR* pchDest, const XCHAR* pchSrc, int nChars)
{
#pragma warning (push)
#pragma warning(disable : 4996)
memcpy(pchDest, pchSrc, nChars * sizeof(XCHAR));
#pragma warning (pop)
}
- static void __stdcall CopyChars(XCHAR* pchDest, size_t nDestLen, const XCHAR* pchSrc, int nChars )
+ static void __stdcall CopyChars(XCHAR* pchDest, size_t nDestLen, const XCHAR* pchSrc, int nChars)
{
#if _MSC_VER >= 1400
memcpy_s(pchDest, nDestLen * sizeof(XCHAR), pchSrc, nChars * sizeof(XCHAR));
@@ -460,7 +460,7 @@ public: #endif
}
- static void __stdcall CopyCharsOverlapped(XCHAR* pchDest, const XCHAR* pchSrc, int nChars )
+ static void __stdcall CopyCharsOverlapped(XCHAR* pchDest, const XCHAR* pchSrc, int nChars)
{
#pragma warning (push)
#pragma warning(disable : 4996)
@@ -490,26 +490,26 @@ public: return int(wcslen(psz));
}
- static int __stdcall StringLengthN(const char* psz, size_t sizeInXChar )
+ static int __stdcall StringLengthN(const char* psz, size_t sizeInXChar)
{
- if ( psz == NULL )
+ if (psz == NULL)
return 0;
- return int( strnlen( psz, sizeInXChar ));
+ return int(strnlen(psz, sizeInXChar));
}
- static int __stdcall StringLengthN(const wchar_t* psz, size_t sizeInXChar )
+ static int __stdcall StringLengthN(const wchar_t* psz, size_t sizeInXChar)
{
- if ( psz == NULL )
+ if (psz == NULL)
return 0;
- return int( wcsnlen( psz, sizeInXChar ));
+ return int(wcsnlen(psz, sizeInXChar));
}
protected:
static void __stdcall Concatenate(CMSimpleStringT& strResult, PCXSTR psz1, int nLength1, PCXSTR psz2, int nLength2)
{
int nNewLength = nLength1+nLength2;
PXSTR pszBuffer = strResult.GetBuffer(nNewLength);
- CopyChars(pszBuffer, nLength1, psz1, nLength1 );
+ CopyChars(pszBuffer, nLength1, psz1, nLength1);
CopyChars(pszBuffer + nLength1, nLength2, psz2, nLength2);
strResult.ReleaseBufferSetLength(nNewLength);
}
@@ -527,7 +527,7 @@ private: if (pNewData != NULL)
{
int nCharsToCopy = ((nOldLength < nLength) ? nOldLength : nLength)+1; // Copy '\0'
- CopyChars( PXSTR( pNewData->data()), nCharsToCopy, PCXSTR( pOldData->data()), nCharsToCopy );
+ CopyChars(PXSTR(pNewData->data()), nCharsToCopy, PCXSTR(pOldData->data()), nCharsToCopy);
pNewData->nDataLength = nOldLength;
pOldData->Release();
Attach(pNewData);
@@ -537,12 +537,12 @@ private: {
return (reinterpret_cast<CMStringData *>(m_pszData) - 1);
}
- PXSTR PrepareWrite( int nLength )
+ PXSTR PrepareWrite(int nLength)
{
CMStringData* pOldData = GetData();
int nShared = 1 - pOldData->nRefs; // nShared < 0 means true, >= 0 means false
int nTooShort = pOldData->nAllocLength-nLength; // nTooShort < 0 means true, >= 0 means false
- if ((nShared | nTooShort) < 0 ) // If either sign bit is set (i.e. either is less than zero), we need to copy data
+ if ((nShared | nTooShort) < 0) // If either sign bit is set (i.e. either is less than zero), we need to copy data
PrepareWrite2(nLength);
return m_pszData;
@@ -561,29 +561,29 @@ private: {
// Grow exponentially, until we hit 1K.
int nNewLength = pOldData->nAllocLength;
- if ( nNewLength > 1024 )
+ if (nNewLength > 1024)
nNewLength += 1024;
else
nNewLength *= 2;
- if ( nNewLength < nLength )
+ if (nNewLength < nLength)
nNewLength = nLength;
- Reallocate( nNewLength );
+ Reallocate(nNewLength);
}
}
- void Reallocate( int nLength )
+ void Reallocate(int nLength)
{
CMStringData* pOldData = GetData();
- if ( pOldData->nAllocLength >= nLength || nLength <= 0)
+ if (pOldData->nAllocLength >= nLength || nLength <= 0)
return;
- CMStringData* pNewData = Realloc( pOldData, nLength, sizeof( XCHAR ));
- if ( pNewData != NULL )
- Attach( pNewData );
+ CMStringData* pNewData = Realloc(pOldData, nLength, sizeof(XCHAR));
+ if (pNewData != NULL)
+ Attach(pNewData);
}
- void SetLength( int nLength )
+ void SetLength(int nLength)
{
GetData()->nDataLength = nLength;
m_pszData[nLength] = 0;
@@ -593,7 +593,7 @@ private: {
CMStringData* pNewData = NULL;
- if (!pData->IsLocked()) {
+ if ( !pData->IsLocked()) {
pNewData = pData;
pNewData->AddRef();
}
@@ -612,184 +612,184 @@ template< typename _CharType = char > class ChTraitsCRT : public ChTraitsBase< _CharType >
{
public:
- static char* __stdcall CharNext( const char* p )
+ static char* __stdcall CharNext(const char* p)
{
- return reinterpret_cast< char* >( _mbsinc( reinterpret_cast< const unsigned char* >( p )));
+ return reinterpret_cast< char* >(_mbsinc(reinterpret_cast< const unsigned char* >(p)));
}
- static int __stdcall IsDigit( char ch )
+ static int __stdcall IsDigit(char ch)
{
- return _ismbcdigit( ch );
+ return _ismbcdigit(ch);
}
- static int __stdcall IsSpace( char ch )
+ static int __stdcall IsSpace(char ch)
{
- return _ismbcspace( ch );
+ return _ismbcspace(ch);
}
- static int __stdcall StringCompare( LPCSTR pszA, LPCSTR pszB )
+ static int __stdcall StringCompare(LPCSTR pszA, LPCSTR pszB)
{
- return _mbscmp( reinterpret_cast< const unsigned char* >( pszA ), reinterpret_cast< const unsigned char* >( pszB ));
+ return _mbscmp(reinterpret_cast< const unsigned char* >(pszA), reinterpret_cast< const unsigned char* >(pszB));
}
- static int __stdcall StringCompareIgnore( LPCSTR pszA, LPCSTR pszB )
+ static int __stdcall StringCompareIgnore(LPCSTR pszA, LPCSTR pszB)
{
- return _mbsicmp( reinterpret_cast< const unsigned char* >( pszA ), reinterpret_cast< const unsigned char* >( pszB ));
+ return _mbsicmp(reinterpret_cast< const unsigned char* >(pszA), reinterpret_cast< const unsigned char* >(pszB));
}
- static int __stdcall StringCollate( LPCSTR pszA, LPCSTR pszB )
+ static int __stdcall StringCollate(LPCSTR pszA, LPCSTR pszB)
{
- return _mbscoll( reinterpret_cast< const unsigned char* >( pszA ), reinterpret_cast< const unsigned char* >( pszB ));
+ return _mbscoll(reinterpret_cast< const unsigned char* >(pszA), reinterpret_cast< const unsigned char* >(pszB));
}
- static int __stdcall StringCollateIgnore( LPCSTR pszA, LPCSTR pszB )
+ static int __stdcall StringCollateIgnore(LPCSTR pszA, LPCSTR pszB)
{
- return _mbsicoll( reinterpret_cast< const unsigned char* >( pszA ), reinterpret_cast< const unsigned char* >( pszB ));
+ return _mbsicoll(reinterpret_cast< const unsigned char* >(pszA), reinterpret_cast< const unsigned char* >(pszB));
}
- static LPCSTR __stdcall StringFindString( LPCSTR pszBlock, LPCSTR pszMatch )
+ static LPCSTR __stdcall StringFindString(LPCSTR pszBlock, LPCSTR pszMatch)
{
- return reinterpret_cast< LPCSTR >( _mbsstr( reinterpret_cast< const unsigned char* >( pszBlock ),
- reinterpret_cast< const unsigned char* >( pszMatch )));
+ return reinterpret_cast< LPCSTR >(_mbsstr(reinterpret_cast< const unsigned char* >(pszBlock),
+ reinterpret_cast< const unsigned char* >(pszMatch)));
}
- static LPSTR __stdcall StringFindString( LPSTR pszBlock, LPCSTR pszMatch )
+ static LPSTR __stdcall StringFindString(LPSTR pszBlock, LPCSTR pszMatch)
{
- return const_cast< LPSTR >( StringFindString( const_cast< LPCSTR >( pszBlock ), pszMatch ));
+ return const_cast< LPSTR >(StringFindString(const_cast< LPCSTR >(pszBlock), pszMatch));
}
- static LPCSTR __stdcall StringFindChar( LPCSTR pszBlock, char chMatch )
+ static LPCSTR __stdcall StringFindChar(LPCSTR pszBlock, char chMatch)
{
- return reinterpret_cast< LPCSTR >( _mbschr( reinterpret_cast< const unsigned char* >( pszBlock ), (unsigned char)chMatch ));
+ return reinterpret_cast< LPCSTR >(_mbschr(reinterpret_cast< const unsigned char* >(pszBlock), (unsigned char)chMatch));
}
- static LPCSTR __stdcall StringFindCharRev( LPCSTR psz, char ch )
+ static LPCSTR __stdcall StringFindCharRev(LPCSTR psz, char ch)
{
- return reinterpret_cast< LPCSTR >( _mbsrchr( reinterpret_cast< const unsigned char* >( psz ), (unsigned char)ch ));
+ return reinterpret_cast< LPCSTR >(_mbsrchr(reinterpret_cast< const unsigned char* >(psz), (unsigned char)ch));
}
- static LPCSTR __stdcall StringScanSet( LPCSTR pszBlock, LPCSTR pszMatch )
+ static LPCSTR __stdcall StringScanSet(LPCSTR pszBlock, LPCSTR pszMatch)
{
- return reinterpret_cast< LPCSTR >( _mbspbrk( reinterpret_cast< const unsigned char* >( pszBlock ),
- reinterpret_cast< const unsigned char* >( pszMatch )));
+ return reinterpret_cast< LPCSTR >(_mbspbrk(reinterpret_cast< const unsigned char* >(pszBlock),
+ reinterpret_cast< const unsigned char* >(pszMatch)));
}
- static int __stdcall StringSpanIncluding( LPCSTR pszBlock, LPCSTR pszSet )
+ static int __stdcall StringSpanIncluding(LPCSTR pszBlock, LPCSTR pszSet)
{
- return (int)_mbsspn( reinterpret_cast< const unsigned char* >( pszBlock ), reinterpret_cast< const unsigned char* >( pszSet ));
+ return (int)_mbsspn(reinterpret_cast< const unsigned char* >(pszBlock), reinterpret_cast< const unsigned char* >(pszSet));
}
- static int __stdcall StringSpanExcluding( LPCSTR pszBlock, LPCSTR pszSet )
+ static int __stdcall StringSpanExcluding(LPCSTR pszBlock, LPCSTR pszSet)
{
- return (int)_mbscspn( reinterpret_cast< const unsigned char* >( pszBlock ), reinterpret_cast< const unsigned char* >( pszSet ));
+ return (int)_mbscspn(reinterpret_cast< const unsigned char* >(pszBlock), reinterpret_cast< const unsigned char* >(pszSet));
}
- static LPSTR __stdcall StringUppercase( LPSTR psz )
+ static LPSTR __stdcall StringUppercase(LPSTR psz)
{
#pragma warning (push)
#pragma warning(disable : 4996)
- return reinterpret_cast< LPSTR >( _mbsupr( reinterpret_cast< unsigned char* >( psz )) );
+ return reinterpret_cast< LPSTR >(_mbsupr(reinterpret_cast< unsigned char* >(psz)));
#pragma warning (pop)
}
- static LPSTR __stdcall StringLowercase( LPSTR psz )
+ static LPSTR __stdcall StringLowercase(LPSTR psz)
{
#pragma warning (push)
#pragma warning(disable : 4996)
- return reinterpret_cast< LPSTR >( _mbslwr( reinterpret_cast< unsigned char* >( psz )) );
+ return reinterpret_cast< LPSTR >(_mbslwr(reinterpret_cast< unsigned char* >(psz)));
#pragma warning (pop)
}
- static LPSTR __stdcall StringUppercase( LPSTR psz, size_t size )
+ static LPSTR __stdcall StringUppercase(LPSTR psz, size_t size)
{
#if _MSC_VER >= 1400
- _mbsupr_s(reinterpret_cast< unsigned char* >( psz ), size);
+ _mbsupr_s(reinterpret_cast< unsigned char* >(psz), size);
#else
- _mbsupr(reinterpret_cast< unsigned char* >( psz ));
+ _mbsupr(reinterpret_cast< unsigned char* >(psz));
#endif
return psz;
}
- static LPSTR __stdcall StringLowercase( LPSTR psz, size_t size )
+ static LPSTR __stdcall StringLowercase(LPSTR psz, size_t size)
{
#if _MSC_VER >= 1400
- _mbslwr_s( reinterpret_cast< unsigned char* >( psz ), size );
+ _mbslwr_s(reinterpret_cast< unsigned char* >(psz), size);
#else
- _mbslwr(reinterpret_cast< unsigned char* >( psz ));
+ _mbslwr(reinterpret_cast< unsigned char* >(psz));
#endif
return psz;
}
- static LPSTR __stdcall StringReverse( LPSTR psz )
+ static LPSTR __stdcall StringReverse(LPSTR psz)
{
- return reinterpret_cast< LPSTR >( _mbsrev( reinterpret_cast< unsigned char* >( psz )) );
+ return reinterpret_cast< LPSTR >(_mbsrev(reinterpret_cast< unsigned char* >(psz)));
}
- static int __stdcall GetFormattedLength( LPCSTR pszFormat, va_list args );
+ static int __stdcall GetFormattedLength(LPCSTR pszFormat, va_list args);
- static int __stdcall Format( LPSTR pszBuffer, LPCSTR pszFormat, va_list args )
+ static int __stdcall Format(LPSTR pszBuffer, LPCSTR pszFormat, va_list args)
{
#pragma warning (push)
#pragma warning(disable : 4996)
- return vsprintf( pszBuffer, pszFormat, args );
+ return vsprintf(pszBuffer, pszFormat, args);
#pragma warning (pop)
}
- static int __stdcall Format( LPSTR pszBuffer, size_t nlength, LPCSTR pszFormat, va_list args );
+ static int __stdcall Format(LPSTR pszBuffer, size_t nlength, LPCSTR pszFormat, va_list args);
- static int __stdcall GetBaseTypeLength( LPCSTR pszSrc )
+ static int __stdcall GetBaseTypeLength(LPCSTR pszSrc)
{
// Returns required buffer length in XCHARs
- return int( strlen( pszSrc ));
+ return int(strlen(pszSrc));
}
- static int __stdcall GetBaseTypeLength( LPCSTR pszSrc, int nLength )
+ static int __stdcall GetBaseTypeLength(LPCSTR pszSrc, int nLength)
{
(void)pszSrc;
// Returns required buffer length in XCHARs
return nLength;
}
- static int __stdcall GetBaseTypeLength( LPCWSTR pszSource )
+ static int __stdcall GetBaseTypeLength(LPCWSTR pszSource)
{
// Returns required buffer length in XCHARs
- return ::WideCharToMultiByte( _AtlGetConversionACP(), 0, pszSource, -1, NULL, 0, NULL, NULL )-1;
+ return ::WideCharToMultiByte(_AtlGetConversionACP(), 0, pszSource, -1, NULL, 0, NULL, NULL)-1;
}
- static int __stdcall GetBaseTypeLength( LPCWSTR pszSource, int nLength )
+ static int __stdcall GetBaseTypeLength(LPCWSTR pszSource, int nLength)
{
// Returns required buffer length in XCHARs
- return ::WideCharToMultiByte( _AtlGetConversionACP(), 0, pszSource, nLength, NULL, 0, NULL, NULL );
+ return ::WideCharToMultiByte(_AtlGetConversionACP(), 0, pszSource, nLength, NULL, 0, NULL, NULL);
}
- static void __stdcall ConvertToBaseType( LPSTR pszDest, int nDestLength, LPCSTR pszSrc, int nSrcLength = -1 )
+ static void __stdcall ConvertToBaseType(LPSTR pszDest, int nDestLength, LPCSTR pszSrc, int nSrcLength = -1)
{
if (nSrcLength == -1) { nSrcLength=1 + GetBaseTypeLength(pszSrc); }
// nLen is in XCHARs
- memcpy_s( pszDest, nDestLength*sizeof( char ),
- pszSrc, nSrcLength*sizeof( char ));
+ memcpy_s(pszDest, nDestLength*sizeof(char),
+ pszSrc, nSrcLength*sizeof(char));
}
- static void __stdcall ConvertToBaseType( LPSTR pszDest, int nDestLength, LPCWSTR pszSrc, int nSrcLength = -1)
+ static void __stdcall ConvertToBaseType(LPSTR pszDest, int nDestLength, LPCWSTR pszSrc, int nSrcLength = -1)
{
// nLen is in XCHARs
- ::WideCharToMultiByte( _AtlGetConversionACP(), 0, pszSrc, nSrcLength, pszDest, nDestLength, NULL, NULL );
+ ::WideCharToMultiByte(_AtlGetConversionACP(), 0, pszSrc, nSrcLength, pszDest, nDestLength, NULL, NULL);
}
- static void ConvertToOem( _CharType* pstrString)
+ static void ConvertToOem(_CharType* pstrString)
{
BOOL fSuccess=::CharToOemA(pstrString, pstrString);
}
- static void ConvertToAnsi( _CharType* pstrString)
+ static void ConvertToAnsi(_CharType* pstrString)
{
BOOL fSuccess=::OemToCharA(pstrString, pstrString);
}
- static void ConvertToOem( _CharType* pstrString, size_t size)
+ static void ConvertToOem(_CharType* pstrString, size_t size)
{
- if(size>UINT_MAX)
+ if (size>UINT_MAX)
{
return;
}
@@ -797,68 +797,68 @@ public: BOOL fSuccess=::CharToOemBuffA(pstrString, pstrString, dwSize);
}
- static void ConvertToAnsi( _CharType* pstrString, size_t size)
+ static void ConvertToAnsi(_CharType* pstrString, size_t size)
{
- if(size>UINT_MAX)
+ if (size>UINT_MAX)
return;
DWORD dwSize=static_cast<DWORD>(size);
BOOL fSuccess=::OemToCharBuffA(pstrString, pstrString, dwSize);
}
- static void __stdcall FloodCharacters( char ch, int nLength, char* pch )
+ static void __stdcall FloodCharacters(char ch, int nLength, char* pch)
{
// nLength is in XCHARs
- memset( pch, ch, nLength );
+ memset(pch, ch, nLength);
}
- static BSTR __stdcall AllocSysString( const char* pchData, int nDataLength )
+ static BSTR __stdcall AllocSysString(const char* pchData, int nDataLength)
{
- int nLen = ::MultiByteToWideChar( _AtlGetConversionACP(), 0, pchData, nDataLength, NULL, NULL );
- BSTR bstr = ::SysAllocStringLen( NULL, nLen );
- if ( bstr != NULL )
- ::MultiByteToWideChar( _AtlGetConversionACP(), 0, pchData, nDataLength, bstr, nLen );
+ int nLen = ::MultiByteToWideChar(_AtlGetConversionACP(), 0, pchData, nDataLength, NULL, NULL);
+ BSTR bstr = ::SysAllocStringLen(NULL, nLen);
+ if (bstr != NULL)
+ ::MultiByteToWideChar(_AtlGetConversionACP(), 0, pchData, nDataLength, bstr, nLen);
return bstr;
}
- static BOOL __stdcall ReAllocSysString( const char* pchData, BSTR* pbstr, int nDataLength )
+ static BOOL __stdcall ReAllocSysString(const char* pchData, BSTR* pbstr, int nDataLength)
{
- int nLen = ::MultiByteToWideChar( _AtlGetConversionACP(), 0, pchData, nDataLength, NULL, NULL );
- BOOL bSuccess = ::SysReAllocStringLen( pbstr, NULL, nLen );
- if ( bSuccess )
- ::MultiByteToWideChar( _AtlGetConversionACP(), 0, pchData, nDataLength, *pbstr, nLen );
+ int nLen = ::MultiByteToWideChar(_AtlGetConversionACP(), 0, pchData, nDataLength, NULL, NULL);
+ BOOL bSuccess = ::SysReAllocStringLen(pbstr, NULL, nLen);
+ if (bSuccess)
+ ::MultiByteToWideChar(_AtlGetConversionACP(), 0, pchData, nDataLength, *pbstr, nLen);
return bSuccess;
}
- static int __stdcall SafeStringLen( LPCSTR psz )
+ static int __stdcall SafeStringLen(LPCSTR psz)
{
// returns length in bytes
- return (psz != NULL) ? int( strlen( psz )) : 0;
+ return (psz != NULL) ? int(strlen(psz)) : 0;
}
- static int __stdcall SafeStringLen( LPCWSTR psz )
+ static int __stdcall SafeStringLen(LPCWSTR psz)
{
// returns length in wchar_ts
- return (psz != NULL) ? int( wcslen( psz )) : 0;
+ return (psz != NULL) ? int(wcslen(psz)) : 0;
}
- static int __stdcall GetCharLen( const wchar_t* pch )
+ static int __stdcall GetCharLen(const wchar_t* pch)
{
// returns char length
return 1;
}
- static int __stdcall GetCharLen( const char* pch )
+ static int __stdcall GetCharLen(const char* pch)
{
// returns char length
- return int( _mbclen( reinterpret_cast< const unsigned char* >( pch )) );
+ return int(_mbclen(reinterpret_cast< const unsigned char* >(pch)));
}
- static DWORD __stdcall GetEnvironmentVariable( LPCSTR pszVar, LPSTR pszBuffer, DWORD dwSize )
+ static DWORD __stdcall GetEnvironmentVariable(LPCSTR pszVar, LPSTR pszBuffer, DWORD dwSize)
{
- return ::GetEnvironmentVariableA( pszVar, pszBuffer, dwSize );
+ return ::GetEnvironmentVariableA(pszVar, pszBuffer, dwSize);
}
};
@@ -866,157 +866,157 @@ public: template<>
class ChTraitsCRT< wchar_t > : public ChTraitsBase< wchar_t >
{
- static DWORD __stdcall _GetEnvironmentVariableW( LPCWSTR pszName, LPWSTR pszBuffer, DWORD nSize )
+ static DWORD __stdcall _GetEnvironmentVariableW(LPCWSTR pszName, LPWSTR pszBuffer, DWORD nSize)
{
- return ::GetEnvironmentVariableW( pszName, pszBuffer, nSize );
+ return ::GetEnvironmentVariableW(pszName, pszBuffer, nSize);
}
public:
- static LPWSTR __stdcall CharNext( LPCWSTR psz )
+ static LPWSTR __stdcall CharNext(LPCWSTR psz)
{
- return const_cast< LPWSTR >( psz+1 );
+ return const_cast< LPWSTR >(psz+1);
}
- static int __stdcall IsDigit( wchar_t ch )
+ static int __stdcall IsDigit(wchar_t ch)
{
- return iswdigit( static_cast<unsigned short>(ch));
+ return iswdigit(static_cast<unsigned short>(ch));
}
- static int __stdcall IsSpace( wchar_t ch )
+ static int __stdcall IsSpace(wchar_t ch)
{
- return iswspace( static_cast<unsigned short>(ch));
+ return iswspace(static_cast<unsigned short>(ch));
}
- static int __stdcall StringCompare( LPCWSTR pszA, LPCWSTR pszB )
+ static int __stdcall StringCompare(LPCWSTR pszA, LPCWSTR pszB)
{
- return wcscmp( pszA, pszB );
+ return wcscmp(pszA, pszB);
}
- static int __stdcall StringCompareIgnore( LPCWSTR pszA, LPCWSTR pszB )
+ static int __stdcall StringCompareIgnore(LPCWSTR pszA, LPCWSTR pszB)
{
- return _wcsicmp( pszA, pszB );
+ return _wcsicmp(pszA, pszB);
}
- static int __stdcall StringCollate( LPCWSTR pszA, LPCWSTR pszB )
+ static int __stdcall StringCollate(LPCWSTR pszA, LPCWSTR pszB)
{
- return wcscoll( pszA, pszB );
+ return wcscoll(pszA, pszB);
}
- static int __stdcall StringCollateIgnore( LPCWSTR pszA, LPCWSTR pszB )
+ static int __stdcall StringCollateIgnore(LPCWSTR pszA, LPCWSTR pszB)
{
- return _wcsicoll( pszA, pszB );
+ return _wcsicoll(pszA, pszB);
}
- static LPCWSTR __stdcall StringFindString( LPCWSTR pszBlock, LPCWSTR pszMatch )
+ static LPCWSTR __stdcall StringFindString(LPCWSTR pszBlock, LPCWSTR pszMatch)
{
- return wcsstr( pszBlock, pszMatch );
+ return wcsstr(pszBlock, pszMatch);
}
- static LPWSTR __stdcall StringFindString( LPWSTR pszBlock, LPCWSTR pszMatch )
+ static LPWSTR __stdcall StringFindString(LPWSTR pszBlock, LPCWSTR pszMatch)
{
- return const_cast< LPWSTR >( StringFindString( const_cast< LPCWSTR >( pszBlock ), pszMatch ));
+ return const_cast< LPWSTR >(StringFindString(const_cast< LPCWSTR >(pszBlock), pszMatch));
}
- static LPCWSTR __stdcall StringFindChar( LPCWSTR pszBlock, wchar_t chMatch )
+ static LPCWSTR __stdcall StringFindChar(LPCWSTR pszBlock, wchar_t chMatch)
{
- return wcschr( pszBlock, chMatch );
+ return wcschr(pszBlock, chMatch);
}
- static LPCWSTR __stdcall StringFindCharRev( LPCWSTR psz, wchar_t ch )
+ static LPCWSTR __stdcall StringFindCharRev(LPCWSTR psz, wchar_t ch)
{
- return wcsrchr( psz, ch );
+ return wcsrchr(psz, ch);
}
- static LPCWSTR __stdcall StringScanSet( LPCWSTR pszBlock, LPCWSTR pszMatch )
+ static LPCWSTR __stdcall StringScanSet(LPCWSTR pszBlock, LPCWSTR pszMatch)
{
- return wcspbrk( pszBlock, pszMatch );
+ return wcspbrk(pszBlock, pszMatch);
}
- static int __stdcall StringSpanIncluding( LPCWSTR pszBlock, LPCWSTR pszSet )
+ static int __stdcall StringSpanIncluding(LPCWSTR pszBlock, LPCWSTR pszSet)
{
- return (int)wcsspn( pszBlock, pszSet );
+ return (int)wcsspn(pszBlock, pszSet);
}
- static int __stdcall StringSpanExcluding( LPCWSTR pszBlock, LPCWSTR pszSet )
+ static int __stdcall StringSpanExcluding(LPCWSTR pszBlock, LPCWSTR pszSet)
{
- return (int)wcscspn( pszBlock, pszSet );
+ return (int)wcscspn(pszBlock, pszSet);
}
- static LPWSTR __stdcall StringUppercase( LPWSTR psz )
+ static LPWSTR __stdcall StringUppercase(LPWSTR psz)
{
#pragma warning (push)
#pragma warning(disable : 4996)
- return _wcsupr( psz );
+ return _wcsupr(psz);
#pragma warning (pop)
}
- static LPWSTR __stdcall StringLowercase( LPWSTR psz )
+ static LPWSTR __stdcall StringLowercase(LPWSTR psz)
{
#pragma warning (push)
#pragma warning(disable : 4996)
- return _wcslwr( psz );
+ return _wcslwr(psz);
#pragma warning (pop)
}
- static LPWSTR __stdcall StringUppercase( LPWSTR psz, size_t )
+ static LPWSTR __stdcall StringUppercase(LPWSTR psz, size_t)
{
- return _wcsupr( psz );
+ return _wcsupr(psz);
}
- static LPWSTR __stdcall StringLowercase( LPWSTR psz, size_t )
+ static LPWSTR __stdcall StringLowercase(LPWSTR psz, size_t)
{
- return _wcslwr( psz );
+ return _wcslwr(psz);
}
- static LPWSTR __stdcall StringReverse( LPWSTR psz )
+ static LPWSTR __stdcall StringReverse(LPWSTR psz)
{
- return _wcsrev( psz );
+ return _wcsrev(psz);
}
- static int __stdcall GetFormattedLength( LPCWSTR pszFormat, va_list args);
+ static int __stdcall GetFormattedLength(LPCWSTR pszFormat, va_list args);
- static int __stdcall Format( LPWSTR pszBuffer, LPCWSTR pszFormat, va_list args)
+ static int __stdcall Format(LPWSTR pszBuffer, LPCWSTR pszFormat, va_list args)
{
#pragma warning (push)
#pragma warning(disable : 4996)
- return vswprintf( pszBuffer, pszFormat, args );
+ return vswprintf(pszBuffer, pszFormat, args);
#pragma warning (pop)
}
- static int __stdcall Format( LPWSTR pszBuffer, size_t nLength, LPCWSTR pszFormat, va_list args);
+ static int __stdcall Format(LPWSTR pszBuffer, size_t nLength, LPCWSTR pszFormat, va_list args);
- static int __stdcall GetBaseTypeLength( LPCSTR pszSrc )
+ static int __stdcall GetBaseTypeLength(LPCSTR pszSrc)
{
// Returns required buffer size in wchar_ts
- return ::MultiByteToWideChar( CP_ACP, 0, pszSrc, -1, NULL, 0 )-1;
+ return ::MultiByteToWideChar(CP_ACP, 0, pszSrc, -1, NULL, 0)-1;
}
- static int __stdcall GetBaseTypeLength( LPCSTR pszSrc, int nLength )
+ static int __stdcall GetBaseTypeLength(LPCSTR pszSrc, int nLength)
{
// Returns required buffer size in wchar_ts
- return ::MultiByteToWideChar( CP_ACP, 0, pszSrc, nLength, NULL, 0 );
+ return ::MultiByteToWideChar(CP_ACP, 0, pszSrc, nLength, NULL, 0);
}
- static int __stdcall GetBaseTypeLength( LPCWSTR pszSrc )
+ static int __stdcall GetBaseTypeLength(LPCWSTR pszSrc)
{
// Returns required buffer size in wchar_ts
- return (int)wcslen( pszSrc );
+ return (int)wcslen(pszSrc);
}
- static int __stdcall GetBaseTypeLength( LPCWSTR pszSrc, int nLength )
+ static int __stdcall GetBaseTypeLength(LPCWSTR pszSrc, int nLength)
{
(void)pszSrc;
// Returns required buffer size in wchar_ts
return nLength;
}
- static void __stdcall ConvertToBaseType( LPWSTR pszDest, int nDestLength, LPCSTR pszSrc, int nSrcLength = -1)
+ static void __stdcall ConvertToBaseType(LPWSTR pszDest, int nDestLength, LPCSTR pszSrc, int nSrcLength = -1)
{
// nLen is in wchar_ts
- ::MultiByteToWideChar( CP_ACP, 0, pszSrc, nSrcLength, pszDest, nDestLength );
+ ::MultiByteToWideChar(CP_ACP, 0, pszSrc, nSrcLength, pszDest, nDestLength);
}
- static void __stdcall ConvertToBaseType( LPWSTR pszDest, int nDestLength, LPCWSTR pszSrc, int nSrcLength = -1 )
+ static void __stdcall ConvertToBaseType(LPWSTR pszDest, int nDestLength, LPCWSTR pszSrc, int nSrcLength = -1)
{
if (nSrcLength == -1) { nSrcLength=1 + GetBaseTypeLength(pszSrc); }
// nLen is in wchar_ts
@@ -1027,68 +1027,68 @@ public: #endif
}
- static void __stdcall FloodCharacters( wchar_t ch, int nLength, LPWSTR psz )
+ static void __stdcall FloodCharacters(wchar_t ch, int nLength, LPWSTR psz)
{
// nLength is in XCHARs
- for ( int i = 0; i < nLength; i++ )
+ for (int i = 0; i < nLength; i++)
{
psz[i] = ch;
}
}
- static BSTR __stdcall AllocSysString( const wchar_t* pchData, int nDataLength )
+ static BSTR __stdcall AllocSysString(const wchar_t* pchData, int nDataLength)
{
- return ::SysAllocStringLen( pchData, nDataLength );
+ return ::SysAllocStringLen(pchData, nDataLength);
}
- static BOOL __stdcall ReAllocSysString( const wchar_t* pchData, BSTR* pbstr, int nDataLength )
+ static BOOL __stdcall ReAllocSysString(const wchar_t* pchData, BSTR* pbstr, int nDataLength)
{
- return ::SysReAllocStringLen( pbstr, pchData, nDataLength );
+ return ::SysReAllocStringLen(pbstr, pchData, nDataLength);
}
- static int __stdcall SafeStringLen( LPCSTR psz )
+ static int __stdcall SafeStringLen(LPCSTR psz)
{
// returns length in bytes
- return (psz != NULL) ? (int)strlen( psz ) : 0;
+ return (psz != NULL) ? (int)strlen(psz) : 0;
}
- static int __stdcall SafeStringLen( LPCWSTR psz )
+ static int __stdcall SafeStringLen(LPCWSTR psz)
{
// returns length in wchar_ts
- return (psz != NULL) ? (int)wcslen( psz ) : 0;
+ return (psz != NULL) ? (int)wcslen(psz) : 0;
}
- static int __stdcall GetCharLen( const wchar_t* pch )
+ static int __stdcall GetCharLen(const wchar_t* pch)
{
(void)pch;
// returns char length
return 1;
}
- static int __stdcall GetCharLen( const char* pch )
+ static int __stdcall GetCharLen(const char* pch)
{
// returns char length
- return (int)( _mbclen( reinterpret_cast< const unsigned char* >( pch )) );
+ return (int)(_mbclen(reinterpret_cast< const unsigned char* >(pch)));
}
- static DWORD __stdcall GetEnvironmentVariable( LPCWSTR pszVar, LPWSTR pszBuffer, DWORD dwSize )
+ static DWORD __stdcall GetEnvironmentVariable(LPCWSTR pszVar, LPWSTR pszBuffer, DWORD dwSize)
{
- return _GetEnvironmentVariableW( pszVar, pszBuffer, dwSize );
+ return _GetEnvironmentVariableW(pszVar, pszBuffer, dwSize);
}
- static void __stdcall ConvertToOem( LPWSTR /*psz*/ )
+ static void __stdcall ConvertToOem(LPWSTR /*psz*/)
{
}
- static void __stdcall ConvertToAnsi( LPWSTR /*psz*/ )
+ static void __stdcall ConvertToAnsi(LPWSTR /*psz*/)
{
}
- static void __stdcall ConvertToOem( LPWSTR /*psz*/, size_t )
+ static void __stdcall ConvertToOem(LPWSTR /*psz*/, size_t)
{
}
- static void __stdcall ConvertToAnsi( LPWSTR /*psz*/, size_t )
+ static void __stdcall ConvertToAnsi(LPWSTR /*psz*/, size_t)
{
}
};
@@ -1110,69 +1110,69 @@ public: {
}
- static void __stdcall Construct( CMStringT* pString )
+ static void __stdcall Construct(CMStringT* pString)
{
- new( pString ) CMStringT;
+ new(pString) CMStringT;
}
// Copy constructor
- CMStringT( const CMStringT& strSrc ) :
- CThisSimpleString( strSrc )
+ CMStringT(const CMStringT& strSrc) :
+ CThisSimpleString(strSrc)
{
}
- CMStringT( const XCHAR* pszSrc ) :
+ CMStringT(const XCHAR* pszSrc) :
CThisSimpleString()
{
// nDestLength is in XCHARs
*this = pszSrc;
}
- CMStringT( const YCHAR* pszSrc ) :
+ CMStringT(const YCHAR* pszSrc) :
CThisSimpleString()
{
*this = pszSrc;
}
- CMStringT( const unsigned char* pszSrc ) :
+ CMStringT(const unsigned char* pszSrc) :
CThisSimpleString()
{
- *this = reinterpret_cast< const char* >( pszSrc );
+ *this = reinterpret_cast< const char* >(pszSrc);
}
- CMStringT( char ch, int nLength = 1 ) :
+ CMStringT(char ch, int nLength = 1) :
CThisSimpleString()
{
- if ( nLength > 0 )
+ if (nLength > 0)
{
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::FloodCharacters( XCHAR( ch ), nLength, pszBuffer );
- this->ReleaseBufferSetLength( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::FloodCharacters(XCHAR(ch), nLength, pszBuffer);
+ this->ReleaseBufferSetLength(nLength);
}
}
- CMStringT( wchar_t ch, int nLength = 1 ) :
+ CMStringT(wchar_t ch, int nLength = 1) :
CThisSimpleString()
{
- if ( nLength > 0 )
+ if (nLength > 0)
{
//Convert ch to the BaseType
wchar_t pszCh[2] = { ch , 0 };
int nBaseTypeCharLen = 1;
- if(ch != L'\0')
+ if (ch != L'\0')
{
nBaseTypeCharLen = StringTraits::GetBaseTypeLength(pszCh);
}
XCHAR *buffBaseTypeChar = new XCHAR[nBaseTypeCharLen+1];
- StringTraits::ConvertToBaseType( buffBaseTypeChar, nBaseTypeCharLen+1, pszCh, 1 );
+ StringTraits::ConvertToBaseType(buffBaseTypeChar, nBaseTypeCharLen+1, pszCh, 1);
//Allocate enough characters in String and flood (replicate) with the (converted character)*nLength
- PXSTR pszBuffer = this->GetBuffer( nLength*nBaseTypeCharLen );
+ PXSTR pszBuffer = this->GetBuffer(nLength*nBaseTypeCharLen);
if (nBaseTypeCharLen == 1)
{ //Optimization for a common case - wide char translates to 1 ansi/wide char.
- StringTraits::FloodCharacters( buffBaseTypeChar[0], nLength, pszBuffer );
+ StringTraits::FloodCharacters(buffBaseTypeChar[0], nLength, pszBuffer);
} else
{
XCHAR* p=pszBuffer;
@@ -1185,25 +1185,25 @@ public: }
}
}
- this->ReleaseBufferSetLength( nLength*nBaseTypeCharLen );
+ this->ReleaseBufferSetLength(nLength*nBaseTypeCharLen);
delete [] buffBaseTypeChar;
}
}
- CMStringT( const XCHAR* pch, int nLength ) :
- CThisSimpleString( pch, nLength )
+ CMStringT(const XCHAR* pch, int nLength) :
+ CThisSimpleString(pch, nLength)
{
}
- CMStringT( const YCHAR* pch, int nLength ) :
+ CMStringT(const YCHAR* pch, int nLength) :
CThisSimpleString()
{
- if ( nLength > 0 )
+ if (nLength > 0)
{
- int nDestLength = StringTraits::GetBaseTypeLength( pch, nLength );
- PXSTR pszBuffer = this->GetBuffer( nDestLength );
- StringTraits::ConvertToBaseType( pszBuffer, nDestLength, pch, nLength );
- this->ReleaseBufferSetLength( nDestLength );
+ int nDestLength = StringTraits::GetBaseTypeLength(pch, nLength);
+ PXSTR pszBuffer = this->GetBuffer(nDestLength);
+ StringTraits::ConvertToBaseType(pszBuffer, nDestLength, pch, nLength);
+ this->ReleaseBufferSetLength(nDestLength);
}
}
@@ -1213,29 +1213,29 @@ public: }
// Assignment operators
- CMStringT& operator=( const CMStringT& strSrc )
+ CMStringT& operator=(const CMStringT& strSrc)
{
- CThisSimpleString::operator=( strSrc );
+ CThisSimpleString::operator=(strSrc);
return *this;
}
- CMStringT& operator=( PCXSTR pszSrc )
+ CMStringT& operator=(PCXSTR pszSrc)
{
- CThisSimpleString::operator=( pszSrc );
+ CThisSimpleString::operator=(pszSrc);
return *this;
}
- CMStringT& operator=( PCYSTR pszSrc )
+ CMStringT& operator=(PCYSTR pszSrc)
{
// nDestLength is in XCHARs
- int nDestLength = (pszSrc != NULL) ? StringTraits::GetBaseTypeLength( pszSrc ) : 0;
- if ( nDestLength > 0 )
+ int nDestLength = (pszSrc != NULL) ? StringTraits::GetBaseTypeLength(pszSrc) : 0;
+ if (nDestLength > 0)
{
- PXSTR pszBuffer = this->GetBuffer( nDestLength );
- StringTraits::ConvertToBaseType( pszBuffer, nDestLength, pszSrc);
- this->ReleaseBufferSetLength( nDestLength );
+ PXSTR pszBuffer = this->GetBuffer(nDestLength);
+ StringTraits::ConvertToBaseType(pszBuffer, nDestLength, pszSrc);
+ this->ReleaseBufferSetLength(nDestLength);
}
else
{
@@ -1245,223 +1245,223 @@ public: return *this;
}
- CMStringT& operator=( const unsigned char* pszSrc )
+ CMStringT& operator=(const unsigned char* pszSrc)
{
- return operator=( reinterpret_cast< const char* >( pszSrc ));
+ return operator=(reinterpret_cast< const char* >(pszSrc));
}
- CMStringT& operator=( char ch )
+ CMStringT& operator=(char ch)
{
char ach[2] = { ch, 0 };
- return operator=( ach );
+ return operator=(ach);
}
- CMStringT& operator=( wchar_t ch )
+ CMStringT& operator=(wchar_t ch)
{
wchar_t ach[2] = { ch, 0 };
- return operator=( ach );
+ return operator=(ach);
}
-// CMStringT& operator=( const VARIANT& var );
+// CMStringT& operator=(const VARIANT& var);
- CMStringT& operator+=( const CMStringT& str )
+ CMStringT& operator+=(const CMStringT& str)
{
- CThisSimpleString::operator+=( str );
+ CThisSimpleString::operator+=(str);
return *this;
}
- CMStringT& operator+=( const CThisSimpleString& str )
+ CMStringT& operator+=(const CThisSimpleString& str)
{
- CThisSimpleString::operator+=( str );
+ CThisSimpleString::operator+=(str);
return *this;
}
- CMStringT& operator+=( PCXSTR pszSrc )
+ CMStringT& operator+=(PCXSTR pszSrc)
{
- CThisSimpleString::operator+=( pszSrc );
+ CThisSimpleString::operator+=(pszSrc);
return *this;
}
// template< int t_nSize >
-// CMStringT& operator+=( const CStaticString< XCHAR, t_nSize >& strSrc )
+// CMStringT& operator+=(const CStaticString< XCHAR, t_nSize >& strSrc)
// {
-// CThisSimpleString::operator+=( strSrc );
+// CThisSimpleString::operator+=(strSrc);
//
// return *this;
// }
- CMStringT& operator+=( PCYSTR pszSrc )
+ CMStringT& operator+=(PCYSTR pszSrc)
{
- CMStringT str( pszSrc );
+ CMStringT str(pszSrc);
- return operator+=( str );
+ return operator+=(str);
}
- CMStringT& operator+=( char ch )
+ CMStringT& operator+=(char ch)
{
- CThisSimpleString::operator+=( ch );
+ CThisSimpleString::operator+=(ch);
return *this;
}
- CMStringT& operator+=( unsigned char ch )
+ CMStringT& operator+=(unsigned char ch)
{
- CThisSimpleString::operator+=( ch );
+ CThisSimpleString::operator+=(ch);
return *this;
}
- CMStringT& operator+=( wchar_t ch )
+ CMStringT& operator+=(wchar_t ch)
{
- CThisSimpleString::operator+=( ch );
+ CThisSimpleString::operator+=(ch);
return *this;
}
// Comparison
- int Compare( PCXSTR psz ) const
+ int Compare(PCXSTR psz) const
{
- return StringTraits::StringCompare( this->GetString(), psz );
+ return StringTraits::StringCompare(this->GetString(), psz);
}
- int CompareNoCase( PCXSTR psz ) const
+ int CompareNoCase(PCXSTR psz) const
{
- return StringTraits::StringCompareIgnore( this->GetString(), psz );
+ return StringTraits::StringCompareIgnore(this->GetString(), psz);
}
- int Collate( PCXSTR psz ) const
+ int Collate(PCXSTR psz) const
{
- return StringTraits::StringCollate( this->GetString(), psz );
+ return StringTraits::StringCollate(this->GetString(), psz);
}
- int CollateNoCase( PCXSTR psz ) const
+ int CollateNoCase(PCXSTR psz) const
{
- return StringTraits::StringCollateIgnore( this->GetString(), psz );
+ return StringTraits::StringCollateIgnore(this->GetString(), psz);
}
// Advanced manipulation
// Delete 'nCount' characters, starting at index 'iIndex'
- int Delete( int iIndex, int nCount = 1 )
+ int Delete(int iIndex, int nCount = 1)
{
- if ( iIndex < 0 )
+ if (iIndex < 0)
iIndex = 0;
- if ( nCount < 0 )
+ if (nCount < 0)
nCount = 0;
int nLength = this->GetLength();
- if ( nCount + iIndex > nLength )
+ if (nCount + iIndex > nLength)
{
nCount = nLength-iIndex;
}
- if ( nCount > 0 )
+ if (nCount > 0)
{
int nNewLength = nLength-nCount;
int nXCHARsToCopy = nLength-(iIndex+nCount)+1;
PXSTR pszBuffer = this->GetBuffer();
#if _MSC_VER >= 1400
- memmove_s( pszBuffer+iIndex, nXCHARsToCopy*sizeof( XCHAR ), pszBuffer+iIndex+nCount, nXCHARsToCopy*sizeof( XCHAR ));
+ memmove_s(pszBuffer+iIndex, nXCHARsToCopy*sizeof(XCHAR), pszBuffer+iIndex+nCount, nXCHARsToCopy*sizeof(XCHAR));
#else
- memmove( pszBuffer+iIndex, pszBuffer+iIndex+nCount, nXCHARsToCopy*sizeof( XCHAR ));
+ memmove(pszBuffer+iIndex, pszBuffer+iIndex+nCount, nXCHARsToCopy*sizeof(XCHAR));
#endif
- this->ReleaseBufferSetLength( nNewLength );
+ this->ReleaseBufferSetLength(nNewLength);
}
return this->GetLength();
}
// Insert character 'ch' before index 'iIndex'
- int Insert( int iIndex, XCHAR ch )
+ int Insert(int iIndex, XCHAR ch)
{
- if ( iIndex < 0 )
+ if (iIndex < 0)
iIndex = 0;
- if ( iIndex > this->GetLength())
+ if (iIndex > this->GetLength())
iIndex = this->GetLength();
int nNewLength = this->GetLength()+1;
- PXSTR pszBuffer = this->GetBuffer( nNewLength );
+ PXSTR pszBuffer = this->GetBuffer(nNewLength);
// move existing bytes down
#if _MSC_VER >= 1400
- memmove_s( pszBuffer+iIndex+1, (nNewLength-iIndex)*sizeof( XCHAR ), pszBuffer+iIndex, (nNewLength-iIndex)*sizeof( XCHAR ));
+ memmove_s(pszBuffer+iIndex+1, (nNewLength-iIndex)*sizeof(XCHAR), pszBuffer+iIndex, (nNewLength-iIndex)*sizeof(XCHAR));
#else
- memmove( pszBuffer+iIndex+1, pszBuffer+iIndex, (nNewLength-iIndex)*sizeof( XCHAR ));
+ memmove(pszBuffer+iIndex+1, pszBuffer+iIndex, (nNewLength-iIndex)*sizeof(XCHAR));
#endif
pszBuffer[iIndex] = ch;
- this->ReleaseBufferSetLength( nNewLength );
+ this->ReleaseBufferSetLength(nNewLength);
return nNewLength;
}
// Insert string 'psz' before index 'iIndex'
- int Insert( int iIndex, PCXSTR psz )
+ int Insert(int iIndex, PCXSTR psz)
{
- if ( iIndex < 0 )
+ if (iIndex < 0)
iIndex = 0;
- if ( iIndex > this->GetLength())
+ if (iIndex > this->GetLength())
{
iIndex = this->GetLength();
}
// nInsertLength and nNewLength are in XCHARs
- int nInsertLength = StringTraits::SafeStringLen( psz );
+ int nInsertLength = StringTraits::SafeStringLen(psz);
int nNewLength = this->GetLength();
- if ( nInsertLength > 0 )
+ if (nInsertLength > 0)
{
nNewLength += nInsertLength;
- PXSTR pszBuffer = this->GetBuffer( nNewLength );
+ PXSTR pszBuffer = this->GetBuffer(nNewLength);
// move existing bytes down
#if _MSC_VER >= 1400
- memmove_s( pszBuffer+iIndex+nInsertLength, (nNewLength-iIndex-nInsertLength+1)*sizeof( XCHAR ), pszBuffer+iIndex, (nNewLength-iIndex-nInsertLength+1)*sizeof( XCHAR ));
- memcpy_s( pszBuffer+iIndex, nInsertLength*sizeof( XCHAR ), psz, nInsertLength*sizeof( XCHAR ));
+ memmove_s(pszBuffer+iIndex+nInsertLength, (nNewLength-iIndex-nInsertLength+1)*sizeof(XCHAR), pszBuffer+iIndex, (nNewLength-iIndex-nInsertLength+1)*sizeof(XCHAR));
+ memcpy_s(pszBuffer+iIndex, nInsertLength*sizeof(XCHAR), psz, nInsertLength*sizeof(XCHAR));
#else
- memmove( pszBuffer+iIndex+nInsertLength, pszBuffer+iIndex, (nNewLength-iIndex-nInsertLength+1)*sizeof( XCHAR ));
- memcpy( pszBuffer+iIndex, psz, nInsertLength*sizeof( XCHAR ));
+ memmove(pszBuffer+iIndex+nInsertLength, pszBuffer+iIndex, (nNewLength-iIndex-nInsertLength+1)*sizeof(XCHAR));
+ memcpy(pszBuffer+iIndex, psz, nInsertLength*sizeof(XCHAR));
#endif
- this->ReleaseBufferSetLength( nNewLength );
+ this->ReleaseBufferSetLength(nNewLength);
}
return nNewLength;
}
// Replace all occurrences of character 'chOld' with character 'chNew'
- int Replace( XCHAR chOld, XCHAR chNew )
+ int Replace(XCHAR chOld, XCHAR chNew)
{
int nCount = 0;
// short-circuit the nop case
- if ( chOld != chNew )
+ if (chOld != chNew)
{
// otherwise modify each character that matches in the string
bool bCopied = false;
- PXSTR pszBuffer = const_cast< PXSTR >( this->GetString()); // We don't actually write to pszBuffer until we've called GetBuffer().
+ PXSTR pszBuffer = const_cast< PXSTR >(this->GetString()); // We don't actually write to pszBuffer until we've called GetBuffer().
int nLength = this->GetLength();
int iChar = 0;
- while( iChar < nLength )
+ while(iChar < nLength)
{
// replace instances of the specified character only
- if ( pszBuffer[iChar] == chOld )
+ if (pszBuffer[iChar] == chOld)
{
- if ( !bCopied )
+ if ( !bCopied)
{
bCopied = true;
- pszBuffer = this->GetBuffer( nLength );
+ pszBuffer = this->GetBuffer(nLength);
}
pszBuffer[iChar] = chNew;
nCount++;
}
- iChar = int( StringTraits::CharNext( pszBuffer+iChar )-pszBuffer );
+ iChar = int(StringTraits::CharNext(pszBuffer+iChar)-pszBuffer);
}
- if ( bCopied )
+ if (bCopied)
{
- this->ReleaseBufferSetLength( nLength );
+ this->ReleaseBufferSetLength(nLength);
}
}
@@ -1469,84 +1469,84 @@ public: }
// Replace all occurrences of string 'pszOld' with string 'pszNew'
- int Replace( PCXSTR pszOld, PCXSTR pszNew )
+ int Replace(PCXSTR pszOld, PCXSTR pszNew)
{
// can't have empty or NULL lpszOld
// nSourceLen is in XCHARs
- int nSourceLen = StringTraits::SafeStringLen( pszOld );
- if ( nSourceLen == 0 )
+ int nSourceLen = StringTraits::SafeStringLen(pszOld);
+ if (nSourceLen == 0)
return 0;
// nReplacementLen is in XCHARs
- int nReplacementLen = StringTraits::SafeStringLen( pszNew );
+ int nReplacementLen = StringTraits::SafeStringLen(pszNew);
// loop once to figure out the size of the result string
int nCount = 0;
{
PCXSTR pszStart = this->GetString();
PCXSTR pszEnd = pszStart+this->GetLength();
- while( pszStart < pszEnd )
+ while(pszStart < pszEnd)
{
PCXSTR pszTarget;
- while( (pszTarget = StringTraits::StringFindString( pszStart, pszOld )) != NULL)
+ while((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != NULL)
{
nCount++;
pszStart = pszTarget+nSourceLen;
}
- pszStart += StringTraits::SafeStringLen( pszStart )+1;
+ pszStart += StringTraits::SafeStringLen(pszStart)+1;
}
}
// if any changes were made, make them
- if ( nCount > 0 )
+ if (nCount > 0)
{
// if the buffer is too small, just
// allocate a new buffer (slow but sure)
int nOldLength = this->GetLength();
int nNewLength = nOldLength+(nReplacementLen-nSourceLen)*nCount;
- PXSTR pszBuffer = this->GetBuffer( __max( nNewLength, nOldLength ));
+ PXSTR pszBuffer = this->GetBuffer(__max(nNewLength, nOldLength));
PXSTR pszStart = pszBuffer;
PXSTR pszEnd = pszStart+nOldLength;
// loop again to actually do the work
- while( pszStart < pszEnd )
+ while(pszStart < pszEnd)
{
PXSTR pszTarget;
- while( (pszTarget = StringTraits::StringFindString( pszStart, pszOld )) != NULL )
+ while((pszTarget = StringTraits::StringFindString(pszStart, pszOld)) != NULL)
{
int nBalance = nOldLength-int(pszTarget-pszBuffer+nSourceLen);
- memmove_s( pszTarget+nReplacementLen, nBalance*sizeof( XCHAR ),
- pszTarget+nSourceLen, nBalance*sizeof( XCHAR ));
- memcpy_s( pszTarget, nReplacementLen*sizeof( XCHAR ),
- pszNew, nReplacementLen*sizeof( XCHAR ));
+ memmove_s(pszTarget+nReplacementLen, nBalance*sizeof(XCHAR),
+ pszTarget+nSourceLen, nBalance*sizeof(XCHAR));
+ memcpy_s(pszTarget, nReplacementLen*sizeof(XCHAR),
+ pszNew, nReplacementLen*sizeof(XCHAR));
pszStart = pszTarget+nReplacementLen;
pszTarget[nReplacementLen+nBalance] = 0;
nOldLength += (nReplacementLen-nSourceLen);
}
- pszStart += StringTraits::SafeStringLen( pszStart )+1;
+ pszStart += StringTraits::SafeStringLen(pszStart)+1;
}
- this->ReleaseBufferSetLength( nNewLength );
+ this->ReleaseBufferSetLength(nNewLength);
}
return nCount;
}
// Remove all occurrences of character 'chRemove'
- int Remove( XCHAR chRemove )
+ int Remove(XCHAR chRemove)
{
int nLength = this->GetLength();
- PXSTR pszBuffer = this->GetBuffer( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
PXSTR pszSource = pszBuffer;
PXSTR pszDest = pszBuffer;
PXSTR pszEnd = pszBuffer+nLength;
- while( pszSource < pszEnd )
+ while(pszSource < pszEnd)
{
- PXSTR pszNewSource = StringTraits::CharNext( pszSource );
- if ( *pszSource != chRemove )
+ PXSTR pszNewSource = StringTraits::CharNext(pszSource);
+ if (*pszSource != chRemove)
{
// Copy the source to the destination. Remember to copy all bytes of an MBCS character
// Copy the source to the destination. Remember to copy all bytes of an MBCS character
@@ -1563,37 +1563,37 @@ public: pszSource = pszNewSource;
}
*pszDest = 0;
- int nCount = int( pszSource-pszDest );
- this->ReleaseBufferSetLength( nLength-nCount );
+ int nCount = int(pszSource-pszDest);
+ this->ReleaseBufferSetLength(nLength-nCount);
return nCount;
}
- CMStringT Tokenize( PCXSTR pszTokens, int& iStart ) const
+ CMStringT Tokenize(PCXSTR pszTokens, int& iStart) const
{
- if ( (pszTokens == NULL) || (*pszTokens == (XCHAR)0))
+ if ((pszTokens == NULL) || (*pszTokens == (XCHAR)0))
{
if (iStart < this->GetLength())
- return CMStringT( this->GetString()+iStart );
+ return CMStringT(this->GetString()+iStart);
}
else
{
PCXSTR pszPlace = this->GetString()+iStart;
PCXSTR pszEnd = this->GetString()+this->GetLength();
- if ( pszPlace < pszEnd )
+ if (pszPlace < pszEnd)
{
- int nIncluding = StringTraits::StringSpanIncluding( pszPlace, pszTokens );
+ int nIncluding = StringTraits::StringSpanIncluding(pszPlace, pszTokens);
- if ( (pszPlace+nIncluding) < pszEnd )
+ if ((pszPlace+nIncluding) < pszEnd)
{
pszPlace += nIncluding;
- int nExcluding = StringTraits::StringSpanExcluding( pszPlace, pszTokens );
+ int nExcluding = StringTraits::StringSpanExcluding(pszPlace, pszTokens);
int iFrom = iStart+nIncluding;
int nUntil = nExcluding;
iStart = iFrom+nUntil+1;
- return Mid( iFrom, nUntil );
+ return Mid(iFrom, nUntil);
}
}
}
@@ -1607,56 +1607,56 @@ public: // find routines
// Find the first occurrence of character 'ch', starting at index 'iStart'
- int Find( XCHAR ch, int iStart = 0 ) const
+ int Find(XCHAR ch, int iStart = 0) const
{
// nLength is in XCHARs
int nLength = this->GetLength();
- if ( iStart < 0 || iStart >= nLength)
+ if (iStart < 0 || iStart >= nLength)
return -1;
// find first single character
- PCXSTR psz = StringTraits::StringFindChar( this->GetString()+iStart, ch );
+ PCXSTR psz = StringTraits::StringFindChar(this->GetString()+iStart, ch);
// return -1 if not found and index otherwise
- return (psz == NULL) ? -1 : int( psz-this->GetString());
+ return (psz == NULL) ? -1 : int(psz-this->GetString());
}
// look for a specific sub-string
// Find the first occurrence of string 'pszSub', starting at index 'iStart'
- int Find( PCXSTR pszSub, int iStart = 0 ) const
+ int Find(PCXSTR pszSub, int iStart = 0) const
{
// iStart is in XCHARs
- if(pszSub == NULL)
+ if (pszSub == NULL)
return -1;
// nLength is in XCHARs
int nLength = this->GetLength();
- if ( iStart < 0 || iStart > nLength )
+ if (iStart < 0 || iStart > nLength)
return -1;
// find first matching substring
- PCXSTR psz = StringTraits::StringFindString( this->GetString()+iStart, pszSub );
+ PCXSTR psz = StringTraits::StringFindString(this->GetString()+iStart, pszSub);
// return -1 for not found, distance from beginning otherwise
- return (psz == NULL) ? -1 : int( psz-this->GetString());
+ return (psz == NULL) ? -1 : int(psz-this->GetString());
}
// Find the first occurrence of any of the characters in string 'pszCharSet'
- int FindOneOf( PCXSTR pszCharSet ) const
+ int FindOneOf(PCXSTR pszCharSet) const
{
- PCXSTR psz = StringTraits::StringScanSet( this->GetString(), pszCharSet );
- return (psz == NULL) ? -1 : int( psz-this->GetString());
+ PCXSTR psz = StringTraits::StringScanSet(this->GetString(), pszCharSet);
+ return (psz == NULL) ? -1 : int(psz-this->GetString());
}
// Find the last occurrence of character 'ch'
- int ReverseFind( XCHAR ch ) const
+ int ReverseFind(XCHAR ch) const
{
// find last single character
- PCXSTR psz = StringTraits::StringFindCharRev( this->GetString(), ch );
+ PCXSTR psz = StringTraits::StringFindCharRev(this->GetString(), ch);
// return -1 if not found, distance from beginning otherwise
- return (psz == NULL) ? -1 : int( psz-this->GetString());
+ return (psz == NULL) ? -1 : int(psz-this->GetString());
}
// manipulation
@@ -1665,9 +1665,9 @@ public: CMStringT& MakeUpper()
{
int nLength = this->GetLength();
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::StringUppercase( pszBuffer, nLength+1 );
- this->ReleaseBufferSetLength( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::StringUppercase(pszBuffer, nLength+1);
+ this->ReleaseBufferSetLength(nLength);
return *this;
}
@@ -1676,9 +1676,9 @@ public: CMStringT& MakeLower()
{
int nLength = this->GetLength();
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::StringLowercase( pszBuffer, nLength+1 );
- this->ReleaseBufferSetLength( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::StringLowercase(pszBuffer, nLength+1);
+ this->ReleaseBufferSetLength(nLength);
return *this;
}
@@ -1687,9 +1687,9 @@ public: CMStringT& MakeReverse()
{
int nLength = this->GetLength();
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::StringReverse( pszBuffer );
- this->ReleaseBufferSetLength( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::StringReverse(pszBuffer);
+ this->ReleaseBufferSetLength(nLength);
return *this;
}
@@ -1705,26 +1705,26 @@ public: PCXSTR psz = this->GetString();
PCXSTR pszLast = NULL;
- while( *psz != 0 )
+ while(*psz != 0)
{
- if ( StringTraits::IsSpace( *psz ))
+ if (StringTraits::IsSpace(*psz))
{
- if ( pszLast == NULL )
+ if (pszLast == NULL)
pszLast = psz;
}
else
{
pszLast = NULL;
}
- psz = StringTraits::CharNext( psz );
+ psz = StringTraits::CharNext(psz);
}
- if ( pszLast != NULL )
+ if (pszLast != NULL)
{
// truncate at trailing space start
- int iLast = int( pszLast-this->GetString());
+ int iLast = int(pszLast-this->GetString());
- this->Truncate( iLast );
+ this->Truncate(iLast);
}
return *this;
@@ -1737,21 +1737,21 @@ public: PCXSTR psz = this->GetString();
- while( StringTraits::IsSpace( *psz ))
+ while(StringTraits::IsSpace(*psz))
{
- psz = StringTraits::CharNext( psz );
+ psz = StringTraits::CharNext(psz);
}
- if ( psz != this->GetString())
+ if (psz != this->GetString())
{
// fix up data and length
- int iFirst = int( psz-this->GetString());
- PXSTR pszBuffer = this->GetBuffer( this->GetLength());
+ int iFirst = int(psz-this->GetString());
+ PXSTR pszBuffer = this->GetBuffer(this->GetLength());
psz = pszBuffer+iFirst;
int nDataLength = this->GetLength()-iFirst;
- memmove_s( pszBuffer, (this->GetLength()+1)*sizeof( XCHAR ),
- psz, (nDataLength+1)*sizeof( XCHAR ));
- this->ReleaseBufferSetLength( nDataLength );
+ memmove_s(pszBuffer, (this->GetLength()+1)*sizeof(XCHAR),
+ psz, (nDataLength+1)*sizeof(XCHAR));
+ this->ReleaseBufferSetLength(nDataLength);
}
return *this;
@@ -1764,21 +1764,21 @@ public: }
// Remove all leading and trailing occurrences of character 'chTarget'
- CMStringT& Trim( XCHAR chTarget )
+ CMStringT& Trim(XCHAR chTarget)
{
- return TrimRight( chTarget ).TrimLeft( chTarget );
+ return TrimRight(chTarget).TrimLeft(chTarget);
}
// Remove all leading and trailing occurrences of any of the characters in the string 'pszTargets'
- CMStringT& Trim( PCXSTR pszTargets )
+ CMStringT& Trim(PCXSTR pszTargets)
{
- return TrimRight( pszTargets ).TrimLeft( pszTargets );
+ return TrimRight(pszTargets).TrimLeft(pszTargets);
}
// trimming anything (either side)
// Remove all trailing occurrences of character 'chTarget'
- CMStringT& TrimRight( XCHAR chTarget )
+ CMStringT& TrimRight(XCHAR chTarget)
{
// find beginning of trailing matches
// by starting at beginning (DBCS aware)
@@ -1786,11 +1786,11 @@ public: PCXSTR psz = this->GetString();
PCXSTR pszLast = NULL;
- while( *psz != 0 )
+ while(*psz != 0)
{
- if ( *psz == chTarget )
+ if (*psz == chTarget)
{
- if ( pszLast == NULL )
+ if (pszLast == NULL)
{
pszLast = psz;
}
@@ -1799,24 +1799,24 @@ public: {
pszLast = NULL;
}
- psz = StringTraits::CharNext( psz );
+ psz = StringTraits::CharNext(psz);
}
- if ( pszLast != NULL )
+ if (pszLast != NULL)
{
// truncate at left-most matching character
- int iLast = int( pszLast-this->GetString());
- this->Truncate( iLast );
+ int iLast = int(pszLast-this->GetString());
+ this->Truncate(iLast);
}
return *this;
}
// Remove all trailing occurrences of any of the characters in string 'pszTargets'
- CMStringT& TrimRight( PCXSTR pszTargets )
+ CMStringT& TrimRight(PCXSTR pszTargets)
{
// if we're not trimming anything, we're not doing any work
- if ( (pszTargets == NULL) || (*pszTargets == 0))
+ if ((pszTargets == NULL) || (*pszTargets == 0))
{
return *this;
}
@@ -1827,11 +1827,11 @@ public: PCXSTR psz = this->GetString();
PCXSTR pszLast = NULL;
- while( *psz != 0 )
+ while(*psz != 0)
{
- if ( StringTraits::StringFindChar( pszTargets, *psz ) != NULL )
+ if (StringTraits::StringFindChar(pszTargets, *psz) != NULL)
{
- if ( pszLast == NULL )
+ if (pszLast == NULL)
{
pszLast = psz;
}
@@ -1840,70 +1840,70 @@ public: {
pszLast = NULL;
}
- psz = StringTraits::CharNext( psz );
+ psz = StringTraits::CharNext(psz);
}
- if ( pszLast != NULL )
+ if (pszLast != NULL)
{
// truncate at left-most matching character
- int iLast = int( pszLast-this->GetString());
- this->Truncate( iLast );
+ int iLast = int(pszLast-this->GetString());
+ this->Truncate(iLast);
}
return *this;
}
// Remove all leading occurrences of character 'chTarget'
- CMStringT& TrimLeft( XCHAR chTarget )
+ CMStringT& TrimLeft(XCHAR chTarget)
{
// find first non-matching character
PCXSTR psz = this->GetString();
- while( chTarget == *psz )
+ while(chTarget == *psz)
{
- psz = StringTraits::CharNext( psz );
+ psz = StringTraits::CharNext(psz);
}
- if ( psz != this->GetString())
+ if (psz != this->GetString())
{
// fix up data and length
- int iFirst = int( psz-this->GetString());
- PXSTR pszBuffer = this->GetBuffer( this->GetLength());
+ int iFirst = int(psz-this->GetString());
+ PXSTR pszBuffer = this->GetBuffer(this->GetLength());
psz = pszBuffer+iFirst;
int nDataLength = this->GetLength()-iFirst;
- memmove_s( pszBuffer, (this->GetLength()+1)*sizeof( XCHAR ),
- psz, (nDataLength+1)*sizeof( XCHAR ));
- this->ReleaseBufferSetLength( nDataLength );
+ memmove_s(pszBuffer, (this->GetLength()+1)*sizeof(XCHAR),
+ psz, (nDataLength+1)*sizeof(XCHAR));
+ this->ReleaseBufferSetLength(nDataLength);
}
return *this;
}
// Remove all leading occurrences of any of the characters in string 'pszTargets'
- CMStringT& TrimLeft( PCXSTR pszTargets )
+ CMStringT& TrimLeft(PCXSTR pszTargets)
{
// if we're not trimming anything, we're not doing any work
- if ( (pszTargets == NULL) || (*pszTargets == 0))
+ if ((pszTargets == NULL) || (*pszTargets == 0))
{
return *this;
}
PCXSTR psz = this->GetString();
- while( (*psz != 0) && (StringTraits::StringFindChar( pszTargets, *psz ) != NULL))
+ while((*psz != 0) && (StringTraits::StringFindChar(pszTargets, *psz) != NULL))
{
- psz = StringTraits::CharNext( psz );
+ psz = StringTraits::CharNext(psz);
}
- if ( psz != this->GetString())
+ if (psz != this->GetString())
{
// fix up data and length
- int iFirst = int( psz-this->GetString());
- PXSTR pszBuffer = this->GetBuffer( this->GetLength());
+ int iFirst = int(psz-this->GetString());
+ PXSTR pszBuffer = this->GetBuffer(this->GetLength());
psz = pszBuffer+iFirst;
int nDataLength = this->GetLength()-iFirst;
- memmove_s( pszBuffer, (this->GetLength()+1)*sizeof( XCHAR ),
- psz, (nDataLength+1)*sizeof( XCHAR ));
- this->ReleaseBufferSetLength( nDataLength );
+ memmove_s(pszBuffer, (this->GetLength()+1)*sizeof(XCHAR),
+ psz, (nDataLength+1)*sizeof(XCHAR));
+ this->ReleaseBufferSetLength(nDataLength);
}
return *this;
@@ -1913,30 +1913,30 @@ public: void AnsiToOem()
{
int nLength = this->GetLength();
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::ConvertToOem( pszBuffer, nLength+1 );
- this->ReleaseBufferSetLength( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::ConvertToOem(pszBuffer, nLength+1);
+ this->ReleaseBufferSetLength(nLength);
}
// Convert the string to the ANSI character set
void OemToAnsi()
{
int nLength = this->GetLength();
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::ConvertToAnsi( pszBuffer, nLength+1 );
- this->ReleaseBufferSetLength( nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::ConvertToAnsi(pszBuffer, nLength+1);
+ this->ReleaseBufferSetLength(nLength);
}
// Very simple sub-string extraction
// Return the substring starting at index 'iFirst'
- CMStringT Mid( int iFirst ) const
+ CMStringT Mid(int iFirst) const
{
- return Mid( iFirst, this->GetLength()-iFirst );
+ return Mid(iFirst, this->GetLength()-iFirst);
}
// Return the substring starting at index 'iFirst', with length 'nCount'
- CMStringT Mid( int iFirst, int nCount ) const
+ CMStringT Mid(int iFirst, int nCount) const
{
// nCount is in XCHARs
@@ -1946,83 +1946,83 @@ public: if (nCount < 0)
nCount = 0;
- if ( (iFirst + nCount) > this->GetLength())
+ if ((iFirst + nCount) > this->GetLength())
nCount = this->GetLength()-iFirst;
- if ( iFirst > this->GetLength())
+ if (iFirst > this->GetLength())
nCount = 0;
// optimize case of returning entire string
- if ( (iFirst == 0) && ((iFirst+nCount) == this->GetLength()))
+ if ((iFirst == 0) && ((iFirst+nCount) == this->GetLength()))
return *this;
- return CMStringT( this->GetString()+iFirst, nCount );
+ return CMStringT(this->GetString()+iFirst, nCount);
}
// Return the substring consisting of the rightmost 'nCount' characters
- CMStringT Right( int nCount ) const
+ CMStringT Right(int nCount) const
{
// nCount is in XCHARs
if (nCount < 0)
nCount = 0;
int nLength = this->GetLength();
- if ( nCount >= nLength )
+ if (nCount >= nLength)
{
return *this;
}
- return CMStringT( this->GetString()+nLength-nCount, nCount );
+ return CMStringT(this->GetString()+nLength-nCount, nCount);
}
// Return the substring consisting of the leftmost 'nCount' characters
- CMStringT Left( int nCount ) const
+ CMStringT Left(int nCount) const
{
// nCount is in XCHARs
if (nCount < 0)
nCount = 0;
int nLength = this->GetLength();
- if ( nCount >= nLength )
+ if (nCount >= nLength)
return *this;
- return CMStringT( this->GetString(), nCount );
+ return CMStringT(this->GetString(), nCount);
}
// Return the substring consisting of the leftmost characters in the set 'pszCharSet'
- CMStringT SpanIncluding( PCXSTR pszCharSet ) const
+ CMStringT SpanIncluding(PCXSTR pszCharSet) const
{
- return Left( StringTraits::StringSpanIncluding( this->GetString(), pszCharSet ));
+ return Left(StringTraits::StringSpanIncluding(this->GetString(), pszCharSet));
}
// Return the substring consisting of the leftmost characters not in the set 'pszCharSet'
- CMStringT SpanExcluding( PCXSTR pszCharSet ) const
+ CMStringT SpanExcluding(PCXSTR pszCharSet) const
{
- return Left( StringTraits::StringSpanExcluding( this->GetString(), pszCharSet ));
+ return Left(StringTraits::StringSpanExcluding(this->GetString(), pszCharSet));
}
// Format data using format string 'pszFormat'
- void Format( PCXSTR pszFormat, ... );
+ void Format(PCXSTR pszFormat, ...);
// Append formatted data using format string 'pszFormat'
- void AppendFormat( PCXSTR pszFormat, ... );
+ void AppendFormat(PCXSTR pszFormat, ...);
- void AppendFormatV( PCXSTR pszFormat, va_list args )
+ void AppendFormatV(PCXSTR pszFormat, va_list args)
{
int nCurrentLength = this->GetLength();
- int nAppendLength = StringTraits::GetFormattedLength( pszFormat, args );
- PXSTR pszBuffer = this->GetBuffer( nCurrentLength+nAppendLength );
- StringTraits::Format( pszBuffer+nCurrentLength,
- nAppendLength+1, pszFormat, args );
- this->ReleaseBufferSetLength( nCurrentLength+nAppendLength );
+ int nAppendLength = StringTraits::GetFormattedLength(pszFormat, args);
+ PXSTR pszBuffer = this->GetBuffer(nCurrentLength+nAppendLength);
+ StringTraits::Format(pszBuffer+nCurrentLength,
+ nAppendLength+1, pszFormat, args);
+ this->ReleaseBufferSetLength(nCurrentLength+nAppendLength);
}
- void FormatV( PCXSTR pszFormat, va_list args )
+ void FormatV(PCXSTR pszFormat, va_list args)
{
- int nLength = StringTraits::GetFormattedLength( pszFormat, args );
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::Format( pszBuffer, nLength+1, pszFormat, args );
- this->ReleaseBufferSetLength( nLength );
+ int nLength = StringTraits::GetFormattedLength(pszFormat, args);
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::Format(pszBuffer, nLength+1, pszFormat, args);
+ this->ReleaseBufferSetLength(nLength);
}
// OLE BSTR support
@@ -2030,30 +2030,30 @@ public: // Allocate a BSTR containing a copy of the string
BSTR AllocSysString() const
{
- BSTR bstrResult = StringTraits::AllocSysString( this->GetString(), this->GetLength());
+ BSTR bstrResult = StringTraits::AllocSysString(this->GetString(), this->GetLength());
return bstrResult;
}
- BSTR SetSysString( BSTR* pbstr ) const
+ BSTR SetSysString(BSTR* pbstr) const
{
- StringTraits::ReAllocSysString( this->GetString(), pbstr, this->GetLength());
+ StringTraits::ReAllocSysString(this->GetString(), pbstr, this->GetLength());
return *pbstr;
}
// Set the string to the value of environment variable 'pszVar'
- BOOL GetEnvironmentVariable( PCXSTR pszVar )
+ BOOL GetEnvironmentVariable(PCXSTR pszVar)
{
- ULONG nLength = StringTraits::GetEnvironmentVariable( pszVar, NULL, 0 );
+ ULONG nLength = StringTraits::GetEnvironmentVariable(pszVar, NULL, 0);
BOOL bRetVal = FALSE;
- if ( nLength == 0 )
+ if (nLength == 0)
{
this->Empty();
}
else
{
- PXSTR pszBuffer = this->GetBuffer( nLength );
- StringTraits::GetEnvironmentVariable( pszVar, pszBuffer, nLength );
+ PXSTR pszBuffer = this->GetBuffer(nLength);
+ StringTraits::GetEnvironmentVariable(pszVar, pszBuffer, nLength);
this->ReleaseBuffer();
bRetVal = TRUE;
}
@@ -2062,237 +2062,237 @@ public: }
// Load the string from resource 'nID'
- BOOL LoadString( UINT nID )
+ BOOL LoadString(UINT nID)
{
- HINSTANCE hInst = StringTraits::FindStringResourceInstance( nID );
- if ( hInst == NULL )
+ HINSTANCE hInst = StringTraits::FindStringResourceInstance(nID);
+ if (hInst == NULL)
return FALSE;
- return LoadString( hInst, nID );
+ return LoadString(hInst, nID);
}
- friend CMStringT __stdcall operator+( const CMStringT& str1, const CMStringT& str2 )
+ friend CMStringT __stdcall operator+(const CMStringT& str1, const CMStringT& str2)
{
CMStringT strResult;
- Concatenate( strResult, str1, str1.GetLength(), str2, str2.GetLength());
+ Concatenate(strResult, str1, str1.GetLength(), str2, str2.GetLength());
return strResult;
}
- friend CMStringT __stdcall operator+( const CMStringT& str1, PCXSTR psz2 )
+ friend CMStringT __stdcall operator+(const CMStringT& str1, PCXSTR psz2)
{
CMStringT strResult;
- Concatenate( strResult, str1, str1.GetLength(), psz2, StringLength( psz2 ));
+ Concatenate(strResult, str1, str1.GetLength(), psz2, StringLength(psz2));
return strResult;
}
- friend CMStringT __stdcall operator+( PCXSTR psz1, const CMStringT& str2 )
+ friend CMStringT __stdcall operator+(PCXSTR psz1, const CMStringT& str2)
{
CMStringT strResult;
- Concatenate( strResult, psz1, StringLength( psz1 ), str2, str2.GetLength());
+ Concatenate(strResult, psz1, StringLength(psz1), str2, str2.GetLength());
return strResult;
}
- friend CMStringT __stdcall operator+( const CMStringT& str1, wchar_t ch2 )
+ friend CMStringT __stdcall operator+(const CMStringT& str1, wchar_t ch2)
{
CMStringT strResult;
- XCHAR chTemp = XCHAR( ch2 );
+ XCHAR chTemp = XCHAR(ch2);
- Concatenate( strResult, str1, str1.GetLength(), &chTemp, 1 );
+ Concatenate(strResult, str1, str1.GetLength(), &chTemp, 1);
return strResult;
}
- friend CMStringT __stdcall operator+( const CMStringT& str1, char ch2 )
+ friend CMStringT __stdcall operator+(const CMStringT& str1, char ch2)
{
CMStringT strResult;
- XCHAR chTemp = XCHAR( ch2 );
+ XCHAR chTemp = XCHAR(ch2);
- Concatenate( strResult, str1, str1.GetLength(), &chTemp, 1 );
+ Concatenate(strResult, str1, str1.GetLength(), &chTemp, 1);
return strResult;
}
- friend CMStringT __stdcall operator+( wchar_t ch1, const CMStringT& str2 )
+ friend CMStringT __stdcall operator+(wchar_t ch1, const CMStringT& str2)
{
CMStringT strResult;
- XCHAR chTemp = XCHAR( ch1 );
+ XCHAR chTemp = XCHAR(ch1);
- Concatenate( strResult, &chTemp, 1, str2, str2.GetLength());
+ Concatenate(strResult, &chTemp, 1, str2, str2.GetLength());
return strResult;
}
- friend CMStringT __stdcall operator+( char ch1, const CMStringT& str2 )
+ friend CMStringT __stdcall operator+(char ch1, const CMStringT& str2)
{
CMStringT strResult;
- XCHAR chTemp = XCHAR( ch1 );
+ XCHAR chTemp = XCHAR(ch1);
- Concatenate( strResult, &chTemp, 1, str2, str2.GetLength());
+ Concatenate(strResult, &chTemp, 1, str2, str2.GetLength());
return strResult;
}
- friend bool __stdcall operator==( const CMStringT& str1, const CMStringT& str2 )
+ friend bool __stdcall operator==(const CMStringT& str1, const CMStringT& str2)
{
- return str1.Compare( str2 ) == 0;
+ return str1.Compare(str2) == 0;
}
- friend bool __stdcall operator==( const CMStringT& str1, PCXSTR psz2 )
+ friend bool __stdcall operator==(const CMStringT& str1, PCXSTR psz2)
{
- return str1.Compare( psz2 ) == 0;
+ return str1.Compare(psz2) == 0;
}
- friend bool __stdcall operator==( PCXSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator==(PCXSTR psz1, const CMStringT& str2)
{
- return str2.Compare( psz1 ) == 0;
+ return str2.Compare(psz1) == 0;
}
- friend bool __stdcall operator==( const CMStringT& str1, PCYSTR psz2 )
+ friend bool __stdcall operator==(const CMStringT& str1, PCYSTR psz2)
{
- CMStringT str2( psz2 );
+ CMStringT str2(psz2);
return str1 == str2;
}
- friend bool __stdcall operator==( PCYSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator==(PCYSTR psz1, const CMStringT& str2)
{
- CMStringT str1( psz1 );
+ CMStringT str1(psz1);
return str1 == str2;
}
- friend bool __stdcall operator!=( const CMStringT& str1, const CMStringT& str2 )
+ friend bool __stdcall operator!=(const CMStringT& str1, const CMStringT& str2)
{
- return str1.Compare( str2 ) != 0;
+ return str1.Compare(str2) != 0;
}
- friend bool __stdcall operator!=( const CMStringT& str1, PCXSTR psz2 )
+ friend bool __stdcall operator!=(const CMStringT& str1, PCXSTR psz2)
{
- return str1.Compare( psz2 ) != 0;
+ return str1.Compare(psz2) != 0;
}
- friend bool __stdcall operator!=( PCXSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator!=(PCXSTR psz1, const CMStringT& str2)
{
- return str2.Compare( psz1 ) != 0;
+ return str2.Compare(psz1) != 0;
}
- friend bool __stdcall operator!=( const CMStringT& str1, PCYSTR psz2 )
+ friend bool __stdcall operator!=(const CMStringT& str1, PCYSTR psz2)
{
- CMStringT str2( psz2 );
+ CMStringT str2(psz2);
return str1 != str2;
}
- friend bool __stdcall operator!=( PCYSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator!=(PCYSTR psz1, const CMStringT& str2)
{
- CMStringT str1( psz1 );
+ CMStringT str1(psz1);
return str1 != str2;
}
- friend bool __stdcall operator<( const CMStringT& str1, const CMStringT& str2 )
+ friend bool __stdcall operator<(const CMStringT& str1, const CMStringT& str2)
{
- return str1.Compare( str2 ) < 0;
+ return str1.Compare(str2) < 0;
}
- friend bool __stdcall operator<( const CMStringT& str1, PCXSTR psz2 )
+ friend bool __stdcall operator<(const CMStringT& str1, PCXSTR psz2)
{
- return str1.Compare( psz2 ) < 0;
+ return str1.Compare(psz2) < 0;
}
- friend bool __stdcall operator<( PCXSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator<(PCXSTR psz1, const CMStringT& str2)
{
- return str2.Compare( psz1 ) > 0;
+ return str2.Compare(psz1) > 0;
}
- friend bool __stdcall operator>( const CMStringT& str1, const CMStringT& str2 )
+ friend bool __stdcall operator>(const CMStringT& str1, const CMStringT& str2)
{
- return str1.Compare( str2 ) > 0;
+ return str1.Compare(str2) > 0;
}
- friend bool __stdcall operator>( const CMStringT& str1, PCXSTR psz2 )
+ friend bool __stdcall operator>(const CMStringT& str1, PCXSTR psz2)
{
- return str1.Compare( psz2 ) > 0;
+ return str1.Compare(psz2) > 0;
}
- friend bool __stdcall operator>( PCXSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator>(PCXSTR psz1, const CMStringT& str2)
{
- return str2.Compare( psz1 ) < 0;
+ return str2.Compare(psz1) < 0;
}
- friend bool __stdcall operator<=( const CMStringT& str1, const CMStringT& str2 )
+ friend bool __stdcall operator<=(const CMStringT& str1, const CMStringT& str2)
{
- return str1.Compare( str2 ) <= 0;
+ return str1.Compare(str2) <= 0;
}
- friend bool __stdcall operator<=( const CMStringT& str1, PCXSTR psz2 )
+ friend bool __stdcall operator<=(const CMStringT& str1, PCXSTR psz2)
{
- return str1.Compare( psz2 ) <= 0;
+ return str1.Compare(psz2) <= 0;
}
- friend bool __stdcall operator<=( PCXSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator<=(PCXSTR psz1, const CMStringT& str2)
{
- return str2.Compare( psz1 ) >= 0;
+ return str2.Compare(psz1) >= 0;
}
- friend bool __stdcall operator>=( const CMStringT& str1, const CMStringT& str2 )
+ friend bool __stdcall operator>=(const CMStringT& str1, const CMStringT& str2)
{
- return str1.Compare( str2 ) >= 0;
+ return str1.Compare(str2) >= 0;
}
- friend bool __stdcall operator>=( const CMStringT& str1, PCXSTR psz2 )
+ friend bool __stdcall operator>=(const CMStringT& str1, PCXSTR psz2)
{
- return str1.Compare( psz2 ) >= 0;
+ return str1.Compare(psz2) >= 0;
}
- friend bool __stdcall operator>=( PCXSTR psz1, const CMStringT& str2 )
+ friend bool __stdcall operator>=(PCXSTR psz1, const CMStringT& str2)
{
- return str2.Compare( psz1 ) <= 0;
+ return str2.Compare(psz1) <= 0;
}
- friend bool __stdcall operator==( XCHAR ch1, const CMStringT& str2 )
+ friend bool __stdcall operator==(XCHAR ch1, const CMStringT& str2)
{
return (str2.GetLength() == 1) && (str2[0] == ch1);
}
- friend bool __stdcall operator==( const CMStringT& str1, XCHAR ch2 )
+ friend bool __stdcall operator==(const CMStringT& str1, XCHAR ch2)
{
return (str1.GetLength() == 1) && (str1[0] == ch2);
}
- friend bool __stdcall operator!=( XCHAR ch1, const CMStringT& str2 )
+ friend bool __stdcall operator!=(XCHAR ch1, const CMStringT& str2)
{
return (str2.GetLength() != 1) || (str2[0] != ch1);
}
- friend bool __stdcall operator!=( const CMStringT& str1, XCHAR ch2 )
+ friend bool __stdcall operator!=(const CMStringT& str1, XCHAR ch2)
{
return (str1.GetLength() != 1) || (str1[0] != ch2);
}
};
template< typename BaseType, class StringTraits >
-inline void CMStringT<BaseType, StringTraits>::Format(PCXSTR pszFormat, ... )
+inline void CMStringT<BaseType, StringTraits>::Format(PCXSTR pszFormat, ...)
{
va_list argList;
- va_start( argList, pszFormat );
- FormatV( pszFormat, argList );
- va_end( argList );
+ va_start(argList, pszFormat);
+ FormatV(pszFormat, argList);
+ va_end(argList);
}
template< typename BaseType, class StringTraits >
-inline void CMStringT<BaseType, StringTraits>::AppendFormat(PCXSTR pszFormat, ... )
+inline void CMStringT<BaseType, StringTraits>::AppendFormat(PCXSTR pszFormat, ...)
{
va_list argList;
- va_start( argList, pszFormat );
- AppendFormatV( pszFormat, argList );
- va_end( argList );
+ va_start(argList, pszFormat);
+ AppendFormatV(pszFormat, argList);
+ va_end(argList);
}
typedef CMStringT< wchar_t, ChTraitsCRT< wchar_t > > CMStringW;
diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index b492ffcddb..bf658d9ab1 100644 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -46,7 +46,7 @@ struct CountryListEntry* g_countries; TCHAR szCoreVersion[100];
PLUGININFOEX pluginInfo = {
- sizeof( PLUGININFOEX ),
+ sizeof(PLUGININFOEX),
"Jabber Protocol",
__VERSION_DWORD,
"Jabber protocol plugin for Miranda NG.",
@@ -90,13 +90,13 @@ static int sttCompareProtocols(const CJabberProto *p1, const CJabberProto *p2) LIST<CJabberProto> g_Instances(1, sttCompareProtocols);
/////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain( HINSTANCE hModule, DWORD, LPVOID )
+BOOL WINAPI DllMain(HINSTANCE hModule, DWORD, LPVOID)
{
hInst = hModule;
return TRUE;
}
-extern "C" __declspec( dllexport ) PLUGININFOEX *MirandaPluginInfoEx( DWORD mirandaVersion )
+extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfo;
}
@@ -106,7 +106,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCO ///////////////////////////////////////////////////////////////////////////////
// OnPreShutdown - prepares Miranda to be shut down
-int __cdecl CJabberProto::OnPreShutdown( WPARAM, LPARAM )
+int __cdecl CJabberProto::OnPreShutdown(WPARAM, LPARAM)
{
UI_SAFE_CLOSE_HWND(m_hwndAgentRegInput);
UI_SAFE_CLOSE_HWND(m_hwndRegProgress);
@@ -145,16 +145,16 @@ static INT_PTR g_SvcParseXmppUri(WPARAM w, LPARAM l) return 0;
}
-static int OnModulesLoaded( WPARAM, LPARAM )
+static int OnModulesLoaded(WPARAM, LPARAM)
{
hModulesLoadedTB = HookEvent(ME_TTB_MODULELOADED, g_OnToolbarInit);
bSecureIM = (ServiceExists("SecureIM/IsContactSecured"));
// file associations manager plugin support
- if ( ServiceExists( MS_ASSOCMGR_ADDNEWURLTYPE )) {
- CreateServiceFunction("JABBER/*" JS_PARSE_XMPP_URI, g_SvcParseXmppUri );
- AssocMgr_AddNewUrlTypeT( "xmpp:", TranslateT("Jabber Link Protocol"), hInst, IDI_JABBER, "JABBER/*" JS_PARSE_XMPP_URI, 0 );
+ if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
+ CreateServiceFunction("JABBER/*" JS_PARSE_XMPP_URI, g_SvcParseXmppUri);
+ AssocMgr_AddNewUrlTypeT("xmpp:", TranslateT("Jabber Link Protocol"), hInst, IDI_JABBER, "JABBER/*" JS_PARSE_XMPP_URI, 0);
}
// init fontservice for info frame
@@ -201,56 +201,55 @@ static int OnModulesLoaded( WPARAM, LPARAM ) ///////////////////////////////////////////////////////////////////////////////
// OnLoad - initialize the plugin instance
-static CJabberProto* jabberProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
+static CJabberProto* jabberProtoInit(const char* pszProtoName, const TCHAR *tszUserName)
{
- CJabberProto *ppro = new CJabberProto( pszProtoName, tszUserName );
+ CJabberProto *ppro = new CJabberProto(pszProtoName, tszUserName);
g_Instances.insert(ppro);
return ppro;
}
-static int jabberProtoUninit( CJabberProto* ppro )
+static int jabberProtoUninit(CJabberProto* ppro)
{
g_Instances.remove(ppro);
delete ppro;
return 0;
}
-extern "C" int __declspec( dllexport ) Load()
+extern "C" int __declspec(dllexport) Load()
{
// set the memory, lists & utf8 managers
- mir_getXI( &xi );
- mir_getTMI( &tmi );
- mir_getLP( &pluginInfo );
+ mir_getXI(&xi);
+ mir_getTMI(&tmi);
+ mir_getLP(&pluginInfo);
WORD v[4];
CallService(MS_SYSTEM_GETFILEVERSION, 0, (LPARAM)v);
mir_sntprintf(szCoreVersion, SIZEOF(szCoreVersion), _T("%d.%d.%d.%d"), v[0], v[1], v[2], v[3]);
- CallService( MS_UTILS_GETCOUNTRYLIST, ( WPARAM )&g_cbCountries, ( LPARAM )&g_countries );
+ CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&g_cbCountries, (LPARAM)&g_countries);
setlocale(LC_ALL, "");
- pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst);
+ pcli = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst);
// Register protocol module
- PROTOCOLDESCRIPTOR pd;
- ZeroMemory( &pd, sizeof( PROTOCOLDESCRIPTOR ));
- pd.cbSize = sizeof( PROTOCOLDESCRIPTOR );
+ PROTOCOLDESCRIPTOR pd = { 0 };
+ pd.cbSize = sizeof(PROTOCOLDESCRIPTOR);
pd.szName = "JABBER";
- pd.fnInit = ( pfnInitProto )jabberProtoInit;
- pd.fnUninit = ( pfnUninitProto )jabberProtoUninit;
+ pd.fnInit = (pfnInitProto)jabberProtoInit;
+ pd.fnUninit = (pfnUninitProto)jabberProtoUninit;
pd.type = PROTOTYPE_PROTOCOL;
- CallService( MS_PROTO_REGISTERMODULE, 0, ( LPARAM )&pd );
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
// Load some fuctions
HMODULE hDll;
- if ( hDll = GetModuleHandleA( "gdi32.dll" ))
+ if (hDll = GetModuleHandleA("gdi32.dll"))
JabberAlphaBlend = (BOOL (WINAPI *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION)) GetProcAddress(hDll, "GdiAlphaBlend");
- if ( JabberAlphaBlend == NULL && ( hDll = LoadLibraryA("msimg32.dll" )))
+ if (JabberAlphaBlend == NULL && (hDll = LoadLibraryA("msimg32.dll")))
JabberAlphaBlend = (BOOL (WINAPI *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION)) GetProcAddress(hDll, "AlphaBlend");
- if ( IsWinVerXPPlus()) {
- if ( hDll = GetModuleHandleA("uxtheme")) {
+ if (IsWinVerXPPlus()) {
+ if (hDll = GetModuleHandleA("uxtheme")) {
JabberDrawThemeParentBackground = (HRESULT (WINAPI *)(HWND,HDC,RECT *))GetProcAddress(hDll, "DrawThemeParentBackground");
JabberIsThemeActive = (BOOL (WINAPI *)())GetProcAddress(hDll, "IsThemeActive");
} }
@@ -266,7 +265,7 @@ extern "C" int __declspec( dllexport ) Load() ///////////////////////////////////////////////////////////////////////////////
// Unload - destroy the plugin instance
-extern "C" int __declspec( dllexport ) Unload( void )
+extern "C" int __declspec(dllexport) Unload(void)
{
UnhookEvent(hModulesLoaded);
UnhookEvent(hModulesLoadedTB);
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index a585b8b3ac..8e987be6bc 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -99,8 +99,8 @@ class CJabberDlgBase: public CProtoDlgBase<CJabberProto> {
typedef CProtoDlgBase<CJabberProto> CSuper;
protected:
- __inline CJabberDlgBase(CJabberProto *proto, int idDialog, HWND parent, bool show_label=true ) :
- CSuper( proto, idDialog, parent, show_label )
+ __inline CJabberDlgBase(CJabberProto *proto, int idDialog, HWND parent, bool show_label=true) :
+ CSuper(proto, idDialog, parent, show_label)
{
}
@@ -214,7 +214,7 @@ protected: #define JABBER_FONT_ITALIC 2
// Font for groupchat log dialog
-#define JABBER_GCLOG_NUM_FONT 6 // 6 fonts ( 0:send, 1:msg, 2:time, 3:nick, 4:sys, 5:/me )
+#define JABBER_GCLOG_NUM_FONT 6 // 6 fonts (0:send, 1:msg, 2:time, 3:nick, 4:sys, 5:/me)
// Old SDK don't have this
#ifndef SPI_GETSCREENSAVERRUNNING
@@ -322,7 +322,7 @@ enum JABBER_SESSION_TYPE struct ThreadData
{
- ThreadData( CJabberProto* _ppro, JABBER_SESSION_TYPE parType );
+ ThreadData(CJabberProto* _ppro, JABBER_SESSION_TYPE parType);
~ThreadData();
HANDLE hThread;
@@ -341,12 +341,12 @@ struct ThreadData int zRecvDatalen;
char* zRecvData;
- void xmpp_client_query( void );
+ void xmpp_client_query(void);
- BOOL zlibInit( void );
+ BOOL zlibInit(void);
void zlibUninit();
- int zlibSend( char* data, int datalen );
- int zlibRecv( char* data, long datalen );
+ int zlibSend(char* data, int datalen);
+ int zlibRecv(char* data, long datalen);
// for nick names resolving
int resolveID;
@@ -370,15 +370,15 @@ struct ThreadData WORD port;
TCHAR newPassword[512];
- void close( void );
- void shutdown( void );
- int recv( char* buf, size_t len );
- int send( char* buffer, int bufsize );
- int send( const char* fmt, ... );
- int send( HXML node );
+ void close(void);
+ void shutdown(void);
+ int recv(char* buf, size_t len);
+ int send(char* buffer, int bufsize);
+ int send(const char* fmt, ...);
+ int send(HXML node);
- int recvws( char* buffer, size_t bufsize, int flags );
- int sendws( char* buffer, size_t bufsize, int flags );
+ int recvws(char* buffer, size_t bufsize, int flags);
+ int sendws(char* buffer, size_t bufsize, int flags);
};
struct JABBER_MODEMSGS
@@ -405,7 +405,7 @@ typedef enum { FT_CONNECTING, FT_INITIALIZING, FT_RECEIVING, FT_DONE, FT_ERROR, struct filetransfer
{
- filetransfer( CJabberProto* proto );
+ filetransfer(CJabberProto* proto);
~filetransfer();
void close();
@@ -484,10 +484,10 @@ struct JABBER_MUC_JIDLIST_INFO HXML iqNode;
CJabberProto* ppro;
- TCHAR* type2str( void ) const;
+ TCHAR* type2str(void) const;
};
-typedef void ( CJabberProto::*JABBER_FORM_SUBMIT_FUNC )( HXML values, void *userdata );
+typedef void (CJabberProto::*JABBER_FORM_SUBMIT_FUNC)(HXML values, void *userdata);
//---- jabber_treelist.c ------------------------------------------------
@@ -621,26 +621,26 @@ enum TJabberFormControlType typedef struct TJabberFormControlInfo *HJFORMCTRL;
typedef struct TJabberFormLayoutInfo *HJFORMLAYOUT;
-void JabberFormCreateUI( HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCompact = FALSE );
+void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCompact = FALSE);
void JabberFormDestroyUI(HWND hwndStatic);
-void JabberFormSetInstruction( HWND hwndForm, const TCHAR *text );
+void JabberFormSetInstruction(HWND hwndForm, const TCHAR *text);
HJFORMLAYOUT JabberFormCreateLayout(HWND hwndStatic); // use mir_free to destroy
HJFORMCTRL JabberFormAppendControl(HWND hwndStatic, HJFORMLAYOUT layout_info, TJabberFormControlType type, const TCHAR *labelStr, const TCHAR *valueStr);
void JabberFormAddListItem(HJFORMCTRL item, const TCHAR *text, bool selected);
void JabberFormLayoutControls(HWND hwndStatic, HJFORMLAYOUT layout_info, int *formHeight);
-void JabberFormCreateDialog( HXML xNode, TCHAR* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata );
+void JabberFormCreateDialog(HXML xNode, TCHAR* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata);
-HXML JabberFormGetData( HWND hwndStatic, HXML xNode );
+HXML JabberFormGetData(HWND hwndStatic, HXML xNode);
//---- jabber_icolib.c ----------------------------------------------
void g_IconsInit();
-HANDLE g_GetIconHandle( int iconId );
-HICON g_LoadIconEx( const char* name, bool big = false );
-void g_ReleaseIcon( HICON hIcon );
+HANDLE g_GetIconHandle(int iconId);
+HICON g_LoadIconEx(const char* name, bool big = false);
+void g_ReleaseIcon(HICON hIcon);
-void ImageList_AddIcon_Icolib( HIMAGELIST hIml, HICON hIcon );
+void ImageList_AddIcon_Icolib(HIMAGELIST hIml, HICON hIcon);
void WindowSetIcon(HWND hWnd, CJabberProto *proto, const char* name);
void WindowFreeIcon(HWND hWnd);
@@ -658,9 +658,9 @@ int g_OnToolbarInit(WPARAM, LPARAM); //---- jabber_misc.c ------------------------------------------------
-void JabberChatDllError( void );
-int JabberCompareJids( const TCHAR* jid1, const TCHAR* jid2 );
-void JabberContactListCreateGroup( TCHAR* groupName );
+void JabberChatDllError(void);
+int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2);
+void JabberContactListCreateGroup(TCHAR* groupName);
TCHAR* EscapeChatTags(TCHAR* pszText);
TCHAR* UnEscapeChatTags(TCHAR* str_in);
@@ -672,18 +672,18 @@ struct CJabberAdhocStartupParams TCHAR* m_szNode;
CJabberProto* m_pProto;
- CJabberAdhocStartupParams( CJabberProto* proto, TCHAR* szJid, TCHAR* szNode = NULL )
+ CJabberAdhocStartupParams(CJabberProto* proto, TCHAR* szJid, TCHAR* szNode = NULL)
{
m_pProto = proto;
- m_szJid = mir_tstrdup( szJid );
- m_szNode = szNode ? mir_tstrdup( szNode ) : NULL;
+ m_szJid = mir_tstrdup(szJid);
+ m_szNode = szNode ? mir_tstrdup(szNode) : NULL;
}
~CJabberAdhocStartupParams()
{
- if ( m_szJid )
- mir_free( m_szJid );
- if ( m_szNode )
- mir_free( m_szNode );
+ if (m_szJid)
+ mir_free(m_szJid);
+ if (m_szNode)
+ mir_free(m_szNode);
}
};
@@ -701,8 +701,7 @@ struct JabberAdHocData //---- jabber_std.cpp -------------------------------------------------------------------
-void __fastcall JFreeVariant( DBVARIANT* dbv );
-char* __fastcall JTranslate( const char* str );
+char* __fastcall JTranslate(const char* str);
//---- jabber_util.cpp ------------------------------------------------------------------
@@ -713,54 +712,54 @@ struct TStringPairsElem struct TStringPairs
{
- TStringPairs( char* );
+ TStringPairs(char*);
~TStringPairs();
- const char* operator[]( const char* name ) const;
+ const char* operator[](const char* name) const;
int numElems;
TStringPairsElem* elems;
};
-TCHAR* __stdcall JabberNickFromJID( const TCHAR* jid );
-TCHAR* JabberPrepareJid( LPCTSTR jid );
-char* __stdcall JabberUrlDecode( char* str );
-void __stdcall JabberUrlDecodeW( WCHAR* str );
-char* __stdcall JabberUrlEncode( const char* str );
-char* __stdcall JabberSha1( char* str );
-TCHAR* __stdcall JabberStrFixLines( const TCHAR* str );
-char* __stdcall JabberUnixToDos( const char* str );
-WCHAR* __stdcall JabberUnixToDosW( const WCHAR* str );
-void __stdcall JabberHttpUrlDecode( TCHAR* str );
-TCHAR* __stdcall JabberHttpUrlEncode( const TCHAR* str );
-int __stdcall JabberCombineStatus( int status1, int status2 );
-TCHAR* __stdcall JabberErrorStr( int errorCode );
-TCHAR* __stdcall JabberErrorMsg( HXML errorNode, int* errorCode = NULL );
-void __stdcall JabberUtfToTchar( const char* str, size_t cbLen, LPTSTR& dest );
-char* __stdcall JabberBase64Encode( const char* buffer, int bufferLen );
-char* __stdcall JabberBase64Decode( const char* buffer, int *resultLen );
-char* __stdcall JabberBase64DecodeW( const WCHAR* buffer, int *resultLen );
-time_t __stdcall JabberIsoToUnixTime( const TCHAR* stamp );
-void __stdcall JabberStringAppend( char* *str, int *sizeAlloced, const char* fmt, ... );
-TCHAR* __stdcall JabberStripJid( const TCHAR* jid, TCHAR* dest, size_t destLen );
-int __stdcall JabberGetPictureType( const char* buf );
-int __stdcall JabberGetPacketID( HXML n );
+TCHAR* __stdcall JabberNickFromJID(const TCHAR *jid);
+TCHAR* JabberPrepareJid(LPCTSTR jid);
+char* __stdcall JabberUrlDecode(char* str);
+void __stdcall JabberUrlDecodeW(WCHAR* str);
+char* __stdcall JabberUrlEncode(const char* str);
+char* __stdcall JabberSha1(char* str);
+TCHAR* __stdcall JabberStrFixLines(const TCHAR *str);
+char* __stdcall JabberUnixToDos(const char* str);
+WCHAR* __stdcall JabberUnixToDosW(const WCHAR* str);
+void __stdcall JabberHttpUrlDecode(TCHAR* str);
+TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str);
+int __stdcall JabberCombineStatus(int status1, int status2);
+TCHAR* __stdcall JabberErrorStr(int errorCode);
+TCHAR* __stdcall JabberErrorMsg(HXML errorNode, int* errorCode = NULL);
+void __stdcall JabberUtfToTchar(const char* str, size_t cbLen, LPTSTR& dest);
+char* __stdcall JabberBase64Encode(const char* buffer, int bufferLen);
+char* __stdcall JabberBase64Decode(const char* buffer, int *resultLen);
+char* __stdcall JabberBase64DecodeW(const WCHAR* buffer, int *resultLen);
+time_t __stdcall JabberIsoToUnixTime(const TCHAR *stamp);
+void __stdcall JabberStringAppend(char* *str, int *sizeAlloced, const char* fmt, ...);
+TCHAR* __stdcall JabberStripJid(const TCHAR *jid, TCHAR* dest, size_t destLen);
+int __stdcall JabberGetPictureType(const char* buf);
+int __stdcall JabberGetPacketID(HXML n);
#define JabberUnixToDosT JabberUnixToDosW
#define JabberBase64DecodeT JabberBase64DecodeW
-const TCHAR *JabberStrIStr( const TCHAR *str, const TCHAR *substr);
+const TCHAR *JabberStrIStr(const TCHAR *str, const TCHAR *substr);
void JabberCopyText(HWND hwnd, TCHAR *text);
void JabberBitmapPremultiplyChannels(HBITMAP hBitmap);
CJabberProto *JabberChooseInstance(bool bIsLink=false);
//---- jabber_xml.cpp -------------------------------------------------------------------
-void strdel( char* parBuffer, int len );
+void strdel(char* parBuffer, int len);
//---- jabber_userinfo.cpp --------------------------------------------------------------
-void JabberUserInfoUpdate( HANDLE hContact );
+void JabberUserInfoUpdate(HANDLE hContact);
//---- jabber_iq_handlers.cpp
BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE);
diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index 09884e79df..c19589ee73 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -1,9 +1,9 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2007 Artem Shpynov
-Copyright ( C ) 2005-12 George Hazan
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2007 Artem Shpynov
+Copyright (C) 2005-12 George Hazan
Module implements an XMPP protocol extension for reporting and executing ad-hoc,
human-oriented commands according to XEP-0050: Ad-Hoc Commands
@@ -12,7 +12,7 @@ http://www.xmpp.org/extensions/xep-0050.html 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
@@ -32,8 +32,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_caps.h"
-#define ShowDlgItem( a, b, c ) ShowWindow( GetDlgItem( a, b ), c )
-#define EnableDlgItem( a, b, c ) EnableWindow( GetDlgItem( a, b ), c )
+#define ShowDlgItem(a, b, c) ShowWindow(GetDlgItem(a, b), c)
+#define EnableDlgItem(a, b, c) EnableWindow(GetDlgItem(a, b), c)
enum
{
@@ -42,58 +42,58 @@ enum };
//Declarations
-static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam );
+static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
//implementations
// convert iqID to dialog hwnd
-HWND CJabberProto::GetWindowFromIq( HXML iqNode )
+HWND CJabberProto::GetWindowFromIq(HXML iqNode)
{
- const TCHAR* id = xmlGetAttrValue( iqNode, _T( "id" ));
+ const TCHAR *id = xmlGetAttrValue(iqNode, _T("id"));
if (_tcslen(id)>4)
return (HWND)_tcstol(id+4,NULL,10);
return m_hwndCommandWindow;
}
// Callback to clear form content
-static BOOL CALLBACK sttDeleteChildWindowsProc( HWND hwnd, LPARAM )
+static BOOL CALLBACK sttDeleteChildWindowsProc(HWND hwnd, LPARAM)
{
- DestroyWindow( hwnd );
+ DestroyWindow(hwnd);
return TRUE;
}
-static void sttEnableControls( HWND hwndDlg, BOOL bEnable, const int * controlsID )
+static void sttEnableControls(HWND hwndDlg, BOOL bEnable, const int * controlsID)
{
int i=0;
- while ( controlsID[i]!=0 )
- EnableDlgItem( hwndDlg, controlsID[i++], bEnable );
+ while (controlsID[i] != 0)
+ EnableDlgItem(hwndDlg, controlsID[i++], bEnable);
}
-static void sttShowControls( HWND hwndDlg, BOOL bShow, int * controlsID )
+static void sttShowControls(HWND hwndDlg, BOOL bShow, int * controlsID)
{
int i=0;
- while ( controlsID[i]!=0 )
- ShowDlgItem( hwndDlg, controlsID[i++], (bShow) ? SW_SHOW : SW_HIDE );
+ while (controlsID[i] != 0)
+ ShowDlgItem(hwndDlg, controlsID[i++], (bShow) ? SW_SHOW : SW_HIDE);
}
static void JabberAdHoc_RefreshFrameScroll(HWND hwndDlg, JabberAdHocData * dat)
{
- HWND hFrame = GetDlgItem( hwndDlg, IDC_FRAME );
- HWND hwndScroll = GetDlgItem( hwndDlg, IDC_VSCROLL );
+ HWND hFrame = GetDlgItem(hwndDlg, IDC_FRAME);
+ HWND hwndScroll = GetDlgItem(hwndDlg, IDC_VSCROLL);
RECT rc;
RECT rcScrollRc;
- GetClientRect( hFrame, &rc );
- GetClientRect( hFrame, &dat->frameRect );
- GetWindowRect( hwndScroll, &rcScrollRc );
+ GetClientRect(hFrame, &rc);
+ GetClientRect(hFrame, &dat->frameRect);
+ GetWindowRect(hwndScroll, &rcScrollRc);
dat->frameRect.right-=(rcScrollRc.right-rcScrollRc.left);
dat->frameHeight = rc.bottom-rc.top;
- if ( dat->frameHeight < dat->CurrentHeight) {
- ShowWindow( hwndScroll, SW_SHOW );
- EnableWindow( hwndScroll, TRUE );
+ if (dat->frameHeight < dat->CurrentHeight) {
+ ShowWindow(hwndScroll, SW_SHOW);
+ EnableWindow(hwndScroll, TRUE);
}
- else ShowWindow( hwndScroll, SW_HIDE );
+ else ShowWindow(hwndScroll, SW_HIDE);
- SetScrollRange( hwndScroll, SB_CTL, 0, dat->CurrentHeight-dat->frameHeight, FALSE );
+ SetScrollRange(hwndScroll, SB_CTL, 0, dat->CurrentHeight-dat->frameHeight, FALSE);
}
@@ -101,238 +101,238 @@ static void JabberAdHoc_RefreshFrameScroll(HWND hwndDlg, JabberAdHocData * dat) // Iq handlers
// Forwards to dialog window procedure
-void CJabberProto::OnIqResult_ListOfCommands( HXML iqNode )
+void CJabberProto::OnIqResult_ListOfCommands(HXML iqNode)
{
- SendMessage( GetWindowFromIq( iqNode ), JAHM_COMMANDLISTRESULT, 0, (LPARAM)xi.copyNode( iqNode ));
+ SendMessage(GetWindowFromIq(iqNode), JAHM_COMMANDLISTRESULT, 0, (LPARAM)xi.copyNode(iqNode));
}
-void CJabberProto::OnIqResult_CommandExecution( HXML iqNode )
+void CJabberProto::OnIqResult_CommandExecution(HXML iqNode)
{
- SendMessage( GetWindowFromIq( iqNode ), JAHM_PROCESSRESULT, (WPARAM)xi.copyNode( iqNode ), 0 );
+ SendMessage(GetWindowFromIq(iqNode), JAHM_PROCESSRESULT, (WPARAM)xi.copyNode(iqNode), 0);
}
-int CJabberProto::AdHoc_RequestListOfCommands( TCHAR * szResponder, HWND hwndDlg )
+int CJabberProto::AdHoc_RequestListOfCommands(TCHAR * szResponder, HWND hwndDlg)
{
int iqId = (int)hwndDlg;
- IqAdd( iqId, IQ_PROC_DISCOCOMMANDS, &CJabberProto::OnIqResult_ListOfCommands );
- m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId, szResponder ) << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS))
- << XATTR( _T("node"), _T(JABBER_FEAT_COMMANDS)));
+ IqAdd(iqId, IQ_PROC_DISCOCOMMANDS, &CJabberProto::OnIqResult_ListOfCommands);
+ m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId, szResponder) << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS))
+ << XATTR(_T("node"), _T(JABBER_FEAT_COMMANDS)));
return iqId;
}
-int CJabberProto::AdHoc_ExecuteCommand( HWND hwndDlg, TCHAR*, JabberAdHocData* dat )
+int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, TCHAR*, JabberAdHocData* dat)
{
- for ( int i = 1; ; i++ ) {
- HXML itemNode = xmlGetNthChild( dat->CommandsNode, _T("item"), i );
+ for (int i = 1; ; i++) {
+ HXML itemNode = xmlGetNthChild(dat->CommandsNode, _T("item"), i);
if ( !itemNode)
break;
- if ( !IsDlgButtonChecked( GetDlgItem( hwndDlg, IDC_FRAME ), i ))
+ if ( !IsDlgButtonChecked(GetDlgItem(hwndDlg, IDC_FRAME), i))
continue;
- const TCHAR* node = xmlGetAttrValue( itemNode, _T("node"));
- if ( node ) {
- const TCHAR *jid2 = xmlGetAttrValue( itemNode, _T("jid"));
+ const TCHAR *node = xmlGetAttrValue(itemNode, _T("node"));
+ if (node) {
+ const TCHAR *jid2 = xmlGetAttrValue(itemNode, _T("jid"));
int iqId = (int)hwndDlg;
- IqAdd( iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution );
+ IqAdd(iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution);
m_ThreadInfo->send(
- XmlNodeIq( _T("set"), iqId, jid2 )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), node ) << XATTR( _T("action"), _T("execute")));
+ XmlNodeIq(_T("set"), iqId, jid2)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), node) << XATTR(_T("action"), _T("execute")));
- EnableDlgItem( hwndDlg, IDC_SUBMIT, FALSE );
- SetDlgItemText( hwndDlg, IDC_SUBMIT, TranslateT( "OK" ));
+ EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
+ SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
} }
- xi.destroyNode( dat->CommandsNode ); dat->CommandsNode = NULL;
+ xi.destroyNode(dat->CommandsNode); dat->CommandsNode = NULL;
return TRUE;
}
//Messages handlers
-int CJabberProto::AdHoc_OnJAHMCommandListResult( HWND hwndDlg, HXML iqNode, JabberAdHocData* dat )
+int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, HXML iqNode, JabberAdHocData* dat)
{
int nodeIdx = 0;
- const TCHAR * type = xmlGetAttrValue( iqNode, _T("type"));
- if ( !type || !_tcscmp( type, _T( "error" )) ) {
+ const TCHAR * type = xmlGetAttrValue(iqNode, _T("type"));
+ if ( !type || !_tcscmp(type, _T("error"))) {
// error occurred here
TCHAR buff[255];
- const TCHAR* code = NULL;
- const TCHAR* description = NULL;
+ const TCHAR *code = NULL;
+ const TCHAR *description = NULL;
- HXML errorNode = xmlGetChild( iqNode, "error" );
- if ( errorNode ) {
- code = xmlGetAttrValue( errorNode, _T("code"));
- description = xmlGetText( errorNode );
+ HXML errorNode = xmlGetChild(iqNode, "error");
+ if (errorNode) {
+ code = xmlGetAttrValue(errorNode, _T("code"));
+ description = xmlGetText(errorNode);
}
- _sntprintf( buff, SIZEOF(buff), TranslateT( "Error %s %s" ), (code) ? code : _T(""), (description) ? description : _T(""));
- JabberFormSetInstruction( hwndDlg, buff );
+ _sntprintf(buff, SIZEOF(buff), TranslateT("Error %s %s"), (code) ? code : _T(""), (description) ? description : _T(""));
+ JabberFormSetInstruction(hwndDlg, buff);
}
- else if ( !_tcscmp( type, _T("result")) ) {
+ else if ( !_tcscmp(type, _T("result"))) {
BOOL validResponse = FALSE;
- EnumChildWindows( GetDlgItem( hwndDlg, IDC_FRAME ), sttDeleteChildWindowsProc, 0 );
+ EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), sttDeleteChildWindowsProc, 0);
dat->CurrentHeight = 0;
dat->curPos = 0;
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE );
- HXML queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode ) {
- const TCHAR* xmlns = xmlGetAttrValue( queryNode, _T( "xmlns" ));
- const TCHAR* node = xmlGetAttrValue( queryNode, _T( "node" ));
- if ( xmlns && node
- && !_tcscmp( xmlns, _T( JABBER_FEAT_DISCO_ITEMS ))
- && !_tcscmp( node, _T( JABBER_FEAT_COMMANDS )) )
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE);
+ HXML queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode) {
+ const TCHAR *xmlns = xmlGetAttrValue(queryNode, _T("xmlns"));
+ const TCHAR *node = xmlGetAttrValue(queryNode, _T("node"));
+ if (xmlns && node
+ && !_tcscmp(xmlns, _T(JABBER_FEAT_DISCO_ITEMS))
+ && !_tcscmp(node, _T(JABBER_FEAT_COMMANDS)))
validResponse = TRUE;
}
- if ( queryNode && xmlGetChild( queryNode ,0) && validResponse ) {
- dat->CommandsNode = xi.copyNode( queryNode );
+ if (queryNode && xmlGetChild(queryNode ,0) && validResponse) {
+ dat->CommandsNode = xi.copyNode(queryNode);
nodeIdx = 1;
int ypos = 20;
- for (nodeIdx = 1; ; nodeIdx++ ) {
- HXML itemNode = xmlGetNthChild( queryNode, _T("item"), nodeIdx );
- if ( itemNode ) {
- const TCHAR *name = xmlGetAttrValue( itemNode, _T("name"));
- if (!name) name = xmlGetAttrValue( itemNode, _T("node"));
- ypos = AdHoc_AddCommandRadio( GetDlgItem( hwndDlg,IDC_FRAME ), TranslateTS(name), nodeIdx, ypos, (nodeIdx==1) ? 1 : 0);
+ for (nodeIdx = 1; ; nodeIdx++) {
+ HXML itemNode = xmlGetNthChild(queryNode, _T("item"), nodeIdx);
+ if (itemNode) {
+ const TCHAR *name = xmlGetAttrValue(itemNode, _T("name"));
+ if ( !name) name = xmlGetAttrValue(itemNode, _T("node"));
+ ypos = AdHoc_AddCommandRadio(GetDlgItem(hwndDlg,IDC_FRAME), TranslateTS(name), nodeIdx, ypos, (nodeIdx==1) ? 1 : 0);
dat->CurrentHeight = ypos;
}
else break;
} }
if (nodeIdx>1) {
- JabberFormSetInstruction( hwndDlg, TranslateT("Select Command"));
- ShowDlgItem( hwndDlg, IDC_FRAME, SW_SHOW);
- ShowDlgItem( hwndDlg, IDC_VSCROLL, SW_SHOW);
- EnableDlgItem( hwndDlg, IDC_SUBMIT, TRUE);
+ JabberFormSetInstruction(hwndDlg, TranslateT("Select Command"));
+ ShowDlgItem(hwndDlg, IDC_FRAME, SW_SHOW);
+ ShowDlgItem(hwndDlg, IDC_VSCROLL, SW_SHOW);
+ EnableDlgItem(hwndDlg, IDC_SUBMIT, TRUE);
} else {
JabberFormSetInstruction(hwndDlg, TranslateT("Not supported"));
} }
- JabberAdHoc_RefreshFrameScroll( hwndDlg, dat );
+ JabberAdHoc_RefreshFrameScroll(hwndDlg, dat);
return (TRUE);
}
int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberAdHocData* dat)
{
- EnumChildWindows( GetDlgItem( hwndDlg, IDC_FRAME ), sttDeleteChildWindowsProc, 0 );
+ EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), sttDeleteChildWindowsProc, 0);
dat->CurrentHeight = 0;
dat->curPos = 0;
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE );
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE);
- if ( workNode == NULL )
+ if (workNode == NULL)
return TRUE;
- dat->AdHocNode = xi.copyNode( workNode );
+ dat->AdHocNode = xi.copyNode(workNode);
const TCHAR *type;
- if (( type = xmlGetAttrValue( workNode, _T("type"))) == NULL ) return TRUE;
- if ( !lstrcmp( type, _T("result")) ) {
+ if ((type = xmlGetAttrValue(workNode, _T("type"))) == NULL) return TRUE;
+ if ( !lstrcmp(type, _T("result"))) {
// wParam = <iq/> node from responder as a result of command execution
HXML commandNode, xNode, n;
- if (( commandNode = xmlGetChild( dat->AdHocNode, _T("command"))) == NULL )
+ if ((commandNode = xmlGetChild(dat->AdHocNode, _T("command"))) == NULL)
return TRUE;
- const TCHAR * status = xmlGetAttrValue( commandNode, _T("status"));
- if (!status) status = _T("completed");
+ const TCHAR * status = xmlGetAttrValue(commandNode, _T("status"));
+ if ( !status) status = _T("completed");
- if (( xNode = xmlGetChild( commandNode , "x" ))) {
+ if ((xNode = xmlGetChild(commandNode , "x"))) {
// use jabber:x:data form
- HWND hFrame = GetDlgItem( hwndDlg, IDC_FRAME );
- ShowWindow( GetDlgItem( hwndDlg, IDC_FRAME_TEXT ), SW_HIDE );
- if (( n = xmlGetChild( xNode , "instructions" )) != NULL && xmlGetText( n )!=NULL )
- JabberFormSetInstruction( hwndDlg, xmlGetText( n ));
- else if (( n = xmlGetChild( xNode , "title" )) != NULL && xmlGetText( n )!=NULL )
- JabberFormSetInstruction( hwndDlg, xmlGetText( n ));
+ HWND hFrame = GetDlgItem(hwndDlg, IDC_FRAME);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME_TEXT), SW_HIDE);
+ if ((n = xmlGetChild(xNode , "instructions")) != NULL && xmlGetText(n)!=NULL)
+ JabberFormSetInstruction(hwndDlg, xmlGetText(n));
+ else if ((n = xmlGetChild(xNode , "title")) != NULL && xmlGetText(n)!=NULL)
+ JabberFormSetInstruction(hwndDlg, xmlGetText(n));
else
JabberFormSetInstruction(hwndDlg, TranslateTS(status));
- JabberFormCreateUI( hFrame, xNode, &dat->CurrentHeight );
- ShowDlgItem( hwndDlg, IDC_FRAME , SW_SHOW);
+ JabberFormCreateUI(hFrame, xNode, &dat->CurrentHeight);
+ ShowDlgItem( hwndDlg, IDC_FRAME , SW_SHOW);
}
else {
//NO X FORM
int toHide[]={ IDC_FRAME_TEXT, IDC_FRAME, IDC_VSCROLL, 0};
- sttShowControls(hwndDlg, FALSE, toHide );
+ sttShowControls(hwndDlg, FALSE, toHide);
const TCHAR * noteText=NULL;
- HXML noteNode = xmlGetChild( commandNode , "note");
+ HXML noteNode = xmlGetChild(commandNode , "note");
if (noteNode)
- noteText = xmlGetText( noteNode );
+ noteText = xmlGetText(noteNode);
JabberFormSetInstruction(hwndDlg, noteText ? noteText : TranslateTS(status));
}
//check actions
- HXML actionsNode = xmlGetChild( commandNode , "actions");
- if ( actionsNode != NULL ) {
- ShowDlgItem( hwndDlg, IDC_PREV, ( xmlGetChild( actionsNode , "prev")!=NULL) ? SW_SHOW : SW_HIDE);
- ShowDlgItem( hwndDlg, IDC_NEXT, ( xmlGetChild( actionsNode , "next")!=NULL) ? SW_SHOW : SW_HIDE);
- ShowDlgItem( hwndDlg, IDC_COMPLETE, ( xmlGetChild( actionsNode , "complete")!=NULL) ? SW_SHOW : SW_HIDE);
- ShowDlgItem( hwndDlg, IDC_SUBMIT, SW_HIDE);
+ HXML actionsNode = xmlGetChild(commandNode , "actions");
+ if (actionsNode != NULL) {
+ ShowDlgItem(hwndDlg, IDC_PREV, (xmlGetChild(actionsNode , "prev")!=NULL) ? SW_SHOW : SW_HIDE);
+ ShowDlgItem(hwndDlg, IDC_NEXT, (xmlGetChild(actionsNode , "next")!=NULL) ? SW_SHOW : SW_HIDE);
+ ShowDlgItem(hwndDlg, IDC_COMPLETE, (xmlGetChild(actionsNode , "complete")!=NULL) ? SW_SHOW : SW_HIDE);
+ ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE);
int toEnable[]={ IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0};
- sttEnableControls( hwndDlg, TRUE, toEnable );
+ sttEnableControls(hwndDlg, TRUE, toEnable);
} else {
int toHide[]={ IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0};
- sttShowControls(hwndDlg, FALSE, toHide );
+ sttShowControls(hwndDlg, FALSE, toHide);
ShowDlgItem(hwndDlg,IDC_SUBMIT, SW_SHOW);
EnableDlgItem(hwndDlg,IDC_SUBMIT, TRUE);
}
- if (!status || _tcscmp(status,_T("executing"))) {
- ShowDlgItem( hwndDlg, IDC_SUBMIT, SW_HIDE);
+ if ( !status || _tcscmp(status,_T("executing"))) {
+ ShowDlgItem(hwndDlg, IDC_SUBMIT, SW_HIDE);
SetWindowText(GetDlgItem(hwndDlg,IDCANCEL), TranslateT("Done"));
} }
- else if ( !lstrcmp( type, _T("error"))) {
+ else if ( !lstrcmp(type, _T("error"))) {
// error occurred here
int toHide[]={ IDC_FRAME, IDC_FRAME_TEXT, IDC_VSCROLL,
IDC_PREV, IDC_NEXT, IDC_COMPLETE, IDC_SUBMIT, 0};
- sttShowControls(hwndDlg, FALSE, toHide );
+ sttShowControls(hwndDlg, FALSE, toHide);
- const TCHAR* code=NULL;
- const TCHAR* description=NULL;
+ const TCHAR *code=NULL;
+ const TCHAR *description=NULL;
TCHAR buff[255];
- HXML errorNode = xmlGetChild( workNode , "error");
- if ( errorNode ) {
- code = xmlGetAttrValue( errorNode, _T("code"));
- description = xmlGetText( errorNode );
+ HXML errorNode = xmlGetChild(workNode , "error");
+ if (errorNode) {
+ code = xmlGetAttrValue(errorNode, _T("code"));
+ description = xmlGetText(errorNode);
}
_sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s"),code ? code : _T(""),description?description:_T(""));
JabberFormSetInstruction(hwndDlg,buff);
}
- JabberAdHoc_RefreshFrameScroll( hwndDlg, dat );
+ JabberAdHoc_RefreshFrameScroll(hwndDlg, dat);
return TRUE;
}
int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData* dat, TCHAR* action)
{
- HXML commandNode = xmlGetChild( dat->AdHocNode, "command" );
- HXML xNode = xmlGetChild( commandNode , "x" );
- HXML dataNode = JabberFormGetData( GetDlgItem( hwndDlg, IDC_FRAME ), xNode);
+ HXML commandNode = xmlGetChild(dat->AdHocNode, "command");
+ HXML xNode = xmlGetChild(commandNode , "x");
+ HXML dataNode = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), xNode);
int iqId = (int)hwndDlg;
- XmlNodeIq iq( _T("set"), iqId, xmlGetAttrValue( dat->AdHocNode, _T("from")));
- HXML command = iq << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS));
+ XmlNodeIq iq(_T("set"), iqId, xmlGetAttrValue(dat->AdHocNode, _T("from")));
+ HXML command = iq << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS));
- const TCHAR* sessionId = xmlGetAttrValue( commandNode, _T("sessionid"));
- if ( sessionId )
- command << XATTR( _T("sessionid"), sessionId );
+ const TCHAR *sessionId = xmlGetAttrValue(commandNode, _T("sessionid"));
+ if (sessionId)
+ command << XATTR(_T("sessionid"), sessionId);
- const TCHAR* node = xmlGetAttrValue( commandNode, _T("node"));
- if ( node )
- command << XATTR( _T("node"), node );
+ const TCHAR *node = xmlGetAttrValue(commandNode, _T("node"));
+ if (node)
+ command << XATTR(_T("node"), node);
- if ( action )
- command << XATTR( _T("action"), action );
+ if (action)
+ command << XATTR(_T("action"), action);
- xmlAddChild( command, dataNode );
- IqAdd( iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution );
- m_ThreadInfo->send( iq );
+ xmlAddChild(command, dataNode);
+ IqAdd(iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution);
+ m_ThreadInfo->send(iq);
- xi.destroyNode( dataNode );
+ xi.destroyNode(dataNode);
JabberFormSetInstruction(hwndDlg,TranslateT("In progress. Please Wait..."));
static const int toDisable[]={IDC_SUBMIT, IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0};
- sttEnableControls( hwndDlg, FALSE, toDisable);
+ sttEnableControls(hwndDlg, FALSE, toDisable);
return TRUE;
}
@@ -353,21 +353,21 @@ int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, TCHAR * labelStr, int id, i int ctrlOffset=20;
int ctrlWidth=rcFrame.right-ctrlOffset;
- HDC hdc = GetDC( hFrame );
- labelHeight = max(ctrlMinHeight, DrawText( hdc , labelStr, -1, &strRect, DT_CALCRECT ));
- ctrlWidth=min( ctrlWidth, strRect.right-strRect.left+20 );
- ReleaseDC( hFrame, hdc );
+ HDC hdc = GetDC(hFrame);
+ labelHeight = max(ctrlMinHeight, DrawText(hdc , labelStr, -1, &strRect, DT_CALCRECT));
+ ctrlWidth=min(ctrlWidth, strRect.right-strRect.left+20);
+ ReleaseDC(hFrame, hdc);
- hCtrl = CreateWindowEx( 0, _T("button"), labelStr, WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, ( HMENU ) id, hInst, NULL );
- SendMessage( hCtrl, WM_SETFONT, ( WPARAM ) SendMessage( GetParent(hFrame), WM_GETFONT, 0, 0 ), 0 );
- SendMessage( hCtrl, BM_SETCHECK, value, 0 );
+ hCtrl = CreateWindowEx(0, _T("button"), labelStr, WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON, ctrlOffset, ypos, ctrlWidth, labelHeight, hFrame, (HMENU) id, hInst, NULL);
+ SendMessage(hCtrl, WM_SETFONT, (WPARAM)SendMessage(GetParent(hFrame), WM_GETFONT, 0, 0), 0);
+ SendMessage(hCtrl, BM_SETCHECK, value, 0);
return (ypos + labelHeight + verticalStep);
}
-static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberAdHocData* dat = ( JabberAdHocData* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JabberAdHocData* dat = (JabberAdHocData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg)
{
case WM_INITDIALOG:
@@ -381,21 +381,21 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR dat->proto = pStartupParams->m_pProto;
SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)dat);
- WindowSetIcon( hwndDlg, dat->proto, "adhoc" );
+ WindowSetIcon(hwndDlg, dat->proto, "adhoc");
dat->proto->m_hwndCommandWindow = hwndDlg;
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
//Firstly hide frame
- LONG frameExStyle = GetWindowLongPtr( GetDlgItem( hwndDlg, IDC_FRAME ), GWL_EXSTYLE );
+ LONG frameExStyle = GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FRAME), GWL_EXSTYLE);
frameExStyle |= WS_EX_CONTROLPARENT;
- SetWindowLongPtr( GetDlgItem( hwndDlg, IDC_FRAME ), GWL_EXSTYLE, frameExStyle );
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FRAME), GWL_EXSTYLE, frameExStyle);
int toHide[]={ IDC_FRAME, IDC_VSCROLL, IDC_PREV, IDC_NEXT, IDC_COMPLETE, IDC_FRAME_TEXT, 0};
- sttShowControls(hwndDlg, FALSE, toHide );
+ sttShowControls(hwndDlg, FALSE, toHide);
int toShow[]={ IDC_INSTRUCTION, IDC_SUBMIT, IDCANCEL, 0};
- sttShowControls(hwndDlg, TRUE, toShow );
+ sttShowControls(hwndDlg, TRUE, toShow);
EnableDlgItem(hwndDlg,IDC_VSCROLL,TRUE);
@@ -404,27 +404,27 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR SetDlgItemText(hwndDlg,IDC_SUBMIT, TranslateT("Execute"));
JabberFormSetInstruction(hwndDlg,TranslateT("Requesting command list. Please wait..."));
- if ( !pStartupParams->m_szNode ) {
+ if ( !pStartupParams->m_szNode) {
dat->proto->AdHoc_RequestListOfCommands(pStartupParams->m_szJid, hwndDlg);
TCHAR Caption[ 512 ];
- _sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Jabber Ad-Hoc commands at"), dat->ResponderJID );
+ _sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Jabber Ad-Hoc commands at"), dat->ResponderJID);
SetWindowText(hwndDlg, Caption);
}
else
{
int iqId = (int)hwndDlg;
- dat->proto->IqAdd( iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution );
+ dat->proto->IqAdd(iqId, IQ_PROC_EXECCOMMANDS, &CJabberProto::OnIqResult_CommandExecution);
dat->proto->m_ThreadInfo->send(
- XmlNodeIq( _T("set"), iqId, pStartupParams->m_szJid )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS))
- << XATTR( _T("node"), pStartupParams->m_szNode ) << XATTR( _T("action"), _T("execute")));
+ XmlNodeIq(_T("set"), iqId, pStartupParams->m_szJid)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS))
+ << XATTR(_T("node"), pStartupParams->m_szNode) << XATTR(_T("action"), _T("execute")));
- EnableDlgItem( hwndDlg, IDC_SUBMIT, FALSE );
- SetDlgItemText( hwndDlg, IDC_SUBMIT, TranslateT( "OK" ));
+ EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE);
+ SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK"));
TCHAR Caption[ 512 ];
- _sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Sending Ad-Hoc command to"), dat->ResponderJID );
+ _sntprintf(Caption, SIZEOF(Caption), _T("%s %s"), TranslateT("Sending Ad-Hoc command to"), dat->ResponderJID);
SetWindowText(hwndDlg, Caption);
}
@@ -444,7 +444,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR }
case WM_COMMAND:
{
- switch ( LOWORD( wParam ))
+ switch (LOWORD(wParam))
{
case IDC_PREV:
@@ -454,14 +454,14 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR case IDC_COMPLETE:
return dat->proto->AdHoc_SubmitCommandForm(hwndDlg,dat,_T("complete"));
case IDC_SUBMIT:
- if (!dat->AdHocNode && dat->CommandsNode && LOWORD( wParam )==IDC_SUBMIT)
+ if ( !dat->AdHocNode && dat->CommandsNode && LOWORD(wParam)==IDC_SUBMIT)
return dat->proto->AdHoc_ExecuteCommand(hwndDlg,dat->ResponderJID, dat);
else
return dat->proto->AdHoc_SubmitCommandForm(hwndDlg,dat, NULL);
case IDCLOSE:
case IDCANCEL:
- xi.destroyNode( dat->AdHocNode ); dat->AdHocNode = NULL;
- DestroyWindow( hwndDlg );
+ xi.destroyNode(dat->AdHocNode); dat->AdHocNode = NULL;
+ DestroyWindow(hwndDlg);
return TRUE;
}
break;
@@ -474,7 +474,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR case WM_MOUSEWHEEL:
{
int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
- if ( zDelta ) {
+ if (zDelta) {
int nScrollLines=0;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,(void*)&nScrollLines,0);
for (int i=0; i<(nScrollLines+1)/2; i++)
@@ -485,9 +485,9 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR case WM_VSCROLL:
{
int pos;
- if ( dat != NULL ) {
+ if (dat != NULL) {
pos = dat->curPos;
- switch ( LOWORD( wParam ))
+ switch (LOWORD(wParam))
{
case SB_LINEDOWN:
pos += 10;
@@ -496,29 +496,29 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR pos -= 10;
break;
case SB_PAGEDOWN:
- pos += ( dat->CurrentHeight - 10 );
+ pos += (dat->CurrentHeight - 10);
break;
case SB_PAGEUP:
- pos -= ( dat->CurrentHeight - 10 );
+ pos -= (dat->CurrentHeight - 10);
break;
case SB_THUMBTRACK:
- pos = HIWORD( wParam );
+ pos = HIWORD(wParam);
break;
}
- if ( pos > ( dat->CurrentHeight - dat->frameHeight ))
+ if (pos > (dat->CurrentHeight - dat->frameHeight))
pos = dat->CurrentHeight - dat->frameHeight;
- if ( pos < 0 )
+ if (pos < 0)
pos = 0;
- if ( dat->curPos != pos ) {
- ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - pos, NULL , &( dat->frameRect ));
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, pos, TRUE );
+ if (dat->curPos != pos) {
+ ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL , &(dat->frameRect));
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE);
RECT Invalid=dat->frameRect;
if (dat->curPos - pos >0)
Invalid.bottom=Invalid.top+(dat->curPos - pos);
else
Invalid.top=Invalid.bottom+(dat->curPos - pos);
- RedrawWindow(GetDlgItem( hwndDlg, IDC_FRAME ), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN);
+ RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN);
dat->curPos = pos;
} }
break;
@@ -529,9 +529,9 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR WindowFreeIcon(hwndDlg);
dat->proto->m_hwndCommandWindow = NULL;
- mir_free( dat->ResponderJID );
- xi.destroyNode( dat->CommandsNode );
- xi.destroyNode( dat->AdHocNode );
+ mir_free(dat->ResponderJID);
+ xi.destroyNode(dat->CommandsNode);
+ xi.destroyNode(dat->AdHocNode);
mir_free(dat);
dat=NULL;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
@@ -541,22 +541,22 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc( HWND hwndDlg, UINT msg, WPAR return FALSE;
}
-int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam )
+int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact;
DBVARIANT dbv;
int res = -1;
JABBER_LIST_ITEM * item=NULL;
- if ((( hContact=( HANDLE ) wParam )!=NULL || (lParam!=0)) && m_bJabberOnline ) {
- if ( wParam && !JGetStringT( hContact, "jid", &dbv )) {
+ if (((hContact=(HANDLE)wParam)!=NULL || (lParam!=0)) && m_bJabberOnline) {
+ if (wParam && !JGetStringT(hContact, "jid", &dbv)) {
TCHAR jid[ JABBER_MAX_JID_LEN ];
int selected = 0;
_tcsncpy(jid, dbv.ptszVal, SIZEOF(jid));
ListLock();
{
- item = ListGetItemPtr( LIST_ROSTER, jid);
+ item = ListGetItemPtr(LIST_ROSTER, jid);
if (item)
{
if (item->resourceCount>1)
@@ -589,21 +589,21 @@ int __cdecl CJabberProto::ContactMenuRunCommands(WPARAM wParam, LPARAM lParam ) }
ListUnlock();
- if (!item || selected) {
- CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams( this, jid, NULL );
- CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_FORM ), NULL, JabberAdHoc_CommandDlgProc, ( LPARAM )(pStartupParams));
+ if ( !item || selected) {
+ CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, jid, NULL);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, (LPARAM)(pStartupParams));
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
else if (lParam!=0)
- CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_FORM ), NULL, JabberAdHoc_CommandDlgProc, lParam );
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, lParam);
}
return res;
}
-void CJabberProto::ContactMenuAdhocCommands( CJabberAdhocStartupParams* param )
+void CJabberProto::ContactMenuAdhocCommands(CJabberAdhocStartupParams* param)
{
- if ( param )
- CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_FORM ), NULL, JabberAdHoc_CommandDlgProc, (LPARAM)param );
+ if (param)
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberAdHoc_CommandDlgProc, (LPARAM)param);
}
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp index b0ad17e8a0..928beab4e0 100644 --- a/protocols/JabberG/src/jabber_agent.cpp +++ b/protocols/JabberG/src/jabber_agent.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
@@ -32,40 +32,40 @@ class CAgentRegProgressDlg : public CJabberDlgBase CCtrlButton m_ok;
public:
- CAgentRegProgressDlg( CJabberProto* _ppro, HWND _owner ) :
- CJabberDlgBase( _ppro, IDD_OPT_REGISTER, _owner, false ),
- m_ok( this, IDOK )
+ CAgentRegProgressDlg(CJabberProto* _ppro, HWND _owner) :
+ CJabberDlgBase(_ppro, IDD_OPT_REGISTER, _owner, false),
+ m_ok(this, IDOK)
{
- m_ok.OnClick = Callback( this, &CAgentRegProgressDlg::OnOk );
+ m_ok.OnClick = Callback(this, &CAgentRegProgressDlg::OnOk);
}
virtual void OnInitDialog()
{
m_proto->m_hwndRegProgress = m_hwnd;
- SetWindowTextA( m_hwnd, "Jabber Agent Registration" );
- TranslateDialogDefault( m_hwnd );
+ SetWindowTextA(m_hwnd, "Jabber Agent Registration");
+ TranslateDialogDefault(m_hwnd);
}
- virtual INT_PTR DlgProc( UINT msg, WPARAM wParam, LPARAM lParam )
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- if ( msg == WM_JABBER_REGDLG_UPDATE ) {
- if (( TCHAR* )lParam == NULL )
- SetDlgItemText( m_hwnd, IDC_REG_STATUS, TranslateT( "No message" ));
+ if (msg == WM_JABBER_REGDLG_UPDATE) {
+ if ((TCHAR*)lParam == NULL)
+ SetDlgItemText(m_hwnd, IDC_REG_STATUS, TranslateT("No message"));
else
- SetDlgItemText( m_hwnd, IDC_REG_STATUS, ( TCHAR* )lParam );
- if ( wParam >= 0 )
- SendMessage( GetDlgItem( m_hwnd, IDC_PROGRESS_REG ), PBM_SETPOS, wParam, 0 );
- if ( wParam >= 100 )
- m_ok.SetText( TranslateT( "OK" ));
+ SetDlgItemText(m_hwnd, IDC_REG_STATUS, (TCHAR*)lParam);
+ if (wParam >= 0)
+ SendMessage(GetDlgItem(m_hwnd, IDC_PROGRESS_REG), PBM_SETPOS, wParam, 0);
+ if (wParam >= 100)
+ m_ok.SetText(TranslateT("OK"));
}
- return CJabberDlgBase::DlgProc( msg, wParam, lParam );
+ return CJabberDlgBase::DlgProc(msg, wParam, lParam);
}
- void OnOk( CCtrlButton* )
+ void OnOk(CCtrlButton*)
{
m_proto->m_hwndRegProgress = NULL;
- EndDialog( m_hwnd, 0 );
+ EndDialog(m_hwnd, 0);
}
};
@@ -83,47 +83,47 @@ class CAgentRegDlg : public CJabberDlgBase CCtrlButton m_submit;
public:
- CAgentRegDlg( CJabberProto* _ppro, TCHAR* _jid ) :
- CJabberDlgBase( _ppro, IDD_FORM, NULL, false ),
- m_submit( this, IDC_SUBMIT ),
- m_jid( _jid ),
- m_agentRegIqNode( NULL )
+ CAgentRegDlg(CJabberProto* _ppro, TCHAR* _jid) :
+ CJabberDlgBase(_ppro, IDD_FORM, NULL, false),
+ m_submit(this, IDC_SUBMIT),
+ m_jid(_jid),
+ m_agentRegIqNode(NULL)
{
- m_submit.OnClick = Callback( this, &CAgentRegDlg::OnSubmit );
+ m_submit.OnClick = Callback(this, &CAgentRegDlg::OnSubmit);
}
virtual void OnInitDialog()
{
- EnableWindow( GetParent( m_hwnd ), FALSE );
+ EnableWindow(GetParent(m_hwnd), FALSE);
m_proto->m_hwndAgentRegInput = m_hwnd;
- SetWindowText( m_hwnd, TranslateT( "Jabber Agent Registration" ));
- SetDlgItemText( m_hwnd, IDC_SUBMIT, TranslateT( "Register" ));
- SetDlgItemText( m_hwnd, IDC_FRAME_TEXT, TranslateT( "Please wait..." ));
+ SetWindowText(m_hwnd, TranslateT("Jabber Agent Registration"));
+ SetDlgItemText(m_hwnd, IDC_SUBMIT, TranslateT("Register"));
+ SetDlgItemText(m_hwnd, IDC_FRAME_TEXT, TranslateT("Please wait..."));
int iqId = m_proto->SerialNext();
- m_proto->IqAdd( iqId, IQ_PROC_GETREGISTER, &CJabberProto::OnIqResultGetRegister );
- m_proto->m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId, m_jid ) << XQUERY( _T(JABBER_FEAT_REGISTER)));
+ m_proto->IqAdd(iqId, IQ_PROC_GETREGISTER, &CJabberProto::OnIqResultGetRegister);
+ m_proto->m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId, m_jid) << XQUERY(_T(JABBER_FEAT_REGISTER)));
- // Enable WS_EX_CONTROLPARENT on IDC_FRAME ( so tab stop goes through all its children )
- LONG frameExStyle = GetWindowLongPtr( GetDlgItem( m_hwnd, IDC_FRAME ), GWL_EXSTYLE );
+ // Enable WS_EX_CONTROLPARENT on IDC_FRAME (so tab stop goes through all its children)
+ LONG frameExStyle = GetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FRAME), GWL_EXSTYLE);
frameExStyle |= WS_EX_CONTROLPARENT;
- SetWindowLongPtr( GetDlgItem( m_hwnd, IDC_FRAME ), GWL_EXSTYLE, frameExStyle );
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_FRAME), GWL_EXSTYLE, frameExStyle);
}
virtual void OnDestroy()
{
- xi.destroyNode( m_agentRegIqNode );
+ xi.destroyNode(m_agentRegIqNode);
JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME));
m_proto->m_hwndAgentRegInput = NULL;
- EnableWindow( GetParent( m_hwnd ), TRUE );
- SetActiveWindow( GetParent( m_hwnd ));
+ EnableWindow(GetParent(m_hwnd), TRUE);
+ SetActiveWindow(GetParent(m_hwnd));
}
- virtual INT_PTR DlgProc( UINT msg, WPARAM wParam, LPARAM lParam )
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch( msg ) {
+ switch(msg) {
case WM_CTLCOLORSTATIC:
- switch( GetDlgCtrlID(( HWND )lParam )) {
+ switch(GetDlgCtrlID((HWND)lParam)) {
case IDC_WHITERECT: case IDC_INSTRUCTION: case IDC_TITLE:
return (INT_PTR)GetStockObject(WHITE_BRUSH);
default:
@@ -131,153 +131,153 @@ public: }
case WM_JABBER_REGINPUT_ACTIVATE:
- if ( wParam == 1 ) { // success
+ if (wParam == 1) { // success
// lParam = <iq/> node from agent JID as a result of "get jabber:iq:register"
- HWND hFrame = GetDlgItem( m_hwnd, IDC_FRAME );
- ShowWindow( GetDlgItem( m_hwnd, IDC_FRAME_TEXT ), SW_HIDE );
+ HWND hFrame = GetDlgItem(m_hwnd, IDC_FRAME);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_FRAME_TEXT), SW_HIDE);
HXML queryNode, xNode;
- if (( m_agentRegIqNode = ( HXML )lParam ) == NULL ) return TRUE;
- if (( queryNode = xmlGetChild( m_agentRegIqNode , "query" )) == NULL ) return TRUE;
+ if ((m_agentRegIqNode = (HXML)lParam) == NULL) return TRUE;
+ if ((queryNode = xmlGetChild(m_agentRegIqNode , "query")) == NULL) return TRUE;
RECT rect;
m_curPos = 0;
- GetClientRect( GetDlgItem( m_hwnd, IDC_FRAME ), &( m_frameRect ));
- GetClientRect( GetDlgItem( m_hwnd, IDC_VSCROLL ), &rect );
- m_frameRect.right -= ( rect.right - rect.left );
- GetClientRect( GetDlgItem( m_hwnd, IDC_FRAME ), &rect );
+ GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &(m_frameRect));
+ GetClientRect(GetDlgItem(m_hwnd, IDC_VSCROLL), &rect);
+ m_frameRect.right -= (rect.right - rect.left);
+ GetClientRect(GetDlgItem(m_hwnd, IDC_FRAME), &rect);
m_frameHeight = rect.bottom - rect.top;
- if (( xNode=xmlGetChild( queryNode , "x" )) != NULL ) {
+ if ((xNode=xmlGetChild(queryNode , "x")) != NULL) {
// use new jabber:x:data form
- HXML n = xmlGetChild( xNode , "instructions" );
- if ( n != NULL && xmlGetText( n )!=NULL )
- JabberFormSetInstruction( m_hwnd, xmlGetText( n ));
+ HXML n = xmlGetChild(xNode , "instructions");
+ if (n != NULL && xmlGetText(n)!=NULL)
+ JabberFormSetInstruction(m_hwnd, xmlGetText(n));
- JabberFormCreateUI( hFrame, xNode, &m_formHeight /*dummy*/ );
+ JabberFormCreateUI(hFrame, xNode, &m_formHeight /*dummy*/);
}
else {
// use old registration information form
HJFORMLAYOUT layout_info = JabberFormCreateLayout(hFrame);
- for ( int i=0; ; i++ ) {
- HXML n = xmlGetChild( queryNode ,i);
- if ( !n )
+ for (int i=0; ; i++) {
+ HXML n = xmlGetChild(queryNode ,i);
+ if ( !n)
break;
- if ( xmlGetName( n )) {
- if ( !lstrcmp( xmlGetName( n ), _T("instructions"))) {
- JabberFormSetInstruction( m_hwnd, xmlGetText( n ));
+ if (xmlGetName(n)) {
+ if ( !lstrcmp(xmlGetName(n), _T("instructions"))) {
+ JabberFormSetInstruction(m_hwnd, xmlGetText(n));
}
- else if ( !lstrcmp( xmlGetName( n ), _T("key")) || !lstrcmp( xmlGetName( n ), _T("registered"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("key")) || !lstrcmp(xmlGetName(n), _T("registered"))) {
// do nothing
}
- else if ( !lstrcmp( xmlGetName( n ), _T("password")))
- JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_PRIVATE, xmlGetName( n ), xmlGetText( n ));
+ else if ( !lstrcmp(xmlGetName(n), _T("password")))
+ JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_PRIVATE, xmlGetName(n), xmlGetText(n));
else // everything else is a normal text field
- JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_SINGLE, xmlGetName( n ), xmlGetText( n ));
+ JabberFormAppendControl(hFrame, layout_info, JFORM_CTYPE_TEXT_SINGLE, xmlGetName(n), xmlGetText(n));
} }
JabberFormLayoutControls(hFrame, layout_info, &m_formHeight);
mir_free(layout_info);
}
- if ( m_formHeight > m_frameHeight ) {
+ if (m_formHeight > m_frameHeight) {
HWND hwndScroll;
- hwndScroll = GetDlgItem( m_hwnd, IDC_VSCROLL );
- EnableWindow( hwndScroll, TRUE );
- SetScrollRange( hwndScroll, SB_CTL, 0, m_formHeight - m_frameHeight, FALSE );
+ hwndScroll = GetDlgItem(m_hwnd, IDC_VSCROLL);
+ EnableWindow(hwndScroll, TRUE);
+ SetScrollRange(hwndScroll, SB_CTL, 0, m_formHeight - m_frameHeight, FALSE);
m_curPos = 0;
}
- EnableWindow( GetDlgItem( m_hwnd, IDC_SUBMIT ), TRUE );
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SUBMIT), TRUE);
}
- else if ( wParam == 0 ) {
+ else if (wParam == 0) {
// lParam = error message
- SetDlgItemText( m_hwnd, IDC_FRAME_TEXT, ( LPCTSTR ) lParam );
+ SetDlgItemText(m_hwnd, IDC_FRAME_TEXT, (LPCTSTR) lParam);
}
return TRUE;
case WM_VSCROLL:
int pos = m_curPos;
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case SB_LINEDOWN: pos += 10; break;
case SB_LINEUP: pos -= 10; break;
- case SB_PAGEDOWN: pos += ( m_frameHeight - 10 ); break;
- case SB_PAGEUP: pos -= ( m_frameHeight - 10 ); break;
- case SB_THUMBTRACK: pos = HIWORD( wParam ); break;
+ case SB_PAGEDOWN: pos += (m_frameHeight - 10); break;
+ case SB_PAGEUP: pos -= (m_frameHeight - 10); break;
+ case SB_THUMBTRACK: pos = HIWORD(wParam); break;
}
- if ( pos > ( m_formHeight - m_frameHeight ))
+ if (pos > (m_formHeight - m_frameHeight))
pos = m_formHeight - m_frameHeight;
- if ( pos < 0 )
+ if (pos < 0)
pos = 0;
- if ( m_curPos != pos ) {
- ScrollWindow( GetDlgItem( m_hwnd, IDC_FRAME ), 0, m_curPos - pos, NULL, &( m_frameRect ));
- SetScrollPos( GetDlgItem( m_hwnd, IDC_VSCROLL ), SB_CTL, pos, TRUE );
+ if (m_curPos != pos) {
+ ScrollWindow(GetDlgItem(m_hwnd, IDC_FRAME), 0, m_curPos - pos, NULL, &(m_frameRect));
+ SetScrollPos(GetDlgItem(m_hwnd, IDC_VSCROLL), SB_CTL, pos, TRUE);
m_curPos = pos;
} }
- return CJabberDlgBase::DlgProc( msg, wParam, lParam );
+ return CJabberDlgBase::DlgProc(msg, wParam, lParam);
}
- void OnSubmit( CCtrlButton* )
+ void OnSubmit(CCtrlButton*)
{
HXML queryNode, xNode;
const TCHAR *from;
- if ( m_agentRegIqNode == NULL ) return;
- if (( from = xmlGetAttrValue( m_agentRegIqNode, _T("from"))) == NULL ) return;
- if (( queryNode = xmlGetChild( m_agentRegIqNode , "query" )) == NULL ) return;
- HWND hFrame = GetDlgItem( m_hwnd, IDC_FRAME );
+ if (m_agentRegIqNode == NULL) return;
+ if ((from = xmlGetAttrValue(m_agentRegIqNode, _T("from"))) == NULL) return;
+ if ((queryNode = xmlGetChild(m_agentRegIqNode , "query")) == NULL) return;
+ HWND hFrame = GetDlgItem(m_hwnd, IDC_FRAME);
- TCHAR *str2 = ( TCHAR* )alloca( sizeof(TCHAR) * 128 );
+ TCHAR *str2 = (TCHAR*)alloca(sizeof(TCHAR) * 128);
int id = 0;
int iqId = m_proto->SerialNext();
- m_proto->IqAdd( iqId, IQ_PROC_SETREGISTER, &CJabberProto::OnIqResultSetRegister );
+ m_proto->IqAdd(iqId, IQ_PROC_SETREGISTER, &CJabberProto::OnIqResultSetRegister);
- XmlNodeIq iq( _T("set"), iqId, from );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_REGISTER));
+ XmlNodeIq iq(_T("set"), iqId, from);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_REGISTER));
- if (( xNode = xmlGetChild( queryNode , "x" )) != NULL ) {
+ if ((xNode = xmlGetChild(queryNode , "x")) != NULL) {
// use new jabber:x:data form
- HXML n = JabberFormGetData( hFrame, xNode );
- xmlAddChild( query, n );
- xi.destroyNode( n );
+ HXML n = JabberFormGetData(hFrame, xNode);
+ xmlAddChild(query, n);
+ xi.destroyNode(n);
}
else {
// use old registration information form
- for ( int i=0; ; i++ ) {
- HXML n = xmlGetChild( queryNode ,i);
- if ( !n )
+ for (int i=0; ; i++) {
+ HXML n = xmlGetChild(queryNode ,i);
+ if ( !n)
break;
- if ( xmlGetName( n )) {
- if ( !lstrcmp( xmlGetName( n ), _T("key"))) {
+ if (xmlGetName(n)) {
+ if ( !lstrcmp(xmlGetName(n), _T("key"))) {
// field that must be passed along with the registration
- if ( xmlGetText( n ))
- xmlAddChild( query, xmlGetName( n ), xmlGetText( n ));
+ if (xmlGetText(n))
+ xmlAddChild(query, xmlGetName(n), xmlGetText(n));
else
- xmlAddChild( query, xmlGetName( n ));
+ xmlAddChild(query, xmlGetName(n));
}
- else if ( !lstrcmp( xmlGetName( n ), _T("registered")) || !lstrcmp( xmlGetName( n ), _T("instructions"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("registered")) || !lstrcmp(xmlGetName(n), _T("instructions"))) {
// do nothing, we will skip these
}
else {
- GetDlgItemText( hFrame, id, str2, 128 );
- xmlAddChild( query, xmlGetName( n ), str2 );
+ GetDlgItemText(hFrame, id, str2, 128);
+ xmlAddChild(query, xmlGetName(n), str2);
id++;
} } } }
- m_proto->m_ThreadInfo->send( iq );
+ m_proto->m_ThreadInfo->send(iq);
- CAgentRegProgressDlg( m_proto, m_hwnd ).DoModal();
+ CAgentRegProgressDlg(m_proto, m_hwnd).DoModal();
Close();
}
};
-void CJabberProto::RegisterAgent( HWND /*hwndDlg*/, TCHAR* jid )
+void CJabberProto::RegisterAgent(HWND /*hwndDlg*/, TCHAR* jid)
{
- ( new CAgentRegDlg( this, jid ))->Show();
+ (new CAgentRegDlg(this, jid))->Show();
}
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp index 158f83e669..bd8014d42a 100644 --- a/protocols/JabberG/src/jabber_bookmarks.cpp +++ b/protocols/JabberG/src/jabber_bookmarks.cpp @@ -1,12 +1,12 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2007 Michael Stepura, George Hazan
+Copyright (C) 2007 Michael Stepura, 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
@@ -30,126 +30,126 @@ struct JabberAddBookmarkDlgParam { JABBER_LIST_ITEM* m_item;
};
-static INT_PTR CALLBACK JabberAddBookmarkDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberAddBookmarkDlgParam* param = (JabberAddBookmarkDlgParam*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JabberAddBookmarkDlgParam* param = (JabberAddBookmarkDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR text[512];
JABBER_LIST_ITEM *item;
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
param = (JabberAddBookmarkDlgParam*)lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
param->ppro->m_hwndJabberAddBookmark = hwndDlg;
- TranslateDialogDefault( hwndDlg );
- if ( item = param->m_item ) {
- if ( !lstrcmp( item->type, _T("conference"))) {
- if (!_tcschr( item->jid, _T( '@' ))) { //no room name - consider it is transport
+ TranslateDialogDefault(hwndDlg);
+ if (item = param->m_item) {
+ if ( !lstrcmp(item->type, _T("conference"))) {
+ if ( !_tcschr(item->jid, _T('@'))) { //no room name - consider it is transport
SendDlgItemMessage(hwndDlg, IDC_AGENT_RADIO, BM_SETCHECK, BST_CHECKED, 0);
- EnableWindow( GetDlgItem( hwndDlg, IDC_NICK ), FALSE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_PASSWORD ), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
}
else SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_SETCHECK, BST_CHECKED, 0);
}
else {
SendDlgItemMessage(hwndDlg, IDC_URL_RADIO, BM_SETCHECK, BST_CHECKED, 0);
- EnableWindow( GetDlgItem( hwndDlg, IDC_NICK ), FALSE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_PASSWORD ), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_UNCHECKED, 0);
- EnableWindow( GetDlgItem( hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE);
}
- EnableWindow( GetDlgItem( hwndDlg, IDC_ROOM_RADIO), FALSE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_URL_RADIO), FALSE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_AGENT_RADIO), FALSE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE );
-
- if ( item->jid ) SetDlgItemText( hwndDlg, IDC_ROOM_JID, item->jid );
- if ( item->name ) SetDlgItemText( hwndDlg, IDC_NAME, item->name );
- if ( item->nick ) SetDlgItemText( hwndDlg, IDC_NICK, item->nick );
- if ( item->password ) SetDlgItemText( hwndDlg, IDC_PASSWORD, item->password );
- if ( item->bAutoJoin ) SendDlgItemMessage( hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_CHECKED, 0 );
- if ( SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_GETCHECK,0, 0) == BST_CHECKED )
- EnableWindow( GetDlgItem( hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ROOM_RADIO), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_URL_RADIO), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_AGENT_RADIO), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE);
+
+ if (item->jid) SetDlgItemText(hwndDlg, IDC_ROOM_JID, item->jid);
+ if (item->name) SetDlgItemText(hwndDlg, IDC_NAME, item->name);
+ if (item->nick) SetDlgItemText(hwndDlg, IDC_NICK, item->nick);
+ if (item->password) SetDlgItemText(hwndDlg, IDC_PASSWORD, item->password);
+ if (item->bAutoJoin) SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_CHECKED, 0);
+ if (SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_GETCHECK,0, 0) == BST_CHECKED)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE);
}
else {
- EnableWindow( GetDlgItem( hwndDlg, IDOK ), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
SendDlgItemMessage(hwndDlg, IDC_ROOM_RADIO, BM_SETCHECK, BST_CHECKED, 0);
}
return TRUE;
case WM_COMMAND:
- switch ( HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case BN_CLICKED:
switch (LOWORD (wParam)) {
case IDC_ROOM_RADIO:
- EnableWindow( GetDlgItem( hwndDlg, IDC_NICK ), TRUE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_PASSWORD ), TRUE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), TRUE);
break;
case IDC_AGENT_RADIO:
case IDC_URL_RADIO:
- EnableWindow( GetDlgItem( hwndDlg, IDC_NICK ), FALSE );
- EnableWindow( GetDlgItem( hwndDlg, IDC_PASSWORD ), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_NICK), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_SETCHECK, BST_UNCHECKED, 0);
- EnableWindow( GetDlgItem( hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_BM_AUTOJOIN), FALSE);
break;
}
}
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDC_ROOM_JID:
- if (( HWND )lParam==GetFocus() && HIWORD( wParam )==EN_CHANGE )
- EnableWindow( GetDlgItem( hwndDlg, IDOK ), GetDlgItemText( hwndDlg, IDC_ROOM_JID, text, SIZEOF( text )));
+ if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE)
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), GetDlgItemText(hwndDlg, IDC_ROOM_JID, text, SIZEOF(text)));
break;
case IDOK:
{
- GetDlgItemText( hwndDlg, IDC_ROOM_JID, text, SIZEOF( text ));
- TCHAR* roomJID = NEWTSTR_ALLOCA( text );
+ GetDlgItemText(hwndDlg, IDC_ROOM_JID, text, SIZEOF(text));
+ TCHAR* roomJID = NEWTSTR_ALLOCA(text);
- if ( param->m_item )
- param->ppro->ListRemove( LIST_BOOKMARK, param->m_item->jid );
+ if (param->m_item)
+ param->ppro->ListRemove(LIST_BOOKMARK, param->m_item->jid);
- item = param->ppro->ListAdd( LIST_BOOKMARK, roomJID );
+ item = param->ppro->ListAdd(LIST_BOOKMARK, roomJID);
item->bUseResource = TRUE;
- if ( SendDlgItemMessage(hwndDlg, IDC_URL_RADIO, BM_GETCHECK,0, 0) == BST_CHECKED )
- replaceStrT( item->type, _T( "url" ));
+ if (SendDlgItemMessage(hwndDlg, IDC_URL_RADIO, BM_GETCHECK,0, 0) == BST_CHECKED)
+ replaceStrT(item->type, _T("url"));
else
- replaceStrT( item->type, _T( "conference" ));
+ replaceStrT(item->type, _T("conference"));
- GetDlgItemText( hwndDlg, IDC_NICK, text, SIZEOF( text ));
- replaceStrT( item->nick, text );
+ GetDlgItemText(hwndDlg, IDC_NICK, text, SIZEOF(text));
+ replaceStrT(item->nick, text);
- GetDlgItemText( hwndDlg, IDC_PASSWORD, text, SIZEOF( text ));
- replaceStrT( item->password, text );
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, text, SIZEOF(text));
+ replaceStrT(item->password, text);
- GetDlgItemText( hwndDlg, IDC_NAME, text, SIZEOF( text ));
- replaceStrT( item->name, ( text[0] == 0 ) ? roomJID : text );
+ GetDlgItemText(hwndDlg, IDC_NAME, text, SIZEOF(text));
+ replaceStrT(item->name, (text[0] == 0) ? roomJID : text);
- item->bAutoJoin = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_GETCHECK,0, 0) == BST_CHECKED );
+ item->bAutoJoin = (SendDlgItemMessage(hwndDlg, IDC_CHECK_BM_AUTOJOIN, BM_GETCHECK,0, 0) == BST_CHECKED);
{
int iqId = param->ppro->SerialNext();
- param->ppro->IqAdd( iqId, IQ_PROC_SETBOOKMARKS, &CJabberProto::OnIqResultSetBookmarks);
+ param->ppro->IqAdd(iqId, IQ_PROC_SETBOOKMARKS, &CJabberProto::OnIqResultSetBookmarks);
- XmlNodeIq iq( _T("set"), iqId);
+ XmlNodeIq iq(_T("set"), iqId);
param->ppro->SetBookmarkRequest(iq);
- param->ppro->m_ThreadInfo->send( iq );
+ param->ppro->m_ThreadInfo->send(iq);
}
}
// fall through
case IDCANCEL:
- EndDialog( hwndDlg, 0 );
+ EndDialog(hwndDlg, 0);
break;
}
break;
case WM_JABBER_CHECK_ONLINE:
- if ( !param->ppro->m_bJabberOnline )
- EndDialog( hwndDlg, 0 );
+ if ( !param->ppro->m_bJabberOnline)
+ EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
@@ -195,45 +195,45 @@ private: void btnAdd_OnClick(CCtrlFilterListView *)
{
- if (!m_proto->m_bJabberOnline) return;
+ if ( !m_proto->m_bJabberOnline) return;
JabberAddBookmarkDlgParam param;
param.ppro = m_proto;
param.m_item = NULL;
- DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_BOOKMARK_ADD ), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
}
void btnEdit_OnClick(CCtrlFilterListView *)
{
- if (!m_proto->m_bJabberOnline) return;
+ if ( !m_proto->m_bJabberOnline) return;
int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
if (iItem < 0) return;
TCHAR *address = (TCHAR *)m_lvBookmarks.GetItemData(iItem);
- if (!address) return;
+ if ( !address) return;
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
- if (!item) return;
+ if ( !item) return;
JabberAddBookmarkDlgParam param;
param.ppro = m_proto;
param.m_item = item;
- DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_BOOKMARK_ADD ), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), m_hwnd, JabberAddBookmarkDlgProc, (LPARAM)¶m);
}
void btnRemove_OnClick(CCtrlFilterListView *)
{
- if (!m_proto->m_bJabberOnline) return;
+ if ( !m_proto->m_bJabberOnline) return;
int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
if (iItem < 0) return;
TCHAR *address = (TCHAR *)m_lvBookmarks.GetItemData(iItem);
- if (!address) return;
+ if ( !address) return;
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
- if (!item) return;
+ if ( !item) return;
m_btnAdd.Disable();
m_btnEdit.Disable();
@@ -246,7 +246,7 @@ private: int iqId = m_proto->SerialNext();
m_proto->IqAdd(iqId, IQ_PROC_SETBOOKMARKS, &CJabberProto::OnIqResultSetBookmarks);
- XmlNodeIq iq( _T("set"), iqId);
+ XmlNodeIq iq(_T("set"), iqId);
m_proto->SetBookmarkRequest(iq);
m_proto->m_ThreadInfo->send(iq);
}
@@ -268,19 +268,19 @@ CJabberDlgBookmarks::CJabberDlgBookmarks(CJabberProto *proto) : void CJabberDlgBookmarks::UpdateData()
{
- if (!m_proto->m_bJabberOnline) return;
+ if ( !m_proto->m_bJabberOnline) return;
int iqId = m_proto->SerialNext();
- m_proto->IqAdd( iqId, IQ_PROC_DISCOBOOKMARKS, &CJabberProto::OnIqResultDiscoBookmarks);
- m_proto->m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId ) << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE))
- << XCHILDNS( _T("storage"), _T("storage:bookmarks")));
+ m_proto->IqAdd(iqId, IQ_PROC_DISCOBOOKMARKS, &CJabberProto::OnIqResultDiscoBookmarks);
+ m_proto->m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId) << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE))
+ << XCHILDNS(_T("storage"), _T("storage:bookmarks")));
}
void CJabberDlgBookmarks::OnInitDialog()
{
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "bookmarks" );
+ WindowSetIcon(m_hwnd, m_proto, "bookmarks");
m_btnAdd.Disable();
m_btnEdit.Disable();
@@ -332,14 +332,14 @@ void CJabberDlgBookmarks::OpenBookmark() if (iItem < 0) return;
TCHAR *address = (TCHAR *)m_lvBookmarks.GetItemData(iItem);
- if (!address) return;
+ if ( !address) return;
JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
- if (!item) return;
+ if ( !item) return;
- if (!lstrcmpi(item->type, _T("conference")))
+ if ( !lstrcmpi(item->type, _T("conference")))
{
- if (!jabberChatDllPresent)
+ if ( !jabberChatDllPresent)
{
JabberChatDllError();
return;
@@ -348,7 +348,7 @@ void CJabberDlgBookmarks::OpenBookmark() m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item
/* some hack for using bookmark to transport not under XEP-0048 */
- if (!_tcschr(item->jid, _T('@')))
+ if ( !_tcschr(item->jid, _T('@')))
{ //the room name is not provided let consider that it is transport and send request to registration
m_proto->RegisterAgent(NULL, item->jid);
} else
@@ -404,7 +404,7 @@ INT_PTR CJabberDlgBookmarks::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) void CJabberDlgBookmarks::OnProtoCheckOnline(WPARAM, LPARAM)
{
- if (!m_proto->m_bJabberOnline)
+ if ( !m_proto->m_bJabberOnline)
{
m_btnAdd.Disable();
m_btnEdit.Disable();
@@ -444,7 +444,7 @@ void CJabberDlgBookmarks::OnProtoRefresh(WPARAM, LPARAM) int CJabberDlgBookmarks::Resizer(UTILRESIZECONTROL *urc)
{
- switch ( urc->wId ) {
+ switch (urc->wId) {
case IDC_BM_LIST:
return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT;
@@ -462,7 +462,7 @@ int CJabberDlgBookmarks::Resizer(UTILRESIZECONTROL *urc) /////////////////////////////////////////////////////////////////////////////////////////
// Launches the Bookmarks manager window
-INT_PTR __cdecl CJabberProto::OnMenuHandleBookmarks( WPARAM, LPARAM)
+INT_PTR __cdecl CJabberProto::OnMenuHandleBookmarks(WPARAM, LPARAM)
{
UI_SAFE_OPEN_EX(CJabberDlgBookmarks, m_pDlgBookmarks, pDlg);
pDlg->UpdateData();
@@ -471,13 +471,13 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleBookmarks( WPARAM, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
// Launches the Bookmark details window, lParam is JABBER_BOOKMARK_ITEM*
-int CJabberProto::AddEditBookmark( JABBER_LIST_ITEM* item )
+int CJabberProto::AddEditBookmark(JABBER_LIST_ITEM* item)
{
- if ( m_bJabberOnline) {
+ if (m_bJabberOnline) {
JabberAddBookmarkDlgParam param;
param.ppro = this;
param.m_item = item;//(JABBER_LIST_ITEM*)lParam;
- DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_BOOKMARK_ADD ), NULL, JabberAddBookmarkDlgProc, (LPARAM)¶m );
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BOOKMARK_ADD), NULL, JabberAddBookmarkDlgProc, (LPARAM)¶m);
}
return 0;
}
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index 9e86b51388..e9c4a443cd 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -33,54 +33,54 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. JABBER_BYTE_TRANSFER::~JABBER_BYTE_TRANSFER()
{
filetransfer* pft = ft;
- if ( pft )
+ if (pft)
pft->jbt = NULL;
- mir_free( srcJID );
- mir_free( dstJID );
- mir_free( streamhostJID );
- mir_free( iqId );
- mir_free( sid );
+ mir_free(srcJID);
+ mir_free(dstJID);
+ mir_free(streamhostJID);
+ mir_free(iqId);
+ mir_free(sid);
- xi.destroyNode( iqNode );
+ xi.destroyNode(iqNode);
// XEP-0065 proxy support
- mir_free( szProxyHost );
- mir_free( szProxyPort );
- mir_free( szProxyJid );
- mir_free( szStreamhostUsed );
+ mir_free(szProxyHost);
+ mir_free(szProxyPort);
+ mir_free(szProxyJid);
+ mir_free(szStreamhostUsed);
}
-void CJabberProto::IqResultProxyDiscovery( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo* pInfo)
{
- JABBER_BYTE_TRANSFER *jbt = ( JABBER_BYTE_TRANSFER * )pInfo->GetUserData();
-
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode ) {
- const TCHAR *queryXmlns = xmlGetAttrValue( queryNode, _T( "xmlns" ));
- if (queryXmlns && !_tcscmp( queryXmlns, _T(JABBER_FEAT_BYTESTREAMS))) {
- HXML streamHostNode = xmlGetChild( queryNode , "streamhost" );
- if ( streamHostNode ) {
- const TCHAR *streamJid = xmlGetAttrValue( streamHostNode, _T( "jid" ));
- const TCHAR *streamHost = xmlGetAttrValue( streamHostNode, _T( "host" ));
- const TCHAR *streamPort = xmlGetAttrValue( streamHostNode, _T( "port" ));
- if ( streamJid && streamHost && streamPort ) {
- jbt->szProxyHost = mir_tstrdup( streamHost );
- jbt->szProxyJid = mir_tstrdup( streamJid );
- jbt->szProxyPort = mir_tstrdup( streamPort );
+ JABBER_BYTE_TRANSFER *jbt = (JABBER_BYTE_TRANSFER *)pInfo->GetUserData();
+
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode) {
+ const TCHAR *queryXmlns = xmlGetAttrValue(queryNode, _T("xmlns"));
+ if (queryXmlns && !_tcscmp(queryXmlns, _T(JABBER_FEAT_BYTESTREAMS))) {
+ HXML streamHostNode = xmlGetChild(queryNode , "streamhost");
+ if (streamHostNode) {
+ const TCHAR *streamJid = xmlGetAttrValue(streamHostNode, _T("jid"));
+ const TCHAR *streamHost = xmlGetAttrValue(streamHostNode, _T("host"));
+ const TCHAR *streamPort = xmlGetAttrValue(streamHostNode, _T("port"));
+ if (streamJid && streamHost && streamPort) {
+ jbt->szProxyHost = mir_tstrdup(streamHost);
+ jbt->szProxyJid = mir_tstrdup(streamJid);
+ jbt->szProxyPort = mir_tstrdup(streamPort);
jbt->bProxyDiscovered = TRUE;
} } } } }
- else if ( pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR )
+ else if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR)
jbt->state = JBT_ERROR;
- if ( jbt->hProxyEvent )
- SetEvent( jbt->hProxyEvent );
+ if (jbt->hProxyEvent)
+ SetEvent(jbt->hProxyEvent);
}
-void JabberByteSendConnection( HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra )
+void JabberByteSendConnection(HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra)
{
- CJabberProto* ppro = ( CJabberProto* )extra;
+ CJabberProto* ppro = (CJabberProto*)extra;
TCHAR szPort[8];
JABBER_BYTE_TRANSFER *jbt;
int recvResult, bytesParsed;
@@ -92,22 +92,22 @@ void JabberByteSendConnection( HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra ) NETLIBCONNINFO connInfo = { sizeof(connInfo) };
CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hConn, (LPARAM)&connInfo);
- mir_sntprintf( szPort, SIZEOF( szPort ), _T("%u"), connInfo.wPort );
- ppro->Log( "bytestream_send_connection incoming connection accepted: %s", connInfo.szIpPort );
+ mir_sntprintf(szPort, SIZEOF(szPort), _T("%u"), connInfo.wPort);
+ ppro->Log("bytestream_send_connection incoming connection accepted: %s", connInfo.szIpPort);
- if (( item = ppro->ListGetItemPtr( LIST_BYTE, szPort )) == NULL ) {
- ppro->Log( "No bytestream session is currently active, connection closed." );
- Netlib_CloseHandle( hConn );
+ if ((item = ppro->ListGetItemPtr(LIST_BYTE, szPort)) == NULL) {
+ ppro->Log("No bytestream session is currently active, connection closed.");
+ Netlib_CloseHandle(hConn);
return;
}
jbt = item->jbt;
- if (( buffer = ( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE )) == NULL ) {
- ppro->Log( "bytestream_send cannot allocate network buffer, connection closed." );
+ if ((buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == NULL) {
+ ppro->Log("bytestream_send cannot allocate network buffer, connection closed.");
jbt->state = JBT_ERROR;
- Netlib_CloseHandle( hConn );
- if ( jbt->hEvent != NULL ) SetEvent( jbt->hEvent );
+ Netlib_CloseHandle(hConn);
+ if (jbt->hEvent != NULL) SetEvent(jbt->hEvent);
return;
}
@@ -115,30 +115,30 @@ void JabberByteSendConnection( HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra ) jbt->hConn = hConn;
jbt->state = JBT_INIT;
datalen = 0;
- while ( jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR ) {
- recvResult = Netlib_Recv( hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
- if ( recvResult <= 0 )
+ while (jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR) {
+ recvResult = Netlib_Recv(hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0);
+ if (recvResult <= 0)
break;
datalen += recvResult;
- bytesParsed = ppro->ByteSendParse( hConn, jbt, buffer, datalen );
- if ( bytesParsed < datalen )
- memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
+ bytesParsed = ppro->ByteSendParse(hConn, jbt, buffer, datalen);
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
datalen -= bytesParsed;
}
- if ( jbt->hConn )
- Netlib_CloseHandle( jbt->hConn );
+ if (jbt->hConn)
+ Netlib_CloseHandle(jbt->hConn);
- ppro->Log( "bytestream_send_connection closing connection" );
+ ppro->Log("bytestream_send_connection closing connection");
jbt->hConn = hListen;
- mir_free( buffer );
+ mir_free(buffer);
- if ( jbt->hEvent != NULL )
- SetEvent( jbt->hEvent );
+ if (jbt->hEvent != NULL)
+ SetEvent(jbt->hEvent);
}
-void CJabberProto::ByteSendThread( JABBER_BYTE_TRANSFER *jbt )
+void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
{
char* localAddr = NULL;
DBVARIANT dbv;
@@ -148,199 +148,199 @@ void CJabberProto::ByteSendThread( JABBER_BYTE_TRANSFER *jbt ) CJabberIqInfo* pInfo = NULL;
int nIqId = 0;
- Log( "Thread started: type=bytestream_send" );
+ Log("Thread started: type=bytestream_send");
BOOL bDirect = m_options.BsDirect;
- if ( m_options.BsProxyManual ) {
+ if (m_options.BsProxyManual) {
proxyJid = NULL;
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "BsProxyServer", &dbv )) {
- proxyJid = mir_a2t( dbv.pszVal );
- JFreeVariant( &dbv );
+ if ( !DBGetContactSettingString(NULL, m_szModuleName, "BsProxyServer", &dbv)) {
+ proxyJid = mir_a2t(dbv.pszVal);
+ db_free(&dbv);
}
- if ( proxyJid ) {
+ if (proxyJid) {
jbt->bProxyDiscovered = FALSE;
jbt->szProxyHost = NULL;
jbt->szProxyPort = NULL;
jbt->szProxyJid = NULL;
- jbt->hProxyEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- pInfo = m_iqManager.AddHandler( &CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, 0, -1, jbt );
+ pInfo = m_iqManager.AddHandler(&CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, 0, -1, jbt);
nIqId = pInfo->GetIqId();
- XmlNodeIq iq( pInfo );
- iq << XQUERY( _T(JABBER_FEAT_BYTESTREAMS));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(_T(JABBER_FEAT_BYTESTREAMS));
+ m_ThreadInfo->send(iq);
- WaitForSingleObject( jbt->hProxyEvent, INFINITE );
- m_iqManager.ExpireIq ( nIqId );
- CloseHandle( jbt->hProxyEvent );
+ WaitForSingleObject(jbt->hProxyEvent, INFINITE);
+ m_iqManager.ExpireIq (nIqId);
+ CloseHandle(jbt->hProxyEvent);
jbt->hProxyEvent = NULL;
- mir_free( proxyJid );
+ mir_free(proxyJid);
- if ( jbt->state == JBT_ERROR && !bDirect ) {
- Log( "Bytestream proxy failure" );
- MsgPopup( pInfo->GetHContact(), TranslateT("Bytestream Proxy not available"), pInfo->GetReceiver());
+ if (jbt->state == JBT_ERROR && !bDirect) {
+ Log("Bytestream proxy failure");
+ MsgPopup( pInfo->GetHContact(), TranslateT("Bytestream Proxy not available"), pInfo->GetReceiver());
jbt->ft->state = FT_DENIED;
- (this->*jbt->pfnFinal)( FALSE, jbt->ft );
+ (this->*jbt->pfnFinal)(FALSE, jbt->ft);
jbt->ft = NULL;
delete jbt;
return;
}
} }
- pInfo = m_iqManager.AddHandler( &CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, 0, -1, jbt );
+ pInfo = m_iqManager.AddHandler(&CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, 0, -1, jbt);
nIqId = pInfo->GetIqId();
{
- XmlNodeIq iq( pInfo );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_BYTESTREAMS)) << XATTR( _T("sid"), jbt->sid );
+ XmlNodeIq iq(pInfo);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_BYTESTREAMS)) << XATTR(_T("sid"), jbt->sid);
- if ( bDirect ) {
- if ( m_options.BsDirectManual ) {
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "BsDirectAddr", &dbv ))
+ if (bDirect) {
+ if (m_options.BsDirectManual) {
+ if ( !DBGetContactSettingString(NULL, m_szModuleName, "BsDirectAddr", &dbv))
localAddr = dbv.pszVal;
}
NETLIBBIND nlb = {0};
- nlb.cbSize = sizeof( NETLIBBIND );
+ nlb.cbSize = sizeof(NETLIBBIND);
nlb.pfnNewConnectionV2 = JabberByteSendConnection;
nlb.pExtra = this;
nlb.wPort = 0; // Use user-specified incoming port ranges, if available
- jbt->hConn = ( HANDLE ) CallService( MS_NETLIB_BINDPORT, ( WPARAM ) m_hNetlibUser, ( LPARAM )&nlb );
- if ( jbt->hConn == NULL ) {
- Log( "Cannot allocate port for bytestream_send thread, thread ended." );
+ jbt->hConn = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlb);
+ if (jbt->hConn == NULL) {
+ Log("Cannot allocate port for bytestream_send thread, thread ended.");
delete jbt;
return;
}
- if ( localAddr == NULL )
- localAddr = (char*)CallService( MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP );
+ if (localAddr == NULL)
+ localAddr = (char*)CallService(MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP);
- mir_sntprintf( szPort, SIZEOF( szPort ), _T("%d"), nlb.wPort );
- JABBER_LIST_ITEM *item = ListAdd( LIST_BYTE, szPort );
+ mir_sntprintf(szPort, SIZEOF(szPort), _T("%d"), nlb.wPort);
+ JABBER_LIST_ITEM *item = ListAdd(LIST_BYTE, szPort);
item->jbt = jbt;
- hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jbt->hEvent = hEvent;
- jbt->hSendEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
- query << XCHILD( _T("streamhost")) << XATTR( _T("jid"), m_ThreadInfo->fullJID ) << XATTR( _T("host"), _A2T(localAddr)) << XATTRI( _T("port"), nlb.wPort );
+ jbt->hSendEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ query << XCHILD(_T("streamhost")) << XATTR(_T("jid"), m_ThreadInfo->fullJID) << XATTR(_T("host"), _A2T(localAddr)) << XATTRI(_T("port"), nlb.wPort);
- NETLIBIPLIST* ihaddr = ( NETLIBIPLIST* )CallService( MS_NETLIB_GETMYIP, 1, 0 );
- for ( unsigned i = 0; i < ihaddr->cbNum; ++i )
- if ( strcmp( localAddr, ihaddr->szIp[i] ))
- query << XCHILD( _T("streamhost")) << XATTR( _T("jid"), m_ThreadInfo->fullJID ) << XATTR( _T("host"), _A2T(ihaddr->szIp[i])) << XATTRI( _T("port"), nlb.wPort );
+ NETLIBIPLIST* ihaddr = (NETLIBIPLIST*)CallService(MS_NETLIB_GETMYIP, 1, 0);
+ for (unsigned i = 0; i < ihaddr->cbNum; ++i)
+ if (strcmp(localAddr, ihaddr->szIp[i]))
+ query << XCHILD(_T("streamhost")) << XATTR(_T("jid"), m_ThreadInfo->fullJID) << XATTR(_T("host"), _A2T(ihaddr->szIp[i])) << XATTRI(_T("port"), nlb.wPort);
- mir_free( ihaddr );
- mir_free( localAddr );
+ mir_free(ihaddr);
+ mir_free(localAddr);
}
- if ( jbt->bProxyDiscovered )
- query << XCHILD( _T("streamhost")) << XATTR( _T("jid"), jbt->szProxyJid ) << XATTR( _T("host"), jbt->szProxyHost ) << XATTR( _T("port"), jbt->szProxyPort );
+ if (jbt->bProxyDiscovered)
+ query << XCHILD(_T("streamhost")) << XATTR(_T("jid"), jbt->szProxyJid) << XATTR(_T("host"), jbt->szProxyHost) << XATTR(_T("port"), jbt->szProxyPort);
- jbt->hProxyEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jbt->szStreamhostUsed = NULL;
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
- WaitForSingleObject( jbt->hProxyEvent, INFINITE );
- m_iqManager.ExpireIq( nIqId );
- CloseHandle( jbt->hProxyEvent );
+ WaitForSingleObject(jbt->hProxyEvent, INFINITE);
+ m_iqManager.ExpireIq(nIqId);
+ CloseHandle(jbt->hProxyEvent);
jbt->hProxyEvent = NULL;
- if ( !jbt->szStreamhostUsed ) {
- if ( bDirect ) {
- SetEvent( jbt->hSendEvent );
- CloseHandle( jbt->hSendEvent );
- CloseHandle( hEvent );
+ if ( !jbt->szStreamhostUsed) {
+ if (bDirect) {
+ SetEvent(jbt->hSendEvent);
+ CloseHandle(jbt->hSendEvent);
+ CloseHandle(hEvent);
jbt->hEvent = NULL;
- if ( jbt->hConn != NULL )
- Netlib_CloseHandle( jbt->hConn );
+ if (jbt->hConn != NULL)
+ Netlib_CloseHandle(jbt->hConn);
jbt->hConn = NULL;
- ListRemove( LIST_BYTE, szPort );
+ ListRemove(LIST_BYTE, szPort);
}
- (this->*jbt->pfnFinal)(( jbt->state==JBT_DONE )?TRUE:FALSE, jbt->ft );
+ (this->*jbt->pfnFinal)((jbt->state==JBT_DONE)?TRUE:FALSE, jbt->ft);
jbt->ft = NULL;
// stupid fix: wait for listening thread exit
- Sleep( 100 );
+ Sleep(100);
delete jbt;
return;
}
- if ( jbt->bProxyDiscovered && !_tcscmp( jbt->szProxyJid, jbt->szStreamhostUsed )) {
+ if (jbt->bProxyDiscovered && !_tcscmp(jbt->szProxyJid, jbt->szStreamhostUsed)) {
// jabber proxy used
- if ( bDirect ) {
- SetEvent( jbt->hSendEvent );
- CloseHandle( jbt->hSendEvent );
- CloseHandle( hEvent );
+ if (bDirect) {
+ SetEvent(jbt->hSendEvent);
+ CloseHandle(jbt->hSendEvent);
+ CloseHandle(hEvent);
jbt->hEvent = NULL;
- if ( jbt->hConn != NULL )
- Netlib_CloseHandle( jbt->hConn );
+ if (jbt->hConn != NULL)
+ Netlib_CloseHandle(jbt->hConn);
jbt->hConn = NULL;
- ListRemove( LIST_BYTE, szPort );
+ ListRemove(LIST_BYTE, szPort);
}
- ByteSendViaProxy( jbt );
+ ByteSendViaProxy(jbt);
}
else {
- SetEvent( jbt->hSendEvent );
- WaitForSingleObject( hEvent, INFINITE );
- CloseHandle( hEvent );
- CloseHandle( jbt->hSendEvent );
+ SetEvent(jbt->hSendEvent);
+ WaitForSingleObject(hEvent, INFINITE);
+ CloseHandle(hEvent);
+ CloseHandle(jbt->hSendEvent);
jbt->hEvent = NULL;
- (this->*jbt->pfnFinal)(( jbt->state == JBT_DONE ) ? TRUE : FALSE, jbt->ft );
+ (this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft);
jbt->ft = NULL;
- if ( jbt->hConn != NULL )
- Netlib_CloseHandle( jbt->hConn );
+ if (jbt->hConn != NULL)
+ Netlib_CloseHandle(jbt->hConn);
jbt->hConn = NULL;
- ListRemove( LIST_BYTE, szPort );
+ ListRemove(LIST_BYTE, szPort);
}
// stupid fix: wait for listening connection thread exit
- Sleep( 100 );
+ Sleep(100);
delete jbt;
- Log( "Thread ended: type=bytestream_send" );
+ Log("Thread ended: type=bytestream_send");
}
-void CJabberProto::ByteInitiateResult( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::ByteInitiateResult(HXML iqNode, CJabberIqInfo* pInfo)
{
- JABBER_BYTE_TRANSFER *jbt = ( JABBER_BYTE_TRANSFER * )pInfo->GetUserData();
-
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode ) {
- const TCHAR* queryXmlns = xmlGetAttrValue( queryNode, _T("xmlns"));
- if ( queryXmlns && !_tcscmp( queryXmlns, _T( JABBER_FEAT_BYTESTREAMS ))) {
- HXML streamHostNode = xmlGetChild( queryNode , "streamhost-used" );
- if ( streamHostNode ) {
- const TCHAR* streamJid = xmlGetAttrValue( streamHostNode, _T("jid"));
- if ( streamJid )
- jbt->szStreamhostUsed = mir_tstrdup( streamJid );
+ JABBER_BYTE_TRANSFER *jbt = (JABBER_BYTE_TRANSFER *)pInfo->GetUserData();
+
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode) {
+ const TCHAR *queryXmlns = xmlGetAttrValue(queryNode, _T("xmlns"));
+ if (queryXmlns && !_tcscmp(queryXmlns, _T(JABBER_FEAT_BYTESTREAMS))) {
+ HXML streamHostNode = xmlGetChild(queryNode , "streamhost-used");
+ if (streamHostNode) {
+ const TCHAR *streamJid = xmlGetAttrValue(streamHostNode, _T("jid"));
+ if (streamJid)
+ jbt->szStreamhostUsed = mir_tstrdup(streamJid);
} } } }
- if ( jbt->hProxyEvent )
- SetEvent( jbt->hProxyEvent );
+ if (jbt->hProxyEvent)
+ SetEvent(jbt->hProxyEvent);
}
-int CJabberProto::ByteSendParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen )
+int CJabberProto::ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen)
{
int nMethods;
BYTE data[10];
int i;
char* str;
- switch ( jbt->state ) {
+ switch (jbt->state) {
case JBT_INIT:
// received:
- // 00-00 ver ( 0x05 )
+ // 00-00 ver (0x05)
// 01-01 nmethods
- // 02-xx list of methods ( nmethods bytes )
+ // 02-xx list of methods (nmethods bytes)
// send:
- // 00-00 ver ( 0x05 )
- // 01-01 select method ( 0=no auth required )
- if ( datalen>=2 && buffer[0]==5 && buffer[1]+2==datalen ) {
+ // 00-00 ver (0x05)
+ // 01-01 select method (0=no auth required)
+ if (datalen>=2 && buffer[0]==5 && buffer[1]+2==datalen) {
nMethods = buffer[1];
- for ( i=0; i<nMethods && buffer[2+i]!=0; i++ );
- if ( i < nMethods ) {
+ for (i=0; i<nMethods && buffer[2+i]!=0; i++);
+ if (i < nMethods) {
data[1] = 0;
jbt->state = JBT_CONNECT;
}
@@ -349,59 +349,59 @@ int CJabberProto::ByteSendParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* jbt->state = JBT_ERROR;
}
data[0] = 5;
- Netlib_Send( hConn, ( char* )data, 2, 0 );
+ Netlib_Send(hConn, (char*)data, 2, 0);
}
else jbt->state = JBT_ERROR;
break;
case JBT_CONNECT:
// received:
- // 00-00 ver ( 0x05 )
- // 01-01 cmd ( 1=connect )
- // 02-02 reserved ( 0 )
- // 03-03 address type ( 3 )
- // 04-44 dst.addr ( 41 bytes: 1-byte length, 40-byte SHA1 hash of [sid,srcJID,dstJID] )
- // 45-46 dst.port ( 0 )
+ // 00-00 ver (0x05)
+ // 01-01 cmd (1=connect)
+ // 02-02 reserved (0)
+ // 03-03 address type (3)
+ // 04-44 dst.addr (41 bytes: 1-byte length, 40-byte SHA1 hash of [sid,srcJID,dstJID])
+ // 45-46 dst.port (0)
// send:
- // 00-00 ver ( 0x05 )
- // 01-01 reply ( 0=success,2=not allowed )
- // 02-02 reserved ( 0 )
- // 03-03 address type ( 1=IPv4 address )
+ // 00-00 ver (0x05)
+ // 01-01 reply (0=success,2=not allowed)
+ // 02-02 reserved (0)
+ // 03-03 address type (1=IPv4 address)
// 04-07 bnd.addr server bound address
// 08-09 bnd.port server bound port
- if ( datalen == 47 && *(( DWORD* )buffer )==0x03000105 && buffer[4]==40 && *(( WORD* )( buffer+45 ))==0 ) {
+ if (datalen == 47 && *((DWORD*)buffer)==0x03000105 && buffer[4]==40 && *((WORD*)(buffer+45))==0) {
TCHAR text[256];
TCHAR *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
TCHAR *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_sntprintf( text, SIZEOF( text ), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid );
+ mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT( text );
- Log( "Auth: '%s'", szAuthString );
- if (( str = JabberSha1( szAuthString )) != NULL ) {
- for ( i=0; i<40 && buffer[i+5]==str[i]; i++ );
- mir_free( str );
+ char* szAuthString = mir_utf8encodeT(text);
+ Log("Auth: '%s'", szAuthString);
+ if ((str = JabberSha1(szAuthString)) != NULL) {
+ for (i=0; i<40 && buffer[i+5]==str[i]; i++);
+ mir_free(str);
- ZeroMemory( data, 10 );
- data[1] = ( i>=20 )?0:2;
+ ZeroMemory(data, 10);
+ data[1] = (i>=20)?0:2;
data[0] = 5;
data[3] = 1;
- Netlib_Send( hConn, ( char* )data, 10, 0 );
+ Netlib_Send(hConn, (char*)data, 10, 0);
// wait stream activation
- WaitForSingleObject( jbt->hSendEvent, INFINITE );
+ WaitForSingleObject(jbt->hSendEvent, INFINITE);
- if ( jbt->state == JBT_ERROR )
+ if (jbt->state == JBT_ERROR)
break;
- if ( i>=20 && (this->*jbt->pfnSend)( hConn, jbt->ft )==TRUE )
+ if (i>=20 && (this->*jbt->pfnSend)(hConn, jbt->ft)==TRUE)
jbt->state = JBT_DONE;
else
jbt->state = JBT_ERROR;
}
- mir_free( szAuthString );
+ mir_free(szAuthString);
}
else
jbt->state = JBT_ERROR;
@@ -413,26 +413,26 @@ int CJabberProto::ByteSendParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* ///////////////// Bytestream receiving /////////////////////////
-void CJabberProto::IqResultStreamActivate( HXML iqNode )
+void CJabberProto::IqResultStreamActivate(HXML iqNode)
{
- int id = JabberGetPacketID( iqNode );
+ int id = JabberGetPacketID(iqNode);
TCHAR listJid[JABBER_MAX_JID_LEN];
- mir_sntprintf(listJid, SIZEOF( listJid ), _T("ftproxy_%d"), id);
+ mir_sntprintf(listJid, SIZEOF(listJid), _T("ftproxy_%d"), id);
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_FTIQID, listJid );
- if ( !item )
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTIQID, listJid);
+ if ( !item)
return;
- if ( !lstrcmp( xmlGetAttrValue( iqNode, _T("type")), _T( "result" )))
+ if ( !lstrcmp(xmlGetAttrValue(iqNode, _T("type")), _T("result")))
item->jbt->bStreamActivated = TRUE;
- if ( item->jbt->hProxyEvent )
- SetEvent( item->jbt->hProxyEvent );
+ if (item->jbt->hProxyEvent)
+ SetEvent(item->jbt->hProxyEvent);
}
-void CJabberProto::ByteSendViaProxy( JABBER_BYTE_TRANSFER *jbt )
+void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt)
{
TCHAR *szHost, *szPort;
WORD port;
@@ -442,11 +442,11 @@ void CJabberProto::ByteSendViaProxy( JABBER_BYTE_TRANSFER *jbt ) int datalen, bytesParsed, recvResult;
BOOL validStreamhost;
- if ( jbt == NULL ) return;
- if (( buffer=( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE )) == NULL ) {
- m_ThreadInfo->send( XmlNodeIq( _T("error"), jbt->iqId, jbt->srcJID )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 406 ) << XATTR( _T("type"), _T("auth"))
- << XCHILDNS( _T("not-acceptable"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ if (jbt == NULL) return;
+ if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == NULL) {
+ m_ThreadInfo->send(XmlNodeIq(_T("error"), jbt->iqId, jbt->srcJID)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 406) << XATTR(_T("type"), _T("auth"))
+ << XCHILDNS(_T("not-acceptable"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
return;
}
@@ -455,106 +455,106 @@ void CJabberProto::ByteSendViaProxy( JABBER_BYTE_TRANSFER *jbt ) szPort = jbt->szProxyPort;
szHost = jbt->szProxyHost;
- port = ( WORD )_ttoi( szPort );
- if ( jbt->streamhostJID ) mir_free( jbt->streamhostJID );
- jbt->streamhostJID = mir_tstrdup( jbt->szProxyJid );
+ port = (WORD)_ttoi(szPort);
+ if (jbt->streamhostJID) mir_free(jbt->streamhostJID);
+ jbt->streamhostJID = mir_tstrdup(jbt->szProxyJid);
NETLIBOPENCONNECTION nloc = { 0 };
- nloc.cbSize = sizeof( nloc );
+ nloc.cbSize = sizeof(nloc);
nloc.szHost = mir_t2a(szHost);
nloc.wPort = port;
- hConn = ( HANDLE ) CallService( MS_NETLIB_OPENCONNECTION, ( WPARAM ) m_hNetlibUser, ( LPARAM )&nloc );
+ hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
mir_free((void*)nloc.szHost);
- if ( hConn != NULL ) {
+ if (hConn != NULL) {
jbt->hConn = hConn;
data[0] = 5;
data[1] = 1;
data[2] = 0;
- Netlib_Send( hConn, data, 3, 0 );
+ Netlib_Send(hConn, data, 3, 0);
jbt->state = JBT_INIT;
datalen = 0;
- while ( jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR && jbt->state!=JBT_SOCKSERR ) {
- recvResult = Netlib_Recv( hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
- if ( recvResult <= 0 )
+ while (jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR && jbt->state!=JBT_SOCKSERR) {
+ recvResult = Netlib_Recv(hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0);
+ if (recvResult <= 0)
break;
datalen += recvResult;
- bytesParsed = ByteSendProxyParse( hConn, jbt, buffer, datalen );
- if ( bytesParsed < datalen )
- memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
+ bytesParsed = ByteSendProxyParse(hConn, jbt, buffer, datalen);
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
datalen -= bytesParsed;
- if ( jbt->state == JBT_DONE ) validStreamhost = TRUE;
+ if (jbt->state == JBT_DONE) validStreamhost = TRUE;
}
- Netlib_CloseHandle( hConn );
+ Netlib_CloseHandle(hConn);
}
- mir_free( buffer );
- (this->*jbt->pfnFinal)(( jbt->state == JBT_DONE ) ? TRUE : FALSE, jbt->ft );
+ mir_free(buffer);
+ (this->*jbt->pfnFinal)((jbt->state == JBT_DONE) ? TRUE : FALSE, jbt->ft);
jbt->ft = NULL;
- if ( !validStreamhost )
- m_ThreadInfo->send( XmlNodeIq( _T("error"), jbt->iqId, jbt->srcJID )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ if ( !validStreamhost)
+ m_ThreadInfo->send(XmlNodeIq(_T("error"), jbt->iqId, jbt->srcJID)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
}
-int CJabberProto::ByteSendProxyParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen )
+int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen)
{
int num = datalen;
- switch ( jbt->state ) {
+ switch (jbt->state) {
case JBT_INIT:
// received:
- // 00-00 ver ( 0x05 )
- // 01-01 selected method ( 0=no auth, 0xff=error )
+ // 00-00 ver (0x05)
+ // 01-01 selected method (0=no auth, 0xff=error)
// send:
- // 00-00 ver ( 0x05 )
- // 01-01 cmd ( 1=connect )
- // 02-02 reserved ( 0 )
- // 03-03 address type ( 3 )
- // 04-44 dst.addr ( 41 bytes: 1-byte length, 40-byte SHA1 hash of [sid,srcJID,dstJID] )
- // 45-46 dst.port ( 0 )
- if ( datalen==2 && buffer[0]==5 && buffer[1]==0 ) {
+ // 00-00 ver (0x05)
+ // 01-01 cmd (1=connect)
+ // 02-02 reserved (0)
+ // 03-03 address type (3)
+ // 04-44 dst.addr (41 bytes: 1-byte length, 40-byte SHA1 hash of [sid,srcJID,dstJID])
+ // 45-46 dst.port (0)
+ if (datalen==2 && buffer[0]==5 && buffer[1]==0) {
BYTE data[47];
- ZeroMemory( data, sizeof( data ));
- *(( DWORD* )data ) = 0x03000105;
+ ZeroMemory(data, sizeof(data));
+ *((DWORD*)data) = 0x03000105;
data[4] = 40;
TCHAR text[256];
TCHAR *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
TCHAR *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_sntprintf( text, SIZEOF( text ), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid );
+ mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT( text );
- Log( "Auth: '%s'", szAuthString );
- char* szHash = JabberSha1( szAuthString );
- strncpy(( char* )( data+5 ), szHash, 40 );
- mir_free( szHash );
- Netlib_Send( hConn, ( char* )data, 47, 0 );
+ char* szAuthString = mir_utf8encodeT(text);
+ Log("Auth: '%s'", szAuthString);
+ char* szHash = JabberSha1(szAuthString);
+ strncpy((char*)(data+5), szHash, 40);
+ mir_free(szHash);
+ Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free( szAuthString );
+ mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
case JBT_CONNECT:
// received:
- // 00-00 ver ( 0x05 )
- // 01-01 reply ( 0=success,2=not allowed )
- // 02-02 reserved ( 0 )
- // 03-03 address type ( 1=IPv4 address,3=host address )
- // 04-mm bnd.addr server bound address ( 4-byte IP if IPv4, 1-byte length + n-byte host address string if host address )
+ // 00-00 ver (0x05)
+ // 01-01 reply (0=success,2=not allowed)
+ // 02-02 reserved (0)
+ // 03-03 address type (1=IPv4 address,3=host address)
+ // 04-mm bnd.addr server bound address (4-byte IP if IPv4, 1-byte length + n-byte host address string if host address)
// nn-nn+1 bnd.port server bound port
- if ( datalen>=5 && buffer[0]==5 && buffer[1]==0 && ( buffer[3]==1 || buffer[3]==3 || buffer[3]==0 )) {
- if ( buffer[3]==1 && datalen>=10 )
+ if (datalen>=5 && buffer[0]==5 && buffer[1]==0 && (buffer[3]==1 || buffer[3]==3 || buffer[3]==0)) {
+ if (buffer[3]==1 && datalen>=10)
num = 10;
- else if ( buffer[3]==3 && datalen>=buffer[4]+7 )
+ else if (buffer[3]==3 && datalen>=buffer[4]+7)
num = buffer[4] + 7;
- else if ( buffer[3]==0 && datalen>=6 )
+ else if (buffer[3]==0 && datalen>=6)
num = 6;
else {
jbt->state = JBT_SOCKSERR;
@@ -562,31 +562,31 @@ int CJabberProto::ByteSendProxyParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, c }
jbt->state = JBT_SENDING;
- jbt->hProxyEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jbt->hProxyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jbt->bStreamActivated = FALSE;
int iqId = SerialNext();
TCHAR listJid[256];
- mir_sntprintf(listJid, SIZEOF( listJid ), _T("ftproxy_%d"), iqId);
+ mir_sntprintf(listJid, SIZEOF(listJid), _T("ftproxy_%d"), iqId);
- JABBER_LIST_ITEM *item = ListAdd( LIST_FTIQID, listJid );
+ JABBER_LIST_ITEM *item = ListAdd(LIST_FTIQID, listJid);
item->jbt = jbt;
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::IqResultStreamActivate );
- m_ThreadInfo->send(
- XmlNodeIq( _T("set"), iqId, jbt->streamhostJID ) << XQUERY( _T(JABBER_FEAT_BYTESTREAMS))
- << XATTR( _T("sid"), jbt->sid ) << XCHILD( _T("activate"), jbt->dstJID ));
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::IqResultStreamActivate);
+ m_ThreadInfo->send(
+ XmlNodeIq(_T("set"), iqId, jbt->streamhostJID) << XQUERY(_T(JABBER_FEAT_BYTESTREAMS))
+ << XATTR(_T("sid"), jbt->sid) << XCHILD(_T("activate"), jbt->dstJID));
- WaitForSingleObject( jbt->hProxyEvent, INFINITE );
+ WaitForSingleObject(jbt->hProxyEvent, INFINITE);
- CloseHandle( jbt->hProxyEvent );
+ CloseHandle(jbt->hProxyEvent);
jbt->hProxyEvent = NULL;
- ListRemove( LIST_FTIQID, listJid );
+ ListRemove(LIST_FTIQID, listJid);
- if ( jbt->bStreamActivated)
- jbt->state = (this->*jbt->pfnSend)( hConn, jbt->ft ) ? JBT_DONE : JBT_ERROR;
+ if (jbt->bStreamActivated)
+ jbt->state = (this->*jbt->pfnSend)(hConn, jbt->ft) ? JBT_DONE : JBT_ERROR;
else
jbt->state = JBT_ERROR;
}
@@ -598,7 +598,7 @@ int CJabberProto::ByteSendProxyParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, c }
-void __cdecl CJabberProto::ByteReceiveThread( JABBER_BYTE_TRANSFER *jbt )
+void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt)
{
HXML iqNode, queryNode = NULL, n;
const TCHAR *sid = NULL, *from = NULL, *to = NULL, *szId = NULL, *szHost, *szPort, *str;
@@ -610,46 +610,46 @@ void __cdecl CJabberProto::ByteReceiveThread( JABBER_BYTE_TRANSFER *jbt ) int datalen, bytesParsed, recvResult;
BOOL validStreamhost = FALSE;
- if ( jbt == NULL ) return;
+ if (jbt == NULL) return;
jbt->state = JBT_INIT;
- if ( iqNode = jbt->iqNode ) {
- from = xmlGetAttrValue( iqNode, _T("from"));
- to = xmlGetAttrValue( iqNode, _T("to"));
- szId = xmlGetAttrValue( iqNode, _T("id"));
+ if (iqNode = jbt->iqNode) {
+ from = xmlGetAttrValue(iqNode, _T("from"));
+ to = xmlGetAttrValue(iqNode, _T("to"));
+ szId = xmlGetAttrValue(iqNode, _T("id"));
- queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode )
- sid = xmlGetAttrValue( queryNode, _T("sid"));
+ queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode)
+ sid = xmlGetAttrValue(queryNode, _T("sid"));
}
- if ( szId && from && to && sid && ( n = xmlGetChild( queryNode , "streamhost" ))!=NULL ) {
- jbt->iqId = mir_tstrdup( szId );
- jbt->srcJID = mir_tstrdup( from );
- jbt->dstJID = mir_tstrdup( to );
- jbt->sid = mir_tstrdup( sid );
+ if (szId && from && to && sid && (n = xmlGetChild(queryNode , "streamhost"))!=NULL) {
+ jbt->iqId = mir_tstrdup(szId);
+ jbt->srcJID = mir_tstrdup(from);
+ jbt->dstJID = mir_tstrdup(to);
+ jbt->sid = mir_tstrdup(sid);
- if (( buffer=( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE ))) {
- for ( i=1; ( n = xmlGetNthChild( queryNode, _T("streamhost"), i ))!=NULL; i++ ) {
- if (( szHost = xmlGetAttrValue( n, _T("host"))) != NULL &&
- ( szPort = xmlGetAttrValue( n, _T("port"))) != NULL &&
- ( str = xmlGetAttrValue( n, _T("jid"))) != NULL ) {
+ if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE))) {
+ for (i=1; (n = xmlGetNthChild(queryNode, _T("streamhost"), i))!=NULL; i++) {
+ if ((szHost = xmlGetAttrValue(n, _T("host"))) != NULL &&
+ (szPort = xmlGetAttrValue(n, _T("port"))) != NULL &&
+ (str = xmlGetAttrValue(n, _T("jid"))) != NULL) {
- port = ( WORD )_ttoi( szPort );
- if ( jbt->streamhostJID ) mir_free( jbt->streamhostJID );
- jbt->streamhostJID = mir_tstrdup( str );
+ port = (WORD)_ttoi(szPort);
+ if (jbt->streamhostJID) mir_free(jbt->streamhostJID);
+ jbt->streamhostJID = mir_tstrdup(str);
- Log( "bytestream_recv connecting to " TCHAR_STR_PARAM ":%d", szHost, port );
+ Log("bytestream_recv connecting to " TCHAR_STR_PARAM ":%d", szHost, port);
NETLIBOPENCONNECTION nloc = { 0 };
- nloc.cbSize = sizeof( nloc );
+ nloc.cbSize = sizeof(nloc);
nloc.szHost = mir_t2a(szHost);
nloc.wPort = port;
- hConn = ( HANDLE ) CallService( MS_NETLIB_OPENCONNECTION, ( WPARAM ) m_hNetlibUser, ( LPARAM )&nloc );
+ hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
mir_free((void*)nloc.szHost);
- if ( hConn == NULL ) {
- Log( "bytestream_recv_connection connection failed ( %d ), try next streamhost", WSAGetLastError());
+ if (hConn == NULL) {
+ Log("bytestream_recv_connection connection failed (%d), try next streamhost", WSAGetLastError());
continue;
}
@@ -658,99 +658,99 @@ void __cdecl CJabberProto::ByteReceiveThread( JABBER_BYTE_TRANSFER *jbt ) data[0] = 5;
data[1] = 1;
data[2] = 0;
- Netlib_Send( hConn, data, 3, 0 );
+ Netlib_Send(hConn, data, 3, 0);
jbt->state = JBT_INIT;
datalen = 0;
- while ( jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR && jbt->state!=JBT_SOCKSERR ) {
- recvResult = Netlib_Recv( hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
- if ( recvResult <= 0 ) break;
+ while (jbt->state!=JBT_DONE && jbt->state!=JBT_ERROR && jbt->state!=JBT_SOCKSERR) {
+ recvResult = Netlib_Recv(hConn, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0);
+ if (recvResult <= 0) break;
datalen += recvResult;
- bytesParsed = ByteReceiveParse( hConn, jbt, buffer, datalen );
- if ( bytesParsed < datalen )
- memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
+ bytesParsed = ByteReceiveParse(hConn, jbt, buffer, datalen);
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
datalen -= bytesParsed;
- if ( jbt->state == JBT_RECVING ) validStreamhost = TRUE;
+ if (jbt->state == JBT_RECVING) validStreamhost = TRUE;
}
- Netlib_CloseHandle( hConn );
- Log( "bytestream_recv_connection closing connection" );
+ Netlib_CloseHandle(hConn);
+ Log("bytestream_recv_connection closing connection");
}
- if ( jbt->state==JBT_ERROR || validStreamhost==TRUE )
+ if (jbt->state==JBT_ERROR || validStreamhost==TRUE)
break;
- Log( "bytestream_recv_connection stream cannot be established, try next streamhost" );
+ Log("bytestream_recv_connection stream cannot be established, try next streamhost");
}
- mir_free( buffer );
+ mir_free(buffer);
}
}
- (this->*jbt->pfnFinal)(( jbt->state==JBT_DONE )?TRUE:FALSE, jbt->ft );
+ (this->*jbt->pfnFinal)((jbt->state==JBT_DONE)?TRUE:FALSE, jbt->ft);
jbt->ft = NULL;
- if ( !validStreamhost && szId && from ) {
- Log( "bytestream_recv_connection session not completed" );
+ if ( !validStreamhost && szId && from) {
+ Log("bytestream_recv_connection session not completed");
- m_ThreadInfo->send( XmlNodeIq( _T("error"), szId, from )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ m_ThreadInfo->send(XmlNodeIq(_T("error"), szId, from)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
}
delete jbt;
- Log( "Thread ended: type=bytestream_recv" );
+ Log("Thread ended: type=bytestream_recv");
}
-int CJabberProto::ByteReceiveParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen )
+int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen)
{
int bytesReceived, num = datalen;
- switch ( jbt->state ) {
+ switch (jbt->state) {
case JBT_INIT:
// received:
- // 00-00 ver ( 0x05 )
- // 01-01 selected method ( 0=no auth, 0xff=error )
+ // 00-00 ver (0x05)
+ // 01-01 selected method (0=no auth, 0xff=error)
// send:
- // 00-00 ver ( 0x05 )
- // 01-01 cmd ( 1=connect )
- // 02-02 reserved ( 0 )
- // 03-03 address type ( 3 )
- // 04-44 dst.addr ( 41 bytes: 1-byte length, 40-byte SHA1 hash of [sid,srcJID,dstJID] )
- // 45-46 dst.port ( 0 )
- if ( datalen==2 && buffer[0]==5 && buffer[1]==0 ) {
+ // 00-00 ver (0x05)
+ // 01-01 cmd (1=connect)
+ // 02-02 reserved (0)
+ // 03-03 address type (3)
+ // 04-44 dst.addr (41 bytes: 1-byte length, 40-byte SHA1 hash of [sid,srcJID,dstJID])
+ // 45-46 dst.port (0)
+ if (datalen==2 && buffer[0]==5 && buffer[1]==0) {
BYTE data[47];
- ZeroMemory( data, sizeof( data ));
- *(( DWORD* )data ) = 0x03000105;
+ ZeroMemory(data, sizeof(data));
+ *((DWORD*)data) = 0x03000105;
data[4] = 40;
TCHAR text[JABBER_MAX_JID_LEN*2];
TCHAR *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
TCHAR *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_sntprintf( text, SIZEOF( text ), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid );
+ mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT( text );
- Log( "Auth: '%s'", szAuthString );
- char* szHash = JabberSha1( szAuthString );
- strncpy(( char* )( data+5 ), szHash, 40 );
- mir_free( szHash );
- Netlib_Send( hConn, ( char* )data, 47, 0 );
+ char* szAuthString = mir_utf8encodeT(text);
+ Log("Auth: '%s'", szAuthString);
+ char* szHash = JabberSha1(szAuthString);
+ strncpy((char*)(data+5), szHash, 40);
+ mir_free(szHash);
+ Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free( szAuthString );
+ mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
case JBT_CONNECT:
// received:
- // 00-00 ver ( 0x05 )
- // 01-01 reply ( 0=success,2=not allowed )
- // 02-02 reserved ( 0 )
- // 03-03 address type ( 1=IPv4 address,3=host address )
- // 04-mm bnd.addr server bound address ( 4-byte IP if IPv4, 1-byte length + n-byte host address string if host address )
+ // 00-00 ver (0x05)
+ // 01-01 reply (0=success,2=not allowed)
+ // 02-02 reserved (0)
+ // 03-03 address type (1=IPv4 address,3=host address)
+ // 04-mm bnd.addr server bound address (4-byte IP if IPv4, 1-byte length + n-byte host address string if host address)
// nn-nn+1 bnd.port server bound port
- if ( datalen>=5 && buffer[0]==5 && buffer[1]==0 && ( buffer[3]==1 || buffer[3]==3 || buffer[3]==0 )) {
- if ( buffer[3]==1 && datalen>=10 )
+ if (datalen>=5 && buffer[0]==5 && buffer[1]==0 && (buffer[3]==1 || buffer[3]==3 || buffer[3]==0)) {
+ if (buffer[3]==1 && datalen>=10)
num = 10;
- else if ( buffer[3]==3 && datalen>=buffer[4]+7 )
+ else if (buffer[3]==3 && datalen>=buffer[4]+7)
num = buffer[4] + 7;
- else if ( buffer[3]==0 && datalen>=6 )
+ else if (buffer[3]==0 && datalen>=6)
num = 6;
else {
jbt->state = JBT_SOCKSERR;
@@ -759,17 +759,17 @@ int CJabberProto::ByteReceiveParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, cha jbt->state = JBT_RECVING;
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), jbt->iqId, jbt->srcJID ) << XQUERY( _T(JABBER_FEAT_BYTESTREAMS))
- << XCHILD( _T("streamhost-used")) << XATTR( _T("jid"), jbt->streamhostJID ));
+ XmlNodeIq(_T("result"), jbt->iqId, jbt->srcJID) << XQUERY(_T(JABBER_FEAT_BYTESTREAMS))
+ << XCHILD(_T("streamhost-used")) << XATTR(_T("jid"), jbt->streamhostJID));
}
else jbt->state = JBT_SOCKSERR;
break;
case JBT_RECVING:
- bytesReceived = (this->*jbt->pfnRecv)( hConn, jbt->ft, buffer, datalen );
- if ( bytesReceived < 0 )
+ bytesReceived = (this->*jbt->pfnRecv)(hConn, jbt->ft, buffer, datalen);
+ if (bytesReceived < 0)
jbt->state = JBT_ERROR;
- else if ( bytesReceived == 0 )
+ else if (bytesReceived == 0)
jbt->state = JBT_DONE;
break;
}
diff --git a/protocols/JabberG/src/jabber_byte.h b/protocols/JabberG/src/jabber_byte.h index 657d797fce..99541ac2e5 100644 --- a/protocols/JabberG/src/jabber_byte.h +++ b/protocols/JabberG/src/jabber_byte.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -42,10 +42,10 @@ struct JABBER_BYTE_TRANSFER HANDLE hConn;
HANDLE hEvent;
HXML iqNode;
- BOOL ( CJabberProto::*pfnSend )( HANDLE hConn, filetransfer* ft );
- int ( CJabberProto::*pfnRecv )( HANDLE hConn, filetransfer* ft, char* buffer, int datalen );
- void ( CJabberProto::*pfnFinal )( BOOL success, filetransfer* ft );
- filetransfer* ft;
+ BOOL (CJabberProto::*pfnSend)(HANDLE hConn, filetransfer *ft);
+ int (CJabberProto::*pfnRecv)(HANDLE hConn, filetransfer *ft, char* buffer, int datalen);
+ void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft);
+ filetransfer *ft;
// XEP-0065 proxy support
BOOL bProxyDiscovered;
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 380cf03087..8c5f3f484b 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -85,180 +85,180 @@ const JabberFeatCapPair g_JabberFeatCapPairsExt[] = { { NULL, 0 }
};
-void CJabberProto::OnIqResultCapsDiscoInfoSI( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultCapsDiscoInfoSI(HXML, CJabberIqInfo* pInfo)
{
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( pInfo->GetFrom());
- if ( !r )
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->GetFrom());
+ if ( !r)
return;
- if ( r->szCapsNode == NULL )
- OnIqResultCapsDiscoInfo( NULL, pInfo );
+ if (r->szCapsNode == NULL)
+ OnIqResultCapsDiscoInfo(NULL, pInfo);
HXML query = pInfo->GetChildNode();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query ) {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) {
// XEP-0232 support
HXML xform;
- for ( int i = 1; ( xform = xmlGetNthChild( query, _T("x"), i)) != NULL; i++ ) {
- TCHAR *szFormTypeValue = XPath( xform, _T("field[@var='FORM_TYPE']/value"));
- if ( szFormTypeValue && !_tcscmp( szFormTypeValue, _T("urn:xmpp:dataforms:softwareinfo"))) {
- if ( r->pSoftwareInfo )
+ for (int i = 1; (xform = xmlGetNthChild(query, _T("x"), i)) != NULL; i++) {
+ TCHAR *szFormTypeValue = XPath(xform, _T("field[@var='FORM_TYPE']/value"));
+ if (szFormTypeValue && !_tcscmp(szFormTypeValue, _T("urn:xmpp:dataforms:softwareinfo"))) {
+ if (r->pSoftwareInfo)
delete r->pSoftwareInfo;
r->pSoftwareInfo = new JABBER_XEP0232_SOFTWARE_INFO;
- if ( r->pSoftwareInfo ) {
- TCHAR *szTmp = XPath( xform, _T("field[@var='os']/value"));
- if ( szTmp )
- r->pSoftwareInfo->szOs = mir_tstrdup( szTmp );
- szTmp = XPath( xform, _T("field[@var='os_version']/value"));
- if ( szTmp )
- r->pSoftwareInfo->szOsVersion = mir_tstrdup( szTmp );
- szTmp = XPath( xform, _T("field[@var='software']/value"));
- if ( szTmp )
- r->pSoftwareInfo->szSoftware = mir_tstrdup( szTmp );
- szTmp = XPath( xform, _T("field[@var='software_version']/value"));
- if ( szTmp )
- r->pSoftwareInfo->szSoftwareVersion = mir_tstrdup( szTmp );
- szTmp = XPath( xform, _T("field[@var='x-miranda-core-version']/value"));
- if ( szTmp )
- r->pSoftwareInfo->szXMirandaCoreVersion = mir_tstrdup( szTmp );
- szTmp = XPath( xform, _T("field[@var='x-miranda-core-is-unicode']/value"));
- if ( !szTmp ) // old deprecated format
- szTmp = XPath( xform, _T("field[@var='x-miranda-is-unicode']/value"));
- if ( szTmp && _ttoi( szTmp ))
+ if (r->pSoftwareInfo) {
+ TCHAR *szTmp = XPath(xform, _T("field[@var='os']/value"));
+ if (szTmp)
+ r->pSoftwareInfo->szOs = mir_tstrdup(szTmp);
+ szTmp = XPath(xform, _T("field[@var='os_version']/value"));
+ if (szTmp)
+ r->pSoftwareInfo->szOsVersion = mir_tstrdup(szTmp);
+ szTmp = XPath(xform, _T("field[@var='software']/value"));
+ if (szTmp)
+ r->pSoftwareInfo->szSoftware = mir_tstrdup(szTmp);
+ szTmp = XPath(xform, _T("field[@var='software_version']/value"));
+ if (szTmp)
+ r->pSoftwareInfo->szSoftwareVersion = mir_tstrdup(szTmp);
+ szTmp = XPath(xform, _T("field[@var='x-miranda-core-version']/value"));
+ if (szTmp)
+ r->pSoftwareInfo->szXMirandaCoreVersion = mir_tstrdup(szTmp);
+ szTmp = XPath(xform, _T("field[@var='x-miranda-core-is-unicode']/value"));
+ if ( !szTmp) // old deprecated format
+ szTmp = XPath(xform, _T("field[@var='x-miranda-is-unicode']/value"));
+ if (szTmp && _ttoi(szTmp))
r->pSoftwareInfo->bXMirandaIsUnicode = TRUE;
- szTmp = XPath( xform, _T("field[@var='x-miranda-core-is-alpha']/value"));
- if ( !szTmp ) // old deprecated format
- szTmp = XPath( xform, _T("field[@var='x-miranda-is-alpha']/value"));
- if ( szTmp && _ttoi( szTmp ))
+ szTmp = XPath(xform, _T("field[@var='x-miranda-core-is-alpha']/value"));
+ if ( !szTmp) // old deprecated format
+ szTmp = XPath(xform, _T("field[@var='x-miranda-is-alpha']/value"));
+ if (szTmp && _ttoi(szTmp))
r->pSoftwareInfo->bXMirandaIsAlpha = TRUE;
- szTmp = XPath( xform, _T("field[@var='x-miranda-jabber-is-debug']/value"));
- if ( szTmp && _ttoi( szTmp ))
+ szTmp = XPath(xform, _T("field[@var='x-miranda-jabber-is-debug']/value"));
+ if (szTmp && _ttoi(szTmp))
r->pSoftwareInfo->bXMirandaIsDebug = TRUE;
}
- JabberUserInfoUpdate( pInfo->GetHContact());
+ JabberUserInfoUpdate(pInfo->GetHContact());
}
}
}
}
-void CJabberProto::OnIqResultCapsDiscoInfo( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo* pInfo)
{
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( pInfo->GetFrom());
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->GetFrom());
HXML query = pInfo->GetChildNode();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query ) {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) {
JabberCapsBits jcbCaps = 0;
HXML feature;
- for ( int i = 1; ( feature = xmlGetNthChild( query, _T("feature"), i )) != NULL; i++ ) {
- const TCHAR *featureName = xmlGetAttrValue( feature, _T("var"));
- if ( featureName ) {
- for ( int j = 0; g_JabberFeatCapPairs[j].szFeature; j++ ) {
- if ( !_tcscmp( g_JabberFeatCapPairs[j].szFeature, featureName )) {
+ for (int i = 1; (feature = xmlGetNthChild(query, _T("feature"), i)) != NULL; i++) {
+ const TCHAR *featureName = xmlGetAttrValue(feature, _T("var"));
+ if (featureName) {
+ for (int j = 0; g_JabberFeatCapPairs[j].szFeature; j++) {
+ if ( !_tcscmp(g_JabberFeatCapPairs[j].szFeature, featureName)) {
jcbCaps |= g_JabberFeatCapPairs[j].jcbCap;
break;
} } } }
// no version info support and no XEP-0115 support?
- if ( r && r->dwVersionRequestTime == -1 && !r->version && !r->software && !r->szCapsNode ) {
+ if (r && r->dwVersionRequestTime == -1 && !r->version && !r->software && !r->szCapsNode) {
r->jcbCachedCaps = jcbCaps;
r->dwDiscoInfoRequestTime = -1;
return;
}
- if (!m_clientCapsManager.SetClientCaps( pInfo->GetIqId(), jcbCaps ))
- if ( r )
+ if ( !m_clientCapsManager.SetClientCaps(pInfo->GetIqId(), jcbCaps))
+ if (r)
r->jcbCachedCaps = jcbCaps;
- JabberUserInfoUpdate( pInfo->GetHContact());
+ JabberUserInfoUpdate(pInfo->GetHContact());
}
else {
// no version info support and no XEP-0115 support?
- if ( r && r->dwVersionRequestTime == -1 && !r->version && !r->software && !r->szCapsNode ) {
+ if (r && r->dwVersionRequestTime == -1 && !r->version && !r->software && !r->szCapsNode) {
r->jcbCachedCaps = JABBER_RESOURCE_CAPS_NONE;
r->dwDiscoInfoRequestTime = -1;
return;
}
- m_clientCapsManager.SetClientCaps( pInfo->GetIqId(), JABBER_RESOURCE_CAPS_ERROR );
+ m_clientCapsManager.SetClientCaps(pInfo->GetIqId(), JABBER_RESOURCE_CAPS_ERROR);
}
}
-JabberCapsBits CJabberProto::GetTotalJidCapabilites( const TCHAR *jid )
+JabberCapsBits CJabberProto::GetTotalJidCapabilites(const TCHAR *jid)
{
- if ( !jid )
+ if ( !jid)
return JABBER_RESOURCE_CAPS_NONE;
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( jid, szBareJid, SIZEOF( szBareJid ));
+ JabberStripJid(jid, szBareJid, SIZEOF(szBareJid));
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_ROSTER, szBareJid );
- if ( !item )
- item = ListGetItemPtr( LIST_VCARD_TEMP, szBareJid );
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, szBareJid);
+ if ( !item)
+ item = ListGetItemPtr(LIST_VCARD_TEMP, szBareJid);
JabberCapsBits jcbToReturn = JABBER_RESOURCE_CAPS_NONE;
// get bare jid info only if where is no resources
- if ( !item || ( item && !item->resourceCount )) {
- jcbToReturn = GetResourceCapabilites( szBareJid, FALSE );
- if ( jcbToReturn & JABBER_RESOURCE_CAPS_ERROR)
+ if ( !item || (item && !item->resourceCount)) {
+ jcbToReturn = GetResourceCapabilites(szBareJid, FALSE);
+ if (jcbToReturn & JABBER_RESOURCE_CAPS_ERROR)
jcbToReturn = JABBER_RESOURCE_CAPS_NONE;
}
- if ( item ) {
- for ( int i = 0; i < item->resourceCount; i++ ) {
+ if (item) {
+ for (int i = 0; i < item->resourceCount; i++) {
TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
- mir_sntprintf( szFullJid, JABBER_MAX_JID_LEN, _T("%s/%s"), szBareJid, item->resource[i].resourceName );
- JabberCapsBits jcb = GetResourceCapabilites( szFullJid, FALSE );
- if ( !( jcb & JABBER_RESOURCE_CAPS_ERROR ))
+ mir_sntprintf(szFullJid, JABBER_MAX_JID_LEN, _T("%s/%s"), szBareJid, item->resource[i].resourceName);
+ JabberCapsBits jcb = GetResourceCapabilites(szFullJid, FALSE);
+ if ( !(jcb & JABBER_RESOURCE_CAPS_ERROR))
jcbToReturn |= jcb;
}
}
return jcbToReturn;
}
-JabberCapsBits CJabberProto::GetResourceCapabilites( const TCHAR *jid, BOOL appendBestResource )
+JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appendBestResource)
{
TCHAR fullJid[ JABBER_MAX_JID_LEN ];
- if ( appendBestResource )
- GetClientJID( jid, fullJid, SIZEOF( fullJid ));
+ if (appendBestResource)
+ GetClientJID(jid, fullJid, SIZEOF(fullJid));
else
- _tcsncpy( fullJid, jid, SIZEOF( fullJid ));
+ _tcsncpy(fullJid, jid, SIZEOF(fullJid));
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( fullJid );
- if ( r == NULL )
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(fullJid);
+ if (r == NULL)
return JABBER_RESOURCE_CAPS_ERROR;
// XEP-0115 mode
- if ( r->szCapsNode && r->szCapsVer ) {
+ if (r->szCapsNode && r->szCapsVer) {
JabberCapsBits jcbCaps = 0, jcbExtCaps = 0;
BOOL bRequestSent = FALSE;
- JabberCapsBits jcbMainCaps = m_clientCapsManager.GetClientCaps( r->szCapsNode, r->szCapsVer );
+ JabberCapsBits jcbMainCaps = m_clientCapsManager.GetClientCaps(r->szCapsNode, r->szCapsVer);
- if ( jcbMainCaps == JABBER_RESOURCE_CAPS_TIMEOUT && !r->dwDiscoInfoRequestTime )
+ if (jcbMainCaps == JABBER_RESOURCE_CAPS_TIMEOUT && !r->dwDiscoInfoRequestTime)
jcbMainCaps = JABBER_RESOURCE_CAPS_ERROR;
- if ( jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT ) {
+ if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) {
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE );
- pInfo->SetTimeout( JABBER_RESOURCE_CAPS_QUERY_TIMEOUT );
- m_clientCapsManager.SetClientCaps( r->szCapsNode, r->szCapsVer, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
+ CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
+ m_clientCapsManager.SetClientCaps(r->szCapsNode, r->szCapsVer, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
r->dwDiscoInfoRequestTime = pInfo->GetRequestTime();
TCHAR queryNode[512];
- mir_sntprintf( queryNode, SIZEOF(queryNode), _T("%s#%s"), r->szCapsNode, r->szCapsVer );
- m_ThreadInfo->send( XmlNodeIq( pInfo ) << XQUERY( _T(JABBER_FEAT_DISCO_INFO)) << XATTR( _T("node"), queryNode ));
+ mir_sntprintf(queryNode, SIZEOF(queryNode), _T("%s#%s"), r->szCapsNode, r->szCapsVer);
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(_T(JABBER_FEAT_DISCO_INFO)) << XATTR(_T("node"), queryNode));
bRequestSent = TRUE;
}
- else if ( jcbMainCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS )
+ else if (jcbMainCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS)
bRequestSent = TRUE;
- else if ( jcbMainCaps != JABBER_RESOURCE_CAPS_TIMEOUT )
+ else if (jcbMainCaps != JABBER_RESOURCE_CAPS_TIMEOUT)
jcbCaps |= jcbMainCaps;
- if ( jcbMainCaps != JABBER_RESOURCE_CAPS_TIMEOUT && r->szCapsExt ) {
- TCHAR *caps = mir_tstrdup( r->szCapsExt );
+ if (jcbMainCaps != JABBER_RESOURCE_CAPS_TIMEOUT && r->szCapsExt) {
+ TCHAR *caps = mir_tstrdup(r->szCapsExt);
- TCHAR *token = _tcstok( caps, _T(" "));
- while ( token ) {
- switch ( jcbExtCaps = m_clientCapsManager.GetClientCaps( r->szCapsNode, token )) {
+ TCHAR *token = _tcstok(caps, _T(" "));
+ while (token) {
+ switch (jcbExtCaps = m_clientCapsManager.GetClientCaps(r->szCapsNode, token)) {
case JABBER_RESOURCE_CAPS_ERROR:
break;
@@ -266,14 +266,14 @@ JabberCapsBits CJabberProto::GetResourceCapabilites( const TCHAR *jid, BOOL appe {
// send disco#info query
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE );
- pInfo->SetTimeout( JABBER_RESOURCE_CAPS_QUERY_TIMEOUT );
- m_clientCapsManager.SetClientCaps( r->szCapsNode, token, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
+ m_clientCapsManager.SetClientCaps(r->szCapsNode, token, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
TCHAR queryNode[512];
- mir_sntprintf( queryNode, SIZEOF(queryNode), _T("%s#%s"), r->szCapsNode, token );
+ mir_sntprintf(queryNode, SIZEOF(queryNode), _T("%s#%s"), r->szCapsNode, token);
m_ThreadInfo->send(
- XmlNodeIq( pInfo ) << XQUERY( _T(JABBER_FEAT_DISCO_INFO)) << XATTR( _T("node"), queryNode ));
+ XmlNodeIq(pInfo) << XQUERY(_T(JABBER_FEAT_DISCO_INFO)) << XATTR(_T("node"), queryNode));
bRequestSent = TRUE;
break;
@@ -286,13 +286,13 @@ JabberCapsBits CJabberProto::GetResourceCapabilites( const TCHAR *jid, BOOL appe jcbCaps |= jcbExtCaps;
}
- token = _tcstok( NULL, _T(" "));
+ token = _tcstok(NULL, _T(" "));
}
mir_free(caps);
}
- if ( bRequestSent )
+ if (bRequestSent)
return JABBER_RESOURCE_CAPS_IN_PROGRESS;
return jcbCaps | r->jcbManualDiscoveredCaps;
@@ -301,46 +301,46 @@ JabberCapsBits CJabberProto::GetResourceCapabilites( const TCHAR *jid, BOOL appe // capability mode (version request + service discovery)
// no version info:
- if ( !r->version && !r->software ) {
+ if ( !r->version && !r->software) {
// version request not sent:
- if ( !r->dwVersionRequestTime ) {
+ if ( !r->dwVersionRequestTime) {
// send version query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE );
- pInfo->SetTimeout( JABBER_RESOURCE_CAPS_QUERY_TIMEOUT );
+ CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
r->dwVersionRequestTime = pInfo->GetRequestTime();
- XmlNodeIq iq( pInfo );
- iq << XQUERY( _T(JABBER_FEAT_VERSION));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(_T(JABBER_FEAT_VERSION));
+ m_ThreadInfo->send(iq);
return JABBER_RESOURCE_CAPS_IN_PROGRESS;
}
// version not received:
- else if ( r->dwVersionRequestTime != -1 ) {
+ else if (r->dwVersionRequestTime != -1) {
// no timeout?
- if ( GetTickCount() - r->dwVersionRequestTime < JABBER_RESOURCE_CAPS_QUERY_TIMEOUT )
+ if (GetTickCount() - r->dwVersionRequestTime < JABBER_RESOURCE_CAPS_QUERY_TIMEOUT)
return JABBER_RESOURCE_CAPS_IN_PROGRESS;
// timeout
r->dwVersionRequestTime = -1;
}
// no version information, try direct service discovery
- if ( !r->dwDiscoInfoRequestTime ) {
+ if ( !r->dwDiscoInfoRequestTime) {
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE );
- pInfo->SetTimeout( JABBER_RESOURCE_CAPS_QUERY_TIMEOUT );
+ CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
r->dwDiscoInfoRequestTime = pInfo->GetRequestTime();
- XmlNodeIq iq( pInfo );
- iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ m_ThreadInfo->send(iq);
return JABBER_RESOURCE_CAPS_IN_PROGRESS;
}
- else if ( r->dwDiscoInfoRequestTime == -1 )
+ else if (r->dwDiscoInfoRequestTime == -1)
return r->jcbCachedCaps | r->jcbManualDiscoveredCaps;
- else if ( GetTickCount() - r->dwDiscoInfoRequestTime < JABBER_RESOURCE_CAPS_QUERY_TIMEOUT )
+ else if (GetTickCount() - r->dwDiscoInfoRequestTime < JABBER_RESOURCE_CAPS_QUERY_TIMEOUT)
return JABBER_RESOURCE_CAPS_IN_PROGRESS;
else
r->dwDiscoInfoRequestTime = -1;
@@ -349,36 +349,36 @@ JabberCapsBits CJabberProto::GetResourceCapabilites( const TCHAR *jid, BOOL appe }
// version info available:
- if ( r->software && r->version ) {
- JabberCapsBits jcbMainCaps = m_clientCapsManager.GetClientCaps( r->software, r->version );
- if ( jcbMainCaps == JABBER_RESOURCE_CAPS_ERROR ) {
+ if (r->software && r->version) {
+ JabberCapsBits jcbMainCaps = m_clientCapsManager.GetClientCaps(r->software, r->version);
+ if (jcbMainCaps == JABBER_RESOURCE_CAPS_ERROR) {
// Bombus hack:
- if ( !_tcscmp( r->software, _T( "Bombus" )) || !_tcscmp( r->software, _T( "BombusMod" ))) {
+ if ( !_tcscmp(r->software, _T("Bombus")) || !_tcscmp(r->software, _T("BombusMod"))) {
jcbMainCaps = JABBER_CAPS_SI|JABBER_CAPS_SI_FT|JABBER_CAPS_IBB|JABBER_CAPS_MESSAGE_EVENTS|JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY|JABBER_CAPS_DATA_FORMS|JABBER_CAPS_LAST_ACTIVITY|JABBER_CAPS_VERSION|JABBER_CAPS_COMMANDS|JABBER_CAPS_VCARD_TEMP;
- m_clientCapsManager.SetClientCaps( r->software, r->version, jcbMainCaps );
+ m_clientCapsManager.SetClientCaps(r->software, r->version, jcbMainCaps);
}
// Neos hack:
- else if ( !_tcscmp( r->software, _T( "neos" ))) {
+ else if ( !_tcscmp(r->software, _T("neos"))) {
jcbMainCaps = JABBER_CAPS_OOB|JABBER_CAPS_MESSAGE_EVENTS|JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY|JABBER_CAPS_LAST_ACTIVITY|JABBER_CAPS_VERSION;
- m_clientCapsManager.SetClientCaps( r->software, r->version, jcbMainCaps );
+ m_clientCapsManager.SetClientCaps(r->software, r->version, jcbMainCaps);
}
// sim hack:
- else if ( !_tcscmp( r->software, _T( "sim" ))) {
+ else if ( !_tcscmp(r->software, _T("sim"))) {
jcbMainCaps = JABBER_CAPS_OOB|JABBER_CAPS_VERSION|JABBER_CAPS_MESSAGE_EVENTS|JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY;
- m_clientCapsManager.SetClientCaps( r->software, r->version, jcbMainCaps );
+ m_clientCapsManager.SetClientCaps(r->software, r->version, jcbMainCaps);
} }
- else if ( jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT ) {
+ else if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) {
// send disco#info query
- CJabberIqInfo *pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE );
- pInfo->SetTimeout( JABBER_RESOURCE_CAPS_QUERY_TIMEOUT );
- m_clientCapsManager.SetClientCaps( r->software, r->version, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
+ CJabberIqInfo *pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
+ pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
+ m_clientCapsManager.SetClientCaps(r->software, r->version, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
r->dwDiscoInfoRequestTime = pInfo->GetRequestTime();
- XmlNodeIq iq( pInfo );
- iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ m_ThreadInfo->send(iq);
jcbMainCaps = JABBER_RESOURCE_CAPS_IN_PROGRESS;
}
@@ -391,9 +391,9 @@ JabberCapsBits CJabberProto::GetResourceCapabilites( const TCHAR *jid, BOOL appe /////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientPartialCaps class members
-CJabberClientPartialCaps::CJabberClientPartialCaps( const TCHAR *szVer )
+CJabberClientPartialCaps::CJabberClientPartialCaps(const TCHAR *szVer)
{
- m_szVer = mir_tstrdup( szVer );
+ m_szVer = mir_tstrdup(szVer);
m_jcbCaps = JABBER_RESOURCE_CAPS_UNINIT;
m_pNext = NULL;
m_nIqId = -1;
@@ -402,21 +402,21 @@ CJabberClientPartialCaps::CJabberClientPartialCaps( const TCHAR *szVer ) CJabberClientPartialCaps::~CJabberClientPartialCaps()
{
- mir_free( m_szVer );
- if ( m_pNext )
+ mir_free(m_szVer);
+ if (m_pNext)
delete m_pNext;
}
-CJabberClientPartialCaps* CJabberClientPartialCaps::SetNext( CJabberClientPartialCaps *pCaps )
+CJabberClientPartialCaps* CJabberClientPartialCaps::SetNext(CJabberClientPartialCaps *pCaps)
{
CJabberClientPartialCaps *pRetVal = m_pNext;
m_pNext = pCaps;
return pRetVal;
}
-void CJabberClientPartialCaps::SetCaps( JabberCapsBits jcbCaps, int nIqId /*= -1*/ )
+void CJabberClientPartialCaps::SetCaps(JabberCapsBits jcbCaps, int nIqId /*= -1*/)
{
- if ( jcbCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS )
+ if (jcbCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS)
m_dwRequestTime = GetTickCount();
else
m_dwRequestTime = 0;
@@ -426,121 +426,121 @@ void CJabberClientPartialCaps::SetCaps( JabberCapsBits jcbCaps, int nIqId /*= -1 JabberCapsBits CJabberClientPartialCaps::GetCaps()
{
- if ( m_jcbCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS && GetTickCount() - m_dwRequestTime > JABBER_RESOURCE_CAPS_QUERY_TIMEOUT ) {
+ if (m_jcbCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS && GetTickCount() - m_dwRequestTime > JABBER_RESOURCE_CAPS_QUERY_TIMEOUT) {
m_jcbCaps = JABBER_RESOURCE_CAPS_TIMEOUT;
m_dwRequestTime = 0;
}
return m_jcbCaps;
}
-CJabberClientPartialCaps* CJabberClientCaps::FindByVersion( const TCHAR *szVer )
+CJabberClientPartialCaps* CJabberClientCaps::FindByVersion(const TCHAR *szVer)
{
- if ( !m_pCaps || !szVer )
+ if ( !m_pCaps || !szVer)
return NULL;
CJabberClientPartialCaps *pCaps = m_pCaps;
- while ( pCaps ) {
- if ( !_tcscmp( szVer, pCaps->GetVersion()))
+ while (pCaps) {
+ if ( !_tcscmp(szVer, pCaps->GetVersion()))
break;
pCaps = pCaps->GetNext();
}
return pCaps;
}
-CJabberClientPartialCaps* CJabberClientCaps::FindById( int nIqId )
+CJabberClientPartialCaps* CJabberClientCaps::FindById(int nIqId)
{
- if ( !m_pCaps || nIqId == -1 )
+ if ( !m_pCaps || nIqId == -1)
return NULL;
CJabberClientPartialCaps *pCaps = m_pCaps;
- while ( pCaps ) {
- if ( pCaps->GetIqId() == nIqId )
+ while (pCaps) {
+ if (pCaps->GetIqId() == nIqId)
break;
pCaps = pCaps->GetNext();
}
return pCaps;
}
-CJabberClientCaps::CJabberClientCaps( const TCHAR *szNode )
+CJabberClientCaps::CJabberClientCaps(const TCHAR *szNode)
{
- m_szNode = mir_tstrdup( szNode );
+ m_szNode = mir_tstrdup(szNode);
m_pCaps = NULL;
m_pNext= NULL;
}
CJabberClientCaps::~CJabberClientCaps() {
- mir_free( m_szNode );
- if ( m_pCaps )
+ mir_free(m_szNode);
+ if (m_pCaps)
delete m_pCaps;
- if ( m_pNext )
+ if (m_pNext)
delete m_pNext;
}
-CJabberClientCaps* CJabberClientCaps::SetNext( CJabberClientCaps *pClient )
+CJabberClientCaps* CJabberClientCaps::SetNext(CJabberClientCaps *pClient)
{
CJabberClientCaps *pRetVal = m_pNext;
m_pNext = pClient;
return pRetVal;
}
-JabberCapsBits CJabberClientCaps::GetPartialCaps( TCHAR *szVer ) {
- CJabberClientPartialCaps *pCaps = FindByVersion( szVer );
- if ( !pCaps )
+JabberCapsBits CJabberClientCaps::GetPartialCaps(TCHAR *szVer) {
+ CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
+ if ( !pCaps)
return JABBER_RESOURCE_CAPS_UNINIT;
return pCaps->GetCaps();
}
-BOOL CJabberClientCaps::SetPartialCaps( const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/ ) {
- CJabberClientPartialCaps *pCaps = FindByVersion( szVer );
- if ( !pCaps ) {
- pCaps = new CJabberClientPartialCaps( szVer );
- if ( !pCaps )
+BOOL CJabberClientCaps::SetPartialCaps(const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/) {
+ CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
+ if ( !pCaps) {
+ pCaps = new CJabberClientPartialCaps(szVer);
+ if ( !pCaps)
return FALSE;
- pCaps->SetNext( m_pCaps );
+ pCaps->SetNext(m_pCaps);
m_pCaps = pCaps;
}
- if ( !(jcbCaps & JABBER_RESOURCE_CAPS_ERROR) && m_szNode && szVer ) {
- if ( !_tcscmp( m_szNode, _T( "http://miranda-im.org/caps" )) && !_tcscmp( szVer, _T( "0.7.0.13" )))
- jcbCaps = jcbCaps & ( ~JABBER_CAPS_MESSAGE_RECEIPTS );
+ if ( !(jcbCaps & JABBER_RESOURCE_CAPS_ERROR) && m_szNode && szVer) {
+ if ( !_tcscmp(m_szNode, _T("http://miranda-im.org/caps")) && !_tcscmp(szVer, _T("0.7.0.13")))
+ jcbCaps = jcbCaps & (~JABBER_CAPS_MESSAGE_RECEIPTS);
}
- pCaps->SetCaps( jcbCaps, nIqId );
+ pCaps->SetCaps(jcbCaps, nIqId);
return TRUE;
}
-BOOL CJabberClientCaps::SetPartialCaps( int nIqId, JabberCapsBits jcbCaps ) {
- CJabberClientPartialCaps *pCaps = FindById( nIqId );
- if ( !pCaps )
+BOOL CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps) {
+ CJabberClientPartialCaps *pCaps = FindById(nIqId);
+ if ( !pCaps)
return FALSE;
if ( !(jcbCaps & JABBER_RESOURCE_CAPS_ERROR) && m_szNode && pCaps->GetVersion()) {
- if ( !_tcscmp( m_szNode, _T( "http://miranda-im.org/caps" )) && !_tcscmp( pCaps->GetVersion(), _T( "0.7.0.13" )))
- jcbCaps = jcbCaps & ( ~JABBER_CAPS_MESSAGE_RECEIPTS );
+ if ( !_tcscmp(m_szNode, _T("http://miranda-im.org/caps")) && !_tcscmp(pCaps->GetVersion(), _T("0.7.0.13")))
+ jcbCaps = jcbCaps & (~JABBER_CAPS_MESSAGE_RECEIPTS);
}
- pCaps->SetCaps( jcbCaps, -1 );
+ pCaps->SetCaps(jcbCaps, -1);
return TRUE;
}
-CJabberClientCapsManager::CJabberClientCapsManager( CJabberProto* proto )
+CJabberClientCapsManager::CJabberClientCapsManager(CJabberProto* proto)
{
ppro = proto;
- InitializeCriticalSection( &m_cs );
+ InitializeCriticalSection(&m_cs);
m_pClients = NULL;
}
CJabberClientCapsManager::~CJabberClientCapsManager()
{
- if ( m_pClients )
+ if (m_pClients)
delete m_pClients;
- DeleteCriticalSection( &m_cs );
+ DeleteCriticalSection(&m_cs);
}
-CJabberClientCaps * CJabberClientCapsManager::FindClient( const TCHAR *szNode )
+CJabberClientCaps * CJabberClientCapsManager::FindClient(const TCHAR *szNode)
{
- if ( !m_pClients || !szNode )
+ if ( !m_pClients || !szNode)
return NULL;
CJabberClientCaps *pClient = m_pClients;
- while ( pClient ) {
- if ( !_tcscmp( szNode, pClient->GetNode()))
+ while (pClient) {
+ if ( !_tcscmp(szNode, pClient->GetNode()))
break;
pClient = pClient->GetNext();
}
@@ -548,58 +548,58 @@ CJabberClientCaps * CJabberClientCapsManager::FindClient( const TCHAR *szNode ) }
void CJabberClientCapsManager::AddDefaultCaps() {
- SetClientCaps( _T(JABBER_CAPS_MIRANDA_NODE), szCoreVersion, JABBER_CAPS_MIRANDA_ALL );
+ SetClientCaps(_T(JABBER_CAPS_MIRANDA_NODE), szCoreVersion, JABBER_CAPS_MIRANDA_ALL);
- for ( int i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++ )
- SetClientCaps( _T(JABBER_CAPS_MIRANDA_NODE), g_JabberFeatCapPairsExt[i].szFeature, g_JabberFeatCapPairsExt[i].jcbCap );
+ for (int i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++)
+ SetClientCaps(_T(JABBER_CAPS_MIRANDA_NODE), g_JabberFeatCapPairsExt[i].szFeature, g_JabberFeatCapPairsExt[i].jcbCap);
}
-JabberCapsBits CJabberClientCapsManager::GetClientCaps( TCHAR *szNode, TCHAR *szVer )
+JabberCapsBits CJabberClientCapsManager::GetClientCaps(TCHAR *szNode, TCHAR *szVer)
{
Lock();
- CJabberClientCaps *pClient = FindClient( szNode );
- if ( !pClient ) {
+ CJabberClientCaps *pClient = FindClient(szNode);
+ if ( !pClient) {
Unlock();
- ppro->Log( "CAPS: get no caps for: " TCHAR_STR_PARAM ", " TCHAR_STR_PARAM, szNode, szVer );
+ ppro->Log("CAPS: get no caps for: " TCHAR_STR_PARAM ", " TCHAR_STR_PARAM, szNode, szVer);
return JABBER_RESOURCE_CAPS_UNINIT;
}
- JabberCapsBits jcbCaps = pClient->GetPartialCaps( szVer );
+ JabberCapsBits jcbCaps = pClient->GetPartialCaps(szVer);
Unlock();
- ppro->Log( "CAPS: get caps %I64x for: " TCHAR_STR_PARAM ", " TCHAR_STR_PARAM, jcbCaps, szNode, szVer );
+ ppro->Log("CAPS: get caps %I64x for: " TCHAR_STR_PARAM ", " TCHAR_STR_PARAM, jcbCaps, szNode, szVer);
return jcbCaps;
}
-BOOL CJabberClientCapsManager::SetClientCaps( const TCHAR *szNode, const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/ )
+BOOL CJabberClientCapsManager::SetClientCaps(const TCHAR *szNode, const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/)
{
Lock();
- CJabberClientCaps *pClient = FindClient( szNode );
- if (!pClient) {
- pClient = new CJabberClientCaps( szNode );
- if ( !pClient ) {
+ CJabberClientCaps *pClient = FindClient(szNode);
+ if ( !pClient) {
+ pClient = new CJabberClientCaps(szNode);
+ if ( !pClient) {
Unlock();
return FALSE;
}
- pClient->SetNext( m_pClients );
+ pClient->SetNext(m_pClients);
m_pClients = pClient;
}
- BOOL bOk = pClient->SetPartialCaps( szVer, jcbCaps, nIqId );
+ BOOL bOk = pClient->SetPartialCaps(szVer, jcbCaps, nIqId);
Unlock();
- ppro->Log( "CAPS: set caps %I64x for: " TCHAR_STR_PARAM ", " TCHAR_STR_PARAM, jcbCaps, szNode, szVer );
+ ppro->Log("CAPS: set caps %I64x for: " TCHAR_STR_PARAM ", " TCHAR_STR_PARAM, jcbCaps, szNode, szVer);
return bOk;
}
-BOOL CJabberClientCapsManager::SetClientCaps( int nIqId, JabberCapsBits jcbCaps )
+BOOL CJabberClientCapsManager::SetClientCaps(int nIqId, JabberCapsBits jcbCaps)
{
Lock();
- if ( !m_pClients ) {
+ if ( !m_pClients) {
Unlock();
return FALSE;
}
BOOL bOk = FALSE;
CJabberClientCaps *pClient = m_pClients;
- while ( pClient ) {
- if ( pClient->SetPartialCaps( nIqId, jcbCaps )) {
- ppro->Log( "CAPS: set caps %I64x for iq %d", jcbCaps, nIqId );
+ while (pClient) {
+ if (pClient->SetPartialCaps(nIqId, jcbCaps)) {
+ ppro->Log("CAPS: set caps %I64x for iq %d", jcbCaps, nIqId);
bOk = TRUE;
break;
}
@@ -609,89 +609,89 @@ BOOL CJabberClientCapsManager::SetClientCaps( int nIqId, JabberCapsBits jcbCaps return bOk;
}
-BOOL CJabberClientCapsManager::HandleInfoRequest( HXML, CJabberIqInfo* pInfo, const TCHAR* szNode )
+BOOL CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo* pInfo, const TCHAR *szNode)
{
int i;
JabberCapsBits jcb = 0;
- if ( szNode ) {
- for ( i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++ ) {
+ if (szNode) {
+ for (i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++) {
TCHAR szExtCap[ 512 ];
- mir_sntprintf( szExtCap, SIZEOF(szExtCap), _T("%s#%s"), _T(JABBER_CAPS_MIRANDA_NODE), g_JabberFeatCapPairsExt[i].szFeature );
- if ( !_tcscmp( szNode, szExtCap )) {
+ mir_sntprintf(szExtCap, SIZEOF(szExtCap), _T("%s#%s"), _T(JABBER_CAPS_MIRANDA_NODE), g_JabberFeatCapPairsExt[i].szFeature);
+ if ( !_tcscmp(szNode, szExtCap)) {
jcb = g_JabberFeatCapPairsExt[i].jcbCap;
break;
}
}
// check features registered through IJabberNetInterface::RegisterFeature() and IJabberNetInterface::AddFeatures()
- for ( i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++ ) {
+ for (i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
TCHAR szExtCap[ 512 ];
- mir_sntprintf( szExtCap, SIZEOF(szExtCap), _T("%s#%s"), _T(JABBER_CAPS_MIRANDA_NODE), ppro->m_lstJabberFeatCapPairsDynamic[i]->szExt );
- if ( !_tcscmp( szNode, szExtCap )) {
+ mir_sntprintf(szExtCap, SIZEOF(szExtCap), _T("%s#%s"), _T(JABBER_CAPS_MIRANDA_NODE), ppro->m_lstJabberFeatCapPairsDynamic[i]->szExt);
+ if ( !_tcscmp(szNode, szExtCap)) {
jcb = ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
break;
}
}
// unknown node, not XEP-0115 request
- if ( !jcb )
+ if ( !jcb)
return FALSE;
}
else {
jcb = JABBER_CAPS_MIRANDA_ALL;
- for ( i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++ )
+ for (i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
jcb |= ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
}
- if (!ppro->m_options.AllowVersionRequests)
+ if ( !ppro->m_options.AllowVersionRequests)
jcb &= ~JABBER_CAPS_VERSION;
- XmlNodeIq iq( _T("result"), pInfo );
+ XmlNodeIq iq(_T("result"), pInfo);
- HXML query = iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO));
- if ( szNode )
- query << XATTR( _T("node"), szNode );
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ if (szNode)
+ query << XATTR(_T("node"), szNode);
- query << XCHILD( _T("identity")) << XATTR( _T("category"), _T("client"))
- << XATTR( _T("type"), _T("pc")) << XATTR( _T("name"), _T("Miranda"));
+ query << XCHILD(_T("identity")) << XATTR(_T("category"), _T("client"))
+ << XATTR(_T("type"), _T("pc")) << XATTR(_T("name"), _T("Miranda"));
- for ( i = 0; g_JabberFeatCapPairs[i].szFeature; i++ )
- if ( jcb & g_JabberFeatCapPairs[i].jcbCap )
- query << XCHILD( _T("feature")) << XATTR( _T("var"), g_JabberFeatCapPairs[i].szFeature );
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++)
+ if (jcb & g_JabberFeatCapPairs[i].jcbCap)
+ query << XCHILD(_T("feature")) << XATTR(_T("var"), g_JabberFeatCapPairs[i].szFeature);
- for ( i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++ )
- if ( jcb & ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap )
- query << XCHILD( _T("feature")) << XATTR( _T("var"), ppro->m_lstJabberFeatCapPairsDynamic[i]->szFeature );
+ for (i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
+ if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap)
+ query << XCHILD(_T("feature")) << XATTR(_T("var"), ppro->m_lstJabberFeatCapPairsDynamic[i]->szFeature);
- if ( ppro->m_options.AllowVersionRequests && !szNode ) {
+ if (ppro->m_options.AllowVersionRequests && !szNode) {
TCHAR szOsBuffer[256] = {0};
TCHAR *os = szOsBuffer;
- if ( ppro->m_options.ShowOSVersion ) {
- if (!GetOSDisplayString(szOsBuffer, SIZEOF(szOsBuffer)))
+ if (ppro->m_options.ShowOSVersion) {
+ if ( !GetOSDisplayString(szOsBuffer, SIZEOF(szOsBuffer)))
lstrcpyn(szOsBuffer, _T(""), SIZEOF(szOsBuffer));
else {
TCHAR *szOsWindows = _T("Microsoft Windows");
- size_t nOsWindowsLength = _tcslen( szOsWindows );
- if (!_tcsnicmp(szOsBuffer, szOsWindows, nOsWindowsLength))
+ size_t nOsWindowsLength = _tcslen(szOsWindows);
+ if ( !_tcsnicmp(szOsBuffer, szOsWindows, nOsWindowsLength))
os += nOsWindowsLength + 1;
}
}
- HXML form = query << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("result"));
- form << XCHILD( _T("field")) << XATTR( _T("var"), _T("FORM_TYPE")) << XATTR( _T("type"), _T("hidden"))
- << XCHILD( _T("value"), _T("urn:xmpp:dataforms:softwareinfo"));
+ HXML form = query << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("result"));
+ form << XCHILD(_T("field")) << XATTR(_T("var"), _T("FORM_TYPE")) << XATTR(_T("type"), _T("hidden"))
+ << XCHILD(_T("value"), _T("urn:xmpp:dataforms:softwareinfo"));
- if ( ppro->m_options.ShowOSVersion ) {
- form << XCHILD( _T("field")) << XATTR( _T("var"), _T("os")) << XCHILD( _T("value"), _T("Microsoft Windows"));
- form << XCHILD( _T("field")) << XATTR( _T("var"), _T("os_version")) << XCHILD( _T("value"), os );
+ if (ppro->m_options.ShowOSVersion) {
+ form << XCHILD(_T("field")) << XATTR(_T("var"), _T("os")) << XCHILD(_T("value"), _T("Microsoft Windows"));
+ form << XCHILD(_T("field")) << XATTR(_T("var"), _T("os_version")) << XCHILD(_T("value"), os);
}
- form << XCHILD( _T("field")) << XATTR( _T("var"), _T("software")) << XCHILD( _T("value"), _T("Miranda NG Jabber Protocol"));
- form << XCHILD( _T("field")) << XATTR( _T("var"), _T("software_version")) << XCHILD( _T("value"), szCoreVersion);
+ form << XCHILD(_T("field")) << XATTR(_T("var"), _T("software")) << XCHILD(_T("value"), _T("Miranda NG Jabber Protocol"));
+ form << XCHILD(_T("field")) << XATTR(_T("var"), _T("software_version")) << XCHILD(_T("value"), szCoreVersion);
}
- ppro->m_ThreadInfo->send( iq );
+ ppro->m_ThreadInfo->send(iq);
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index e0525f2a16..d9597590fe 100644 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -185,15 +185,15 @@ protected: DWORD m_dwRequestTime;
public:
- CJabberClientPartialCaps( const TCHAR *szVer );
+ CJabberClientPartialCaps(const TCHAR *szVer);
~CJabberClientPartialCaps();
- CJabberClientPartialCaps* SetNext( CJabberClientPartialCaps *pCaps );
+ CJabberClientPartialCaps* SetNext(CJabberClientPartialCaps *pCaps);
__inline CJabberClientPartialCaps* GetNext()
{ return m_pNext;
}
- void SetCaps( JabberCapsBits jcbCaps, int nIqId = -1 );
+ void SetCaps(JabberCapsBits jcbCaps, int nIqId = -1);
JabberCapsBits GetCaps();
__inline TCHAR* GetVersion()
@@ -214,21 +214,21 @@ protected: CJabberClientCaps *m_pNext;
protected:
- CJabberClientPartialCaps* FindByVersion( const TCHAR *szVer );
- CJabberClientPartialCaps* FindById( int nIqId );
+ CJabberClientPartialCaps* FindByVersion(const TCHAR *szVer);
+ CJabberClientPartialCaps* FindById(int nIqId);
public:
- CJabberClientCaps( const TCHAR *szNode );
+ CJabberClientCaps(const TCHAR *szNode);
~CJabberClientCaps();
- CJabberClientCaps* SetNext( CJabberClientCaps *pClient );
+ CJabberClientCaps* SetNext(CJabberClientCaps *pClient);
__inline CJabberClientCaps* GetNext()
{ return m_pNext;
}
- JabberCapsBits GetPartialCaps( TCHAR *szVer );
- BOOL SetPartialCaps( const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId = -1 );
- BOOL SetPartialCaps( int nIqId, JabberCapsBits jcbCaps );
+ JabberCapsBits GetPartialCaps(TCHAR *szVer);
+ BOOL SetPartialCaps(const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
+ BOOL SetPartialCaps(int nIqId, JabberCapsBits jcbCaps);
__inline TCHAR* GetNode()
{ return m_szNode;
@@ -244,26 +244,26 @@ protected: CJabberProto* ppro;
protected:
- CJabberClientCaps *FindClient( const TCHAR *szNode );
+ CJabberClientCaps *FindClient(const TCHAR *szNode);
public:
- CJabberClientCapsManager( CJabberProto* proto );
+ CJabberClientCapsManager(CJabberProto* proto);
~CJabberClientCapsManager();
__inline void Lock()
- { EnterCriticalSection( &m_cs );
+ { EnterCriticalSection(&m_cs);
}
__inline void Unlock()
- { LeaveCriticalSection( &m_cs );
+ { LeaveCriticalSection(&m_cs);
}
void AddDefaultCaps();
- JabberCapsBits GetClientCaps( TCHAR *szNode, TCHAR *szVer );
- BOOL SetClientCaps( const TCHAR *szNode, const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId = -1 );
- BOOL SetClientCaps( int nIqId, JabberCapsBits jcbCaps );
+ JabberCapsBits GetClientCaps(TCHAR *szNode, TCHAR *szVer);
+ BOOL SetClientCaps(const TCHAR *szNode, const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
+ BOOL SetClientCaps(int nIqId, JabberCapsBits jcbCaps);
- BOOL HandleInfoRequest( HXML iqNode, CJabberIqInfo* pInfo, const TCHAR* szNode );
+ BOOL HandleInfoRequest(HXML iqNode, CJabberIqInfo* pInfo, const TCHAR *szNode);
};
struct JabberFeatCapPair
diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp index 88d3038ab7..0f56ba9894 100644 --- a/protocols/JabberG/src/jabber_captcha.cpp +++ b/protocols/JabberG/src/jabber_captcha.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -36,26 +36,26 @@ struct CAPTCHA_FORM_PARAMS TCHAR Result[MAX_PATH];
};
-INT_PTR CALLBACK JabberCaptchaFormDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+INT_PTR CALLBACK JabberCaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- CAPTCHA_FORM_PARAMS *params = (CAPTCHA_FORM_PARAMS*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CAPTCHA_FORM_PARAMS *params = (CAPTCHA_FORM_PARAMS*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG: {
- TranslateDialogDefault( hwndDlg );
- SendMessage( hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIconBig(IDI_KEYS));
- SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(IDI_KEYS));
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIconBig(IDI_KEYS));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(IDI_KEYS));
params = (CAPTCHA_FORM_PARAMS*)lParam;
LPCTSTR hint = params->hint;
- if ( hint == NULL )
+ if (hint == NULL)
hint = TranslateT("Enter the text you see");
- SetDlgItemText( hwndDlg, IDC_INSTRUCTION, TranslateTS( hint ));
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG )params );
+ SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateTS(hint));
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)params);
return TRUE;
}
case WM_CTLCOLORSTATIC:
- switch( GetWindowLongPtr((HWND)lParam, GWL_ID)) {
+ switch(GetWindowLongPtr((HWND)lParam, GWL_ID)) {
case IDC_WHITERECT:
case IDC_INSTRUCTION:
case IDC_TITLE:
@@ -64,93 +64,93 @@ INT_PTR CALLBACK JabberCaptchaFormDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam return NULL;
case WM_PAINT:
- if ( params ) {
+ if (params) {
PAINTSTRUCT ps;
HDC hdc, hdcMem;
RECT rc;
- GetClientRect( hwndDlg, &rc );
- hdc = BeginPaint( hwndDlg, &ps );
- hdcMem = CreateCompatibleDC( hdc );
- HGDIOBJ hOld = SelectObject( hdcMem, params->bmp );
+ GetClientRect(hwndDlg, &rc);
+ hdc = BeginPaint(hwndDlg, &ps);
+ hdcMem = CreateCompatibleDC(hdc);
+ HGDIOBJ hOld = SelectObject(hdcMem, params->bmp);
- int y = ( rc.bottom + rc.top - params->h ) / 2;
- int x = ( rc.right + rc.left - params->w ) / 2;
- BitBlt( hdc, x, y, params->w, params->h, hdcMem, 0,0, SRCCOPY );
- SelectObject( hdcMem, hOld );
- DeleteDC( hdcMem );
+ int y = (rc.bottom + rc.top - params->h) / 2;
+ int x = (rc.right + rc.left - params->w) / 2;
+ BitBlt(hdc, x, y, params->w, params->h, hdcMem, 0,0, SRCCOPY);
+ SelectObject(hdcMem, hOld);
+ DeleteDC(hdcMem);
- EndPaint( hwndDlg, &ps );
+ EndPaint(hwndDlg, &ps);
}
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
- EndDialog( hwndDlg, 0 );
+ EndDialog(hwndDlg, 0);
return TRUE;
case IDC_SUBMIT:
- GetDlgItemText( hwndDlg, IDC_VALUE, params->Result, SIZEOF(params->Result));
- EndDialog( hwndDlg, 1 );
+ GetDlgItemText(hwndDlg, IDC_VALUE, params->Result, SIZEOF(params->Result));
+ EndDialog(hwndDlg, 1);
return TRUE;
}
break;
case WM_CLOSE:
- EndDialog( hwndDlg, 0 );
+ EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
- WindowFreeIcon( hwndDlg );
+ WindowFreeIcon(hwndDlg);
break;
}
return FALSE;
}
-bool CJabberProto::ProcessCaptcha (HXML node, HXML parentNode, ThreadData* info ) {
+bool CJabberProto::ProcessCaptcha (HXML node, HXML parentNode, ThreadData* info) {
CAPTCHA_FORM_PARAMS param;
char *ImageBuf = 0;
const TCHAR *PicType = 0;
TCHAR *CaptchaPath = 0;
- HXML x = xmlGetChildByTag( node, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
- if ( x == NULL )
+ HXML x = xmlGetChildByTag(node, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if (x == NULL)
return false;
HXML y = xmlGetChildByTag(x, _T("field"), _T("var"), _T("from"));
- if ( y == NULL )
+ if (y == NULL)
return false;
- if (( y = xmlGetChild( y, "value" )) == NULL )
+ if ((y = xmlGetChild(y, "value")) == NULL)
return false;
- param.fromjid = xmlGetText( y );
+ param.fromjid = xmlGetText(y);
- if (( y = xmlGetChildByTag(x, _T("field"), _T("var"), _T("sid"))) == NULL )
+ if ((y = xmlGetChildByTag(x, _T("field"), _T("var"), _T("sid"))) == NULL)
return false;
- if (( y = xmlGetChild( y, "value" )) == NULL )
+ if ((y = xmlGetChild(y, "value")) == NULL)
return false;
- param.sid = xmlGetText( y );
+ param.sid = xmlGetText(y);
- if (( y = xmlGetChildByTag(x, _T("field"), _T("var"), _T("ocr"))) == NULL )
+ if ((y = xmlGetChildByTag(x, _T("field"), _T("var"), _T("ocr"))) == NULL)
return false;
param.hint = xmlGetAttrValue (y, _T("label"));
- param.from = xmlGetAttrValue( parentNode, _T("from"));
- param.to = xmlGetAttrValue( parentNode, _T("to"));
- param.challenge = xmlGetAttrValue( parentNode, _T("id"));
- HXML o = xmlGetChild( parentNode, "data" );
- if ( o == NULL || xmlGetText( o ) == NULL )
+ param.from = xmlGetAttrValue(parentNode, _T("from"));
+ param.to = xmlGetAttrValue(parentNode, _T("to"));
+ param.challenge = xmlGetAttrValue(parentNode, _T("id"));
+ HXML o = xmlGetChild(parentNode, "data");
+ if (o == NULL || xmlGetText(o) == NULL)
return false;
GetCaptchaImage(parentNode, ImageBuf, PicType, CaptchaPath);
- char* p = mir_t2a( CaptchaPath );
- param.bmp = ( HBITMAP ) CallService( MS_UTILS_LOADBITMAP, 0, ( LPARAM )p );
+ char* p = mir_t2a(CaptchaPath);
+ param.bmp = (HBITMAP) CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)p);
DeleteFile(CaptchaPath);
mir_free(CaptchaPath);
mir_free(p);
BITMAP bmp = {0};
- GetObject( param.bmp, sizeof(bmp), &bmp );
+ GetObject(param.bmp, sizeof(bmp), &bmp);
param.w = bmp.bmWidth;
param.h = bmp.bmHeight;
int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CAPTCHAFORM), NULL, JabberCaptchaFormDlgProc, (LPARAM)¶m);
@@ -161,18 +161,18 @@ bool CJabberProto::ProcessCaptcha (HXML node, HXML parentNode, ThreadData* info return true;
}
-void CJabberProto::GetCaptchaImage ( HXML node, char *ImageBuf, const TCHAR *PicType, TCHAR*& CaptchaPath ) {
- HXML o = xmlGetChild( node , "data" );
+void CJabberProto::GetCaptchaImage (HXML node, char *ImageBuf, const TCHAR *PicType, TCHAR*& CaptchaPath) {
+ HXML o = xmlGetChild(node , "data");
int bufferLen;
- char* buffer = JabberBase64DecodeT(xmlGetText( o ), &bufferLen );
- if ( buffer == NULL )
+ char* buffer = JabberBase64DecodeT(xmlGetText(o), &bufferLen);
+ if (buffer == NULL)
return;
- const TCHAR* szPicType;
- HXML m = xmlGetChild( node , "TYPE" );
- if ( m == NULL || xmlGetText( m ) == NULL ) {
+ const TCHAR *szPicType;
+ HXML m = xmlGetChild(node , "TYPE");
+ if (m == NULL || xmlGetText(m) == NULL) {
LBL_NoTypeSpecified:
- switch( JabberGetPictureType( buffer )) {
+ switch(JabberGetPictureType(buffer)) {
case PA_FORMAT_GIF: szPicType = _T("image/gif"); break;
case PA_FORMAT_BMP: szPicType = _T("image/bmp"); break;
case PA_FORMAT_PNG: szPicType = _T("image/png"); break;
@@ -182,11 +182,11 @@ void CJabberProto::GetCaptchaImage ( HXML node, char *ImageBuf, const TCHAR *Pic }
}
else {
- const TCHAR* tszType = xmlGetText( m );
- if ( !_tcscmp( tszType, _T("image/jpeg")) ||
- !_tcscmp( tszType, _T("image/png")) ||
- !_tcscmp( tszType, _T("image/gif")) ||
- !_tcscmp( tszType, _T("image/bmp")))
+ const TCHAR *tszType = xmlGetText(m);
+ if ( !_tcscmp(tszType, _T("image/jpeg")) ||
+ !_tcscmp(tszType, _T("image/png")) ||
+ !_tcscmp(tszType, _T("image/gif")) ||
+ !_tcscmp(tszType, _T("image/bmp")))
szPicType = tszType;
else
goto LBL_NoTypeSpecified;
@@ -199,22 +199,22 @@ LBL_Ret: TCHAR filename[MAX_PATH];
mir_sntprintf(filename, SIZEOF(filename), _T("%%TEMP%%\\captcha.%s"), ext);
CaptchaPath = Utils_ReplaceVarsT(filename);
- HANDLE hFile = CreateFile( CaptchaPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
- if ( hFile == INVALID_HANDLE_VALUE )
+ HANDLE hFile = CreateFile(CaptchaPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
goto LBL_Ret;
- if ( !WriteFile( hFile, buffer, bufferLen, &nWritten, NULL ))
+ if ( !WriteFile(hFile, buffer, bufferLen, &nWritten, NULL))
goto LBL_Ret;
- CloseHandle( hFile );
+ CloseHandle(hFile);
ImageBuf = buffer;
PicType = szPicType;
}
void CJabberProto::sendCaptchaResult(TCHAR* buf, ThreadData* info, LPCTSTR from, LPCTSTR challenge, LPCTSTR fromjid, LPCTSTR sid){
- XmlNodeIq iq( _T("set"), SerialNext());
- HXML query= iq <<XATTR(_T("to"), from) << XCHILD(_T("captcha")) << XATTR( _T("xmlns"), _T("urn:xmpp:captcha")) << XCHILD (_T("x")) << XATTR(_T("xmlns"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("submit"));
+ XmlNodeIq iq(_T("set"), SerialNext());
+ HXML query= iq <<XATTR(_T("to"), from) << XCHILD(_T("captcha")) << XATTR(_T("xmlns"), _T("urn:xmpp:captcha")) << XCHILD (_T("x")) << XATTR(_T("xmlns"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("submit"));
query << XCHILD(_T("field")) << XATTR (_T("var"), _T("FORM_TYPE")) << XCHILD(_T("value"), _T("urn:xmpp:captcha"));
query << XCHILD(_T("field")) << XATTR (_T("var"), _T("from")) << XCHILD(_T("value"), fromjid);
query << XCHILD(_T("field")) << XATTR (_T("var"), _T("challenge")) << XCHILD(_T("value"), challenge);
@@ -223,8 +223,8 @@ void CJabberProto::sendCaptchaResult(TCHAR* buf, ThreadData* info, LPCTSTR from, info -> send (iq);
}
-void CJabberProto::sendCaptchaError(ThreadData* info, LPCTSTR from, LPCTSTR to, LPCTSTR challenge ) {
- XmlNode message( _T("message"));
+void CJabberProto::sendCaptchaError(ThreadData* info, LPCTSTR from, LPCTSTR to, LPCTSTR challenge) {
+ XmlNode message(_T("message"));
HXML query= message << XATTR(_T("type"), _T("error")) << XATTR(_T("to"), from) << XATTR(_T("id"), challenge) << XATTR(_T("from"), to)
<< XCHILD(_T("error")) << XATTR(_T("type"), _T("modify"))
<< XCHILD(_T("not-acceptable")) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 8dacc24619..6db767c192 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.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
@@ -99,7 +99,7 @@ static TRoleOrAffiliationInfo sttRoleItems[] = /////////////////////////////////////////////////////////////////////////////////////////
// JabberGcInit - initializes the new chat
-static const TCHAR* sttStatuses[] = { _T("Visitors"), _T("Participants"), _T("Moderators"), _T("Owners") };
+static const TCHAR *sttStatuses[] = { _T("Visitors"), _T("Participants"), _T("Moderators"), _T("Owners") };
int JabberGcGetStatus(JABBER_GC_AFFILIATION a, JABBER_GC_ROLE r)
{
@@ -120,10 +120,10 @@ int JabberGcGetStatus(JABBER_RESOURCE_STATUS *r) return JabberGcGetStatus(r->affiliation, r->role);
}
-int CJabberProto::JabberGcInit( WPARAM wParam, LPARAM )
+int CJabberProto::JabberGcInit(WPARAM wParam, LPARAM)
{
int i;
- JABBER_LIST_ITEM* item = ( JABBER_LIST_ITEM* )wParam;
+ JABBER_LIST_ITEM* item = (JABBER_LIST_ITEM*)wParam;
GCSESSION gcw = {0};
GCEVENT gce = {0};
@@ -131,45 +131,45 @@ int CJabberProto::JabberGcInit( WPARAM wParam, LPARAM ) for (i = 0; i < SIZEOF(sttAffiliationItems); ++i) sttAffiliationItems[i].translate();
for (i = 0; i < SIZEOF(sttRoleItems); ++i) sttRoleItems[i].translate();
- TCHAR* szNick = JabberNickFromJID( item->jid );
+ TCHAR* szNick = JabberNickFromJID(item->jid);
gcw.cbSize = sizeof(GCSESSION);
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.ptszName = szNick;
gcw.ptszID = item->jid;
gcw.dwFlags = GC_TCHAR;
- CallServiceSync( MS_GC_NEWSESSION, NULL, (LPARAM)&gcw );
+ CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw);
- HANDLE hContact = HContactFromJID( item->jid );
- if ( hContact != NULL ) {
+ HANDLE hContact = HContactFromJID(item->jid);
+ if (hContact != NULL) {
DBVARIANT dbv;
- if ( JABBER_LIST_ITEM* bookmark = ListGetItemPtr( LIST_BOOKMARK, item->jid ))
- if ( bookmark->name ) {
- if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbv ))
- JFreeVariant( &dbv );
+ if (JABBER_LIST_ITEM* bookmark = ListGetItemPtr(LIST_BOOKMARK, item->jid))
+ if (bookmark->name) {
+ if ( !DBGetContactSettingTString(hContact, "CList", "MyHandle", &dbv))
+ db_free(&dbv);
else
- DBWriteContactSettingTString( hContact, "CList", "MyHandle", bookmark->name );
+ db_set_ts(hContact, "CList", "MyHandle", bookmark->name);
}
- if ( !JGetStringT( hContact, "MyNick", &dbv )) {
- if ( !lstrcmp( dbv.ptszVal, szNick ))
- JDeleteSetting( hContact, "MyNick" );
+ if ( !JGetStringT(hContact, "MyNick", &dbv)) {
+ if ( !lstrcmp(dbv.ptszVal, szNick))
+ JDeleteSetting(hContact, "MyNick");
else
- JSetStringT( hContact, "MyNick", item->nick );
- JFreeVariant( &dbv );
+ JSetStringT(hContact, "MyNick", item->nick);
+ db_free(&dbv);
}
- else JSetStringT( hContact, "MyNick", item->nick );
+ else JSetStringT(hContact, "MyNick", item->nick);
- TCHAR *passw = JGetStringCrypt( hContact, "LoginPassword" );
- if ( lstrcmp_null( passw, item->password )) {
- if ( !item->password || !item->password[0] )
- JDeleteSetting( hContact, "LoginPassword" );
+ TCHAR *passw = JGetStringCrypt(hContact, "LoginPassword");
+ if (lstrcmp_null(passw, item->password)) {
+ if ( !item->password || !item->password[0])
+ JDeleteSetting(hContact, "LoginPassword");
else
- JSetStringCrypt( hContact, "LoginPassword", item->password );
+ JSetStringCrypt(hContact, "LoginPassword", item->password);
}
mir_free(passw);
}
- mir_free( szNick );
+ mir_free(szNick);
item->bChatActive = TRUE;
@@ -178,30 +178,30 @@ int CJabberProto::JabberGcInit( WPARAM wParam, LPARAM ) gce.cbSize = sizeof(GCEVENT);
gce.pDest = &gcd;
gce.dwFlags = GC_TCHAR;
- for (i = SIZEOF(sttStatuses)-1; i >= 0; i-- ) {
- gce.ptszStatus = TranslateTS( sttStatuses[i] );
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ for (i = SIZEOF(sttStatuses)-1; i >= 0; i--) {
+ gce.ptszStatus = TranslateTS(sttStatuses[i]);
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
gce.cbSize = sizeof(GCEVENT);
gce.pDest = &gcd;
gcd.iType = GC_EVENT_CONTROL;
- CallServiceSync( MS_GC_EVENT, (item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE, (LPARAM)&gce );
- CallServiceSync( MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce );
+ CallServiceSync(MS_GC_EVENT, (item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
return 0;
}
-void CJabberProto::GcLogCreate( JABBER_LIST_ITEM* item )
+void CJabberProto::GcLogCreate(JABBER_LIST_ITEM* item)
{
- if ( item->bChatActive )
+ if (item->bChatActive)
return;
- NotifyEventHooks( m_hInitChat, (WPARAM)item, 0 );
+ NotifyEventHooks(m_hInitChat, (WPARAM)item, 0);
}
-void CJabberProto::GcLogShowInformation( JABBER_LIST_ITEM *item, JABBER_RESOURCE_STATUS *user, TJabberGcLogInfoType type )
+void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, JABBER_RESOURCE_STATUS *user, TJabberGcLogInfoType type)
{
- if (!item || !user || (item->bChatActive != 2)) return;
+ if ( !item || !user || (item->bChatActive != 2)) return;
TCHAR buf[512] = _T("");
@@ -275,34 +275,34 @@ void CJabberProto::GcLogShowInformation( JABBER_LIST_ITEM *item, JABBER_RESOURCE gce.cbSize = sizeof(GCEVENT);
gce.ptszNick = user->resourceName;
gce.ptszUID = user->resourceName;
- gce.ptszText = EscapeChatTags( buf );
+ gce.ptszText = EscapeChatTags(buf);
gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
gce.pDest = &gcd;
gce.time = time(0);
gcd.iType = GC_EVENT_INFORMATION;
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
- mir_free( (void*)gce.ptszText ); // Since we processed msgText and created a new string
+ mir_free((void*)gce.ptszText); // Since we processed msgText and created a new string
}
}
-void CJabberProto::GcLogUpdateMemberStatus( JABBER_LIST_ITEM* item, const TCHAR* resource, const TCHAR* nick, const TCHAR* jid, int action, HXML reason, int nStatusCode )
+void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM* item, const TCHAR *resource, const TCHAR *nick, const TCHAR *jid, int action, HXML reason, int nStatusCode)
{
int statusToSet = 0;
- const TCHAR* szReason = NULL;
- if ( reason != NULL && xmlGetText( reason ) != NULL )
- szReason = xmlGetText( reason );
-
- if ( !szReason ) {
- if ( nStatusCode == 322 )
- szReason = TranslateT( "because room is now members-only" );
- else if ( nStatusCode == 301 )
- szReason = TranslateT( "user banned" );
+ const TCHAR *szReason = NULL;
+ if (reason != NULL && xmlGetText(reason) != NULL)
+ szReason = xmlGetText(reason);
+
+ if ( !szReason) {
+ if (nStatusCode == 322)
+ szReason = TranslateT("because room is now members-only");
+ else if (nStatusCode == 301)
+ szReason = TranslateT("user banned");
}
- TCHAR* myNick = (item->nick == NULL) ? NULL : mir_tstrdup( item->nick );
- if ( myNick == NULL )
- myNick = JabberNickFromJID( m_szJabberJID );
+ TCHAR* myNick = (item->nick == NULL) ? NULL : mir_tstrdup(item->nick);
+ if (myNick == NULL)
+ myNick = JabberNickFromJID(m_szJabberJID);
GCDEST gcd = { m_szModuleName, 0, 0 };
gcd.ptszID = item->jid;
@@ -315,62 +315,62 @@ void CJabberProto::GcLogUpdateMemberStatus( JABBER_LIST_ITEM* item, const TCHAR* gce.ptszText = szReason;
gce.dwFlags = GC_TCHAR;
gce.pDest = &gcd;
- if ( item->bChatActive == 2 ) {
+ if (item->bChatActive == 2) {
gce.dwFlags |= GCEF_ADDTOLOG;
gce.time = time(0);
}
- switch( gcd.iType = action ) {
+ switch(gcd.iType = action) {
case GC_EVENT_PART: break;
case GC_EVENT_KICK:
- gce.ptszStatus = TranslateT( "Moderator" );
+ gce.ptszStatus = TranslateT("Moderator");
break;
default:
- for ( int i=0; i < item->resourceCount; i++ ) {
+ for (int i=0; i < item->resourceCount; i++) {
JABBER_RESOURCE_STATUS& JS = item->resource[i];
- if ( !lstrcmp( resource, JS.resourceName )) {
- if ( action != GC_EVENT_JOIN ) {
- switch( action ) {
+ if ( !lstrcmp(resource, JS.resourceName)) {
+ if (action != GC_EVENT_JOIN) {
+ switch(action) {
case 0:
gcd.iType = GC_EVENT_ADDSTATUS;
case GC_EVENT_REMOVESTATUS:
gce.dwFlags &= ~GCEF_ADDTOLOG;
}
- gce.ptszText = TranslateT( "Moderator" );
+ gce.ptszText = TranslateT("Moderator");
}
- gce.ptszStatus = TranslateTS( sttStatuses[JabberGcGetStatus(&JS)] );
- gce.bIsMe = ( lstrcmp( nick, myNick ) == 0 );
+ gce.ptszStatus = TranslateTS(sttStatuses[JabberGcGetStatus(&JS)]);
+ gce.bIsMe = (lstrcmp(nick, myNick) == 0);
statusToSet = JS.status;
break;
} } }
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
- if ( statusToSet != 0 ) {
+ if (statusToSet != 0) {
gce.ptszText = nick;
- if ( statusToSet == ID_STATUS_AWAY || statusToSet == ID_STATUS_NA || statusToSet == ID_STATUS_DND )
+ if (statusToSet == ID_STATUS_AWAY || statusToSet == ID_STATUS_NA || statusToSet == ID_STATUS_DND)
gce.dwItemData = 3;
else
gce.dwItemData = 1;
gcd.iType = GC_EVENT_SETSTATUSEX;
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
gce.ptszUID = resource;
gce.dwItemData = statusToSet;
gcd.iType = GC_EVENT_SETCONTACTSTATUS;
- CallServiceSync( MS_GC_EVENT, NULL, ( LPARAM )&gce );
+ CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
- mir_free( myNick );
+ mir_free(myNick);
}
-void CJabberProto::GcQuit( JABBER_LIST_ITEM* item, int code, HXML reason )
+void CJabberProto::GcQuit(JABBER_LIST_ITEM* item, int code, HXML reason)
{
TCHAR *szMessage = NULL;
- const TCHAR* szReason = NULL;
- if ( reason != NULL && xmlGetText( reason ) != NULL )
- szReason = xmlGetText( reason );
+ const TCHAR *szReason = NULL;
+ if (reason != NULL && xmlGetText(reason) != NULL)
+ szReason = xmlGetText(reason);
GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
gcd.ptszID = item->jid;
@@ -381,36 +381,36 @@ void CJabberProto::GcQuit( JABBER_LIST_ITEM* item, int code, HXML reason ) gce.dwFlags = GC_TCHAR;
gce.pDest = &gcd;
- if ( code != 307 && code != 301 ) {
- CallServiceSync( MS_GC_EVENT, SESSION_TERMINATE, ( LPARAM )&gce );
- CallServiceSync( MS_GC_EVENT, WINDOW_CLEARLOG, ( LPARAM )&gce );
+ if (code != 307 && code != 301) {
+ CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, (LPARAM)&gce);
DBVARIANT dbvMessage;
- if (!DBGetContactSettingTString( NULL, m_szModuleName, "GcMsgQuit", &dbvMessage)) {
+ if ( !DBGetContactSettingTString(NULL, m_szModuleName, "GcMsgQuit", &dbvMessage)) {
szMessage = NEWTSTR_ALLOCA(dbvMessage.ptszVal);
DBFreeVariant(&dbvMessage);
}
else szMessage = TranslateTS(JABBER_GC_MSG_QUIT);
}
else {
- TCHAR* myNick = JabberNickFromJID( m_szJabberJID );
- GcLogUpdateMemberStatus( item, myNick, myNick, NULL, GC_EVENT_KICK, reason );
- mir_free( myNick );
- CallServiceSync( MS_GC_EVENT, SESSION_OFFLINE, ( LPARAM )&gce );
+ TCHAR* myNick = JabberNickFromJID(m_szJabberJID);
+ GcLogUpdateMemberStatus(item, myNick, myNick, NULL, GC_EVENT_KICK, reason);
+ mir_free(myNick);
+ CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
}
- DBDeleteContactSetting( HContactFromJID( item->jid ), "CList", "Hidden" );
+ DBDeleteContactSetting(HContactFromJID(item->jid), "CList", "Hidden");
item->bChatActive = FALSE;
- if ( m_bJabberOnline ) {
+ if (m_bJabberOnline) {
TCHAR szPresenceTo[ JABBER_MAX_JID_LEN ];
- mir_sntprintf( szPresenceTo, SIZEOF( szPresenceTo ), _T("%s/%s"), item->jid, item->nick );
+ mir_sntprintf(szPresenceTo, SIZEOF(szPresenceTo), _T("%s/%s"), item->jid, item->nick);
m_ThreadInfo->send(
- XmlNode( _T("presence")) << XATTR( _T("to"), szPresenceTo ) << XATTR( _T("type"), _T("unavailable"))
- << XCHILD( _T("status"), szMessage));
+ XmlNode(_T("presence")) << XATTR(_T("to"), szPresenceTo) << XATTR(_T("type"), _T("unavailable"))
+ << XCHILD(_T("status"), szMessage));
- ListRemove( LIST_CHATROOM, item->jid );
+ ListRemove(LIST_CHATROOM, item->jid);
} }
/////////////////////////////////////////////////////////////////////////////////////////
@@ -427,26 +427,26 @@ static struct gc_item *sttFindGcMenuItem(GCMENUITEMS *items, DWORD id) static void sttSetupGcMenuItem(GCMENUITEMS *items, DWORD id, bool disabled)
{
for (int i = 0; i < items->nItems; ++i)
- if (!id || (items->Item[i].dwID == id))
+ if ( !id || (items->Item[i].dwID == id))
items->Item[i].bDisabled = disabled;
}
static void sttShowGcMenuItem(GCMENUITEMS *items, DWORD id, int type)
{
for (int i = 0; i < items->nItems; ++i)
- if (!id || (items->Item[i].dwID == id))
+ if ( !id || (items->Item[i].dwID == id))
items->Item[i].uType = type;
}
static void sttSetupGcMenuItems(GCMENUITEMS *items, DWORD *ids, bool disabled)
{
- for ( ; *ids; ++ids)
+ for (; *ids; ++ids)
sttSetupGcMenuItem(items, *ids, disabled);
}
static void sttShowGcMenuItems(GCMENUITEMS *items, DWORD *ids, int type)
{
- for ( ; *ids; ++ids)
+ for (; *ids; ++ids)
sttShowGcMenuItem(items, *ids, type);
}
@@ -547,30 +547,30 @@ static struct gc_item sttListItems[] = { LPGENT("Copy in-room JID"), IDM_CPY_INROOMJID, MENU_ITEM }
};
-int CJabberProto::JabberGcMenuHook( WPARAM, LPARAM lParam )
+int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
{
- GCMENUITEMS* gcmi = ( GCMENUITEMS* )lParam;
- if ( gcmi == NULL )
+ GCMENUITEMS* gcmi = (GCMENUITEMS*)lParam;
+ if (gcmi == NULL)
return 0;
- if ( lstrcmpiA( gcmi->pszModule, m_szModuleName ))
+ if (lstrcmpiA(gcmi->pszModule, m_szModuleName))
return 0;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, gcmi->pszID );
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, gcmi->pszID);
+ if (item == NULL)
return 0;
JABBER_RESOURCE_STATUS *me = NULL, *him = NULL;
- for ( int i=0; i < item->resourceCount; i++ ) {
+ for (int i=0; i < item->resourceCount; i++) {
JABBER_RESOURCE_STATUS& p = item->resource[i];
- if ( !lstrcmp( p.resourceName, item->nick )) me = &p;
- if ( !lstrcmp( p.resourceName, gcmi->pszUID )) him = &p;
+ if ( !lstrcmp(p.resourceName, item->nick )) me = &p;
+ if ( !lstrcmp(p.resourceName, gcmi->pszUID)) him = &p;
}
- if ( gcmi->Type == MENU_ON_LOG ) {
+ if (gcmi->Type == MENU_ON_LOG) {
static TCHAR url_buf[1024] = {0};
- gcmi->nItems = SIZEOF( sttLogListItems );
+ gcmi->nItems = SIZEOF(sttLogListItems);
gcmi->Item = sttLogListItems;
static DWORD sttModeratorItems[] = { IDM_LST_PARTICIPANT, 0 };
@@ -587,13 +587,13 @@ int CJabberProto::JabberGcMenuHook( WPARAM, LPARAM lParam ) gc_item *pItem = sttFindGcMenuItem(gcmi, idx);
pItem->pszDesc = bufPtr;
pItem->uType = MENU_POPUPITEM;
- for ( ; *bufPtr && !_istspace(*bufPtr); ++bufPtr) ;
+ for (; *bufPtr && !_istspace(*bufPtr); ++bufPtr) ;
*bufPtr++ = 0;
if (++idx > IDM_LINK9) break;
}
}
- for ( ; idx <= IDM_LINK9; ++idx)
+ for (; idx <= IDM_LINK9; ++idx)
sttFindGcMenuItem(gcmi, idx)->uType = 0;
if ( !GetAsyncKeyState(VK_CONTROL)) {
@@ -606,7 +606,7 @@ int CJabberProto::JabberGcMenuHook( WPARAM, LPARAM lParam ) sttSetupGcMenuItem(gcmi, IDM_BOOKMARKS, FALSE);
}
}
- else if ( gcmi->Type == MENU_ON_NICKLIST ) {
+ else if (gcmi->Type == MENU_ON_NICKLIST) {
gcmi->nItems = SIZEOF(sttListItems);
gcmi->Item = sttListItems;
@@ -626,7 +626,7 @@ int CJabberProto::JabberGcMenuHook( WPARAM, LPARAM lParam ) if (++idx > IDM_LINK9) break;
}
- for ( ; idx <= IDM_LINK9; ++idx)
+ for (; idx <= IDM_LINK9; ++idx)
sttFindGcMenuItem(gcmi, idx)->uType = 0;
for (i = 0; i < SIZEOF(sttAffiliationItems); ++i) {
@@ -664,7 +664,7 @@ int CJabberProto::JabberGcMenuHook( WPARAM, LPARAM lParam ) sttSetupGcMenuItem(gcmi, IDM_CPY_RJID, TRUE);
}
- if (!force) {
+ if ( !force) {
if (me->role < ROLE_MODERATOR || (me->affiliation <= him->affiliation))
sttSetupGcMenuItem(gcmi, IDM_KICK, TRUE);
@@ -712,7 +712,7 @@ class CGroupchatInviteDlg : public CJabberDlgBase hContact = db_find_next(hContact))
{
char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (lstrcmpA(proto, m_proto->m_szModuleName) || DBGetContactSettingByte(hContact, proto, "ChatRoom", 0))
+ if (lstrcmpA(proto, m_proto->m_szModuleName) || db_get_b(hContact, proto, "ChatRoom", 0))
if (HANDLE hItem = m_clc.FindContact(hContact))
m_clc.DeleteItem(hItem);
} }
@@ -732,14 +732,14 @@ class CGroupchatInviteDlg : public CJabberDlgBase void InviteUser(TCHAR *pUser, TCHAR *text)
{
- XmlNode msg( _T("message"));
- HXML invite = msg << XATTR( _T("to"), m_room ) << XATTRID( m_proto->SerialNext())
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_MUC_USER))
- << XCHILD( _T("invite")) << XATTR( _T("to"), pUser );
- if ( text )
- invite << XCHILD( _T("reason"), text );
-
- m_proto->m_ThreadInfo->send( msg );
+ XmlNode msg(_T("message"));
+ HXML invite = msg << XATTR(_T("to"), m_room) << XATTRID(m_proto->SerialNext())
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_MUC_USER))
+ << XCHILD(_T("invite")) << XATTR(_T("to"), pUser);
+ if (text)
+ invite << XCHILD(_T("reason"), text);
+
+ m_proto->m_ThreadInfo->send(msg);
}
public:
@@ -753,11 +753,11 @@ public: m_clc(this, IDC_CLIST)
{
m_room = mir_tstrdup(room);
- m_btnAddJid.OnClick = Callback( this, &CGroupchatInviteDlg::OnCommand_AddJid );
- m_btnInvite.OnClick = Callback( this, &CGroupchatInviteDlg::OnCommand_Invite );
+ m_btnAddJid.OnClick = Callback(this, &CGroupchatInviteDlg::OnCommand_AddJid);
+ m_btnInvite.OnClick = Callback(this, &CGroupchatInviteDlg::OnCommand_Invite);
m_clc.OnNewContact =
- m_clc.OnListRebuilt = Callback( this, &CGroupchatInviteDlg::FilterList );
- m_clc.OnOptionsChanged = Callback( this, &CGroupchatInviteDlg::ResetListOptions );
+ m_clc.OnListRebuilt = Callback(this, &CGroupchatInviteDlg::FilterList);
+ m_clc.OnOptionsChanged = Callback(this, &CGroupchatInviteDlg::ResetListOptions);
}
~CGroupchatInviteDlg()
@@ -783,24 +783,24 @@ public: FilterList(&m_clc);
}
- void OnCommand_AddJid( CCtrlButton* )
+ void OnCommand_AddJid(CCtrlButton*)
{
TCHAR buf[JABBER_MAX_JID_LEN];
m_txtNewJid.GetText(buf, SIZEOF(buf));
m_txtNewJid.SetTextA("");
HANDLE hContact = m_proto->HContactFromJID(buf);
- if ( hContact )
+ if (hContact)
{
- int hItem = SendDlgItemMessage( m_hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0 );
- if ( hItem )
- SendDlgItemMessage( m_hwnd, IDC_CLIST, CLM_SETCHECKMARK, hItem, 1 );
+ int hItem = SendDlgItemMessage(m_hwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem)
+ SendDlgItemMessage(m_hwnd, IDC_CLIST, CLM_SETCHECKMARK, hItem, 1);
return;
}
int i;
for (i = 0; i < m_newJids.getCount(); ++i)
- if (!lstrcmp(m_newJids[i]->jid, buf))
+ if ( !lstrcmp(m_newJids[i]->jid, buf))
break;
if (i != m_newJids.getCount())
return;
@@ -817,9 +817,9 @@ public: m_newJids.insert(jidData);
}
- void OnCommand_Invite( CCtrlButton* )
+ void OnCommand_Invite(CCtrlButton*)
{
- if (!m_room) return;
+ if ( !m_room) return;
TCHAR *text = m_txtReason.GetText();
HWND hwndList = GetDlgItem(m_hwnd, IDC_CLIST);
@@ -830,7 +830,7 @@ public: hContact = db_find_next(hContact))
{
char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (!lstrcmpA(proto, m_proto->m_szModuleName) && !DBGetContactSettingByte(hContact, proto, "ChatRoom", 0))
+ if ( !lstrcmpA(proto, m_proto->m_szModuleName) && !db_get_b(hContact, proto, "ChatRoom", 0))
{
if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0))
{
@@ -838,9 +838,9 @@ public: {
DBVARIANT dbv={0};
m_proto->JGetStringT(hContact, "jid", &dbv);
- if (dbv.ptszVal && ( dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR ))
+ if (dbv.ptszVal && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
InviteUser(dbv.ptszVal, text);
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
}
}
@@ -859,20 +859,20 @@ public: /////////////////////////////////////////////////////////////////////////////////////////
// Context menu processing
-void CJabberProto::AdminSet( const TCHAR* to, const TCHAR* ns, const TCHAR* szItem, const TCHAR* itemVal, const TCHAR* var, const TCHAR* varVal )
+void CJabberProto::AdminSet(const TCHAR *to, const TCHAR *ns, const TCHAR *szItem, const TCHAR *itemVal, const TCHAR *var, const TCHAR *varVal)
{
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), to ) << XQUERY( ns ) << XCHILD( _T("item")) << XATTR( szItem, itemVal ) << XATTR( var, varVal ));
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), to) << XQUERY(ns) << XCHILD(_T("item")) << XATTR(szItem, itemVal) << XATTR(var, varVal));
}
-void CJabberProto::AdminSetReason( const TCHAR* to, const TCHAR* ns, const TCHAR* szItem, const TCHAR* itemVal, const TCHAR* var, const TCHAR* varVal , const TCHAR* rsn)
-{ m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), to ) << XQUERY( ns ) << XCHILD( _T("item")) << XATTR( szItem, itemVal ) << XATTR( var, varVal ) << XCHILD( _T("reason"), rsn));
+void CJabberProto::AdminSetReason(const TCHAR *to, const TCHAR *ns, const TCHAR *szItem, const TCHAR *itemVal, const TCHAR *var, const TCHAR *varVal , const TCHAR *rsn)
+{ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), to) << XQUERY(ns) << XCHILD(_T("item")) << XATTR(szItem, itemVal) << XATTR(var, varVal) << XCHILD(_T("reason"), rsn));
}
-void CJabberProto::AdminGet( const TCHAR* to, const TCHAR* ns, const TCHAR* var, const TCHAR* varVal, JABBER_IQ_PFUNC foo )
+void CJabberProto::AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var, const TCHAR *varVal, JABBER_IQ_PFUNC foo)
{
int id = SerialNext();
- IqAdd( id, IQ_PROC_NONE, foo );
- m_ThreadInfo->send( XmlNodeIq( _T("get"), id, to ) << XQUERY( ns ) << XCHILD( _T("item")) << XATTR( var, varVal ));
+ IqAdd(id, IQ_PROC_NONE, foo);
+ m_ThreadInfo->send(XmlNodeIq(_T("get"), id, to) << XQUERY(ns) << XCHILD(_T("item")) << XATTR(var, varVal));
}
// Member info dialog
@@ -898,7 +898,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
dat = (TUserInfoData *)lParam;
- WindowSetIcon( hwndDlg, dat->ppro, "group" );
+ WindowSetIcon(hwndDlg, dat->ppro, "group");
LOGFONT lf;
GetObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_TXT_NICK, WM_GETFONT, 0, 0), sizeof(lf), &lf);
@@ -956,9 +956,9 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam }
case WM_COMMAND:
- if (!dat)break;
+ if ( !dat)break;
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
PostMessage(hwndDlg, WM_CLOSE, 0, 0);
break;
@@ -981,7 +981,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam switch (value)
{
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( dat->him->szRealJid, szBareJid, SIZEOF(szBareJid));
+ JabberStripJid(dat->him->szRealJid, szBareJid, SIZEOF(szBareJid));
case AFFILIATION_NONE:
if (dat->him->szRealJid)
dat->ppro->AdminSet(dat->item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("none"));
@@ -1047,11 +1047,11 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam case WM_DESTROY:
{
- WindowFreeIcon( hwndDlg );
- g_ReleaseIcon(( HICON )SendDlgItemMessage( hwndDlg, IDC_BTN_AFFILIATION, BM_SETIMAGE, IMAGE_ICON, 0 ));
- g_ReleaseIcon(( HICON )SendDlgItemMessage( hwndDlg, IDC_BTN_ROLE, BM_SETIMAGE, IMAGE_ICON, 0 ));
+ WindowFreeIcon(hwndDlg);
+ g_ReleaseIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_BTN_AFFILIATION, BM_SETIMAGE, IMAGE_ICON, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_BTN_ROLE, BM_SETIMAGE, IMAGE_ICON, 0));
TUserInfoData *dat = (TUserInfoData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (!dat)break;
+ if ( !dat)break;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
mir_free(dat);
break;
@@ -1060,16 +1060,16 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam return FALSE;
}
-static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* gch )
+static void sttNickListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* gch)
{
JABBER_RESOURCE_STATUS *me = NULL, *him = NULL;
- for ( int i=0; i < item->resourceCount; i++ ) {
+ for (int i=0; i < item->resourceCount; i++) {
JABBER_RESOURCE_STATUS& p = item->resource[i];
- if ( !lstrcmp( p.resourceName, item->nick )) me = &p;
- if ( !lstrcmp( p.resourceName, gch->ptszUID )) him = &p;
+ if ( !lstrcmp(p.resourceName, item->nick )) me = &p;
+ if ( !lstrcmp(p.resourceName, gch->ptszUID)) him = &p;
}
- if ( him == NULL || me == NULL )
+ if (him == NULL || me == NULL)
return;
// 1 kick per second, prevents crashes...
@@ -1087,12 +1087,12 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* return;
}
- switch( gch->dwData ) {
+ switch(gch->dwData) {
case IDM_SLAP:
{
- if ( ppro->m_bJabberOnline ) {
+ if (ppro->m_bJabberOnline) {
DBVARIANT dbv = {0};
- TCHAR *szMessage = DBGetContactSettingTString( NULL, ppro->m_szModuleName, "GcMsgSlap", &dbv) ?
+ TCHAR *szMessage = DBGetContactSettingTString(NULL, ppro->m_szModuleName, "GcMsgSlap", &dbv) ?
NEWTSTR_ALLOCA(TranslateTS(JABBER_GC_MSG_SLAP)) : dbv.ptszVal;
TCHAR buf[256];
@@ -1102,11 +1102,11 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* mir_sntprintf(buf, SIZEOF(buf), _T("%s%s%s"), szMessage, him->resourceName, p+2);
}
else lstrcpyn(buf, szMessage, SIZEOF(buf));
- UnEscapeChatTags( buf );
+ UnEscapeChatTags(buf);
- ppro->m_ThreadInfo->send(
- XmlNode( _T("message")) << XATTR( _T("to"), item->jid ) << XATTR( _T("type"), _T("groupchat"))
- << XCHILD( _T("body"), buf ));
+ ppro->m_ThreadInfo->send(
+ XmlNode(_T("message")) << XATTR(_T("to"), item->jid) << XATTR(_T("type"), _T("groupchat"))
+ << XCHILD(_T("body"), buf));
if (szMessage == dbv.ptszVal)
DBFreeVariant(&dbv);
@@ -1117,15 +1117,15 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* {
HANDLE hContact;
JABBER_SEARCH_RESULT jsr = {0};
- mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s/%s"), item->jid, him->resourceName );
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s/%s"), item->jid, him->resourceName);
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
- JABBER_LIST_ITEM* item = ppro->ListAdd( LIST_VCARD_TEMP, jsr.jid );
+ JABBER_LIST_ITEM* item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
item->bUseResource = TRUE;
- ppro->ListAddResource( LIST_VCARD_TEMP, jsr.jid, him->status, him->statusMessage, him->priority );
+ ppro->ListAddResource(LIST_VCARD_TEMP, jsr.jid, him->status, him->statusMessage, him->priority);
- hContact = ( HANDLE )CallProtoService( ppro->m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, ( LPARAM )&jsr );
- CallService( MS_USERINFO_SHOWDIALOG, ( WPARAM )hContact, 0 );
+ hContact = (HANDLE)CallProtoService(ppro->m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&jsr);
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
break;
}
case IDM_INFO:
@@ -1144,14 +1144,14 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL)
{
dwLastBanKickTime = GetTickCount();
- mir_sntprintf( szBuffer, SIZEOF(szBuffer), _T("%s: "), me->resourceName );
- mir_sntprintf( szTitle, SIZEOF(szTitle), _T("%s %s"), TranslateT( "Reason to kick" ), him->resourceName );
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: "), me->resourceName);
+ mir_sntprintf(szTitle, SIZEOF(szTitle), _T("%s %s"), TranslateT("Reason to kick"), him->resourceName);
TCHAR *resourceName_copy = mir_tstrdup(him->resourceName); // copy resource name to prevent possible crash if user list rebuilds
- if ( ppro->EnterString(szBuffer, SIZEOF(szBuffer), szTitle, JES_MULTINE, "gcReason_" ))
- ppro->m_ThreadInfo->send(
- XmlNodeIq( _T("set"), ppro->SerialNext(), item->jid ) << XQUERY( xmlnsAdmin )
- << XCHILD( _T("item")) << XATTR( _T("nick"), resourceName_copy ) << XATTR( _T("role"), _T("none"))
- << XCHILD( _T("reason"), szBuffer ));
+ if (ppro->EnterString(szBuffer, SIZEOF(szBuffer), szTitle, JES_MULTINE, "gcReason_"))
+ ppro->m_ThreadInfo->send(
+ XmlNodeIq(_T("set"), ppro->SerialNext(), item->jid) << XQUERY(xmlnsAdmin)
+ << XCHILD(_T("item")) << XATTR(_T("nick"), resourceName_copy) << XATTR(_T("role"), _T("none"))
+ << XCHILD(_T("reason"), szBuffer));
mir_free(resourceName_copy);
}
@@ -1178,7 +1178,7 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* if (him->szRealJid)
{
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( him->szRealJid, szBareJid, SIZEOF(szBareJid));
+ JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("none"));
}
else
@@ -1191,7 +1191,7 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* if (him->szRealJid)
{
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( him->szRealJid, szBareJid, SIZEOF(szBareJid));
+ JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("member"));
}
else
@@ -1204,7 +1204,7 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* if (him->szRealJid)
{
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( him->szRealJid, szBareJid, SIZEOF(szBareJid));
+ JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("admin"));
}
else
@@ -1217,7 +1217,7 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* if (him->szRealJid)
{
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( him->szRealJid, szBareJid, SIZEOF(szBareJid));
+ JabberStripJid(him->szRealJid, szBareJid, SIZEOF(szBareJid));
ppro->AdminSet(item->jid, xmlnsAdmin, _T("jid"), szBareJid, _T("affiliation"), _T("owner"));
}
else
@@ -1227,18 +1227,18 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* case IDM_SET_BAN:
if ((GetTickCount() - dwLastBanKickTime) > BAN_KICK_INTERVAL) {
- if ( him->szRealJid && *him->szRealJid ) {
+ if (him->szRealJid && *him->szRealJid) {
TCHAR szVictimBareJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( him->szRealJid, szVictimBareJid, SIZEOF(szVictimBareJid));
+ JabberStripJid(him->szRealJid, szVictimBareJid, SIZEOF(szVictimBareJid));
- mir_sntprintf( szBuffer, SIZEOF(szBuffer), _T("%s: "), me->resourceName );
- mir_sntprintf( szTitle, SIZEOF(szTitle), _T("%s %s"), TranslateT( "Reason to ban" ), him->resourceName );
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s: "), me->resourceName);
+ mir_sntprintf(szTitle, SIZEOF(szTitle), _T("%s %s"), TranslateT("Reason to ban"), him->resourceName);
- if ( ppro->EnterString(szBuffer, SIZEOF(szBuffer), szTitle, JES_MULTINE, "gcReason_" )) {
+ if (ppro->EnterString(szBuffer, SIZEOF(szBuffer), szTitle, JES_MULTINE, "gcReason_")) {
ppro->m_ThreadInfo->send(
- XmlNodeIq( _T("set"), ppro->SerialNext(), item->jid ) << XQUERY( xmlnsAdmin )
- << XCHILD( _T("item")) << XATTR( _T("jid"), szVictimBareJid ) << XATTR( _T("affiliation"), _T("outcast"))
- << XCHILD( _T("reason"), szBuffer ));
+ XmlNodeIq(_T("set"), ppro->SerialNext(), item->jid) << XQUERY(xmlnsAdmin)
+ << XCHILD(_T("item")) << XATTR(_T("jid"), szVictimBareJid) << XATTR(_T("affiliation"), _T("outcast"))
+ << XCHILD(_T("reason"), szBuffer));
}
}
}
@@ -1256,28 +1256,28 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* int idx = gch->dwData - IDM_LINK0;
LISTFOREACH(i, ppro, LIST_CHATROOM)
if (JABBER_LIST_ITEM *item = ppro->ListGetItemPtrFromIndex(i))
- if (!idx--)
+ if ( !idx--)
{
szInviteTo = item->jid;
break;
}
- if (!szInviteTo) break;
+ if ( !szInviteTo) break;
- mir_sntprintf( szTitle, SIZEOF(szTitle), TranslateT("Invite %s to %s"), him->resourceName, szInviteTo );
+ mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("Invite %s to %s"), him->resourceName, szInviteTo);
*szBuffer = 0;
- if (!ppro->EnterString(szBuffer, SIZEOF(szBuffer), szTitle, JES_MULTINE))
+ if ( !ppro->EnterString(szBuffer, SIZEOF(szBuffer), szTitle, JES_MULTINE))
break;
mir_sntprintf(szTitle, SIZEOF(szTitle), _T("%s/%s"), item->jid, resourceName_copy);
- XmlNode msg( _T("message"));
- HXML invite = msg << XATTR( _T("to"), szTitle ) << XATTRID(ppro->SerialNext())
+ XmlNode msg(_T("message"));
+ HXML invite = msg << XATTR(_T("to"), szTitle) << XATTRID(ppro->SerialNext())
<< XCHILD(_T("x"), szBuffer)
<< XATTR(_T("xmlns"), _T("jabber:x:conference"))
- << XATTR( _T("jid"), szInviteTo )
+ << XATTR(_T("jid"), szInviteTo)
<< XCHILD(_T("invite")) << XATTR(_T("from"), item->nick);
- ppro->m_ThreadInfo->send( msg );
+ ppro->m_ThreadInfo->send(msg);
}
dwLastBanKickTime = GetTickCount();
break;
@@ -1300,16 +1300,16 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* {
HANDLE hContact;
JABBER_SEARCH_RESULT jsr ={0};
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), him->szRealJid);
if (TCHAR *tmp = _tcschr(jsr.jid, _T('/'))) *tmp = 0;
- JABBER_LIST_ITEM* item = ppro->ListAdd( LIST_VCARD_TEMP, jsr.jid );
+ JABBER_LIST_ITEM* item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
item->bUseResource = TRUE;
- ppro->ListAddResource( LIST_VCARD_TEMP, jsr.jid, him->status, him->statusMessage, him->priority );
+ ppro->ListAddResource(LIST_VCARD_TEMP, jsr.jid, him->status, him->statusMessage, him->priority);
- hContact = ( HANDLE )CallProtoService( ppro->m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, ( LPARAM )&jsr );
- CallService( MS_USERINFO_SHOWDIALOG, ( WPARAM )hContact, 0 );
+ hContact = (HANDLE)CallProtoService(ppro->m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&jsr);
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
break;
}
@@ -1317,7 +1317,7 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* if (him->szRealJid && *him->szRealJid)
{
JABBER_SEARCH_RESULT jsr={0};
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), him->szRealJid);
if (TCHAR *tmp = _tcschr(jsr.jid, _T('/'))) *tmp = 0;
@@ -1333,78 +1333,78 @@ static void sttNickListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* }
}
-static void sttLogListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* gch )
+static void sttLogListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* gch)
{
TCHAR szBuffer[ 1024 ];
TCHAR szCaption[ 1024 ];
szBuffer[ 0 ] = _T('\0');
- switch( gch->dwData ) {
+ switch(gch->dwData) {
case IDM_LST_PARTICIPANT:
- ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("role"), _T("participant"), &CJabberProto::OnIqResultMucGetVoiceList );
+ ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("role"), _T("participant"), &CJabberProto::OnIqResultMucGetVoiceList);
break;
case IDM_LST_MEMBER:
- ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("member"), &CJabberProto::OnIqResultMucGetMemberList );
+ ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("member"), &CJabberProto::OnIqResultMucGetMemberList);
break;
case IDM_LST_MODERATOR:
- ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("role"), _T("moderator"), &CJabberProto::OnIqResultMucGetModeratorList );
+ ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("role"), _T("moderator"), &CJabberProto::OnIqResultMucGetModeratorList);
break;
case IDM_LST_BAN:
- ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList );
+ ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList);
break;
case IDM_LST_ADMIN:
- ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("admin"), &CJabberProto::OnIqResultMucGetAdminList );
+ ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("admin"), &CJabberProto::OnIqResultMucGetAdminList);
break;
case IDM_LST_OWNER:
- ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("owner"), &CJabberProto::OnIqResultMucGetOwnerList );
+ ppro->AdminGet(gch->pDest->ptszID, xmlnsAdmin, _T("affiliation"), _T("owner"), &CJabberProto::OnIqResultMucGetOwnerList);
break;
case IDM_TOPIC:
- mir_sntprintf( szCaption, SIZEOF(szCaption), _T("%s %s"), TranslateT( "Set topic for" ), gch->pDest->ptszID );
+ mir_sntprintf(szCaption, SIZEOF(szCaption), _T("%s %s"), TranslateT("Set topic for"), gch->pDest->ptszID);
TCHAR szTmpBuff[ SIZEOF(szBuffer) * 2 ];
- if ( item->itemResource.statusMessage ) {
+ if (item->itemResource.statusMessage) {
int j = 0;
- for ( int i = 0; i < SIZEOF(szTmpBuff); i++ ) {
- if ( item->itemResource.statusMessage[ i ] != _T('\n') || ( i && item->itemResource.statusMessage[ i - 1 ] == _T('\r')))
+ for (int i = 0; i < SIZEOF(szTmpBuff); i++) {
+ if (item->itemResource.statusMessage[ i ] != _T('\n') || (i && item->itemResource.statusMessage[ i - 1 ] == _T('\r')))
szTmpBuff[ j++ ] = item->itemResource.statusMessage[ i ];
else {
szTmpBuff[ j++ ] = _T('\r');
szTmpBuff[ j++ ] = _T('\n');
}
- if ( !item->itemResource.statusMessage[ i ] )
+ if ( !item->itemResource.statusMessage[ i ])
break;
}
}
else szTmpBuff[ 0 ] = _T('\0');
- if ( ppro->EnterString( szTmpBuff, SIZEOF(szTmpBuff), szCaption, JES_RICHEDIT, "gcTopic_" ))
- ppro->m_ThreadInfo->send(
- XmlNode( _T("message")) << XATTR( _T("to"), gch->pDest->ptszID ) << XATTR( _T("type"), _T("groupchat"))
- << XCHILD( _T("subject"), szTmpBuff ));
+ if (ppro->EnterString(szTmpBuff, SIZEOF(szTmpBuff), szCaption, JES_RICHEDIT, "gcTopic_"))
+ ppro->m_ThreadInfo->send(
+ XmlNode(_T("message")) << XATTR(_T("to"), gch->pDest->ptszID) << XATTR(_T("type"), _T("groupchat"))
+ << XCHILD(_T("subject"), szTmpBuff));
break;
case IDM_NICK:
- mir_sntprintf( szCaption, SIZEOF(szCaption), _T("%s %s"), TranslateT( "Change nickname in" ), gch->pDest->ptszID );
- if ( item->nick )
- mir_sntprintf( szBuffer, SIZEOF(szBuffer), _T("%s"), item->nick );
- if ( ppro->EnterString(szBuffer, SIZEOF(szBuffer), szCaption, JES_COMBO, "gcNick_" )) {
- JABBER_LIST_ITEM* item = ppro->ListGetItemPtr( LIST_CHATROOM, gch->pDest->ptszID );
- if ( item != NULL ) {
+ mir_sntprintf(szCaption, SIZEOF(szCaption), _T("%s %s"), TranslateT("Change nickname in"), gch->pDest->ptszID);
+ if (item->nick)
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), item->nick);
+ if (ppro->EnterString(szBuffer, SIZEOF(szBuffer), szCaption, JES_COMBO, "gcNick_")) {
+ JABBER_LIST_ITEM* item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
+ if (item != NULL) {
TCHAR text[ 1024 ];
- mir_sntprintf( text, SIZEOF( text ), _T("%s/%s"), gch->pDest->ptszID, szBuffer );
- ppro->SendPresenceTo( ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, NULL );
+ mir_sntprintf(text, SIZEOF(text), _T("%s/%s"), gch->pDest->ptszID, szBuffer);
+ ppro->SendPresenceTo(ppro->m_iStatus == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : ppro->m_iStatus, text, NULL);
} }
break;
case IDM_INVITE:
{
- CGroupchatInviteDlg *dlg = new CGroupchatInviteDlg( ppro, gch->pDest->ptszID );
+ CGroupchatInviteDlg *dlg = new CGroupchatInviteDlg(ppro, gch->pDest->ptszID);
dlg->Show();
break;
}
@@ -1412,38 +1412,38 @@ static void sttLogListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* case IDM_CONFIG:
{
int iqId = ppro->SerialNext();
- ppro->IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc );
+ ppro->IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetMuc);
- XmlNodeIq iq( _T("get"), iqId, gch->pDest->ptszID );
- iq << XQUERY( xmlnsOwner );
- ppro->m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("get"), iqId, gch->pDest->ptszID);
+ iq << XQUERY(xmlnsOwner);
+ ppro->m_ThreadInfo->send(iq);
break;
}
case IDM_BOOKMARKS:
{
- JABBER_LIST_ITEM* item = ppro->ListGetItemPtr( LIST_BOOKMARK, gch->pDest->ptszID );
- if ( item == NULL ) {
- item = ppro->ListGetItemPtr( LIST_CHATROOM, gch->pDest->ptszID );
+ JABBER_LIST_ITEM* item = ppro->ListGetItemPtr(LIST_BOOKMARK, gch->pDest->ptszID);
+ if (item == NULL) {
+ item = ppro->ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
if (item != NULL) {
item->type = _T("conference");
- HANDLE hContact = ppro->HContactFromJID( item->jid );
- item->name = ( TCHAR* )CallService( MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR );
- ppro->AddEditBookmark( item );
+ HANDLE hContact = ppro->HContactFromJID(item->jid);
+ item->name = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
+ ppro->AddEditBookmark(item);
}
}
break;
}
case IDM_DESTROY:
- mir_sntprintf( szBuffer, SIZEOF(szBuffer), _T("%s %s"), TranslateT( "Reason to destroy" ), gch->pDest->ptszID );
- if ( !ppro->EnterString(szBuffer, SIZEOF(szBuffer), NULL, JES_MULTINE, "gcReason_" ))
+ mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s %s"), TranslateT("Reason to destroy"), gch->pDest->ptszID);
+ if ( !ppro->EnterString(szBuffer, SIZEOF(szBuffer), NULL, JES_MULTINE, "gcReason_"))
break;
- ppro->m_ThreadInfo->send(
- XmlNodeIq( _T("set"), ppro->SerialNext(), gch->pDest->ptszID ) << XQUERY( xmlnsOwner )
- << XCHILD( _T("destroy")) << XCHILD( _T("reason"), szBuffer ));
+ ppro->m_ThreadInfo->send(
+ XmlNodeIq(_T("set"), ppro->SerialNext(), gch->pDest->ptszID) << XQUERY(xmlnsOwner)
+ << XCHILD(_T("destroy")) << XCHILD(_T("reason"), szBuffer));
case IDM_LEAVE:
- ppro->GcQuit( item, 0, NULL );
+ ppro->GcQuit(item, 0, NULL);
break;
case IDM_PRESENCE_ONLINE:
@@ -1452,8 +1452,8 @@ static void sttLogListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* case IDM_PRESENCE_DND:
case IDM_PRESENCE_FREE4CHAT:
{
- if ( HANDLE h = ppro->HContactFromJID( item->jid ))
- ppro->OnMenuHandleDirectPresence( (WPARAM)h, 0, gch->dwData );
+ if (HANDLE h = ppro->HContactFromJID(item->jid))
+ ppro->OnMenuHandleDirectPresence((WPARAM)h, 0, gch->dwData);
break;
}
@@ -1492,22 +1492,22 @@ static void sttLogListHook( CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* /////////////////////////////////////////////////////////////////////////////////////////
// Sends a private message to a chat user
-static void sttSendPrivateMessage( CJabberProto* ppro, JABBER_LIST_ITEM* item, const TCHAR* nick )
+static void sttSendPrivateMessage(CJabberProto* ppro, JABBER_LIST_ITEM* item, const TCHAR *nick)
{
TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
- mir_sntprintf( szFullJid, SIZEOF(szFullJid), _T("%s/%s"), item->jid, nick );
- HANDLE hContact = ppro->DBCreateContact( szFullJid, NULL, TRUE, FALSE );
- if ( hContact != NULL ) {
- for ( int i=0; i < item->resourceCount; i++ ) {
- if ( _tcsicmp( item->resource[i].resourceName, nick ) == 0 ) {
- ppro->JSetWord( hContact, "Status", item->resource[i].status );
+ mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), item->jid, nick);
+ HANDLE hContact = ppro->DBCreateContact(szFullJid, NULL, TRUE, FALSE);
+ if (hContact != NULL) {
+ for (int i=0; i < item->resourceCount; i++) {
+ if (_tcsicmp(item->resource[i].resourceName, nick) == 0) {
+ ppro->JSetWord(hContact, "Status", item->resource[i].status);
break;
} }
- DBWriteContactSettingByte( hContact, "CList", "Hidden", 1 );
- ppro->JSetStringT( hContact, "Nick", nick );
- DBWriteContactSettingDword( hContact, "Ignore", "Mask1", 0 );
- CallService( MS_MSG_SENDMESSAGE, ( WPARAM )hContact, 0 );
+ db_set_b(hContact, "CList", "Hidden", 1);
+ ppro->JSetStringT(hContact, "Nick", nick);
+ db_set_dw(hContact, "Ignore", "Mask1", 0);
+ CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
} }
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1515,47 +1515,47 @@ static void sttSendPrivateMessage( CJabberProto* ppro, JABBER_LIST_ITEM* item, c int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
{
- GCHOOK* gch = ( GCHOOK* )lParam;
- if ( gch == NULL )
+ GCHOOK* gch = (GCHOOK*)lParam;
+ if (gch == NULL)
return 0;
- if ( lstrcmpiA( gch->pDest->pszModule, m_szModuleName ))
+ if (lstrcmpiA(gch->pDest->pszModule, m_szModuleName))
return 0;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, gch->pDest->ptszID );
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, gch->pDest->ptszID);
+ if (item == NULL)
return 0;
- switch ( gch->pDest->iType ) {
+ switch (gch->pDest->iType) {
case GC_USER_MESSAGE:
- if ( gch->pszText && lstrlen( gch->ptszText) > 0 ) {
- trtrim( gch->ptszText );
+ if (gch->pszText && lstrlen(gch->ptszText) > 0) {
+ trtrim(gch->ptszText);
- if ( m_bJabberOnline ) {
+ if (m_bJabberOnline) {
TCHAR* buf = NEWTSTR_ALLOCA(gch->ptszText);
- UnEscapeChatTags( buf );
- m_ThreadInfo->send(
- XmlNode( _T("message")) << XATTR( _T("to"), item->jid ) << XATTR( _T("type"), _T("groupchat"))
- << XCHILD( _T("body"), buf ));
+ UnEscapeChatTags(buf);
+ m_ThreadInfo->send(
+ XmlNode(_T("message")) << XATTR(_T("to"), item->jid) << XATTR(_T("type"), _T("groupchat"))
+ << XCHILD(_T("body"), buf));
} }
break;
case GC_USER_PRIVMESS:
- sttSendPrivateMessage( this, item, gch->ptszUID );
+ sttSendPrivateMessage(this, item, gch->ptszUID);
break;
case GC_USER_LOGMENU:
- sttLogListHook( this, item, gch );
+ sttLogListHook(this, item, gch);
break;
case GC_USER_NICKLISTMENU:
- sttNickListHook( this, item, gch );
+ sttNickListHook(this, item, gch);
break;
case GC_USER_CHANMGR:
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));
break;
}
@@ -1563,66 +1563,66 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam) }
/////////////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::AddMucListItem( JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str , TCHAR* rsn)
+void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str , TCHAR* rsn)
{
- const TCHAR* field = ( jidListInfo->type == MUC_BANLIST || _tcschr(str,'@')) ? _T("jid") : _T("nick");
+ const TCHAR *field = (jidListInfo->type == MUC_BANLIST || _tcschr(str,'@')) ? _T("jid") : _T("nick");
TCHAR* roomJid = jidListInfo->roomJid;
- if ( jidListInfo->type == MUC_BANLIST ) {
- AdminSetReason( roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("outcast"), rsn);
- AdminGet( roomJid, xmlnsAdmin, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList);
+ if (jidListInfo->type == MUC_BANLIST) {
+ AdminSetReason(roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("outcast"), rsn);
+ AdminGet(roomJid, xmlnsAdmin, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList);
} }
-void CJabberProto::AddMucListItem( JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str )
+void CJabberProto::AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str)
{
- const TCHAR* field = ( jidListInfo->type == MUC_BANLIST || _tcschr(str,'@')) ? _T("jid") : _T("nick");
+ const TCHAR *field = (jidListInfo->type == MUC_BANLIST || _tcschr(str,'@')) ? _T("jid") : _T("nick");
TCHAR* roomJid = jidListInfo->roomJid;
switch (jidListInfo->type) {
case MUC_VOICELIST:
- AdminSet( roomJid, xmlnsAdmin, field, str, _T("role"), _T("participant"));
- AdminGet( roomJid, xmlnsAdmin, _T("role"), _T("participant"), &CJabberProto::OnIqResultMucGetVoiceList);
+ AdminSet(roomJid, xmlnsAdmin, field, str, _T("role"), _T("participant"));
+ AdminGet(roomJid, xmlnsAdmin, _T("role"), _T("participant"), &CJabberProto::OnIqResultMucGetVoiceList);
break;
case MUC_MEMBERLIST:
- AdminSet( roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("member"));
- AdminGet( roomJid, xmlnsAdmin, _T("affiliation"), _T("member"), &CJabberProto::OnIqResultMucGetMemberList);
+ AdminSet(roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("member"));
+ AdminGet(roomJid, xmlnsAdmin, _T("affiliation"), _T("member"), &CJabberProto::OnIqResultMucGetMemberList);
break;
case MUC_MODERATORLIST:
- AdminSet( roomJid, xmlnsAdmin, field, str, _T("role"), _T("moderator"));
- AdminGet( roomJid, xmlnsAdmin, _T("role"), _T("moderator"), &CJabberProto::OnIqResultMucGetModeratorList);
+ AdminSet(roomJid, xmlnsAdmin, field, str, _T("role"), _T("moderator"));
+ AdminGet(roomJid, xmlnsAdmin, _T("role"), _T("moderator"), &CJabberProto::OnIqResultMucGetModeratorList);
break;
case MUC_BANLIST:
- AdminSet( roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("outcast"));
- AdminGet( roomJid, xmlnsAdmin, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList);
+ AdminSet(roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("outcast"));
+ AdminGet(roomJid, xmlnsAdmin, _T("affiliation"), _T("outcast"), &CJabberProto::OnIqResultMucGetBanList);
break;
case MUC_ADMINLIST:
- AdminSet( roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("admin"));
- AdminGet( roomJid, xmlnsAdmin, _T("affiliation"), _T("admin"), &CJabberProto::OnIqResultMucGetAdminList);
+ AdminSet(roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("admin"));
+ AdminGet(roomJid, xmlnsAdmin, _T("affiliation"), _T("admin"), &CJabberProto::OnIqResultMucGetAdminList);
break;
case MUC_OWNERLIST:
- AdminSet( roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("owner"));
- AdminGet( roomJid, xmlnsAdmin, _T("affiliation"), _T("owner"), &CJabberProto::OnIqResultMucGetOwnerList);
+ AdminSet(roomJid, xmlnsAdmin, field, str, _T("affiliation"), _T("owner"));
+ AdminGet(roomJid, xmlnsAdmin, _T("affiliation"), _T("owner"), &CJabberProto::OnIqResultMucGetOwnerList);
break;
} }
-void CJabberProto::DeleteMucListItem( JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* jid )
+void CJabberProto::DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* jid)
{
TCHAR* roomJid = jidListInfo->roomJid;
- switch ( jidListInfo->type ) {
- case MUC_VOICELIST: // change role to visitor ( from participant )
- AdminSet( roomJid, xmlnsAdmin, _T("jid"), jid, _T("role"), _T("visitor"));
+ switch (jidListInfo->type) {
+ case MUC_VOICELIST: // change role to visitor (from participant)
+ AdminSet(roomJid, xmlnsAdmin, _T("jid"), jid, _T("role"), _T("visitor"));
break;
- case MUC_BANLIST: // change affiliation to none ( from outcast )
- case MUC_MEMBERLIST: // change affiliation to none ( from member )
- AdminSet( roomJid, xmlnsAdmin, _T("jid"), jid, _T("affiliation"), _T("none"));
+ case MUC_BANLIST: // change affiliation to none (from outcast)
+ case MUC_MEMBERLIST: // change affiliation to none (from member)
+ AdminSet(roomJid, xmlnsAdmin, _T("jid"), jid, _T("affiliation"), _T("none"));
break;
- case MUC_MODERATORLIST: // change role to participant ( from moderator )
- AdminSet( roomJid, xmlnsAdmin, _T("jid"), jid, _T("role"), _T("participant"));
+ case MUC_MODERATORLIST: // change role to participant (from moderator)
+ AdminSet(roomJid, xmlnsAdmin, _T("jid"), jid, _T("role"), _T("participant"));
break;
- case MUC_ADMINLIST: // change affiliation to member ( from admin )
- AdminSet( roomJid, xmlnsAdmin, _T("jid"), jid, _T("affiliation"), _T("member"));
+ case MUC_ADMINLIST: // change affiliation to member (from admin)
+ AdminSet(roomJid, xmlnsAdmin, _T("jid"), jid, _T("affiliation"), _T("member"));
break;
- case MUC_OWNERLIST: // change affiliation to admin ( from owner )
- AdminSet( roomJid, xmlnsAdmin, _T("jid"), jid, _T("affiliation"), _T("admin"));
+ case MUC_OWNERLIST: // change affiliation to admin (from owner)
+ AdminSet(roomJid, xmlnsAdmin, _T("jid"), jid, _T("affiliation"), _T("admin"));
break;
} }
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index ca2c82b3e4..6a804623a6 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2007 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2007 Victor Pavlychko
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
@@ -83,9 +83,9 @@ static void sttRtfAppendXml(StringBuf *buf, HXML node, DWORD flags, int indent); void CJabberProto::OnConsoleProcessXml(HXML node, DWORD flags)
{
- if ( node && m_pDlgConsole ) {
- if ( xmlGetName( node )) {
- if ( FilterXml( node, flags )) {
+ if (node && m_pDlgConsole) {
+ if (xmlGetName(node)) {
+ if (FilterXml(node, flags)) {
StringBuf buf = {0};
sttAppendBufRaw(&buf, RTF_HEADER);
sttRtfAppendXml(&buf, node, flags, 1);
@@ -96,8 +96,8 @@ void CJabberProto::OnConsoleProcessXml(HXML node, DWORD flags) }
}
else {
- for ( int i = 0; i < xmlGetChildCount( node ); i++ )
- OnConsoleProcessXml( xmlGetChild( node, i), flags );
+ for (int i = 0; i < xmlGetChildCount(node); i++)
+ OnConsoleProcessXml(xmlGetChild(node, i), flags);
}
}
}
@@ -108,12 +108,12 @@ bool CJabberProto::RecursiveCheckFilter(HXML node, DWORD flags) for (i = 0; i < xmlGetAttrCount(node); ++i)
{
- if ( JabberStrIStr( xmlGetAttr( node,i ), m_filterInfo.pattern ))
+ if (JabberStrIStr(xmlGetAttr(node,i), m_filterInfo.pattern))
return true;
}
- for (i = 0; i < xmlGetChildCount( node ); ++i) {
- if (RecursiveCheckFilter( xmlGetChild( node, i ), flags))
+ for (i = 0; i < xmlGetChildCount(node); ++i) {
+ if (RecursiveCheckFilter(xmlGetChild(node, i), flags))
return true;
}
@@ -122,9 +122,9 @@ bool CJabberProto::RecursiveCheckFilter(HXML node, DWORD flags) bool CJabberProto::FilterXml(HXML node, DWORD flags)
{
- if (!m_filterInfo.msg && !lstrcmp(xmlGetName( node ), _T("message"))) return false;
- if (!m_filterInfo.presence && !lstrcmp(xmlGetName( node ), _T("presence"))) return false;
- if (!m_filterInfo.iq && !lstrcmp(xmlGetName( node ), _T("iq"))) return false;
+ if ( !m_filterInfo.msg && !lstrcmp(xmlGetName(node), _T("message"))) return false;
+ if ( !m_filterInfo.presence && !lstrcmp(xmlGetName(node), _T("presence"))) return false;
+ if ( !m_filterInfo.iq && !lstrcmp(xmlGetName(node), _T("iq"))) return false;
if (m_filterInfo.type == TFilterInfo::T_OFF) return true;
bool result = false;
@@ -134,18 +134,18 @@ bool CJabberProto::FilterXml(HXML node, DWORD flags) {
case TFilterInfo::T_JID:
{
- const TCHAR *attrValue = xmlGetAttrValue( node,(flags&JCPF_OUT)?_T("to"):_T("from"));
- if (!attrValue) break;
+ const TCHAR *attrValue = xmlGetAttrValue(node,(flags&JCPF_OUT)?_T("to"):_T("from"));
+ if ( !attrValue) break;
result = JabberStrIStr(attrValue, m_filterInfo.pattern) ? true : false;
break;
}
case TFilterInfo::T_XMLNS:
{
- if ( !xmlGetChildCount( node )) break;
+ if ( !xmlGetChildCount(node)) break;
- const TCHAR *attrValue = xmlGetAttrValue( xmlGetChild( node, 0 ), _T("xmlns"));
- if ( !attrValue )
+ const TCHAR *attrValue = xmlGetAttrValue(xmlGetChild(node, 0), _T("xmlns"));
+ if ( !attrValue)
break;
result = JabberStrIStr(attrValue, m_filterInfo.pattern) ? true : false;
@@ -165,7 +165,7 @@ bool CJabberProto::FilterXml(HXML node, DWORD flags) static void sttAppendBufRaw(StringBuf *buf, const char *str)
{
- if (!str) return;
+ if ( !str) return;
int length = lstrlenA(str);
if (buf->size - buf->offset < length+1)
@@ -181,7 +181,7 @@ static void sttAppendBufW(StringBuf *buf, const WCHAR *str) {
char tmp[32];
- if (!str) return;
+ if ( !str) return;
sttAppendBufRaw(buf, "{\\uc1 ");
for (const WCHAR *p = str; *p; ++p)
@@ -227,56 +227,56 @@ static void sttRtfAppendXml(StringBuf *buf, HXML node, DWORD flags, int indent) if (flags&JCPF_OUT) sttAppendBufRaw(buf, "\\highlight4 ");
sttAppendBufRaw(buf, "<");
sttAppendBufRaw(buf, RTF_BEGINTAGNAME);
- sttAppendBufW(buf, (TCHAR*)xmlGetName( node ));
+ sttAppendBufW(buf, (TCHAR*)xmlGetName(node));
sttAppendBufRaw(buf, RTF_ENDTAGNAME);
- for (i = 0; i < xmlGetAttrCount( node); i++)
+ for (i = 0; i < xmlGetAttrCount(node); i++)
{
- TCHAR* attr = ( TCHAR* )xmlGetAttrName( node, i );
+ TCHAR* attr = (TCHAR*)xmlGetAttrName(node, i);
sttAppendBufRaw(buf, " ");
sttAppendBufRaw(buf, RTF_BEGINATTRNAME);
sttAppendBufW(buf, attr);
sttAppendBufRaw(buf, RTF_ENDATTRNAME);
sttAppendBufRaw(buf, "=\"");
sttAppendBufRaw(buf, RTF_BEGINATTRVAL);
- sttAppendBufT(buf, ( TCHAR* )xmlGetAttr( node, i));
+ sttAppendBufT(buf, (TCHAR*)xmlGetAttr(node, i));
sttAppendBufRaw(buf, "\"");
sttAppendBufRaw(buf, RTF_ENDATTRVAL);
}
- if ( xmlGetChild( node ) || xmlGetText( node ))
+ if (xmlGetChild(node) || xmlGetText(node))
{
sttAppendBufRaw(buf, ">");
- if ( xmlGetChild( node ))
+ if (xmlGetChild(node))
sttAppendBufRaw(buf, RTF_ENDTAG);
}
- if (xmlGetText( node ))
+ if (xmlGetText(node))
{
- if ( xmlGetChildCount( node ))
+ if (xmlGetChildCount(node))
{
sttAppendBufRaw(buf, RTF_BEGINTEXT);
char *indentTextLevel = (char *)mir_alloc(128);
- mir_snprintf( indentTextLevel, 128, RTF_TEXTINDENT_FMT, (int)(( indent + 1) * 200 ));
+ mir_snprintf(indentTextLevel, 128, RTF_TEXTINDENT_FMT, (int)((indent + 1) * 200));
sttAppendBufRaw(buf, indentTextLevel);
mir_free(indentTextLevel);
}
- sttAppendBufT(buf, xmlGetText( node ));
- if ( xmlGetChild( node ))
+ sttAppendBufT(buf, xmlGetText(node));
+ if (xmlGetChild(node))
sttAppendBufRaw(buf, RTF_ENDTEXT);
}
- for (i = 0; i < xmlGetChildCount( node ) ; ++i)
- sttRtfAppendXml(buf, xmlGetChild( node ,i), flags & ~(JCPF_IN|JCPF_OUT), indent+1);
+ for (i = 0; i < xmlGetChildCount(node) ; ++i)
+ sttRtfAppendXml(buf, xmlGetChild(node ,i), flags & ~(JCPF_IN|JCPF_OUT), indent+1);
- if (xmlGetChildCount( node ) || xmlGetText( node ))
+ if (xmlGetChildCount(node) || xmlGetText(node))
{
sttAppendBufRaw(buf, RTF_BEGINTAG);
sttAppendBufRaw(buf, indentLevel);
sttAppendBufRaw(buf, "</");
sttAppendBufRaw(buf, RTF_BEGINTAGNAME);
- sttAppendBufT(buf, xmlGetName( node ));
+ sttAppendBufT(buf, xmlGetName(node));
sttAppendBufRaw(buf, RTF_ENDTAGNAME);
sttAppendBufRaw(buf, ">");
} else
@@ -371,20 +371,20 @@ void CJabberDlgConsole::OnInitDialog() int i;
- WindowSetIcon( m_hwnd, m_proto, "xmlconsole" );
+ WindowSetIcon(m_hwnd, m_proto, "xmlconsole");
SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR);
SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXLIMITTEXT, 0, 0x80000000);
- m_proto->m_filterInfo.msg = DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_msg", TRUE);
- m_proto->m_filterInfo.presence = DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_presence", TRUE);
- m_proto->m_filterInfo.iq = DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_iq", TRUE);
- m_proto->m_filterInfo.type = (TFilterInfo::Type)DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_ftype", TFilterInfo::T_OFF);
+ m_proto->m_filterInfo.msg = db_get_b(NULL, m_proto->m_szModuleName, "consoleWnd_msg", TRUE);
+ m_proto->m_filterInfo.presence = db_get_b(NULL, m_proto->m_szModuleName, "consoleWnd_presence", TRUE);
+ m_proto->m_filterInfo.iq = db_get_b(NULL, m_proto->m_szModuleName, "consoleWnd_iq", TRUE);
+ m_proto->m_filterInfo.type = (TFilterInfo::Type)db_get_b(NULL, m_proto->m_szModuleName, "consoleWnd_ftype", TFilterInfo::T_OFF);
DBVARIANT dbv;
*m_proto->m_filterInfo.pattern = 0;
if ( !m_proto->JGetStringT(NULL, "consoleWnd_fpattern", &dbv)) {
lstrcpyn(m_proto->m_filterInfo.pattern, dbv.ptszVal, SIZEOF(m_proto->m_filterInfo.pattern));
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER));
@@ -417,7 +417,7 @@ void CJabberDlgConsole::OnInitDialog() for (i = 0; i < SIZEOF(filter_modes); ++i)
if (filter_modes[i].type == m_proto->m_filterInfo.type)
{
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon));
break;
}
@@ -429,10 +429,10 @@ void CJabberDlgConsole::OnInitDialog() void CJabberDlgConsole::OnClose()
{
- DBWriteContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_msg", m_proto->m_filterInfo.msg);
- DBWriteContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_presence", m_proto->m_filterInfo.presence);
- DBWriteContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_iq", m_proto->m_filterInfo.iq);
- DBWriteContactSettingByte(NULL, m_proto->m_szModuleName, "consoleWnd_ftype", m_proto->m_filterInfo.type);
+ db_set_b(NULL, m_proto->m_szModuleName, "consoleWnd_msg", m_proto->m_filterInfo.msg);
+ db_set_b(NULL, m_proto->m_szModuleName, "consoleWnd_presence", m_proto->m_filterInfo.presence);
+ db_set_b(NULL, m_proto->m_szModuleName, "consoleWnd_iq", m_proto->m_filterInfo.iq);
+ db_set_b(NULL, m_proto->m_szModuleName, "consoleWnd_ftype", m_proto->m_filterInfo.type);
m_proto->JSetStringT(NULL, "consoleWnd_fpattern", m_proto->m_filterInfo.pattern);
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "consoleWnd_");
@@ -442,11 +442,11 @@ void CJabberDlgConsole::OnClose() void CJabberDlgConsole::OnDestroy()
{
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_MSG, BM_SETIMAGE, IMAGE_ICON, 0 ));
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_PRESENCE, BM_SETIMAGE, IMAGE_ICON, 0 ));
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_IQ, BM_SETIMAGE, IMAGE_ICON, 0 ));
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, 0 ));
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_FILTER_REFRESH, BM_SETIMAGE, IMAGE_ICON, 0 ));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_MSG, BM_SETIMAGE, IMAGE_ICON, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_PRESENCE, BM_SETIMAGE, IMAGE_ICON, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_IQ, BM_SETIMAGE, IMAGE_ICON, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER_REFRESH, BM_SETIMAGE, IMAGE_ICON, 0));
m_proto->m_pDlgConsole = NULL;
CSuper::OnDestroy();
@@ -494,7 +494,7 @@ void CJabberDlgConsole::OnProtoRefresh(WPARAM, LPARAM lParam) int CJabberDlgConsole::Resizer(UTILRESIZECONTROL *urc)
{
- switch ( urc->wId )
+ switch (urc->wId)
{
case IDC_CONSOLE:
return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT;
@@ -527,7 +527,7 @@ int CJabberDlgConsole::Resizer(UTILRESIZECONTROL *urc) INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg )
+ switch (msg)
{
case WM_GETMINMAXINFO:
{
@@ -543,7 +543,7 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) {
case IDOK:
{
- if (!m_proto->m_bJabberOnline)
+ if ( !m_proto->m_bJabberOnline)
{
MessageBox(m_hwnd, TranslateT("Can't send data while you are offline."), TranslateT("Jabber Error"), MB_ICONSTOP|MB_OK);
return TRUE;
@@ -554,10 +554,10 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) GetWindowText(GetDlgItem(m_hwnd, IDC_CONSOLEIN), textToSend, length);
int bytesProcessed = 0;
- XmlNode xmlTmp( textToSend, &bytesProcessed, NULL);
+ XmlNode xmlTmp(textToSend, &bytesProcessed, NULL);
if (xmlTmp)
{
- m_proto->m_ThreadInfo->send( xmlTmp );
+ m_proto->m_ThreadInfo->send(xmlTmp);
}
else
{
@@ -622,7 +622,7 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) for (i = 0; i < SIZEOF(filter_modes); ++i)
if (filter_modes[i].type == m_proto->m_filterInfo.type)
{
- g_ReleaseIcon(( HICON )SendDlgItemMessage( m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
break;
}
EnableWindow(GetDlgItem(m_hwnd, IDC_CB_FILTER), (m_proto->m_filterInfo.type == TFilterInfo::T_OFF) ? FALSE : TRUE);
@@ -667,12 +667,12 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return CSuper::DlgProc(msg, wParam, lParam);
}
-void __cdecl CJabberProto::ConsoleThread( void* )
+void __cdecl CJabberProto::ConsoleThread(void*)
{
MSG msg;
- while ( GetMessage(&msg, NULL, 0, 0 )) {
- if ( msg.message == WM_CREATECONSOLE ) {
- m_pDlgConsole = new CJabberDlgConsole( this );
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ if (msg.message == WM_CREATECONSOLE) {
+ m_pDlgConsole = new CJabberDlgConsole(this);
m_pDlgConsole->Show();
continue;
}
@@ -687,17 +687,17 @@ void CJabberProto::ConsoleInit() {
LoadLibraryA("riched20.dll");
InitializeCriticalSection(&m_filterInfo.csPatternLock);
- m_hThreadConsole = JForkThreadEx( &CJabberProto::ConsoleThread, 0, &m_dwConsoleThreadId );
+ m_hThreadConsole = JForkThreadEx(&CJabberProto::ConsoleThread, 0, &m_dwConsoleThreadId);
}
void CJabberProto::ConsoleUninit()
{
- if ( m_hThreadConsole ) {
+ if (m_hThreadConsole) {
PostThreadMessage(m_dwConsoleThreadId, WM_QUIT, 0, 0);
- if ( WaitForSingleObject( m_hThreadConsole, 5000 ) == WAIT_TIMEOUT) {
- TerminateThread( m_hThreadConsole, 0 );
+ if (WaitForSingleObject(m_hThreadConsole, 5000) == WAIT_TIMEOUT) {
+ TerminateThread(m_hThreadConsole, 0);
}
- CloseHandle( m_hThreadConsole );
+ CloseHandle(m_hThreadConsole);
m_hThreadConsole = NULL;
}
@@ -707,10 +707,10 @@ void CJabberProto::ConsoleUninit() INT_PTR __cdecl CJabberProto::OnMenuHandleConsole(WPARAM, LPARAM)
{
- if ( m_pDlgConsole )
- SetForegroundWindow( m_pDlgConsole->GetHwnd());
+ if (m_pDlgConsole)
+ SetForegroundWindow(m_pDlgConsole->GetHwnd());
else
- if ( m_hThreadConsole )
- PostThreadMessage( m_dwConsoleThreadId, WM_CREATECONSOLE, 0, 0 );
+ if (m_hThreadConsole)
+ PostThreadMessage(m_dwConsoleThreadId, WM_CREATECONSOLE, 0, 0);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_db_utils.h b/protocols/JabberG/src/jabber_db_utils.h index ae9a6c9781..4b09bac744 100644 --- a/protocols/JabberG/src/jabber_db_utils.h +++ b/protocols/JabberG/src/jabber_db_utils.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
@@ -42,11 +42,11 @@ struct CMDBTraits<1> enum { DBTypeId = DBVT_BYTE };
static __forceinline DBType Get(char *szModule, char *szSetting, DBType value)
{
- return DBGetContactSettingByte(NULL, szModule, szSetting, value);
+ return db_get_b(NULL, szModule, szSetting, value);
}
static __forceinline void Set(char *szModule, char *szSetting, DBType value)
{
- DBWriteContactSettingByte(NULL, szModule, szSetting, value);
+ db_set_b(NULL, szModule, szSetting, value);
}
};
@@ -57,11 +57,11 @@ struct CMDBTraits<2> enum { DBTypeId = DBVT_WORD };
static __forceinline DBType Get(char *szModule, char *szSetting, DBType value)
{
- return DBGetContactSettingWord(NULL, szModule, szSetting, value);
+ return db_get_w(NULL, szModule, szSetting, value);
}
static __forceinline void Set(char *szModule, char *szSetting, DBType value)
{
- DBWriteContactSettingWord(NULL, szModule, szSetting, value);
+ db_set_w(NULL, szModule, szSetting, value);
}
};
@@ -76,11 +76,11 @@ struct CMDBTraits<4> }
static __forceinline DBType Get(char *szModule, char *szSetting, DBType value)
{
- return DBGetContactSettingDword(NULL, szModule, szSetting, value);
+ return db_get_dw(NULL, szModule, szSetting, value);
}
static __forceinline void Set(char *szModule, char *szSetting, DBType value)
{
- DBWriteContactSettingDword(NULL, szModule, szSetting, value);
+ db_set_dw(NULL, szModule, szSetting, value);
}
};
@@ -142,7 +142,7 @@ public: {
CMString result;
DBVARIANT dbv;
- if (!DBGetContactSettingTString(NULL, m_proto->m_szModuleName, m_szSetting, &dbv))
+ if ( !DBGetContactSettingTString(NULL, m_proto->m_szModuleName, m_szSetting, &dbv))
{
result = dbv.ptszVal;
DBFreeVariant(&dbv);
@@ -151,7 +151,7 @@ public: }
__forceinline Type operator= (Type value)
{
- DBWriteContactSettingTString(NULL, m_proto->m_szModuleName, m_szSetting, value);
+ db_set_ts(NULL, m_proto->m_szModuleName, m_szSetting, value);
return value;
}
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index eadfd2d5d1..8b37a6677d 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -164,109 +164,109 @@ static struct static void sttApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode);
-void CJabberProto::OnIqResultServiceDiscoveryInfo( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo* pInfo)
{
m_SDManager.Lock();
- CJabberSDNode* pNode = m_SDManager.FindByIqId( pInfo->GetIqId(), TRUE );
- if ( !pNode ) {
+ CJabberSDNode* pNode = m_SDManager.FindByIqId(pInfo->GetIqId(), TRUE);
+ if ( !pNode) {
m_SDManager.Unlock();
return;
}
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML query = xmlGetChild( iqNode , "query" );
- if ( !query )
- pNode->SetInfoRequestId( JABBER_DISCO_RESULT_ERROR );
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML query = xmlGetChild(iqNode , "query");
+ if ( !query)
+ pNode->SetInfoRequestId(JABBER_DISCO_RESULT_ERROR);
else {
HXML feature;
int i;
- for ( i = 1; ( feature = xmlGetNthChild( query, _T("feature"), i )) != NULL; i++ )
- pNode->AddFeature( xmlGetAttrValue( feature, _T("var")));
+ for (i = 1; (feature = xmlGetNthChild(query, _T("feature"), i)) != NULL; i++)
+ pNode->AddFeature(xmlGetAttrValue(feature, _T("var")));
HXML identity;
- for ( i = 1; ( identity = xmlGetNthChild( query, _T("identity"), i )) != NULL; i++ )
- pNode->AddIdentity( xmlGetAttrValue( identity, _T("category")), xmlGetAttrValue( identity, _T("type")), xmlGetAttrValue( identity, _T("name")));
+ for (i = 1; (identity = xmlGetNthChild(query, _T("identity"), i)) != NULL; i++)
+ pNode->AddIdentity(xmlGetAttrValue(identity, _T("category")), xmlGetAttrValue(identity, _T("type")), xmlGetAttrValue(identity, _T("name")));
- pNode->SetInfoRequestId( JABBER_DISCO_RESULT_OK );
- pNode->SetInfoRequestErrorText( NULL );
+ pNode->SetInfoRequestId(JABBER_DISCO_RESULT_OK);
+ pNode->SetInfoRequestErrorText(NULL);
}
}
else {
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR ) {
- HXML errorNode = xmlGetChild( iqNode , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
- pNode->SetInfoRequestErrorText( str );
- mir_free( str );
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
+ HXML errorNode = xmlGetChild(iqNode , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
+ pNode->SetInfoRequestErrorText(str);
+ mir_free(str);
}
- else pNode->SetInfoRequestErrorText( TranslateT("request timeout."));
+ else pNode->SetInfoRequestErrorText(TranslateT("request timeout."));
- pNode->SetInfoRequestId( JABBER_DISCO_RESULT_ERROR );
+ pNode->SetInfoRequestId(JABBER_DISCO_RESULT_ERROR);
}
m_SDManager.Unlock();
- if ( m_pDlgServiceDiscovery ) {
+ if (m_pDlgServiceDiscovery) {
ApplyNodeIcon(pNode->GetTreeItemHandle(), pNode);
- PostMessage( m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0);
}
}
-void CJabberProto::OnIqResultServiceDiscoveryItems( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo* pInfo)
{
m_SDManager.Lock();
- CJabberSDNode* pNode = m_SDManager.FindByIqId( pInfo->GetIqId(), FALSE );
- if ( !pNode ) {
+ CJabberSDNode* pNode = m_SDManager.FindByIqId(pInfo->GetIqId(), FALSE);
+ if ( !pNode) {
m_SDManager.Unlock();
return;
}
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML query = xmlGetChild( iqNode , "query" );
- if ( !query )
- pNode->SetItemsRequestId( JABBER_DISCO_RESULT_ERROR );
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML query = xmlGetChild(iqNode , "query");
+ if ( !query)
+ pNode->SetItemsRequestId(JABBER_DISCO_RESULT_ERROR);
else {
HXML item;
- for ( int i = 1; ( item = xmlGetNthChild( query, _T("item"), i )) != NULL; i++ ) {
- pNode->AddChildNode( xmlGetAttrValue( item, _T("jid")), xmlGetAttrValue( item, _T("node")), xmlGetAttrValue( item, _T("name")));
+ for (int i = 1; (item = xmlGetNthChild(query, _T("item"), i)) != NULL; i++) {
+ pNode->AddChildNode(xmlGetAttrValue(item, _T("jid")), xmlGetAttrValue(item, _T("node")), xmlGetAttrValue(item, _T("name")));
}
- pNode->SetItemsRequestId( JABBER_DISCO_RESULT_OK );
- pNode->SetItemsRequestErrorText( NULL );
+ pNode->SetItemsRequestId(JABBER_DISCO_RESULT_OK);
+ pNode->SetItemsRequestErrorText(NULL);
}
}
else {
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR ) {
- HXML errorNode = xmlGetChild( iqNode , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
- pNode->SetItemsRequestErrorText( str );
- mir_free( str );
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) {
+ HXML errorNode = xmlGetChild(iqNode , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
+ pNode->SetItemsRequestErrorText(str);
+ mir_free(str);
}
else {
- pNode->SetItemsRequestErrorText( _T("request timeout."));
+ pNode->SetItemsRequestErrorText(_T("request timeout."));
}
- pNode->SetItemsRequestId( JABBER_DISCO_RESULT_ERROR );
+ pNode->SetItemsRequestId(JABBER_DISCO_RESULT_ERROR);
}
m_SDManager.Unlock();
- if ( m_pDlgServiceDiscovery ) {
+ if (m_pDlgServiceDiscovery) {
ApplyNodeIcon(pNode->GetTreeItemHandle(), pNode);
- PostMessage( m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0);
}
}
-void CJabberProto::OnIqResultServiceDiscoveryRootInfo( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultServiceDiscoveryRootInfo(HXML iqNode, CJabberIqInfo* pInfo)
{
- if (!pInfo->m_pUserData) return;
+ if ( !pInfo->m_pUserData) return;
m_SDManager.Lock();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML query = xmlGetChild( iqNode , "query" );
- if ( query ) {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML query = xmlGetChild(iqNode , "query");
+ if (query) {
HXML feature;
int i;
- for ( i = 1; ( feature = xmlGetNthChild( query, _T("feature"), i )) != NULL; i++ ) {
- if ( !lstrcmp( xmlGetAttrValue( feature, _T("var")), (TCHAR *)pInfo->m_pUserData)) {
- CJabberSDNode *pNode = m_SDManager.AddPrimaryNode( pInfo->GetReceiver(), xmlGetAttrValue( iqNode, _T("node")), NULL);
- SendBothRequests( pNode, NULL );
+ for (i = 1; (feature = xmlGetNthChild(query, _T("feature"), i)) != NULL; i++) {
+ if ( !lstrcmp(xmlGetAttrValue(feature, _T("var")), (TCHAR *)pInfo->m_pUserData)) {
+ CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), xmlGetAttrValue(iqNode, _T("node")), NULL);
+ SendBothRequests(pNode, NULL);
break;
} } } }
m_SDManager.Unlock();
@@ -274,59 +274,59 @@ void CJabberProto::OnIqResultServiceDiscoveryRootInfo( HXML iqNode, CJabberIqInf UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_REFRESH);
}
-void CJabberProto::OnIqResultServiceDiscoveryRootItems( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultServiceDiscoveryRootItems(HXML iqNode, CJabberIqInfo* pInfo)
{
- if (!pInfo->m_pUserData)
+ if ( !pInfo->m_pUserData)
return;
- XmlNode packet( NULL );
+ XmlNode packet(NULL);
m_SDManager.Lock();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML query = xmlGetChild( iqNode , "query" );
- if ( query ) {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML query = xmlGetChild(iqNode , "query");
+ if (query) {
HXML item;
- for ( int i = 1; ( item = xmlGetNthChild( query, _T("item"), i )) != NULL; i++ ) {
- const TCHAR *szJid = xmlGetAttrValue( item, _T("jid"));
- const TCHAR *szNode = xmlGetAttrValue( item, _T("node"));
- CJabberIqInfo* pNewInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid );
+ for (int i = 1; (item = xmlGetNthChild(query, _T("item"), i)) != NULL; i++) {
+ const TCHAR *szJid = xmlGetAttrValue(item, _T("jid"));
+ const TCHAR *szNode = xmlGetAttrValue(item, _T("node"));
+ CJabberIqInfo* pNewInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid);
pNewInfo->m_pUserData = pInfo->m_pUserData;
- pNewInfo->SetTimeout( 30000 );
+ pNewInfo->SetTimeout(30000);
- XmlNodeIq iq( pNewInfo );
- iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO)) << XATTR( _T("node"), szNode );
- xmlAddChild( packet, iq );
+ XmlNodeIq iq(pNewInfo);
+ iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO)) << XATTR(_T("node"), szNode);
+ xmlAddChild(packet, iq);
} } }
m_SDManager.Unlock();
- if ( xmlGetChild( packet ,0))
- m_ThreadInfo->send( packet );
+ if (xmlGetChild(packet ,0))
+ m_ThreadInfo->send(packet);
}
BOOL CJabberProto::SendInfoRequest(CJabberSDNode* pNode, HXML parent)
{
- if ( !pNode || !m_bJabberOnline )
+ if ( !pNode || !m_bJabberOnline)
return FALSE;
// disco#info
if ( !pNode->GetInfoRequestId()) {
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
- pInfo->SetTimeout( 30000 );
- pNode->SetInfoRequestId( pInfo->GetIqId());
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
+ pInfo->SetTimeout(30000);
+ pNode->SetInfoRequestId(pInfo->GetIqId());
- XmlNodeIq iq( pInfo );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO));
- if ( pNode->GetNode())
- xmlAddAttr( query, _T("node"), pNode->GetNode());
+ XmlNodeIq iq(pInfo);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ if (pNode->GetNode())
+ xmlAddAttr(query, _T("node"), pNode->GetNode());
- if ( parent )
- xmlAddChild( parent, iq );
+ if (parent)
+ xmlAddChild(parent, iq);
else
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
- if ( m_pDlgServiceDiscovery ) {
+ if (m_pDlgServiceDiscovery) {
ApplyNodeIcon(pNode->GetTreeItemHandle(), pNode);
- PostMessage( m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0);
}
return TRUE;
@@ -334,46 +334,46 @@ BOOL CJabberProto::SendInfoRequest(CJabberSDNode* pNode, HXML parent) BOOL CJabberProto::SendBothRequests(CJabberSDNode* pNode, HXML parent)
{
- if ( !pNode || !m_bJabberOnline )
+ if ( !pNode || !m_bJabberOnline)
return FALSE;
// disco#info
if ( !pNode->GetInfoRequestId()) {
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
- pInfo->SetTimeout( 30000 );
- pNode->SetInfoRequestId( pInfo->GetIqId());
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryInfo, JABBER_IQ_TYPE_GET, pNode->GetJid());
+ pInfo->SetTimeout(30000);
+ pNode->SetInfoRequestId(pInfo->GetIqId());
- XmlNodeIq iq( pInfo );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO));
- if ( pNode->GetNode())
- xmlAddAttr( query, _T("node"), pNode->GetNode());
+ XmlNodeIq iq(pInfo);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ if (pNode->GetNode())
+ xmlAddAttr(query, _T("node"), pNode->GetNode());
- if ( parent )
- xmlAddChild( parent, iq );
+ if (parent)
+ xmlAddChild(parent, iq);
else
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
// disco#items
if ( !pNode->GetItemsRequestId()) {
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultServiceDiscoveryItems, JABBER_IQ_TYPE_GET, pNode->GetJid());
- pInfo->SetTimeout( 30000 );
- pNode->SetItemsRequestId( pInfo->GetIqId());
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryItems, JABBER_IQ_TYPE_GET, pNode->GetJid());
+ pInfo->SetTimeout(30000);
+ pNode->SetItemsRequestId(pInfo->GetIqId());
- XmlNodeIq iq( pInfo );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS));
- if ( pNode->GetNode())
- xmlAddAttr( query, _T("node"), pNode->GetNode());
+ XmlNodeIq iq(pInfo);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS));
+ if (pNode->GetNode())
+ xmlAddAttr(query, _T("node"), pNode->GetNode());
- if ( parent )
- xmlAddChild( parent, iq );
+ if (parent)
+ xmlAddChild(parent, iq);
else
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
- if ( m_pDlgServiceDiscovery ) {
+ if (m_pDlgServiceDiscovery) {
ApplyNodeIcon(pNode->GetTreeItemHandle(), pNode);
- PostMessage( m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0);
}
return TRUE;
@@ -383,61 +383,61 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) {
TCHAR szJid[ JABBER_MAX_JID_LEN ];
TCHAR szNode[ 512 ];
- if ( !GetDlgItemText( hwndDlg, IDC_COMBO_JID, szJid, SIZEOF( szJid )))
+ if ( !GetDlgItemText(hwndDlg, IDC_COMBO_JID, szJid, SIZEOF(szJid)))
szJid[ 0 ] = 0;
- if ( !GetDlgItemText( hwndDlg, IDC_COMBO_NODE, szNode, SIZEOF( szNode )))
+ if ( !GetDlgItemText(hwndDlg, IDC_COMBO_NODE, szNode, SIZEOF(szNode)))
szNode[ 0 ] = 0;
ComboAddRecentString(hwndDlg, IDC_COMBO_JID, "discoWnd_rcJid", szJid);
ComboAddRecentString(hwndDlg, IDC_COMBO_NODE, "discoWnd_rcNode", szNode);
- if ( _tcslen( szJid )) {
+ if (_tcslen(szJid)) {
HWND hwndList = GetDlgItem(hwndDlg, IDC_TREE_DISCO);
TreeList_Reset(hwndList);
m_SDManager.Lock();
m_SDManager.RemoveAll();
- if (!lstrcmp(szJid, _T(SD_FAKEJID_MYAGENTS))) {
+ if ( !lstrcmp(szJid, _T(SD_FAKEJID_MYAGENTS))) {
sttBrowseMode = SD_BROWSE_MYAGENTS;
JABBER_LIST_ITEM *item = NULL;
LISTFOREACH(i, this, LIST_ROSTER)
{
- if (( item=ListGetItemPtrFromIndex( i )) != NULL ) {
- if ( _tcschr( item->jid, '@' )==NULL && _tcschr( item->jid, '/' )==NULL && item->subscription!=SUB_NONE ) {
- HANDLE hContact = HContactFromJID( item->jid );
- if ( hContact != NULL )
- JSetByte( hContact, "IsTransport", TRUE );
+ if ((item=ListGetItemPtrFromIndex(i)) != NULL) {
+ if (_tcschr(item->jid, '@')==NULL && _tcschr(item->jid, '/')==NULL && item->subscription!=SUB_NONE) {
+ HANDLE hContact = HContactFromJID(item->jid);
+ if (hContact != NULL)
+ JSetByte(hContact, "IsTransport", TRUE);
- if ( m_lstTransports.getIndex( item->jid ) == -1 )
- m_lstTransports.insert( mir_tstrdup( item->jid ));
+ if (m_lstTransports.getIndex(item->jid) == -1)
+ m_lstTransports.insert(mir_tstrdup(item->jid));
CJabberSDNode* pNode = m_SDManager.AddPrimaryNode(item->jid, NULL, NULL);
- SendBothRequests( pNode, NULL );
+ SendBothRequests(pNode, NULL);
} }
} }
- else if (!lstrcmp(szJid, _T(SD_FAKEJID_CONFERENCES))) {
+ else if ( !lstrcmp(szJid, _T(SD_FAKEJID_CONFERENCES))) {
sttBrowseMode = SD_BROWSE_CONFERENCES;
TCHAR *szServerJid = mir_a2t(m_ThreadInfo->server);
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid );
- pInfo->m_pUserData = (void *)_T(JABBER_FEAT_MUC);
- pInfo->SetTimeout( 30000 );
- XmlNodeIq iq( pInfo );
- iq << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS));
- m_ThreadInfo->send( iq );
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
+ pInfo->m_pUserData = (void*)_T(JABBER_FEAT_MUC);
+ pInfo->SetTimeout(30000);
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS));
+ m_ThreadInfo->send(iq);
mir_free(szServerJid);
}
- else if (!lstrcmp(szJid, _T(SD_FAKEJID_AGENTS))) {
+ else if ( !lstrcmp(szJid, _T(SD_FAKEJID_AGENTS))) {
sttBrowseMode = SD_BROWSE_AGENTS;
TCHAR *szServerJid = mir_a2t(m_ThreadInfo->server);
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid );
- pInfo->m_pUserData = (void *)_T("jabber:iq:gateway");
- pInfo->SetTimeout( 30000 );
- XmlNodeIq iq( pInfo );
- iq << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS));
- m_ThreadInfo->send( iq );
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, szServerJid);
+ pInfo->m_pUserData = (void*)_T("jabber:iq:gateway");
+ pInfo->SetTimeout(30000);
+ XmlNodeIq iq(pInfo);
+ iq << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS));
+ m_ThreadInfo->send(iq);
mir_free(szServerJid);
}
- else if (!lstrcmp(szJid, _T(SD_FAKEJID_FAVORITES))) {
+ else if ( !lstrcmp(szJid, _T(SD_FAKEJID_FAVORITES))) {
sttBrowseMode = SD_BROWSE_FAVORITES;
int count = JGetDword(NULL, "discoWnd_favCount", 0);
for (int i = 0; i < count; ++i)
@@ -445,26 +445,26 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favName_%d", i);
- if (!JGetStringT(NULL, setting, &dbv)) {
+ if ( !JGetStringT(NULL, setting, &dbv)) {
DBVARIANT dbvJid, dbvNode;
mir_snprintf(setting, sizeof(setting), "discoWnd_favJID_%d", i);
JGetStringT(NULL, setting, &dbvJid);
mir_snprintf(setting, sizeof(setting), "discoWnd_favNode_%d", i);
JGetStringT(NULL, setting, &dbvNode);
CJabberSDNode* pNode = m_SDManager.AddPrimaryNode(dbvJid.ptszVal, dbvNode.ptszVal, dbv.ptszVal);
- SendBothRequests( pNode, NULL );
- JFreeVariant(&dbv);
- JFreeVariant(&dbvJid);
- JFreeVariant(&dbvNode);
+ SendBothRequests(pNode, NULL);
+ db_free(&dbv);
+ db_free(&dbvJid);
+ db_free(&dbvNode);
} } }
else {
sttBrowseMode = SD_BROWSE_NORMAL;
- CJabberSDNode* pNode = m_SDManager.AddPrimaryNode(szJid, _tcslen( szNode ) ? szNode : NULL, NULL);
- SendBothRequests( pNode, NULL );
+ CJabberSDNode* pNode = m_SDManager.AddPrimaryNode(szJid, _tcslen(szNode) ? szNode : NULL, NULL);
+ SendBothRequests(pNode, NULL);
}
m_SDManager.Unlock();
- PostMessage( hwndDlg, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(hwndDlg, WM_JABBER_REFRESH, 0, 0);
}
}
@@ -485,7 +485,7 @@ BOOL CJabberProto::IsNodeRegistered(CJabberSDNode *pNode) void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode)
{
- if (!hItem || !pNode) return;
+ if ( !hItem || !pNode) return;
int iIcon = -1, iOverlay = -1;
@@ -509,13 +509,13 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) for (int i = 0; i < SIZEOF(sttNodeIcons); ++i)
{
- if (!sttNodeIcons[i].iconIndex && !sttNodeIcons[i].iconName) continue;
+ if ( !sttNodeIcons[i].iconIndex && !sttNodeIcons[i].iconName) continue;
if (sttNodeIcons[i].category)
{
CJabberSDIdentity *iIdentity;
for (iIdentity = pNode->GetFirstIdentity(); iIdentity; iIdentity = iIdentity->GetNext())
- if (!lstrcmp(iIdentity->GetCategory(), sttNodeIcons[i].category) &&
+ if ( !lstrcmp(iIdentity->GetCategory(), sttNodeIcons[i].category) &&
(!sttNodeIcons[i].type || !lstrcmp(iIdentity->GetType(), sttNodeIcons[i].type)))
{
iIcon = sttNodeIcons[i].listIndex;
@@ -528,7 +528,7 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) {
CJabberSDFeature *iFeature;
for (iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!lstrcmp(iFeature->GetVar(), sttNodeIcons[i].feature))
+ if ( !lstrcmp(iFeature->GetVar(), sttNodeIcons[i].feature))
{
iIcon = sttNodeIcons[i].listIndex;
break;
@@ -542,7 +542,7 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) BOOL CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode* pNode)
{
- if (!m_pDlgServiceDiscovery) return FALSE;
+ if ( !m_pDlgServiceDiscovery) return FALSE;
CJabberSDNode* pTmp = pNode;
while (pTmp) {
@@ -553,17 +553,17 @@ BOOL CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode* pNode) (LPARAM)pTmp);
TreeList_AppendColumn(hNewItem, pTmp->GetJid());
TreeList_AppendColumn(hNewItem, pTmp->GetNode());
- if (!pTmp->GetInfoRequestId())
+ if ( !pTmp->GetInfoRequestId())
TreeList_MakeFakeParent(hNewItem, TRUE);
else
TreeList_MakeFakeParent(hNewItem, FALSE);
- pTmp->SetTreeItemHandle( hNewItem );
+ pTmp->SetTreeItemHandle(hNewItem);
}
ApplyNodeIcon(pNode->GetTreeItemHandle(), pNode);
- if ( pTmp->GetFirstChildNode())
- SyncTree( pTmp->GetTreeItemHandle(), pTmp->GetFirstChildNode());
+ if (pTmp->GetFirstChildNode())
+ SyncTree(pTmp->GetTreeItemHandle(), pTmp->GetFirstChildNode());
pTmp = pTmp->GetNext();
}
@@ -631,18 +631,18 @@ void CJabberDlgDiscovery::OnInitDialog() {
CSuper::OnInitDialog();
-// TranslateDialogDefault( m_hwnd );
- WindowSetIcon( m_hwnd, m_proto, "servicediscovery" );
+// TranslateDialogDefault(m_hwnd);
+ WindowSetIcon(m_hwnd, m_proto, "servicediscovery");
int i;
- if ( m_jid ) {
- SetDlgItemText( m_hwnd, IDC_COMBO_JID, m_jid );
- SetDlgItemText( m_hwnd, IDC_COMBO_NODE, _T(""));
+ if (m_jid) {
+ SetDlgItemText(m_hwnd, IDC_COMBO_JID, m_jid);
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
m_focusEditAfterBrowse = false;
} else {
- SetDlgItemTextA( m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->server );
- SetDlgItemText( m_hwnd, IDC_COMBO_NODE, _T(""));
+ SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->server);
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
m_focusEditAfterBrowse = true;
}
@@ -651,7 +651,7 @@ void CJabberDlgDiscovery::OnInitDialog() m_btnBookmarks.MakePush();
CheckDlgButton(m_hwnd,
- DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "discoWnd_useTree", 1) ?
+ db_get_b(NULL, m_proto->m_szModuleName, "discoWnd_useTree", 1) ?
IDC_BTN_VIEWTREE : IDC_BTN_VIEWLIST,
TRUE);
@@ -667,15 +667,15 @@ void CJabberDlgDiscovery::OnInitDialog() HWND hwndList = m_lstDiscoTree.GetHwnd();//GetDlgItem(m_hwnd, IDC_TREE_DISCO);
LVCOLUMN lvc = {0};
lvc.mask = LVCF_SUBITEM|LVCF_WIDTH|LVCF_TEXT;
- lvc.cx = DBGetContactSettingWord(NULL, m_proto->m_szModuleName, "discoWnd_cx0", 200);
+ lvc.cx = db_get_w(NULL, m_proto->m_szModuleName, "discoWnd_cx0", 200);
lvc.iSubItem = 0;
lvc.pszText = TranslateT("Node hierarchy");
ListView_InsertColumn(hwndList, 0, &lvc);
- lvc.cx = DBGetContactSettingWord(NULL, m_proto->m_szModuleName, "discoWnd_cx1", 200);
+ lvc.cx = db_get_w(NULL, m_proto->m_szModuleName, "discoWnd_cx1", 200);
lvc.iSubItem = 1;
lvc.pszText = _T("JID");
ListView_InsertColumn(hwndList, 1, &lvc);
- lvc.cx = DBGetContactSettingWord(NULL, m_proto->m_szModuleName, "discoWnd_cx2", 200);
+ lvc.cx = db_get_w(NULL, m_proto->m_szModuleName, "discoWnd_cx2", 200);
lvc.iSubItem = 2;
lvc.pszText = TranslateT("Node");
ListView_InsertColumn(hwndList, 2, &lvc);
@@ -702,29 +702,29 @@ void CJabberDlgDiscovery::OnInitDialog() TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_progress"), SD_OVERLAY_PROGRESS);
TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_ok"), SD_OVERLAY_REGISTERED);
- TreeList_SetMode(hwndList, DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "discoWnd_useTree", 1) ? TLM_TREE : TLM_REPORT);
+ TreeList_SetMode(hwndList, db_get_b(NULL, m_proto->m_szModuleName, "discoWnd_useTree", 1) ? TLM_TREE : TLM_REPORT);
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "discoWnd_");
}
void CJabberDlgDiscovery::OnClose()
{
- DBWriteContactSettingByte(NULL, m_proto->m_szModuleName, "discoWnd_useTree", IsDlgButtonChecked(m_hwnd, IDC_BTN_VIEWTREE));
+ db_set_b(NULL, m_proto->m_szModuleName, "discoWnd_useTree", IsDlgButtonChecked(m_hwnd, IDC_BTN_VIEWTREE));
HWND hwndList = GetDlgItem(m_hwnd, IDC_TREE_DISCO);
LVCOLUMN lvc = {0};
lvc.mask = LVCF_WIDTH;
ListView_GetColumn(hwndList, 0, &lvc);
- DBWriteContactSettingWord(NULL, m_proto->m_szModuleName, "discoWnd_cx0", lvc.cx);
+ db_set_w(NULL, m_proto->m_szModuleName, "discoWnd_cx0", lvc.cx);
ListView_GetColumn(hwndList, 1, &lvc);
- DBWriteContactSettingWord(NULL, m_proto->m_szModuleName, "discoWnd_cx1", lvc.cx);
+ db_set_w(NULL, m_proto->m_szModuleName, "discoWnd_cx1", lvc.cx);
ListView_GetColumn(hwndList, 2, &lvc);
- DBWriteContactSettingWord(NULL, m_proto->m_szModuleName, "discoWnd_cx2", lvc.cx);
+ db_set_w(NULL, m_proto->m_szModuleName, "discoWnd_cx2", lvc.cx);
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "discoWnd_");
- DestroyWindow( m_hwnd );
+ DestroyWindow(m_hwnd);
CSuper::OnClose();
}
@@ -744,7 +744,7 @@ int CJabberDlgDiscovery::Resizer(UTILRESIZECONTROL *urc) {
RECT rc;
- switch ( urc->wId ) {
+ switch (urc->wId) {
case IDC_COMBO_JID:
{
GetWindowRect(GetDlgItem(m_hwnd, urc->wId), &rc);
@@ -799,9 +799,9 @@ void CJabberDlgDiscovery::btnViewAsList_OnClick(CCtrlButton *) void CJabberDlgDiscovery::btnGoHome_OnClick(CCtrlButton *)
{
- SetDlgItemTextA( m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->server );
- SetDlgItemText( m_hwnd, IDC_COMBO_NODE, _T(""));
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->server);
+ SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *)
@@ -813,7 +813,7 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favName_%d", i);
- if (!m_proto->JGetStringT(NULL, setting, &dbv))
+ if ( !m_proto->JGetStringT(NULL, setting, &dbv))
{
HMENU hSubMenu = CreatePopupMenu();
AppendMenu(hSubMenu, MF_STRING, 100+i*10+0, TranslateT("Navigate"));
@@ -821,7 +821,7 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) AppendMenu(hSubMenu, MF_STRING, 100+i*10+1, TranslateT("Remove"));
AppendMenu(hMenu, MF_POPUP|MF_STRING, (UINT_PTR)hSubMenu, dbv.ptszVal);
}
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
int res = 0;
if (GetMenuItemCount(hMenu)) {
@@ -865,13 +865,13 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favJID_%d", res);
- if (!m_proto->JGetStringT(NULL, setting, &dbv)) SetDlgItemText(m_hwnd, IDC_COMBO_JID, dbv.ptszVal);
- JFreeVariant(&dbv);
+ if ( !m_proto->JGetStringT(NULL, setting, &dbv)) SetDlgItemText(m_hwnd, IDC_COMBO_JID, dbv.ptszVal);
+ db_free(&dbv);
mir_snprintf(setting, sizeof(setting), "discoWnd_favNode_%d", res);
- if (!m_proto->JGetStringT(NULL, setting, &dbv)) SetDlgItemText(m_hwnd, IDC_COMBO_NODE, dbv.ptszVal);
- JFreeVariant(&dbv);
+ if ( !m_proto->JGetStringT(NULL, setting, &dbv)) SetDlgItemText(m_hwnd, IDC_COMBO_NODE, dbv.ptszVal);
+ db_free(&dbv);
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
} else
if (res == 1)
@@ -906,7 +906,7 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) break;
}
SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
CheckDlgButton(m_hwnd, IDC_BTN_FAVORITE, FALSE);
@@ -915,21 +915,21 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) void CJabberDlgDiscovery::btnRefresh_OnClick(CCtrlButton *)
{
HTREELISTITEM hItem = (HTREELISTITEM)TreeList_GetActiveItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO));
- if (!hItem) return;
+ if ( !hItem) return;
m_proto->m_SDManager.Lock();
- XmlNode packet( NULL );
- CJabberSDNode* pNode = (CJabberSDNode* )TreeList_GetData(hItem);
- if ( pNode ) {
+ XmlNode packet(NULL);
+ CJabberSDNode* pNode = (CJabberSDNode*)TreeList_GetData(hItem);
+ if (pNode) {
TreeList_ResetItem(GetDlgItem(m_hwnd, IDC_TREE_DISCO), hItem);
pNode->ResetInfo();
- m_proto->SendBothRequests( pNode, packet );
+ m_proto->SendBothRequests(pNode, packet);
TreeList_MakeFakeParent(hItem, FALSE);
}
m_proto->m_SDManager.Unlock();
- if ( xmlGetChild( packet ,0))
- m_proto->m_ThreadInfo->send( packet );
+ if (xmlGetChild(packet ,0))
+ m_proto->m_ThreadInfo->send(packet);
}
void CJabberDlgDiscovery::btnBrowse_OnClick(CCtrlButton *)
@@ -951,7 +951,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (TreeList_ProcessMessage(m_hwnd, msg, wParam, lParam, IDC_TREE_DISCO, &result))
return result;
- switch ( msg ) {
+ switch (msg) {
case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
@@ -964,7 +964,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (m_proto->m_nSDBrowseMode == SD_BROWSE_MYAGENTS) {
SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_MYAGENTS));
SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
break;
@@ -985,17 +985,17 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) CJabberSDNode* pNode = m_proto->m_SDManager.GetPrimaryNode();
while (pNode)
{
- if ( pNode->GetJid()) {
+ if (pNode->GetJid()) {
if ( !pNode->GetTreeItemHandle()) {
HTREELISTITEM hNewItem = TreeList_AddItem(
- GetDlgItem( m_hwnd, IDC_TREE_DISCO), NULL,
+ GetDlgItem(m_hwnd, IDC_TREE_DISCO), NULL,
pNode->GetName() ? pNode->GetName() : pNode->GetJid(),
(LPARAM)pNode);
TreeList_AppendColumn(hNewItem, pNode->GetJid());
TreeList_AppendColumn(hNewItem, pNode->GetNode());
- pNode->SetTreeItemHandle( hNewItem );
+ pNode->SetTreeItemHandle(hNewItem);
} }
- m_proto->SyncTree( NULL, pNode );
+ m_proto->SyncTree(NULL, pNode);
pNode = pNode->GetNext();
}
m_proto->m_SDManager.Unlock();
@@ -1020,25 +1020,25 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (iLast < 0) iLast = ListView_GetItemCount(hwndList) - 1;
m_proto->m_SDManager.Lock();
- XmlNode packet( NULL );
+ XmlNode packet(NULL);
for (int i = iFirst; i <= iLast; ++i)
{
LVITEM lvi = {0};
lvi.mask = LVIF_PARAM;
lvi.iItem = i;
ListView_GetItem(hwndList, &lvi);
- if (!lvi.lParam)
+ if ( !lvi.lParam)
continue;
CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData((HTREELISTITEM)lvi.lParam);
- if (!pNode || pNode->GetInfoRequestId())
+ if ( !pNode || pNode->GetInfoRequestId())
continue;
m_proto->SendInfoRequest(pNode, packet);
}
m_proto->m_SDManager.Unlock();
- if ( xmlGetChild( packet, 0))
- m_proto->m_ThreadInfo->send( packet );
+ if (xmlGetChild(packet, 0))
+ m_proto->m_ThreadInfo->send(packet);
KillTimer(m_hwnd, AUTODISCO_TIMER);
m_proto->m_dwSDLastRefresh = GetTickCount();
@@ -1050,9 +1050,9 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if (GetWindowLongPtr((HWND)wParam, GWL_ID) == IDC_TREE_DISCO)
{
HWND hwndList = (HWND)wParam;
- POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) };
+ POINT pt = { (signed short)LOWORD(lParam), (signed short)HIWORD(lParam) };
- if (( pt.x == -1 ) && ( pt.y == -1 )) {
+ if ((pt.x == -1) && (pt.y == -1)) {
LVITEM lvi = {0};
lvi.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED);
if (lvi.iItem < 0) return FALSE;
@@ -1065,18 +1065,18 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) }
HTREELISTITEM hItem = TreeList_GetActiveItem(hwndList);
- if (!hItem) break;
+ if ( !hItem) break;
CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData(hItem);
- if (!pNode) break;
+ if ( !pNode) break;
m_proto->ServiceDiscoveryShowMenu(pNode, hItem, pt);
}
break;
case WM_NOTIFY:
- if ( wParam == IDC_TREE_DISCO ) {
- NMHDR* pHeader = (NMHDR* )lParam;
- if ( pHeader->code == LVN_GETINFOTIP ) {
+ if (wParam == IDC_TREE_DISCO) {
+ NMHDR* pHeader = (NMHDR*)lParam;
+ if (pHeader->code == LVN_GETINFOTIP) {
NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
LVITEM lvi;
lvi.mask = LVIF_PARAM;
@@ -1084,31 +1084,31 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) ListView_GetItem(pHeader->hwndFrom, &lvi);
HTREELISTITEM hItem = (HTREELISTITEM)lvi.lParam;
m_proto->m_SDManager.Lock();
- CJabberSDNode* pNode = (CJabberSDNode* )TreeList_GetData(hItem);
- if ( pNode ) {
- pNode->GetTooltipText( pInfoTip->pszText, pInfoTip->cchTextMax );
+ CJabberSDNode* pNode = (CJabberSDNode*)TreeList_GetData(hItem);
+ if (pNode) {
+ pNode->GetTooltipText(pInfoTip->pszText, pInfoTip->cchTextMax);
}
m_proto->m_SDManager.Unlock();
}
- else if ( pHeader->code == TVN_ITEMEXPANDED ) {
+ else if (pHeader->code == TVN_ITEMEXPANDED) {
NMTREEVIEW *pNmTreeView = (NMTREEVIEW *)lParam;
HTREELISTITEM hItem = (HTREELISTITEM)pNmTreeView->itemNew.hItem;
m_proto->m_SDManager.Lock();
- XmlNode packet( NULL );
+ XmlNode packet(NULL);
CJabberSDNode* pNode;
- pNode = (CJabberSDNode* )TreeList_GetData(hItem);
- if ( pNode )
+ pNode = (CJabberSDNode*)TreeList_GetData(hItem);
+ if (pNode)
{
- m_proto->SendBothRequests( pNode, packet );
+ m_proto->SendBothRequests(pNode, packet);
TreeList_MakeFakeParent(hItem, FALSE);
}
m_proto->m_SDManager.Unlock();
- if ( xmlGetChild( packet ))
- m_proto->m_ThreadInfo->send( packet );
+ if (xmlGetChild(packet))
+ m_proto->m_ThreadInfo->send(packet);
}
- else if ( pHeader->code == NM_CUSTOMDRAW ) {
+ else if (pHeader->code == NM_CUSTOMDRAW) {
LPNMLVCUSTOMDRAW lpnmlvcd = (LPNMLVCUSTOMDRAW)lParam;
if (lpnmlvcd->nmcd.dwDrawStage != CDDS_PREPAINT)
return CDRF_DODEFAULT;
@@ -1134,13 +1134,13 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case IDOK:
{
HWND hwndFocus = GetFocus();
- if (!hwndFocus) return TRUE;
+ if ( !hwndFocus) return TRUE;
if (GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_TXT_FILTERTEXT)
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BTN_FILTERAPPLY, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BTN_FILTERAPPLY, 0), 0);
else if (m_hwnd == (hwndFocus = GetParent(hwndFocus)))
break;
else if ((GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_COMBO_NODE) || (GetWindowLongPtr(hwndFocus, GWL_ID) == IDC_COMBO_JID))
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
return TRUE;
}
case IDCANCEL:
@@ -1162,7 +1162,7 @@ INT_PTR CJabberDlgDiscovery::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) }
// extern references to used functions:
-void SearchAddToRecent( TCHAR* szAddr, HWND hwndDialog = NULL );
+void SearchAddToRecent(TCHAR* szAddr, HWND hwndDialog = NULL);
void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM hItem, POINT pt)
{
@@ -1253,7 +1253,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM continue;
}
- if (!items[i].feature)
+ if ( !items[i].feature)
{
if (items[i].title)
{
@@ -1265,7 +1265,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM AppendMenu(hMenu, MF_STRING, items[i].action, TranslateTS(items[i].title));
lastSeparator = FALSE;
} else
- if (!lastSeparator)
+ if ( !lastSeparator)
{
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
lastSeparator = TRUE;
@@ -1276,7 +1276,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM bool bFeatureOk = !bFilterItems;
if (bFilterItems)
for (CJabberSDFeature *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!lstrcmp(iFeature->GetVar(), items[i].feature))
+ if ( !lstrcmp(iFeature->GetVar(), items[i].feature))
{
bFeatureOk = true;
break;
@@ -1289,7 +1289,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM AppendMenu(hMenu, MF_STRING, items[i].action, TranslateTS(items[i].title));
lastSeparator = FALSE;
} else
- if (!lastSeparator)
+ if ( !lastSeparator)
{
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
lastSeparator = TRUE;
@@ -1297,7 +1297,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM }
}
- if (!GetMenuItemCount(hMenu))
+ if ( !GetMenuItemCount(hMenu))
{
DestroyMenu(hMenu);
return;
@@ -1311,44 +1311,44 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_REFRESH:
{
m_SDManager.Lock();
- XmlNode packet( NULL );
- if ( pNode )
+ XmlNode packet(NULL);
+ if (pNode)
{
TreeList_ResetItem(GetDlgItem(m_pDlgServiceDiscovery->GetHwnd(), IDC_TREE_DISCO), hItem);
pNode->ResetInfo();
- SendBothRequests( pNode, packet );
+ SendBothRequests(pNode, packet);
TreeList_MakeFakeParent(hItem, FALSE);
}
m_SDManager.Unlock();
- if ( xmlGetChild( packet ))
- m_ThreadInfo->send( packet );
+ if (xmlGetChild(packet))
+ m_ThreadInfo->send(packet);
break;
}
case SD_ACT_REFRESHCHILDREN:
{
m_SDManager.Lock();
- XmlNode packet( NULL );
- for (int iChild = TreeList_GetChildrenCount(hItem); iChild--; ) {
+ XmlNode packet(NULL);
+ for (int iChild = TreeList_GetChildrenCount(hItem); iChild--;) {
HTREELISTITEM hNode = TreeList_GetChild(hItem, iChild);
CJabberSDNode *pNode = (CJabberSDNode *)TreeList_GetData(hNode);
- if ( pNode )
+ if (pNode)
{
TreeList_ResetItem(GetDlgItem(m_pDlgServiceDiscovery->GetHwnd(), IDC_TREE_DISCO), hNode);
pNode->ResetInfo();
- SendBothRequests( pNode, packet );
+ SendBothRequests(pNode, packet);
TreeList_MakeFakeParent(hNode, FALSE);
}
- if ( xmlGetChildCount( packet ) > 50 ) {
- m_ThreadInfo->send( packet );
- packet = XmlNode( NULL );
+ if (xmlGetChildCount(packet) > 50) {
+ m_ThreadInfo->send(packet);
+ packet = XmlNode(NULL);
} }
m_SDManager.Unlock();
- if ( xmlGetChildCount( packet ))
- m_ThreadInfo->send( packet );
+ if (xmlGetChildCount(packet))
+ m_ThreadInfo->send(packet);
break;
}
@@ -1387,7 +1387,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM break;
case SD_ACT_ADHOC:
- ContactMenuAdhocCommands( new CJabberAdhocStartupParams( this, pNode->GetJid(), pNode->GetNode()));
+ ContactMenuAdhocCommands(new CJabberAdhocStartupParams(this, pNode->GetJid(), pNode->GetNode()));
break;
case SD_ACT_ADDDIRECTORY:
@@ -1397,11 +1397,11 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_PROXY:
m_options.BsDirect = FALSE;
m_options.BsProxyManual = TRUE;
- JSetStringT( NULL, "BsProxyServer", pNode->GetJid());
+ JSetStringT(NULL, "BsProxyServer", pNode->GetJid());
break;
case SD_ACT_JOIN:
- if ( jabberChatDllPresent )
+ if (jabberChatDllPresent)
GroupchatJoinRoomByJid(m_pDlgServiceDiscovery->GetHwnd(), pNode->GetJid());
else
JabberChatDllError();
@@ -1409,26 +1409,26 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_BOOKMARK:
{
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_BOOKMARK, pNode->GetJid());
- if ( item == NULL ) {
- item = ListGetItemPtr( LIST_BOOKMARK, pNode->GetJid());
- if ( item == NULL ) {
- item = ListAdd( LIST_ROOM, pNode->GetJid());
- item->name = mir_tstrdup( pNode->GetName());
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid());
+ if (item == NULL) {
+ item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid());
+ if (item == NULL) {
+ item = ListAdd(LIST_ROOM, pNode->GetJid());
+ item->name = mir_tstrdup(pNode->GetName());
}
- if ( item != NULL ) {
+ if (item != NULL) {
item->type = _T("conference");
- AddEditBookmark( item );
+ AddEditBookmark(item);
} }
break;
}
case SD_ACT_USERMENU:
{
- HANDLE hContact = HContactFromJID( pNode->GetJid());
- if ( !hContact ) {
- hContact = DBCreateContact( pNode->GetJid(), pNode->GetName(), TRUE, FALSE );
- JABBER_LIST_ITEM* item = ListAdd( LIST_VCARD_TEMP, pNode->GetJid());
+ HANDLE hContact = HContactFromJID(pNode->GetJid());
+ if ( !hContact) {
+ hContact = DBCreateContact(pNode->GetJid(), pNode->GetName(), TRUE, FALSE);
+ JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
}
HMENU hContactMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0);
@@ -1442,17 +1442,17 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM {
TCHAR * jid = pNode->GetJid();
HANDLE hContact = HContactFromJID(pNode->GetJid());
- if ( !hContact ) {
+ if ( !hContact) {
JABBER_SEARCH_RESULT jsr={0};
- mir_sntprintf( jsr.jid, SIZEOF(jsr.jid), _T("%s"), jid );
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
- hContact = ( HANDLE )CallProtoService( m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, ( LPARAM )&jsr );
+ mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), jid);
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
+ hContact = (HANDLE)CallProtoService(m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&jsr);
}
- if ( ListGetItemPtr( LIST_VCARD_TEMP, pNode->GetJid()) == NULL ) {
- JABBER_LIST_ITEM* item = ListAdd( LIST_VCARD_TEMP, pNode->GetJid());
+ if (ListGetItemPtr(LIST_VCARD_TEMP, pNode->GetJid()) == NULL) {
+ JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
- if ( item->resource == NULL )
- ListAddResource( LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, NULL, 0);
+ if (item->resource == NULL)
+ ListAddResource(LIST_VCARD_TEMP, jid, ID_STATUS_OFFLINE, NULL, 0);
}
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
break;
@@ -1461,22 +1461,22 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_ROSTER:
{
HANDLE hContact = DBCreateContact(pNode->GetJid(), pNode->GetName(), FALSE, FALSE);
- DBDeleteContactSetting( hContact, "CList", "NotOnList" );
- JABBER_LIST_ITEM* item = ListAdd( LIST_VCARD_TEMP, pNode->GetJid());
+ DBDeleteContactSetting(hContact, "CList", "NotOnList");
+ JABBER_LIST_ITEM* item = ListAdd(LIST_VCARD_TEMP, pNode->GetJid());
item->bUseResource = TRUE;
break;
}
case SD_ACT_LOGON:
case SD_ACT_LOGOFF:
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), pNode->GetJid()) << XATTR( _T("type"), ( res != SD_ACT_LOGON ) ? _T("unavailable") : NULL ));
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), pNode->GetJid()) << XATTR(_T("type"), (res != SD_ACT_LOGON) ? _T("unavailable") : NULL));
break;
case SD_ACT_UNREGISTER:
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), pNode->GetJid()) << XQUERY( _T(JABBER_FEAT_REGISTER)) << XCHILD( _T("remove")));
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), pNode->GetJid()) << XQUERY(_T(JABBER_FEAT_REGISTER)) << XCHILD(_T("remove")));
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext()) << XQUERY( _T(JABBER_FEAT_IQ_ROSTER))
- << XCHILD( _T("item")) << XATTR( _T("jid"), pNode->GetJid()) << XATTR( _T("subscription"), _T("remove")));
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext()) << XQUERY(_T(JABBER_FEAT_IQ_ROSTER))
+ << XCHILD(_T("item")) << XATTR(_T("jid"), pNode->GetJid()) << XATTR(_T("subscription"), _T("remove")));
break;
default:
@@ -1491,12 +1491,12 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM void CJabberProto::LaunchServiceDiscovery(TCHAR *jid)
{
- if ( m_pDlgServiceDiscovery ) {
- SetForegroundWindow( m_pDlgServiceDiscovery->GetHwnd());
+ if (m_pDlgServiceDiscovery) {
+ SetForegroundWindow(m_pDlgServiceDiscovery->GetHwnd());
if (jid) {
- SetDlgItemText( m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_JID, jid);
- SetDlgItemTextA( m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_NODE, "");
- PostMessage( m_pDlgServiceDiscovery->GetHwnd(), WM_COMMAND, MAKEWPARAM( IDC_BUTTON_BROWSE, 0 ), 0 );
+ SetDlgItemText(m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_JID, jid);
+ SetDlgItemTextA(m_pDlgServiceDiscovery->GetHwnd(), IDC_COMBO_NODE, "");
+ PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
} else {
m_pDlgServiceDiscovery = new CJabberDlgDiscovery(this, jid);
@@ -1504,25 +1504,25 @@ void CJabberProto::LaunchServiceDiscovery(TCHAR *jid) }
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscovery( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscovery(WPARAM, LPARAM)
{
LaunchServiceDiscovery(NULL);
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryMyTransports( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryMyTransports(WPARAM, LPARAM)
{
LaunchServiceDiscovery(_T(SD_FAKEJID_MYAGENTS));
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryTransports( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryTransports(WPARAM, LPARAM)
{
LaunchServiceDiscovery(_T(SD_FAKEJID_AGENTS));
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryConferences( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleServiceDiscoveryConferences(WPARAM, LPARAM)
{
LaunchServiceDiscovery(_T(SD_FAKEJID_CONFERENCES));
return 0;
diff --git a/protocols/JabberG/src/jabber_disco.h b/protocols/JabberG/src/jabber_disco.h index 79df12781e..5bd2ab3f3a 100644 --- a/protocols/JabberG/src/jabber_disco.h +++ b/protocols/JabberG/src/jabber_disco.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2005-07 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2005-07 Maxim Mluhov
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
@@ -132,7 +132,7 @@ protected: TCHAR *m_szInfoError;
TCHAR *m_szItemsError;
public:
- CJabberSDNode( const TCHAR *szJid = NULL, const TCHAR *szNode = NULL, const TCHAR *szName = NULL)
+ CJabberSDNode(const TCHAR *szJid = NULL, const TCHAR *szNode = NULL, const TCHAR *szName = NULL)
{
m_szJid = mir_tstrdup(szJid);
m_szNode = mir_tstrdup(szNode);
@@ -155,21 +155,21 @@ public: }
BOOL RemoveAll()
{
- replaceStrT( m_szJid, NULL );
- replaceStrT( m_szNode, NULL );
- replaceStrT( m_szName, NULL );
- replaceStrT( m_szInfoError, NULL );
- replaceStrT( m_szItemsError, NULL );
- if ( m_pIdentities )
+ replaceStrT(m_szJid, NULL);
+ replaceStrT(m_szNode, NULL);
+ replaceStrT(m_szName, NULL);
+ replaceStrT(m_szInfoError, NULL);
+ replaceStrT(m_szItemsError, NULL);
+ if (m_pIdentities)
delete m_pIdentities;
m_pIdentities = NULL;
- if ( m_pFeatures )
+ if (m_pFeatures)
delete m_pFeatures;
m_pFeatures = NULL;
- if ( m_pNext )
+ if (m_pNext)
delete m_pNext;
m_pNext = NULL;
- if ( m_pChild )
+ if (m_pChild)
delete m_pChild;
m_pChild = NULL;
m_nInfoRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED;
@@ -181,15 +181,15 @@ public: }
BOOL ResetInfo()
{
- replaceStrT( m_szInfoError, NULL );
- replaceStrT( m_szItemsError, NULL );
- if ( m_pIdentities )
+ replaceStrT(m_szInfoError, NULL);
+ replaceStrT(m_szItemsError, NULL);
+ if (m_pIdentities)
delete m_pIdentities;
m_pIdentities = NULL;
- if ( m_pFeatures )
+ if (m_pFeatures)
delete m_pFeatures;
m_pFeatures = NULL;
- if ( m_pChild )
+ if (m_pChild)
delete m_pChild;
m_pChild = NULL;
m_nInfoRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED;
@@ -273,19 +273,19 @@ public: }
CJabberSDNode* FindByIqId(int nIqId, BOOL bInfoId = TRUE)
{
- if (( m_nInfoRequestId == nIqId && bInfoId ) || ( m_nItemsRequestId == nIqId && !bInfoId ))
+ if ((m_nInfoRequestId == nIqId && bInfoId) || (m_nItemsRequestId == nIqId && !bInfoId))
return this;
CJabberSDNode *pNode = NULL;
- if ( m_pChild && (pNode = m_pChild->FindByIqId( nIqId, bInfoId )))
+ if (m_pChild && (pNode = m_pChild->FindByIqId(nIqId, bInfoId)))
return pNode;
CJabberSDNode *pTmpNode = NULL;
pNode = m_pNext;
- while ( pNode ) {
- if (( pNode->m_nInfoRequestId == nIqId && bInfoId ) || ( pNode->m_nItemsRequestId == nIqId && !bInfoId ))
+ while (pNode) {
+ if ((pNode->m_nInfoRequestId == nIqId && bInfoId) || (pNode->m_nItemsRequestId == nIqId && !bInfoId))
return pNode;
- if ( pNode->m_pChild && (pTmpNode = pNode->m_pChild->FindByIqId( nIqId, bInfoId )))
+ if (pNode->m_pChild && (pTmpNode = pNode->m_pChild->FindByIqId(nIqId, bInfoId)))
return pTmpNode;
pNode = pNode->GetNext();
}
@@ -293,54 +293,54 @@ public: }
BOOL AddFeature(const TCHAR *szFeature)
{
- if ( !szFeature )
+ if ( !szFeature)
return FALSE;
- CJabberSDFeature *pFeature = new CJabberSDFeature( szFeature );
- if ( !pFeature )
+ CJabberSDFeature *pFeature = new CJabberSDFeature(szFeature);
+ if ( !pFeature)
return FALSE;
- pFeature->SetNext( m_pFeatures );
+ pFeature->SetNext(m_pFeatures);
m_pFeatures = pFeature;
return TRUE;
}
BOOL AddIdentity(const TCHAR *szCategory, const TCHAR *szType, const TCHAR *szName)
{
- if ( !szCategory || !szType )
+ if ( !szCategory || !szType)
return FALSE;
- CJabberSDIdentity *pIdentity = new CJabberSDIdentity( szCategory, szType, szName );
- if ( !pIdentity )
+ CJabberSDIdentity *pIdentity = new CJabberSDIdentity(szCategory, szType, szName);
+ if ( !pIdentity)
return FALSE;
- pIdentity->SetNext( m_pIdentities );
+ pIdentity->SetNext(m_pIdentities);
m_pIdentities = pIdentity;
return TRUE;
}
BOOL AddChildNode(const TCHAR *szJid, const TCHAR *szNode, const TCHAR *szName)
{
- if ( !szJid )
+ if ( !szJid)
return FALSE;
- CJabberSDNode *pNode = new CJabberSDNode( szJid, szNode, szName );
- if ( !pNode )
+ CJabberSDNode *pNode = new CJabberSDNode(szJid, szNode, szName);
+ if ( !pNode)
return FALSE;
- pNode->SetNext( m_pChild );
+ pNode->SetNext(m_pChild);
m_pChild = pNode;
return TRUE;
}
BOOL AppendString(TCHAR **ppBuffer, TCHAR *szString)
{
- if ( !*ppBuffer ) {
- *ppBuffer = mir_tstrdup( szString );
+ if ( !*ppBuffer) {
+ *ppBuffer = mir_tstrdup(szString);
return TRUE;
}
- *ppBuffer = (TCHAR *)mir_realloc( *ppBuffer, (_tcslen( *ppBuffer) + _tcslen(szString) + 1 ) * sizeof( TCHAR ));
+ *ppBuffer = (TCHAR *)mir_realloc(*ppBuffer, (_tcslen(*ppBuffer) + _tcslen(szString) + 1) * sizeof(TCHAR));
_tcscat(*ppBuffer, szString);
return TRUE;
@@ -361,65 +361,65 @@ public: TCHAR szTmp[ 8192 ];
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T("Jid: %s\r\n"), m_szJid );
- AppendString( &szBuffer, szTmp );
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("Jid: %s\r\n"), m_szJid);
+ AppendString(&szBuffer, szTmp);
- if ( m_szNode ) {
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T("%s: %s\r\n"), TranslateT("Node"), m_szNode );
- AppendString( &szBuffer, szTmp );
+ if (m_szNode) {
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s: %s\r\n"), TranslateT("Node"), m_szNode);
+ AppendString(&szBuffer, szTmp);
}
- if ( m_pIdentities ) {
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T("\r\n%s:\r\n"), TranslateT("Identities"));
- AppendString( &szBuffer, szTmp );
+ if (m_pIdentities) {
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("\r\n%s:\r\n"), TranslateT("Identities"));
+ AppendString(&szBuffer, szTmp);
CJabberSDIdentity *pIdentity = m_pIdentities;
- while ( pIdentity ) {
- if ( pIdentity->GetName())
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T(" %c %s (%s: %s, %s: %s)\r\n"),
+ while (pIdentity) {
+ if (pIdentity->GetName())
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T(" %c %s (%s: %s, %s: %s)\r\n"),
CHR_BULLET, pIdentity->GetName(),
TranslateT("category"), pIdentity->GetCategory(),
TranslateT("type"), pIdentity->GetType());
else
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T(" %c %s: %s, %s: %s\r\n"),
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T(" %c %s: %s, %s: %s\r\n"),
CHR_BULLET,
TranslateT("Category"), pIdentity->GetCategory(),
TranslateT("Type"), pIdentity->GetType());
- AppendString( &szBuffer, szTmp );
+ AppendString(&szBuffer, szTmp);
pIdentity = pIdentity->GetNext();
}
}
- if ( m_pFeatures ) {
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T("\r\n%s:\r\n"), TranslateT("Supported features"));
- AppendString( &szBuffer, szTmp );
+ if (m_pFeatures) {
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("\r\n%s:\r\n"), TranslateT("Supported features"));
+ AppendString(&szBuffer, szTmp);
CJabberSDFeature *pFeature = m_pFeatures;
- while ( pFeature ) {
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T(" %c %s\r\n"), CHR_BULLET, pFeature->GetVar());
+ while (pFeature) {
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T(" %c %s\r\n"), CHR_BULLET, pFeature->GetVar());
- AppendString( &szBuffer, szTmp );
+ AppendString(&szBuffer, szTmp);
pFeature = pFeature->GetNext();
}
}
- if ( m_szInfoError ) {
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T("\r\n%s: %s\r\n"), TranslateT("Info request error"), m_szInfoError );
- AppendString( &szBuffer, szTmp );
+ if (m_szInfoError) {
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("\r\n%s: %s\r\n"), TranslateT("Info request error"), m_szInfoError);
+ AppendString(&szBuffer, szTmp);
}
- if ( m_szItemsError ) {
- mir_sntprintf( szTmp, SIZEOF( szTmp ), _T("\r\n%s: %s\r\n"), TranslateT("Items request error"), m_szItemsError );
- AppendString( &szBuffer, szTmp );
+ if (m_szItemsError) {
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("\r\n%s: %s\r\n"), TranslateT("Items request error"), m_szItemsError);
+ AppendString(&szBuffer, szTmp);
}
szBuffer[lstrlen(szBuffer)-2] = 0; // remove CR/LF
- mir_sntprintf( szText, nMaxLength, _T("%s"), szBuffer );
+ mir_sntprintf(szText, nMaxLength, _T("%s"), szBuffer);
- mir_free( szBuffer );
+ mir_free(szBuffer);
return TRUE;
}
@@ -462,14 +462,14 @@ public: }
CJabberSDNode* AddPrimaryNode(const TCHAR *szJid, const TCHAR *szNode, const TCHAR *szName)
{
- if ( !szJid )
+ if ( !szJid)
return FALSE;
- CJabberSDNode *pNode = new CJabberSDNode( szJid, szNode, szName );
- if ( !pNode )
+ CJabberSDNode *pNode = new CJabberSDNode(szJid, szNode, szName);
+ if ( !pNode)
return NULL;
- pNode->SetNext( m_pPrimaryNodes );
+ pNode->SetNext(m_pPrimaryNodes);
m_pPrimaryNodes = pNode;
return pNode;
@@ -479,8 +479,8 @@ public: CJabberSDNode *pNode = NULL;
CJabberSDNode *pTmpNode = NULL;
pNode = m_pPrimaryNodes;
- while ( pNode ) {
- if ( pTmpNode = pNode->FindByIqId( nIqId, bInfoId ))
+ while (pNode) {
+ if (pTmpNode = pNode->FindByIqId(nIqId, bInfoId))
return pTmpNode;
pNode = pNode->GetNext();
}
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp index 3f416aa54b..2ac6da3a18 100644 --- a/protocols/JabberG/src/jabber_events.cpp +++ b/protocols/JabberG/src/jabber_events.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -39,28 +39,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////////////////
// OnContactDeleted - processes a contact deletion
-int CJabberProto::OnContactDeleted( WPARAM wParam, LPARAM )
+int CJabberProto::OnContactDeleted(WPARAM wParam, LPARAM)
{
- if ( !m_bJabberOnline ) // should never happen
+ if ( !m_bJabberOnline) // should never happen
return 0;
DBVARIANT dbv;
- if ( !JGetStringT(( HANDLE ) wParam, JGetByte( (HANDLE ) wParam, "ChatRoom", 0 )?(char*)"ChatRoomID":(char*)"jid", &dbv )) {
- if ( ListExist( LIST_ROSTER, dbv.ptszVal )) {
- if ( !_tcschr( dbv.ptszVal, _T( '@' ))) {
+ if ( !JGetStringT((HANDLE)wParam, JGetByte((HANDLE) wParam, "ChatRoom", 0)?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
+ if (ListExist(LIST_ROSTER, dbv.ptszVal)) {
+ if ( !_tcschr(dbv.ptszVal, _T('@'))) {
TCHAR szStrippedJid[JABBER_MAX_JID_LEN];
- JabberStripJid( m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid));
- TCHAR *szDog = _tcschr( szStrippedJid, _T('@'));
- if ( szDog && _tcsicmp( szDog + 1, dbv.ptszVal ))
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), dbv.ptszVal ) << XQUERY( _T(JABBER_FEAT_REGISTER)) << XCHILD( _T("remove")));
+ JabberStripJid(m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid));
+ TCHAR *szDog = _tcschr(szStrippedJid, _T('@'));
+ if (szDog && _tcsicmp(szDog + 1, dbv.ptszVal))
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), dbv.ptszVal) << XQUERY(_T(JABBER_FEAT_REGISTER)) << XCHILD(_T("remove")));
}
// Remove from roster, server also handles the presence unsubscription process.
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext()) << XQUERY( _T(JABBER_FEAT_IQ_ROSTER))
- << XCHILD( _T("item")) << XATTR( _T("jid"), dbv.ptszVal ) << XATTR( _T("subscription"), _T("remove")));
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext()) << XQUERY(_T(JABBER_FEAT_IQ_ROSTER))
+ << XCHILD(_T("item")) << XATTR(_T("jid"), dbv.ptszVal) << XATTR(_T("subscription"), _T("remove")));
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
return 0;
}
@@ -68,146 +68,146 @@ int CJabberProto::OnContactDeleted( WPARAM wParam, LPARAM ) /////////////////////////////////////////////////////////////////////////////////////////
// JabberDbSettingChanged - process database changes
-static TCHAR* sttSettingToTchar( DBCONTACTWRITESETTING* cws )
+static TCHAR* sttSettingToTchar(DBCONTACTWRITESETTING* cws)
{
- switch( cws->value.type ) {
+ switch(cws->value.type) {
case DBVT_ASCIIZ:
- return mir_a2t( cws->value.pszVal );
+ return mir_a2t(cws->value.pszVal);
case DBVT_UTF8:
- return mir_utf8decodeT( cws->value.pszVal );
+ return mir_utf8decodeT(cws->value.pszVal);
case DBVT_WCHAR:
- return mir_u2t( cws->value.pwszVal );
+ return mir_u2t(cws->value.pwszVal);
}
return NULL;
}
-void __cdecl CJabberProto::OnRenameGroup( DBCONTACTWRITESETTING* cws, HANDLE hContact )
+void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING* cws, HANDLE hContact)
{
DBVARIANT jid, dbv;
- if ( JGetStringT( hContact, "jid", &jid ))
+ if (JGetStringT(hContact, "jid", &jid))
return;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, jid.ptszVal );
- JFreeVariant( &jid );
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, jid.ptszVal);
+ db_free(&jid);
+ if (item == NULL)
return;
TCHAR* nick;
- if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbv )) {
- nick = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !DBGetContactSettingTString(hContact, "CList", "MyHandle", &dbv)) {
+ nick = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
- else if ( !JGetStringT( hContact, "Nick", &dbv )) {
- nick = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ else if ( !JGetStringT(hContact, "Nick", &dbv)) {
+ nick = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
- else nick = JabberNickFromJID( item->jid );
- if ( nick == NULL )
+ else nick = JabberNickFromJID(item->jid);
+ if (nick == NULL)
return;
- if ( cws->value.type == DBVT_DELETED ) {
- if ( item->group != NULL ) {
- Log( "Group set to nothing" );
- AddContactToRoster( item->jid, nick, NULL );
+ if (cws->value.type == DBVT_DELETED) {
+ if (item->group != NULL) {
+ Log("Group set to nothing");
+ AddContactToRoster(item->jid, nick, NULL);
}
}
else {
- TCHAR* p = sttSettingToTchar( cws );
- if ( cws->value.pszVal != NULL && lstrcmp( p, item->group )) {
- Log( "Group set to " TCHAR_STR_PARAM, p );
- if ( p )
- AddContactToRoster( item->jid, nick, p );
+ TCHAR* p = sttSettingToTchar(cws);
+ if (cws->value.pszVal != NULL && lstrcmp(p, item->group)) {
+ Log("Group set to " TCHAR_STR_PARAM, p);
+ if (p)
+ AddContactToRoster(item->jid, nick, p);
}
- mir_free( p );
+ mir_free(p);
}
- mir_free( nick );
+ mir_free(nick);
}
-void __cdecl CJabberProto::OnRenameContact( DBCONTACTWRITESETTING* cws, HANDLE hContact )
+void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING* cws, HANDLE hContact)
{
DBVARIANT jid;
- if ( JGetStringT( hContact, "jid", &jid ))
+ if (JGetStringT(hContact, "jid", &jid))
return;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, jid.ptszVal );
- JFreeVariant( &jid );
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, jid.ptszVal);
+ db_free(&jid);
+ if (item == NULL)
return;
- if ( cws->value.type == DBVT_DELETED ) {
- TCHAR* nick = ( TCHAR* )CallService( MS_CLIST_GETCONTACTDISPLAYNAME, ( WPARAM )hContact, GCDNF_NOMYHANDLE | GCDNF_TCHAR );
- AddContactToRoster( item->jid, nick, item->group );
+ if (cws->value.type == DBVT_DELETED) {
+ TCHAR* nick = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_NOMYHANDLE | GCDNF_TCHAR);
+ AddContactToRoster(item->jid, nick, item->group);
mir_free(nick);
return;
}
- TCHAR* newNick = sttSettingToTchar( cws );
- if ( newNick ) {
- if ( lstrcmp( item->nick, newNick )) {
- Log( "Renaming contact " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM " -> " TCHAR_STR_PARAM, item->jid, item->nick, newNick );
- AddContactToRoster( item->jid, newNick, item->group );
+ TCHAR* newNick = sttSettingToTchar(cws);
+ if (newNick) {
+ if (lstrcmp(item->nick, newNick)) {
+ Log("Renaming contact " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM " -> " TCHAR_STR_PARAM, item->jid, item->nick, newNick);
+ AddContactToRoster(item->jid, newNick, item->group);
}
- mir_free( newNick );
+ mir_free(newNick);
} }
-void __cdecl CJabberProto::OnAddContactForever( DBCONTACTWRITESETTING* cws, HANDLE hContact )
+void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING* cws, HANDLE hContact)
{
- if ( cws->value.type != DBVT_DELETED && !( cws->value.type==DBVT_BYTE && cws->value.bVal==0 ))
+ if (cws->value.type != DBVT_DELETED && !(cws->value.type==DBVT_BYTE && cws->value.bVal==0))
return;
DBVARIANT jid, dbv;
- if ( JGetStringT( hContact, "jid", &jid ))
+ if (JGetStringT(hContact, "jid", &jid))
return;
TCHAR *nick;
- Log( "Add " TCHAR_STR_PARAM " permanently to list", jid.pszVal );
- if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbv )) {
- nick = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ Log("Add " TCHAR_STR_PARAM " permanently to list", jid.pszVal);
+ if ( !DBGetContactSettingTString(hContact, "CList", "MyHandle", &dbv)) {
+ nick = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
- else if ( !JGetStringT( hContact, "Nick", &dbv )) {
- nick = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ else if ( !JGetStringT(hContact, "Nick", &dbv)) {
+ nick = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
- else nick = JabberNickFromJID( jid.ptszVal );
- if ( nick == NULL ) {
- JFreeVariant( &jid );
+ else nick = JabberNickFromJID(jid.ptszVal);
+ if (nick == NULL) {
+ db_free(&jid);
return;
}
- if ( !DBGetContactSettingTString( hContact, "CList", "Group", &dbv )) {
- AddContactToRoster( jid.ptszVal, nick, dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) {
+ AddContactToRoster(jid.ptszVal, nick, dbv.ptszVal);
+ db_free(&dbv);
}
- else AddContactToRoster( jid.ptszVal, nick, NULL );
+ else AddContactToRoster(jid.ptszVal, nick, NULL);
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), jid.ptszVal ) << XATTR( _T("type"), _T("subscribe")));
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), jid.ptszVal) << XATTR(_T("type"), _T("subscribe")));
- SendGetVcard( jid.ptszVal );
+ SendGetVcard(jid.ptszVal);
- mir_free( nick );
- DBDeleteContactSetting( hContact, "CList", "Hidden" );
- JFreeVariant( &jid );
+ mir_free(nick);
+ DBDeleteContactSetting(hContact, "CList", "Hidden");
+ db_free(&jid);
}
-int __cdecl CJabberProto::OnDbSettingChanged( WPARAM wParam, LPARAM lParam )
+int __cdecl CJabberProto::OnDbSettingChanged(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact = ( HANDLE ) wParam;
- if ( hContact == NULL || !m_bJabberOnline )
+ HANDLE hContact = (HANDLE)wParam;
+ if (hContact == NULL || !m_bJabberOnline)
return 0;
- DBCONTACTWRITESETTING* cws = ( DBCONTACTWRITESETTING* )lParam;
- if ( strcmp( cws->szModule, "CList" ))
+ DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam;
+ if (strcmp(cws->szModule, "CList"))
return 0;
- if ( !strcmp( cws->szSetting, "Group" ))
- OnRenameGroup( cws, hContact );
- else if ( !strcmp( cws->szSetting, "MyHandle" ))
- OnRenameContact( cws, hContact );
- else if ( !strcmp( cws->szSetting, "NotOnList" ))
- OnAddContactForever( cws, hContact );
+ if ( !strcmp(cws->szSetting, "Group"))
+ OnRenameGroup(cws, hContact);
+ else if ( !strcmp(cws->szSetting, "MyHandle"))
+ OnRenameContact(cws, hContact);
+ else if ( !strcmp(cws->szSetting, "NotOnList"))
+ OnAddContactForever(cws, hContact);
return 0;
}
@@ -215,7 +215,7 @@ int __cdecl CJabberProto::OnDbSettingChanged( WPARAM wParam, LPARAM lParam ) /////////////////////////////////////////////////////////////////////////////////////////
// OnIdleChanged - tracks idle start time for XEP-0012 support
-int CJabberProto::OnIdleChanged( WPARAM, LPARAM lParam )
+int CJabberProto::OnIdleChanged(WPARAM, LPARAM lParam)
{
// don't report idle time, if user disabled
if (lParam & IDF_PRIVACY) {
@@ -223,11 +223,11 @@ int CJabberProto::OnIdleChanged( WPARAM, LPARAM lParam ) return 0;
}
- if ( lParam & IDF_ISIDLE ) {
+ if (lParam & IDF_ISIDLE) {
MIRANDA_IDLE_INFO mii = { 0 };
- mii.cbSize = sizeof( mii );
- CallService( MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii );
- m_tmJabberIdleStartTime = time( 0 ) - mii.idleTime * 60;
+ mii.cbSize = sizeof(mii);
+ CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii);
+ m_tmJabberIdleStartTime = time(0) - mii.idleTime * 60;
} else
m_tmJabberIdleStartTime = 0;
return 0;
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 5db215d024..3c53957be8 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.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
@@ -29,72 +29,72 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define JABBER_NETWORK_BUFFER_SIZE 2048
-void __cdecl CJabberProto::FileReceiveThread( filetransfer* ft )
+void __cdecl CJabberProto::FileReceiveThread(filetransfer *ft)
{
char* buffer;
int datalen;
- ThreadData info( this, JABBER_SESSION_NORMAL );
+ ThreadData info(this, JABBER_SESSION_NORMAL);
- Log( "Thread started: type=file_receive server='%s' port='%d'", ft->httpHostName, ft->httpPort );
+ Log("Thread started: type=file_receive server='%s' port='%d'", ft->httpHostName, ft->httpPort);
ft->type = FT_OOB;
- if (( buffer=( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE )) == NULL ) {
- Log( "Cannot allocate network buffer, thread ended" );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0 );
+ if ((buffer=(char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE)) == NULL) {
+ Log("Cannot allocate network buffer, thread ended");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
delete ft;
return;
}
NETLIBOPENCONNECTION nloc = { 0 };
- nloc.cbSize = sizeof( nloc );
- nloc.cbSize = sizeof( NETLIBOPENCONNECTION );
+ nloc.cbSize = sizeof(nloc);
+ nloc.cbSize = sizeof(NETLIBOPENCONNECTION);
nloc.szHost = ft->httpHostName;
nloc.wPort = ft->httpPort;
- info.s = ( HANDLE ) CallService( MS_NETLIB_OPENCONNECTION, ( WPARAM ) m_hNetlibUser, ( LPARAM )&nloc );
- if ( info.s == NULL ) {
- Log( "Connection failed ( %d ), thread ended", WSAGetLastError());
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0 );
- mir_free( buffer );
+ info.s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
+ if (info.s == NULL) {
+ Log("Connection failed (%d), thread ended", WSAGetLastError());
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
+ mir_free(buffer);
delete ft;
return;
}
ft->s = info.s;
- info.send( "GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", ft->httpPath, ft->httpHostName );
+ info.send("GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", ft->httpPath, ft->httpHostName);
ft->state = FT_CONNECTING;
- Log( "Entering file_receive recv loop" );
+ Log("Entering file_receive recv loop");
datalen = 0;
- while ( ft->state != FT_DONE && ft->state != FT_ERROR ) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR) {
int recvResult, bytesParsed;
- Log( "Waiting for data..." );
- recvResult = info.recv( buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen );
- if ( recvResult <= 0 )
+ Log("Waiting for data...");
+ recvResult = info.recv(buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen);
+ if (recvResult <= 0)
break;
datalen += recvResult;
- bytesParsed = FileReceiveParse( ft, buffer, datalen );
- if ( bytesParsed < datalen )
- memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
+ bytesParsed = FileReceiveParse(ft, buffer, datalen);
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
datalen -= bytesParsed;
}
ft->s = NULL;
- if ( ft->state==FT_DONE || ( ft->state==FT_RECEIVING && ft->std.currentFileSize < 0 ))
+ if (ft->state==FT_DONE || (ft->state==FT_RECEIVING && ft->std.currentFileSize < 0))
ft->complete();
- Log( "Thread ended: type=file_receive server='%s'", ft->httpHostName );
+ Log("Thread ended: type=file_receive server='%s'", ft->httpHostName);
- mir_free( buffer );
+ mir_free(buffer);
delete ft;
}
-int CJabberProto::FileReceiveParse( filetransfer* ft, char* buffer, int datalen )
+int CJabberProto::FileReceiveParse(filetransfer *ft, char* buffer, int datalen)
{
char* p, *q, *s, *eob;
char* str;
@@ -103,49 +103,49 @@ int CJabberProto::FileReceiveParse( filetransfer* ft, char* buffer, int datalen eob = buffer + datalen;
p = buffer;
num = 0;
- while ( true ) {
- if ( ft->state==FT_CONNECTING || ft->state==FT_INITIALIZING ) {
- for ( q=p; q+1<eob && ( *q!='\r' || *( q+1 )!='\n' ); q++ );
- if ( q+1 < eob ) {
- if (( str=( char* )mir_alloc( q-p+1 )) != NULL ) {
- strncpy( str, p, q-p );
+ while (true) {
+ if (ft->state==FT_CONNECTING || ft->state==FT_INITIALIZING) {
+ for (q=p; q+1<eob && (*q!='\r' || *(q+1)!='\n'); q++);
+ if (q+1 < eob) {
+ if ((str=(char*)mir_alloc(q-p+1)) != NULL) {
+ strncpy(str, p, q-p);
str[q-p] = '\0';
- Log( "FT Got: %s", str );
- if ( ft->state == FT_CONNECTING ) {
+ Log("FT Got: %s", str);
+ if (ft->state == FT_CONNECTING) {
// looking for "HTTP/1.1 200 OK"
- if ( sscanf( str, "HTTP/%*d.%*d %d %*s", &code )==1 && code==200 ) {
+ if (sscanf(str, "HTTP/%*d.%*d %d %*s", &code)==1 && code==200) {
ft->state = FT_INITIALIZING;
ft->std.currentFileSize = -1;
- Log( "Change to FT_INITIALIZING" );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0 );
+ Log("Change to FT_INITIALIZING");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0);
}
}
else { // FT_INITIALIZING
- if ( str[0] == '\0' ) {
+ if (str[0] == '\0') {
TCHAR* s;
- if (( s = _tcsrchr( ft->httpPath, '/' )) != NULL )
+ if ((s = _tcsrchr(ft->httpPath, '/')) != NULL)
s++;
else
s = ft->httpPath;
- ft->std.tszCurrentFile = mir_tstrdup( s );
- JabberHttpUrlDecode( ft->std.tszCurrentFile );
- if ( ft->create() == -1 ) {
+ ft->std.tszCurrentFile = mir_tstrdup(s);
+ JabberHttpUrlDecode(ft->std.tszCurrentFile);
+ if (ft->create() == -1) {
ft->state = FT_ERROR;
break;
}
ft->state = FT_RECEIVING;
ft->std.currentFileProgress = 0;
- Log( "Change to FT_RECEIVING" );
+ Log("Change to FT_RECEIVING");
}
- else if (( s=strchr( str, ':' )) != NULL ) {
+ else if ((s=strchr(str, ':')) != NULL) {
*s = '\0';
- if ( !strcmp( str, "Content-Length" ))
- ft->std.totalBytes = ft->std.currentFileSize = _atoi64( s+1 );
+ if ( !strcmp(str, "Content-Length"))
+ ft->std.totalBytes = ft->std.currentFileSize = _atoi64(s+1);
} }
- mir_free( str );
+ mir_free(str);
q += 2;
- num += ( q-p );
+ num += (q-p);
p = q;
}
else {
@@ -157,26 +157,26 @@ int CJabberProto::FileReceiveParse( filetransfer* ft, char* buffer, int datalen break;
}
}
- else if ( ft->state == FT_RECEIVING ) {
+ else if (ft->state == FT_RECEIVING) {
int bufferSize, writeSize;
__int64 remainingBytes;
- if ( ft->std.currentFileSize < 0 || ft->std.currentFileProgress < ft->std.currentFileSize ) {
+ if (ft->std.currentFileSize < 0 || ft->std.currentFileProgress < ft->std.currentFileSize) {
bufferSize = eob - p;
remainingBytes = ft->std.currentFileSize - ft->std.currentFileProgress;
- if ( remainingBytes < bufferSize )
+ if (remainingBytes < bufferSize)
writeSize = remainingBytes;
else
writeSize = bufferSize;
- if ( _write( ft->fileId, p, writeSize ) != writeSize ) {
- Log( "_write() error" );
+ if (_write(ft->fileId, p, writeSize) != writeSize) {
+ Log("_write() error");
ft->state = FT_ERROR;
}
else {
ft->std.currentFileProgress += writeSize;
ft->std.totalProgress += writeSize;
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, ( LPARAM )&ft->std );
- if ( ft->std.currentFileProgress == ft->std.currentFileSize )
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
+ if (ft->std.currentFileProgress == ft->std.currentFileSize)
ft->state = FT_DONE;
}
}
@@ -189,181 +189,181 @@ int CJabberProto::FileReceiveParse( filetransfer* ft, char* buffer, int datalen return num;
}
-void JabberFileServerConnection( JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, void* extra )
+void JabberFileServerConnection(JABBER_SOCKET hConnection, DWORD /*dwRemoteIP*/, void* extra)
{
- CJabberProto* ppro = ( CJabberProto* )extra;
+ CJabberProto* ppro = (CJabberProto*)extra;
NETLIBCONNINFO connInfo = { sizeof(connInfo) };
CallService(MS_NETLIB_GETCONNECTIONINFO, (WPARAM)hConnection, (LPARAM)&connInfo);
TCHAR szPort[10];
- mir_sntprintf( szPort, SIZEOF( szPort ), _T("%d"), connInfo.wPort );
- ppro->Log( "File server incoming connection accepted: %s", connInfo.szIpPort );
+ mir_sntprintf(szPort, SIZEOF(szPort), _T("%d"), connInfo.wPort);
+ ppro->Log("File server incoming connection accepted: %s", connInfo.szIpPort);
- JABBER_LIST_ITEM *item = ppro->ListGetItemPtr( LIST_FILE, szPort );
- if ( item == NULL ) {
- ppro->Log( "No file is currently served, file server connection closed." );
- Netlib_CloseHandle( hConnection );
+ JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_FILE, szPort);
+ if (item == NULL) {
+ ppro->Log("No file is currently served, file server connection closed.");
+ Netlib_CloseHandle(hConnection);
return;
}
- filetransfer* ft = item->ft;
+ filetransfer *ft = item->ft;
JABBER_SOCKET slisten = ft->s;
ft->s = hConnection;
- ppro->Log( "Set ft->s to %d ( saving %d )", hConnection, slisten );
+ ppro->Log("Set ft->s to %d (saving %d)", hConnection, slisten);
- char* buffer = ( char* )mir_alloc( JABBER_NETWORK_BUFFER_SIZE+1 );
- if ( buffer == NULL ) {
- ppro->Log( "Cannot allocate network buffer, file server connection closed." );
- Netlib_CloseHandle( hConnection );
+ char* buffer = (char*)mir_alloc(JABBER_NETWORK_BUFFER_SIZE+1);
+ if (buffer == NULL) {
+ ppro->Log("Cannot allocate network buffer, file server connection closed.");
+ Netlib_CloseHandle(hConnection);
ft->state = FT_ERROR;
- if ( ft->hFileEvent != NULL )
- SetEvent( ft->hFileEvent );
+ if (ft->hFileEvent != NULL)
+ SetEvent(ft->hFileEvent);
return;
}
- ppro->Log( "Entering recv loop for this file connection... ( ft->s is hConnection )" );
+ ppro->Log("Entering recv loop for this file connection... (ft->s is hConnection)");
int datalen = 0;
- while ( ft->state!=FT_DONE && ft->state!=FT_ERROR ) {
+ while (ft->state!=FT_DONE && ft->state!=FT_ERROR) {
int recvResult, bytesParsed;
- recvResult = Netlib_Recv( hConnection, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0 );
- if ( recvResult <= 0 )
+ recvResult = Netlib_Recv(hConnection, buffer+datalen, JABBER_NETWORK_BUFFER_SIZE-datalen, 0);
+ if (recvResult <= 0)
break;
datalen += recvResult;
buffer[datalen] = '\0';
- ppro->Log( "RECV:%s", buffer );
+ ppro->Log("RECV:%s", buffer);
- bytesParsed = ppro->FileSendParse( hConnection, ft, buffer, datalen );
- if ( bytesParsed < datalen )
- memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
+ bytesParsed = ppro->FileSendParse(hConnection, ft, buffer, datalen);
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
datalen -= bytesParsed;
}
- ppro->Log( "Closing connection for this file transfer... ( ft->s is now hBind )" );
- Netlib_CloseHandle( hConnection );
+ ppro->Log("Closing connection for this file transfer... (ft->s is now hBind)");
+ Netlib_CloseHandle(hConnection);
ft->s = slisten;
- ppro->Log( "ft->s is restored to %d", ft->s );
- if ( ft->hFileEvent != NULL )
- SetEvent( ft->hFileEvent );
- mir_free( buffer );
+ ppro->Log("ft->s is restored to %d", ft->s);
+ if (ft->hFileEvent != NULL)
+ SetEvent(ft->hFileEvent);
+ mir_free(buffer);
}
-void __cdecl CJabberProto::FileServerThread( filetransfer* ft )
+void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
{
- Log( "Thread started: type=file_send" );
+ Log("Thread started: type=file_send");
- ThreadData info( this, JABBER_SESSION_NORMAL );
+ ThreadData info(this, JABBER_SESSION_NORMAL);
ft->type = FT_OOB;
NETLIBBIND nlb = {0};
- nlb.cbSize = sizeof( NETLIBBIND );
+ nlb.cbSize = sizeof(NETLIBBIND);
nlb.pfnNewConnectionV2 = JabberFileServerConnection;
nlb.pExtra = this;
nlb.wPort = 0; // Use user-specified incoming port ranges, if available
- info.s = ( HANDLE ) CallService( MS_NETLIB_BINDPORT, ( WPARAM ) m_hNetlibUser, ( LPARAM )&nlb );
- if ( info.s == NULL ) {
- Log( "Cannot allocate port to bind for file server thread, thread ended." );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0 );
+ info.s = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)m_hNetlibUser, (LPARAM)&nlb);
+ if (info.s == NULL) {
+ Log("Cannot allocate port to bind for file server thread, thread ended.");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
delete ft;
return;
}
ft->s = info.s;
- Log( "ft->s = %d", info.s );
+ Log("ft->s = %d", info.s);
- HANDLE hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
ft->hFileEvent = hEvent;
TCHAR szPort[20];
- mir_sntprintf( szPort, SIZEOF( szPort ), _T("%d"), nlb.wPort );
- JABBER_LIST_ITEM *item = ListAdd( LIST_FILE, szPort );
+ mir_sntprintf(szPort, SIZEOF(szPort), _T("%d"), nlb.wPort);
+ JABBER_LIST_ITEM *item = ListAdd(LIST_FILE, szPort);
item->ft = ft;
- TCHAR* ptszResource = ListGetBestClientResourceNamePtr( ft->jid );
- if ( ptszResource != NULL ) {
+ TCHAR* ptszResource = ListGetBestClientResourceNamePtr(ft->jid);
+ if (ptszResource != NULL) {
ft->state = FT_CONNECTING;
- for ( int i=0; i < ft->std.totalFiles && ft->state != FT_ERROR && ft->state != FT_DENIED; i++ ) {
+ for (int i=0; i < ft->std.totalFiles && ft->state != FT_ERROR && ft->state != FT_DENIED; i++) {
ft->std.currentFileNumber = i;
ft->state = FT_CONNECTING;
- if ( ft->httpPath ) mir_free( ft->httpPath );
+ if (ft->httpPath) mir_free(ft->httpPath);
ft->httpPath = NULL;
TCHAR* p;
- if (( p = _tcschr( ft->std.ptszFiles[i], '\\' )) != NULL )
+ if ((p = _tcschr(ft->std.ptszFiles[i], '\\')) != NULL)
p++;
else
p = ft->std.ptszFiles[i];
- TCHAR* pFileName = JabberHttpUrlEncode( p );
- if ( pFileName != NULL ) {
+ TCHAR* pFileName = JabberHttpUrlEncode(p);
+ if (pFileName != NULL) {
int id = SerialNext();
- if ( ft->iqId ) mir_free( ft->iqId );
- ft->iqId = ( TCHAR* )mir_alloc( sizeof(TCHAR)*( strlen( JABBER_IQID )+20 ));
- wsprintf( ft->iqId, _T(JABBER_IQID)_T("%d"), id );
+ if (ft->iqId) mir_free(ft->iqId);
+ ft->iqId = (TCHAR*)mir_alloc(sizeof(TCHAR)*(strlen(JABBER_IQID)+20));
+ wsprintf(ft->iqId, _T(JABBER_IQID)_T("%d"), id);
char *myAddr = NULL;
DBVARIANT dbv;
if (m_options.BsDirect && m_options.BsDirectManual) {
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "BsDirectAddr", &dbv ))
+ if ( !DBGetContactSettingString(NULL, m_szModuleName, "BsDirectAddr", &dbv))
myAddr = dbv.pszVal;
}
- if ( myAddr == NULL )
- myAddr = (char*)CallService( MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP );
+ if (myAddr == NULL)
+ myAddr = (char*)CallService(MS_NETLIB_ADDRESSTOSTRING, 1, nlb.dwExternalIP);
char szAddr[ 256 ];
- mir_snprintf( szAddr, sizeof(szAddr), "http://%s:%d/%s", myAddr, nlb.wPort, pFileName );
+ mir_snprintf(szAddr, sizeof(szAddr), "http://%s:%d/%s", myAddr, nlb.wPort, pFileName);
- mir_free( pFileName );
- mir_free( myAddr );
+ mir_free(pFileName);
+ mir_free(myAddr);
int len = lstrlen(ptszResource) + lstrlen(ft->jid) + 2;
- TCHAR* fulljid = ( TCHAR* )alloca( sizeof( TCHAR )*len );
- wsprintf( fulljid, _T("%s/%s"), ft->jid, ptszResource );
+ TCHAR* fulljid = (TCHAR*)alloca(sizeof(TCHAR)*len);
+ wsprintf(fulljid, _T("%s/%s"), ft->jid, ptszResource);
- XmlNodeIq iq( _T("set"), id, fulljid );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_OOB));
- query << XCHILD( _T("url"), _A2T(szAddr));
- query << XCHILD( _T("desc"), ft->szDescription);
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("set"), id, fulljid);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_OOB));
+ query << XCHILD(_T("url"), _A2T(szAddr));
+ query << XCHILD(_T("desc"), ft->szDescription);
+ m_ThreadInfo->send(iq);
- Log( "Waiting for the file to be sent..." );
- WaitForSingleObject( hEvent, INFINITE );
+ Log("Waiting for the file to be sent...");
+ WaitForSingleObject(hEvent, INFINITE);
}
- Log( "File sent, advancing to the next file..." );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0 );
+ Log("File sent, advancing to the next file...");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0);
}
- CloseHandle( hEvent );
+ CloseHandle(hEvent);
ft->hFileEvent = NULL;
- Log( "Finish all files" );
+ Log("Finish all files");
}
ft->s = NULL;
- Log( "ft->s is NULL" );
+ Log("ft->s is NULL");
- ListRemove( LIST_FILE, szPort );
+ ListRemove(LIST_FILE, szPort);
- switch ( ft->state ) {
+ switch (ft->state) {
case FT_DONE:
- Log( "Finish successfully" );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0 );
+ Log("Finish successfully");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
break;
case FT_DENIED:
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ft, 0 );
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ft, 0);
break;
default: // FT_ERROR:
- Log( "Finish with errors" );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0 );
+ Log("Finish with errors");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
break;
}
- Log( "Thread ended: type=file_send" );
+ Log("Thread ended: type=file_send");
delete ft;
}
-int CJabberProto::FileSendParse( JABBER_SOCKET s, filetransfer* ft, char* buffer, int datalen )
+int CJabberProto::FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer, int datalen)
{
char* p, *q, *t, *eob;
char* str;
@@ -375,90 +375,90 @@ int CJabberProto::FileSendParse( JABBER_SOCKET s, filetransfer* ft, char* buffer eob = buffer + datalen;
p = buffer;
num = 0;
- while ( ft->state==FT_CONNECTING || ft->state==FT_INITIALIZING ) {
- for ( q=p; q+1<eob && ( *q!='\r' || *( q+1 )!='\n' ); q++ );
- if ( q+1 >= eob )
+ while (ft->state==FT_CONNECTING || ft->state==FT_INITIALIZING) {
+ for (q=p; q+1<eob && (*q!='\r' || *(q+1)!='\n'); q++);
+ if (q+1 >= eob)
break;
- if (( str=( char* )mir_alloc( q-p+1 )) == NULL ) {
+ if ((str=(char*)mir_alloc(q-p+1)) == NULL) {
ft->state = FT_ERROR;
break;
}
- strncpy( str, p, q-p );
+ strncpy(str, p, q-p);
str[q-p] = '\0';
- Log( "FT Got: %s", str );
- if ( ft->state == FT_CONNECTING ) {
+ Log("FT Got: %s", str);
+ if (ft->state == FT_CONNECTING) {
// looking for "GET filename.ext HTTP/1.1"
- if ( !strncmp( str, "GET ", 4 )) {
- for ( t=str+4; *t!='\0' && *t!=' '; t++ );
+ if ( !strncmp(str, "GET ", 4)) {
+ for (t=str+4; *t!='\0' && *t!=' '; t++);
*t = '\0';
- for ( t=str+4; *t!='\0' && *t=='/'; t++ );
- ft->httpPath = mir_a2t( t );
- JabberHttpUrlDecode( ft->httpPath );
+ for (t=str+4; *t!='\0' && *t=='/'; t++);
+ ft->httpPath = mir_a2t(t);
+ JabberHttpUrlDecode(ft->httpPath);
ft->state = FT_INITIALIZING;
- Log( "Change to FT_INITIALIZING" );
+ Log("Change to FT_INITIALIZING");
}
}
else { // FT_INITIALIZING
- if ( str[0] == '\0' ) {
+ if (str[0] == '\0') {
struct _stati64 statbuf;
- mir_free( str );
+ mir_free(str);
num += 2;
currentFile = ft->std.currentFileNumber;
- TCHAR* t = _tcsrchr( ft->std.ptszFiles[ currentFile ], '\\' );
- if ( t != NULL )
+ TCHAR* t = _tcsrchr(ft->std.ptszFiles[ currentFile ], '\\');
+ if (t != NULL)
t++;
else
t = ft->std.ptszFiles[currentFile];
- if ( ft->httpPath==NULL || lstrcmp( ft->httpPath, t )) {
- if ( ft->httpPath == NULL )
- Log( "Requested file name does not matched ( httpPath==NULL )" );
+ if (ft->httpPath==NULL || lstrcmp(ft->httpPath, t)) {
+ if (ft->httpPath == NULL)
+ Log("Requested file name does not matched (httpPath==NULL)");
else
- Log( "Requested file name does not matched ( '%s' vs. '%s' )", ft->httpPath, t );
+ Log("Requested file name does not matched ('%s' vs. '%s')", ft->httpPath, t);
ft->state = FT_ERROR;
break;
}
- Log( "Sending [%s]", ft->std.ptszFiles[ currentFile ] );
- _tstati64( ft->std.ptszFiles[ currentFile ], &statbuf ); // file size in statbuf.st_size
- if (( fileId = _topen( ft->std.ptszFiles[currentFile], _O_BINARY|_O_RDONLY )) < 0 ) {
- Log( "File cannot be opened" );
+ Log("Sending [%s]", ft->std.ptszFiles[ currentFile ]);
+ _tstati64(ft->std.ptszFiles[ currentFile ], &statbuf); // file size in statbuf.st_size
+ if ((fileId = _topen(ft->std.ptszFiles[currentFile], _O_BINARY|_O_RDONLY)) < 0) {
+ Log("File cannot be opened");
ft->state = FT_ERROR;
- mir_free( ft->httpPath );
+ mir_free(ft->httpPath);
ft->httpPath = NULL;
break;
}
char fileBuffer[ 2048 ];
- int bytes = mir_snprintf( fileBuffer, sizeof(fileBuffer), "HTTP/1.1 200 OK\r\nContent-Length: %I64u\r\n\r\n", statbuf.st_size );
- WsSend( s, fileBuffer, bytes, MSG_DUMPASTEXT );
+ int bytes = mir_snprintf(fileBuffer, sizeof(fileBuffer), "HTTP/1.1 200 OK\r\nContent-Length: %I64u\r\n\r\n", statbuf.st_size);
+ WsSend(s, fileBuffer, bytes, MSG_DUMPASTEXT);
ft->std.flags |= PFTS_SENDING;
ft->std.currentFileProgress = 0;
- Log( "Sending file data..." );
+ Log("Sending file data...");
- while (( numRead = _read( fileId, fileBuffer, 2048 )) > 0 ) {
- if ( Netlib_Send( s, fileBuffer, numRead, 0 ) != numRead ) {
+ while ((numRead = _read(fileId, fileBuffer, 2048)) > 0) {
+ if (Netlib_Send(s, fileBuffer, numRead, 0) != numRead) {
ft->state = FT_ERROR;
break;
}
ft->std.currentFileProgress += numRead;
ft->std.totalProgress += numRead;
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, ( LPARAM )&ft->std );
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
}
- _close( fileId );
- if ( ft->state != FT_ERROR )
+ _close(fileId);
+ if (ft->state != FT_ERROR)
ft->state = FT_DONE;
- Log( "Finishing this file..." );
- mir_free( ft->httpPath );
+ Log("Finishing this file...");
+ mir_free(ft->httpPath);
ft->httpPath = NULL;
break;
} }
- mir_free( str );
+ mir_free(str);
q += 2;
- num += ( q-p );
+ num += (q-p);
p = q;
}
@@ -468,49 +468,49 @@ int CJabberProto::FileSendParse( JABBER_SOCKET s, filetransfer* ft, char* buffer /////////////////////////////////////////////////////////////////////////////////////////
// filetransfer class members
-filetransfer::filetransfer( CJabberProto* proto )
+filetransfer::filetransfer(CJabberProto* proto)
{
- memset( this, 0, sizeof( filetransfer ));
+ memset(this, 0, sizeof(filetransfer));
ppro = proto;
fileId = -1;
- std.cbSize = sizeof( std );
+ std.cbSize = sizeof(std);
std.flags = PFTS_TCHAR;
}
filetransfer::~filetransfer()
{
- ppro->Log( "Destroying file transfer session %08p", this );
+ ppro->Log("Destroying file transfer session %08p", this);
- if ( !bCompleted )
- ppro->JSendBroadcast( std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, this, 0 );
+ if ( !bCompleted)
+ ppro->JSendBroadcast(std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, this, 0);
close();
- if ( hWaitEvent != INVALID_HANDLE_VALUE )
- CloseHandle( hWaitEvent );
+ if (hWaitEvent != INVALID_HANDLE_VALUE)
+ CloseHandle(hWaitEvent);
- if ( jid ) mir_free( jid );
- if ( sid ) mir_free( sid );
- if ( iqId ) mir_free( iqId );
- if ( fileSize ) mir_free( fileSize );
- if ( httpHostName ) mir_free( httpHostName );
- if ( httpPath ) mir_free( httpPath );
- if ( szDescription ) mir_free( szDescription );
+ if (jid) mir_free(jid);
+ if (sid) mir_free(sid);
+ if (iqId) mir_free(iqId);
+ if (fileSize) mir_free(fileSize);
+ if (httpHostName) mir_free(httpHostName);
+ if (httpPath) mir_free(httpPath);
+ if (szDescription) mir_free(szDescription);
- if ( std.tszWorkingDir ) mir_free( std.tszWorkingDir );
- if ( std.tszCurrentFile ) mir_free( std.tszCurrentFile );
+ if (std.tszWorkingDir) mir_free(std.tszWorkingDir);
+ if (std.tszCurrentFile) mir_free(std.tszCurrentFile);
- if ( std.ptszFiles ) {
- for ( int i=0; i < std.totalFiles; i++ )
- if ( std.ptszFiles[i] ) mir_free( std.ptszFiles[i] );
+ if (std.ptszFiles) {
+ for (int i=0; i < std.totalFiles; i++)
+ if (std.ptszFiles[i]) mir_free(std.ptszFiles[i]);
- mir_free( std.ptszFiles );
+ mir_free(std.ptszFiles);
} }
void filetransfer::close()
{
- if ( fileId != -1 ) {
- _close( fileId );
+ if (fileId != -1) {
+ _close(fileId);
fileId = -1;
} }
@@ -519,34 +519,34 @@ void filetransfer::complete() close();
bCompleted = true;
- ppro->JSendBroadcast( std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, this, 0);
+ ppro->JSendBroadcast(std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, this, 0);
}
int filetransfer::create()
{
- if ( fileId != -1 )
+ if (fileId != -1)
return fileId;
TCHAR filefull[ MAX_PATH ];
- mir_sntprintf( filefull, SIZEOF(filefull), _T("%s\\%s"), std.tszWorkingDir, std.tszCurrentFile );
- replaceStrT( std.tszCurrentFile, filefull );
+ mir_sntprintf(filefull, SIZEOF(filefull), _T("%s\\%s"), std.tszWorkingDir, std.tszCurrentFile);
+ replaceStrT(std.tszCurrentFile, filefull);
- if ( hWaitEvent != INVALID_HANDLE_VALUE )
- CloseHandle( hWaitEvent );
- hWaitEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ if (hWaitEvent != INVALID_HANDLE_VALUE)
+ CloseHandle(hWaitEvent);
+ hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if ( ppro->JSendBroadcast( std.hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, this, ( LPARAM )&std ))
- WaitForSingleObject( hWaitEvent, INFINITE );
+ if (ppro->JSendBroadcast(std.hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, this, (LPARAM)&std))
+ WaitForSingleObject(hWaitEvent, INFINITE);
- if ( fileId == -1 ) {
- ppro->Log( "Saving to [%s]", std.tszCurrentFile );
- fileId = _topen( std.tszCurrentFile, _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IREAD | _S_IWRITE );
+ if (fileId == -1) {
+ ppro->Log("Saving to [%s]", std.tszCurrentFile);
+ fileId = _topen(std.tszCurrentFile, _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IREAD | _S_IWRITE);
}
- if ( fileId == -1 )
- ppro->Log( "Cannot create file '%s' during a file transfer", filefull );
- else if ( std.currentFileSize != 0 )
- _chsize( fileId, std.currentFileSize );
+ if (fileId == -1)
+ ppro->Log("Cannot create file '%s' during a file transfer", filefull);
+ else if (std.currentFileSize != 0)
+ _chsize(fileId, std.currentFileSize);
return fileId;
}
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp index a90dcf62fa..cbdee873fc 100644 --- a/protocols/JabberG/src/jabber_form.cpp +++ b/protocols/JabberG/src/jabber_form.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
@@ -24,19 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_caps.h"
-static BOOL CALLBACK JabberFormMultiLineWndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
+static BOOL CALLBACK JabberFormMultiLineWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
+ switch (msg) {
//case WM_GETDLGCODE:
// return DLGC_WANTARROWS|DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTALLKEYS;
case WM_KEYDOWN:
- if ( wParam == VK_TAB ) {
- SetFocus( GetNextDlgTabItem( GetParent( GetParent( hwnd )), hwnd, GetKeyState( VK_SHIFT )<0?TRUE:FALSE ));
+ if (wParam == VK_TAB) {
+ SetFocus(GetNextDlgTabItem(GetParent(GetParent(hwnd)), hwnd, GetKeyState(VK_SHIFT)<0?TRUE:FALSE));
return TRUE;
};
break;
}
- return CallWindowProc(( WNDPROC ) GetWindowLongPtr( hwnd, GWLP_USERDATA ), hwnd, msg, wParam, lParam );
+ return CallWindowProc((WNDPROC) GetWindowLongPtr(hwnd, GWLP_USERDATA), hwnd, msg, wParam, lParam);
}
struct TJabberFormControlInfo
@@ -96,7 +96,7 @@ void JabberFormCenterContent(HWND hwndStatic) int dx=(minX-rcWindow.left)/2;
oldChild=NULL;
hWndChild=GetWindow(hwndStatic,GW_CHILD);
- while (hWndChild!=oldChild && hWndChild!=NULL )
+ while (hWndChild!=oldChild && hWndChild!=NULL)
{
DWORD style=GetWindowLongPtr(hWndChild, GWL_STYLE);
RECT rc;
@@ -111,9 +111,9 @@ void JabberFormCenterContent(HWND hwndStatic) }
}
-void JabberFormSetInstruction( HWND hwndForm, const TCHAR *text )
+void JabberFormSetInstruction(HWND hwndForm, const TCHAR *text)
{
- if (!text) text = _T("");
+ if ( !text) text = _T("");
int len = lstrlen(text);
int fixedLen = len;
@@ -136,7 +136,7 @@ void JabberFormSetInstruction( HWND hwndForm, const TCHAR *text ) text = fixedText;
}
- SetDlgItemText( hwndForm, IDC_INSTRUCTION, text );
+ SetDlgItemText(hwndForm, IDC_INSTRUCTION, text);
RECT rcText;
GetWindowRect(GetDlgItem(hwndForm, IDC_INSTRUCTION), &rcText);
@@ -207,21 +207,21 @@ void JabberFormSetInstruction( HWND hwndForm, const TCHAR *text ) if (fixedText) mir_free(fixedText);
}
-static TJabberFormControlType JabberFormTypeNameToId( const TCHAR *type )
+static TJabberFormControlType JabberFormTypeNameToId(const TCHAR *type)
{
- if ( !_tcscmp( type, _T("text-private")))
+ if ( !_tcscmp(type, _T("text-private")))
return JFORM_CTYPE_TEXT_PRIVATE;
- if ( !_tcscmp( type, _T("text-multi")) || !_tcscmp( type, _T("jid-multi")))
+ if ( !_tcscmp(type, _T("text-multi")) || !_tcscmp(type, _T("jid-multi")))
return JFORM_CTYPE_TEXT_MULTI;
- if ( !_tcscmp( type, _T("boolean")))
+ if ( !_tcscmp(type, _T("boolean")))
return JFORM_CTYPE_BOOLEAN;
- if ( !_tcscmp( type, _T("list-single")))
+ if ( !_tcscmp(type, _T("list-single")))
return JFORM_CTYPE_LIST_SINGLE;
- if ( !_tcscmp( type, _T("list-multi")))
+ if ( !_tcscmp(type, _T("list-multi")))
return JFORM_CTYPE_LIST_MULTI;
- if ( !_tcscmp( type, _T("fixed")))
+ if ( !_tcscmp(type, _T("fixed")))
return JFORM_CTYPE_FIXED;
- if ( !_tcscmp( type, _T("hidden")))
+ if ( !_tcscmp(type, _T("hidden")))
return JFORM_CTYPE_HIDDEN;
// else
return JFORM_CTYPE_TEXT_SINGLE;
@@ -233,9 +233,9 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo if (item->hLabel)
{
SetRect(&rcLabel, 0, 0, layout_info->width, 0);
- HDC hdc = GetDC( item->hLabel );
+ HDC hdc = GetDC(item->hLabel);
HFONT hfntSave = (HFONT)SelectObject(hdc, (HFONT)SendMessage(item->hLabel, WM_GETFONT, 0, 0));
- DrawText( hdc, labelStr, -1, &rcLabel, DT_CALCRECT|DT_WORDBREAK );
+ DrawText(hdc, labelStr, -1, &rcLabel, DT_CALCRECT|DT_WORDBREAK);
SelectObject(hdc, hfntSave);
ReleaseDC(item->hLabel, hdc);
}
@@ -255,9 +255,9 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo if (item->type == JFORM_CTYPE_BOOLEAN)
{
SetRect(&rcCtrl, 0, 0, layout_info->width-20, 0);
- HDC hdc = GetDC( item->hCtrl );
+ 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;
@@ -265,9 +265,9 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo if (item->type == JFORM_CTYPE_FIXED)
{
SetRect(&rcCtrl, 0, 0, layout_info->width, 0);
- HDC hdc = GetDC( item->hCtrl );
+ 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);
@@ -295,13 +295,13 @@ void JabberFormLayoutSingleControl(TJabberFormControlInfo *item, TJabberFormLayo }
#define JabberFormCreateLabel() \
- CreateWindow( _T("static"), labelStr, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \
- 0, 0, 0, 0, hwndStatic, ( HMENU )-1, hInst, NULL )
+ CreateWindow(_T("static"), labelStr, WS_CHILD|WS_VISIBLE|SS_CENTERIMAGE, \
+ 0, 0, 0, 0, hwndStatic, (HMENU)-1, hInst, NULL)
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);
@@ -316,62 +316,62 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo case JFORM_CTYPE_TEXT_PRIVATE:
{
item->hLabel = JabberFormCreateLabel();
- item->hCtrl = CreateWindowEx( WS_EX_CLIENTEDGE, _T("edit"), valueStr,
+ 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 );
+ 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,
+ 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 );
- WNDPROC oldWndProc = ( WNDPROC ) SetWindowLongPtr( item->hCtrl, GWLP_WNDPROC, ( LONG_PTR )JabberFormMultiLineWndProc );
- SetWindowLongPtr( item->hCtrl, GWLP_USERDATA, ( LONG_PTR ) oldWndProc );
+ hwndStatic, (HMENU) layout_info->id, hInst, NULL);
+ WNDPROC oldWndProc = (WNDPROC) SetWindowLongPtr(item->hCtrl, GWLP_WNDPROC, (LONG_PTR)JabberFormMultiLineWndProc);
+ SetWindowLongPtr(item->hCtrl, GWLP_USERDATA, (LONG_PTR) oldWndProc);
++layout_info->id;
break;
}
case JFORM_CTYPE_BOOLEAN:
{
- item->hCtrl = CreateWindowEx( 0, _T("button"), labelStr,
+ 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 );
+ 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,
+ 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 );
+ 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",
+ 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 );
+ hwndStatic, (HMENU) layout_info->id, hInst, NULL);
++layout_info->id;
break;
}
case JFORM_CTYPE_FIXED:
{
- item->hCtrl = CreateWindow( _T("edit"), valueStr,
+ 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 );
+ hwndStatic, (HMENU)-1, hInst, NULL);
break;
}
case JFORM_CTYPE_HIDDEN:
@@ -381,18 +381,18 @@ TJabberFormControlInfo *JabberFormAppendControl(HWND hwndStatic, TJabberFormLayo case JFORM_CTYPE_TEXT_SINGLE:
{
item->hLabel = labelStr ? (JabberFormCreateLabel()) : NULL;
- item->hCtrl = CreateWindowEx( WS_EX_CLIENTEDGE, _T("edit"), valueStr,
+ 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 );
+ hwndStatic, (HMENU) layout_info->id, hInst, NULL);
++layout_info->id;
break;
}
}
- HFONT hFont = ( HFONT ) SendMessage( GetParent(hwndStatic), WM_GETFONT, 0, 0 );
- if (item->hLabel) SendMessage( item->hLabel, WM_SETFONT, ( WPARAM ) hFont, 0 );
- if (item->hCtrl) SendMessage( item->hCtrl, WM_SETFONT, ( WPARAM ) hFont, 0 );
+ HFONT hFont = (HFONT)SendMessage(GetParent(hwndStatic), WM_GETFONT, 0, 0);
+ if (item->hLabel) SendMessage(item->hLabel, WM_SETFONT, (WPARAM)hFont, 0);
+ if (item->hCtrl) SendMessage(item->hCtrl, WM_SETFONT, (WPARAM)hFont, 0);
JabberFormLayoutSingleControl(item, layout_info, labelStr, valueStr);
@@ -419,7 +419,7 @@ void JabberFormAddListItem(TJabberFormControlInfo *item, TCHAR *text, bool selec void JabberFormLayoutControls(HWND hwndStatic, TJabberFormLayoutInfo *layout_info, int *formHeight)
{
TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
- if (!controls) return;
+ if ( !controls) return;
for (int i = 0; i < controls->getCount(); ++i)
{
@@ -442,7 +442,7 @@ void JabberFormLayoutControls(HWND hwndStatic, TJabberFormLayoutInfo *layout_inf HJFORMLAYOUT JabberFormCreateLayout(HWND hwndStatic)
{
RECT frameRect;
- GetClientRect( hwndStatic, &frameRect );
+ GetClientRect(hwndStatic, &frameRect);
TJabberFormLayoutInfo *layout_info = (TJabberFormLayoutInfo *)mir_alloc(sizeof(TJabberFormLayoutInfo));
layout_info->compact = false;
@@ -456,73 +456,73 @@ HJFORMLAYOUT JabberFormCreateLayout(HWND hwndStatic) return layout_info;
}
-void JabberFormCreateUI( HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCompact )
+void JabberFormCreateUI(HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCompact)
{
JabberFormDestroyUI(hwndStatic);
HXML v, o, vs;
int i, j, k;
- const TCHAR* label, *typeName, *varStr, *str, *valueText;
+ const TCHAR *label, *typeName, *varStr, *str, *valueText;
TCHAR *labelStr, *valueStr, *p;
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 );
+ GetClientRect(hwndStatic, &frameRect);
TJabberFormLayoutInfo layout_info;
layout_info.compact = bCompact ? true : false;
layout_info.ctrlHeight = 20;
layout_info.id = 0;
layout_info.width = frameRect.right - frameRect.left - 20;
- if (!bCompact) layout_info.width -= 10;
+ if ( !bCompact) layout_info.width -= 10;
layout_info.y_spacing = bCompact ? 1 : 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);
- if ( !n )
+ for (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 );
+ 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 );
+ labelStr = mir_tstrdup(varStr);
TJabberFormControlType type = JabberFormTypeNameToId(typeName);
- if (( v = xmlGetChild( n , "value" )) != NULL )
+ if ((v = xmlGetChild(n , "value")) != NULL)
{
- valueText = xmlGetText( v );
+ valueText = xmlGetText(v);
if (type != JFORM_CTYPE_TEXT_MULTI)
{
- valueStr = mir_tstrdup( valueText );
+ valueStr = mir_tstrdup(valueText);
} else
{
size_t size = 1;
- for ( j=0; ; j++ ) {
- v = xmlGetChild( n ,j);
- if ( !v )
+ 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;
+ if (xmlGetName(v) && !lstrcmp(xmlGetName(v), _T("value")) && xmlGetText(v))
+ size += _tcslen(xmlGetText(v)) + 2;
}
- valueStr = ( TCHAR* )mir_alloc( sizeof(TCHAR)*size );
+ valueStr = (TCHAR*)mir_alloc(sizeof(TCHAR)*size);
valueStr[0] = '\0';
- for ( j=0; ; j++ ) {
- v = xmlGetChild( n ,j);
- if ( !v )
+ 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 (xmlGetName(v) && !lstrcmp(xmlGetName(v), _T("value")) && xmlGetText(v)) {
+ if (valueStr[0])
+ _tcscat(valueStr, _T("\r\n"));
+ _tcscat(valueStr, xmlGetText(v));
} }
}
} else
@@ -532,51 +532,51 @@ void JabberFormCreateUI( HWND hwndStatic, HXML xNode, int *formHeight, BOOL bCom 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++ ) {
- o = xmlGetChild( n ,j);
- if ( !o )
+ for (j=0; ; j++) {
+ o = xmlGetChild(n ,j);
+ if ( !o)
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 ) {
+ 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 )))
+ if (valueText != NULL && !_tcscmp(valueText, xmlGetText(v)))
selected = true;
JabberFormAddListItem(item, p, selected);
- mir_free( p );
+ mir_free(p);
} } } }
} else
if (type == JFORM_CTYPE_LIST_MULTI)
{
- for ( j=0; ; j++ ) {
- o = xmlGetChild( n ,j);
- if ( !o )
+ for (j=0; ; j++) {
+ o = xmlGetChild(n ,j);
+ if ( !o)
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 ) {
+ 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 )
+ for (k=0; ; k++) {
+ vs = xmlGetChild(n ,k);
+ if ( !vs)
break;
- if ( !lstrcmp( xmlGetName( vs ), _T("value")) && xmlGetText( vs ) && !_tcscmp( xmlGetText( vs ), xmlGetText( v )))
+ 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, p, selected);
+ mir_free(p);
} } } } } } } } }
JabberFormLayoutControls(hwndStatic, &layout_info, formHeight);
@@ -587,7 +587,7 @@ void JabberFormDestroyUI(HWND hwndStatic) TJabberFormControlList *controls = (TJabberFormControlList *)GetWindowLongPtr(hwndStatic, GWLP_USERDATA);
if (controls)
{
- for ( int i = 0; i < controls->getCount(); i++ )
+ for (int i = 0; i < controls->getCount(); i++)
mir_free((*controls)[i]);
controls->destroy();
delete controls;
@@ -595,7 +595,7 @@ void JabberFormDestroyUI(HWND hwndStatic) }
}
-HXML JabberFormGetData( HWND hwndStatic, HXML xNode )
+HXML JabberFormGetData(HWND hwndStatic, HXML xNode)
{
HWND hFrame, hCtrl;
HXML n, v, o;
@@ -603,113 +603,113 @@ HXML JabberFormGetData( HWND hwndStatic, HXML xNode ) const TCHAR *varName, *type, *fieldStr, *labelText, *str2;
TCHAR *p, *q, *str;
- if ( xNode == NULL || xmlGetName( xNode ) == NULL || lstrcmp( xmlGetName( xNode ), _T("x")) || hwndStatic == NULL )
+ if (xNode == NULL || xmlGetName(xNode) == NULL || lstrcmp(xmlGetName(xNode), _T("x")) || hwndStatic == NULL)
return NULL;
hFrame = hwndStatic;
id = 0;
- XmlNode x( _T("x"));
- x << XATTR( _T("xmlns"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("submit"));
+ XmlNode x(_T("x"));
+ x << XATTR(_T("xmlns"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("submit"));
- for ( int i=0; ; i++ ) {
- n = xmlGetChild( xNode ,i);
- if ( !n )
+ for (int i=0; ; i++) {
+ n = xmlGetChild(xNode ,i);
+ if ( !n)
break;
fieldStr = NULL;
- if ( lstrcmp( xmlGetName( n ), _T("field")))
+ if (lstrcmp(xmlGetName(n), _T("field")))
continue;
- if (( varName = xmlGetAttrValue( n, _T("var"))) == NULL || ( type = xmlGetAttrValue( n, _T("type"))) == NULL )
+ if ((varName = xmlGetAttrValue(n, _T("var"))) == NULL || (type = xmlGetAttrValue(n, _T("type"))) == NULL)
continue;
- hCtrl = GetDlgItem( hFrame, id );
- HXML field = x << XCHILD( _T("field")) << XATTR( _T("var"), varName );
+ hCtrl = GetDlgItem(hFrame, id);
+ HXML field = x << XCHILD(_T("field")) << XATTR(_T("var"), varName);
- if ( !_tcscmp( type, _T("text-multi")) || !_tcscmp( type, _T("jid-multi"))) {
- len = GetWindowTextLength( GetDlgItem( hFrame, id ));
- str = ( TCHAR* )mir_alloc( sizeof(TCHAR)*( len+1 ));
- GetDlgItemText( hFrame, id, str, len+1 );
+ if ( !_tcscmp(type, _T("text-multi")) || !_tcscmp(type, _T("jid-multi"))) {
+ len = GetWindowTextLength(GetDlgItem(hFrame, id));
+ str = (TCHAR*)mir_alloc(sizeof(TCHAR)*(len+1));
+ GetDlgItemText(hFrame, id, str, len+1);
p = str;
- while ( p != NULL ) {
- if (( q = _tcsstr( p, _T("\r\n"))) != NULL )
+ while (p != NULL) {
+ if ((q = _tcsstr(p, _T("\r\n"))) != NULL)
*q = '\0';
- field << XCHILD( _T("value"), p );
+ field << XCHILD(_T("value"), p);
p = q ? q+2 : NULL;
}
- mir_free( str );
+ mir_free(str);
id++;
}
- else if ( !_tcscmp( type, _T("boolean"))) {
+ else if ( !_tcscmp(type, _T("boolean"))) {
TCHAR buf[ 10 ];
- _itot( IsDlgButtonChecked( hFrame, id ) == BST_CHECKED ? 1 : 0, buf, 10 );
- field << XCHILD( _T("value"), buf );
+ _itot(IsDlgButtonChecked(hFrame, id) == BST_CHECKED ? 1 : 0, buf, 10);
+ field << XCHILD(_T("value"), buf);
id++;
}
- else if ( !_tcscmp( type, _T("list-single"))) {
- len = GetWindowTextLength( GetDlgItem( hFrame, id ));
- str = ( TCHAR* )mir_alloc( sizeof( TCHAR )*( len+1 ));
- GetDlgItemText( hFrame, id, str, len+1 );
+ else if ( !_tcscmp(type, _T("list-single"))) {
+ len = GetWindowTextLength(GetDlgItem(hFrame, id));
+ str = (TCHAR*)mir_alloc(sizeof(TCHAR)*(len+1));
+ GetDlgItemText(hFrame, id, str, len+1);
v = NULL;
- for ( j=0; ; j++ ) {
- o = xmlGetChild( n ,j);
- if ( !o )
+ for (j=0; ; j++) {
+ o = xmlGetChild(n ,j);
+ if ( !o)
break;
- if ( !lstrcmp( xmlGetName( o ), _T("option"))) {
- if (( v = xmlGetChild( o , "value" )) != NULL && xmlGetText( v )) {
- if (( str2 = xmlGetAttrValue( o, _T("label"))) == NULL )
- str2 = xmlGetText( v );
- if ( !lstrcmp( str2, str ))
+ if ( !lstrcmp(xmlGetName(o), _T("option"))) {
+ if ((v = xmlGetChild(o , "value")) != NULL && xmlGetText(v)) {
+ if ((str2 = xmlGetAttrValue(o, _T("label"))) == NULL)
+ str2 = xmlGetText(v);
+ if ( !lstrcmp(str2, str))
break;
} } }
- if ( o )
- field << XCHILD( _T("value"), xmlGetText( v ));
+ if (o)
+ field << XCHILD(_T("value"), xmlGetText(v));
- mir_free( str );
+ mir_free(str);
id++;
}
- else if ( !_tcscmp( type, _T("list-multi"))) {
- int count = SendMessage( hCtrl, LB_GETCOUNT, 0, 0 );
- for ( j=0; j<count; j++ ) {
- if ( SendMessage( hCtrl, LB_GETSEL, j, 0 ) > 0 ) {
+ else if ( !_tcscmp(type, _T("list-multi"))) {
+ int count = SendMessage(hCtrl, LB_GETCOUNT, 0, 0);
+ for (j=0; j<count; j++) {
+ if (SendMessage(hCtrl, LB_GETSEL, j, 0) > 0) {
// an entry is selected
- len = SendMessage( hCtrl, LB_GETTEXTLEN, j, 0 );
- if (( str = ( TCHAR* )mir_alloc(( len+1 )*sizeof( TCHAR ))) != NULL ) {
- SendMessage( hCtrl, LB_GETTEXT, j, ( LPARAM )str );
- for ( k=0; ; k++ ) {
- o = xmlGetChild( n ,k);
- if ( !o )
+ len = SendMessage(hCtrl, LB_GETTEXTLEN, j, 0);
+ if ((str = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR))) != NULL) {
+ SendMessage(hCtrl, LB_GETTEXT, j, (LPARAM)str);
+ for (k=0; ; k++) {
+ o = xmlGetChild(n ,k);
+ if ( !o)
break;
- if ( xmlGetName( o ) && !lstrcmp( xmlGetName( o ), _T("option"))) {
- if (( v = xmlGetChild( o , "value" )) != NULL && xmlGetText( v )) {
- if (( labelText = xmlGetAttrValue( o, _T("label"))) == NULL )
- labelText = xmlGetText( v );
+ if (xmlGetName(o) && !lstrcmp(xmlGetName(o), _T("option"))) {
+ if ((v = xmlGetChild(o , "value")) != NULL && xmlGetText(v)) {
+ if ((labelText = xmlGetAttrValue(o, _T("label"))) == NULL)
+ labelText = xmlGetText(v);
- if ( !lstrcmp( labelText, str ))
- field << XCHILD( _T("value"), xmlGetText( v ));
+ if ( !lstrcmp(labelText, str))
+ field << XCHILD(_T("value"), xmlGetText(v));
} } }
- mir_free( str );
+ mir_free(str);
} } }
id++;
}
- else if ( !_tcscmp( type, _T("fixed")) || !_tcscmp( type, _T("hidden"))) {
- v = xmlGetChild( n , "value" );
- if ( v != NULL && xmlGetText( v ) != NULL )
- field << XCHILD( _T("value"), xmlGetText( v ));
+ else if ( !_tcscmp(type, _T("fixed")) || !_tcscmp(type, _T("hidden"))) {
+ v = xmlGetChild(n , "value");
+ if (v != NULL && xmlGetText(v) != NULL)
+ field << XCHILD(_T("value"), xmlGetText(v));
}
else { // everything else is considered "text-single" or "text-private"
- len = GetWindowTextLength( GetDlgItem( hFrame, id ));
- str = ( TCHAR* )mir_alloc( sizeof(TCHAR)*( len+1 ));
- GetDlgItemText( hFrame, id, str, len+1 );
- field << XCHILD( _T("value"), str );
- mir_free( str );
+ len = GetWindowTextLength(GetDlgItem(hFrame, id));
+ str = (TCHAR*)mir_alloc(sizeof(TCHAR)*(len+1));
+ GetDlgItemText(hFrame, id, str, len+1);
+ field << XCHILD(_T("value"), str);
+ mir_free(str);
id++;
} }
- return xi.copyNode( x );
+ return xi.copyNode(x);
}
struct JABBER_FORM_INFO
@@ -720,74 +720,74 @@ struct JABBER_FORM_INFO HXML xNode;
TCHAR defTitle[128]; // Default title if no <title/> in xNode
RECT frameRect; // Clipping region of the frame to scroll
- int frameHeight; // Height of the frame ( can be eliminated, redundant to frameRect )
+ int frameHeight; // Height of the frame (can be eliminated, redundant to frameRect)
int formHeight; // Actual height of the form
int curPos; // Current scroll position
JABBER_FORM_SUBMIT_FUNC pfnSubmit;
void *userdata;
};
-static INT_PTR CALLBACK JabberFormDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
JABBER_FORM_INFO *jfi;
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
{
HXML n;
LONG frameExStyle;
- // lParam is ( JABBER_FORM_INFO * )
- TranslateDialogDefault( hwndDlg );
- ShowWindow( GetDlgItem( hwndDlg, IDC_FRAME_TEXT ), SW_HIDE );
- jfi = ( JABBER_FORM_INFO * ) lParam;
- if ( jfi != NULL ) {
+ // lParam is (JABBER_FORM_INFO *)
+ TranslateDialogDefault(hwndDlg);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME_TEXT), SW_HIDE);
+ jfi = (JABBER_FORM_INFO *) lParam;
+ if (jfi != NULL) {
// Set dialog title
- if ( jfi->xNode!=NULL && ( n = xmlGetChild( jfi->xNode , "title" )) != NULL && xmlGetText( n ) != NULL )
- SetWindowText( hwndDlg, xmlGetText( n ));
- else if ( jfi->defTitle != NULL )
- SetWindowText( hwndDlg, TranslateTS( jfi->defTitle ));
+ if (jfi->xNode!=NULL && (n = xmlGetChild(jfi->xNode , "title")) != NULL && xmlGetText(n) != NULL)
+ SetWindowText(hwndDlg, xmlGetText(n));
+ else if (jfi->defTitle != NULL)
+ SetWindowText(hwndDlg, TranslateTS(jfi->defTitle));
// Set instruction field
- if ( jfi->xNode!=NULL && ( n = xmlGetChild( jfi->xNode , "instructions" )) != NULL && xmlGetText( n ) != NULL )
- JabberFormSetInstruction( hwndDlg, xmlGetText( n ));
+ 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 )
- JabberFormSetInstruction( hwndDlg, xmlGetText( n ));
- else if ( jfi->defTitle != NULL )
- JabberFormSetInstruction( hwndDlg, TranslateTS( jfi->defTitle ));
+ 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));
}
// Create form
- if ( jfi->xNode != NULL ) {
+ 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 );
- GetClientRect( GetDlgItem( hwndDlg, IDC_FRAME ), &rect );
+ GetClientRect(GetDlgItem(hwndDlg, IDC_FRAME), &(jfi->frameRect));
+ GetClientRect(GetDlgItem(hwndDlg, IDC_VSCROLL), &rect);
+ jfi->frameRect.right -= (rect.right - rect.left);
+ GetClientRect(GetDlgItem(hwndDlg, IDC_FRAME), &rect);
jfi->frameHeight = rect.bottom - rect.top;
- JabberFormCreateUI( GetDlgItem( hwndDlg, IDC_FRAME ), jfi->xNode, &( jfi->formHeight ));
+ JabberFormCreateUI(GetDlgItem(hwndDlg, IDC_FRAME), jfi->xNode, &(jfi->formHeight));
}
}
- if ( jfi->formHeight > jfi->frameHeight ) {
+ if (jfi->formHeight > jfi->frameHeight) {
HWND hwndScroll;
- hwndScroll = GetDlgItem( hwndDlg, IDC_VSCROLL );
- EnableWindow( hwndScroll, TRUE );
- SetScrollRange( hwndScroll, SB_CTL, 0, jfi->formHeight - jfi->frameHeight, FALSE );
+ hwndScroll = GetDlgItem(hwndDlg, IDC_VSCROLL);
+ EnableWindow(hwndScroll, TRUE);
+ SetScrollRange(hwndScroll, SB_CTL, 0, jfi->formHeight - jfi->frameHeight, FALSE);
jfi->curPos = 0;
}
- // Enable WS_EX_CONTROLPARENT on IDC_FRAME ( so tab stop goes through all its children )
- frameExStyle = GetWindowLongPtr( GetDlgItem( hwndDlg, IDC_FRAME ), GWL_EXSTYLE );
+ // Enable WS_EX_CONTROLPARENT on IDC_FRAME (so tab stop goes through all its children)
+ frameExStyle = GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FRAME), GWL_EXSTYLE);
frameExStyle |= WS_EX_CONTROLPARENT;
- SetWindowLongPtr( GetDlgItem( hwndDlg, IDC_FRAME ), GWL_EXSTYLE, frameExStyle );
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FRAME), GWL_EXSTYLE, frameExStyle);
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR ) jfi );
- if ( jfi->pfnSubmit != NULL )
- EnableWindow( GetDlgItem( hwndDlg, IDC_SUBMIT ), TRUE );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) jfi);
+ if (jfi->pfnSubmit != NULL)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SUBMIT), TRUE);
}
return TRUE;
@@ -803,21 +803,21 @@ static INT_PTR CALLBACK JabberFormDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam case WM_MOUSEWHEEL:
{
- int zDelta = GET_WHEEL_DELTA_WPARAM( wParam );
- if ( zDelta ) {
+ int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
+ if (zDelta) {
int nScrollLines=0;
- SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0 );
- for (int i = 0; i < ( nScrollLines + 1 ) / 2; i++ )
- SendMessage( hwndDlg, WM_VSCROLL, ( zDelta < 0 ) ? SB_LINEDOWN : SB_LINEUP, 0 );
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0);
+ for (int i = 0; i < (nScrollLines + 1) / 2; i++)
+ SendMessage(hwndDlg, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0);
}
}
break;
case WM_VSCROLL:
- jfi = ( JABBER_FORM_INFO * ) GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
- if ( jfi != NULL ) {
+ jfi = (JABBER_FORM_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (jfi != NULL) {
int pos = jfi->curPos;
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case SB_LINEDOWN:
pos += 15;
break;
@@ -825,51 +825,51 @@ static INT_PTR CALLBACK JabberFormDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam pos -= 15;
break;
case SB_PAGEDOWN:
- pos += ( jfi->frameHeight - 10 );
+ pos += (jfi->frameHeight - 10);
break;
case SB_PAGEUP:
- pos -= ( jfi->frameHeight - 10 );
+ pos -= (jfi->frameHeight - 10);
break;
case SB_THUMBTRACK:
- pos = HIWORD( wParam );
+ pos = HIWORD(wParam);
break;
}
- if ( pos > ( jfi->formHeight - jfi->frameHeight ))
+ if (pos > (jfi->formHeight - jfi->frameHeight))
pos = jfi->formHeight - jfi->frameHeight;
- if ( pos < 0 )
+ if (pos < 0)
pos = 0;
- if ( jfi->curPos != pos ) {
- ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, jfi->curPos - pos, NULL, &( jfi->frameRect ));
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, pos, TRUE );
+ if (jfi->curPos != pos) {
+ ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, jfi->curPos - pos, NULL, &(jfi->frameRect));
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE);
jfi->curPos = pos;
}
}
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ 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 );
- xi.destroyNode( n );
+ 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);
+ xi.destroyNode(n);
}
// fall through
case IDCANCEL:
case IDCLOSE:
- DestroyWindow( hwndDlg );
+ DestroyWindow(hwndDlg);
return TRUE;
}
break;
case WM_CLOSE:
- DestroyWindow( hwndDlg );
+ DestroyWindow(hwndDlg);
break;
case WM_DESTROY:
- JabberFormDestroyUI( GetDlgItem( hwndDlg, IDC_FRAME ));
- jfi = ( JABBER_FORM_INFO * ) GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JabberFormDestroyUI(GetDlgItem(hwndDlg, IDC_FRAME));
+ jfi = (JABBER_FORM_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
delete jfi;
break;
}
@@ -877,29 +877,29 @@ static INT_PTR CALLBACK JabberFormDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam return FALSE;
}
-static VOID CALLBACK JabberFormCreateDialogApcProc( void* param )
+static VOID CALLBACK JabberFormCreateDialogApcProc(void* param)
{
- CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_FORM ), NULL, JabberFormDlgProc, ( LPARAM )param );
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FORM), NULL, JabberFormDlgProc, (LPARAM)param);
}
-void CJabberProto::FormCreateDialog( HXML xNode, TCHAR* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata )
+void CJabberProto::FormCreateDialog(HXML xNode, TCHAR* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata)
{
JABBER_FORM_INFO *jfi = new JABBER_FORM_INFO;
- memset( jfi, 0, sizeof( JABBER_FORM_INFO ));
+ memset(jfi, 0, sizeof(JABBER_FORM_INFO));
jfi->ppro = this;
- jfi->xNode = xi.copyNode( xNode );
- if ( defTitle )
- _tcsncpy( jfi->defTitle, defTitle, SIZEOF( jfi->defTitle ));
+ jfi->xNode = xi.copyNode(xNode);
+ if (defTitle)
+ _tcsncpy(jfi->defTitle, defTitle, SIZEOF(jfi->defTitle));
jfi->pfnSubmit = pfnSubmit;
jfi->userdata = userdata;
- CallFunctionAsync( JabberFormCreateDialogApcProc, jfi );
+ CallFunctionAsync(JabberFormCreateDialogApcProc, jfi);
}
//=======================================================================================
JABBER_FORM_INFO::~JABBER_FORM_INFO()
{
- xi.destroyNode( xNode );
- mir_free( userdata );
+ xi.destroyNode(xNode);
+ mir_free(userdata);
}
\ No newline at end of file diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 4ded28d84d..eb4f9a58e7 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -31,161 +31,161 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_ibb.h"
#include "jabber_caps.h"
-void CJabberProto::FtCancel( filetransfer* ft )
+void CJabberProto::FtCancel(filetransfer *ft)
{
JABBER_LIST_ITEM *item;
JABBER_BYTE_TRANSFER *jbt;
JABBER_IBB_TRANSFER *jibb;
- Log( "Invoking JabberFtCancel()" );
+ Log("Invoking JabberFtCancel()");
// For file sending session that is still in si negotiation phase
- if ( m_iqManager.ExpireByUserData( ft ))
+ if (m_iqManager.ExpireByUserData(ft))
return;
// For file receiving session that is still in si negotiation phase
LISTFOREACH(i, this, LIST_FTRECV)
{
- item = ListGetItemPtrFromIndex( i );
- if ( item->ft == ft ) {
- Log( "Canceling file receiving session while in si negotiation" );
- ListRemoveByIndex( i );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0 );
+ item = ListGetItemPtrFromIndex(i);
+ if (item->ft == ft) {
+ Log("Canceling file receiving session while in si negotiation");
+ ListRemoveByIndex(i);
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
delete ft;
return;
}
}
// For file transfer through bytestream
- if (( jbt=ft->jbt ) != NULL ) {
- Log( "Canceling bytestream session" );
+ if ((jbt=ft->jbt) != NULL) {
+ Log("Canceling bytestream session");
jbt->state = JBT_ERROR;
- if ( jbt->hConn ) {
- Log( "Force closing bytestream session" );
- Netlib_CloseHandle( jbt->hConn );
+ if (jbt->hConn) {
+ Log("Force closing bytestream session");
+ Netlib_CloseHandle(jbt->hConn);
jbt->hConn = NULL;
}
- if ( jbt->hSendEvent ) SetEvent( jbt->hSendEvent );
- if ( jbt->hEvent ) SetEvent( jbt->hEvent );
- if ( jbt->hProxyEvent ) SetEvent( jbt->hProxyEvent );
+ if (jbt->hSendEvent) SetEvent(jbt->hSendEvent);
+ if (jbt->hEvent) SetEvent(jbt->hEvent);
+ if (jbt->hProxyEvent) SetEvent(jbt->hProxyEvent);
}
// For file transfer through IBB
- if (( jibb=ft->jibb ) != NULL ) {
- Log( "Canceling IBB session" );
+ if ((jibb=ft->jibb) != NULL) {
+ Log("Canceling IBB session");
jibb->state = JIBB_ERROR;
- m_iqManager.ExpireByUserData( jibb );
+ m_iqManager.ExpireByUserData(jibb);
}
}
///////////////// File sending using stream initiation /////////////////////////
-void CJabberProto::FtInitiate( TCHAR* jid, filetransfer* ft )
+void CJabberProto::FtInitiate(TCHAR* jid, filetransfer *ft)
{
TCHAR *rs;
TCHAR *filename, *p;
int i;
TCHAR sid[9];
- if ( jid==NULL || ft==NULL || !m_bJabberOnline || ( rs=ListGetBestClientResourceNamePtr( jid ))==NULL ) {
- if ( ft ) {
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0 );
+ if (jid==NULL || ft==NULL || !m_bJabberOnline || (rs=ListGetBestClientResourceNamePtr(jid))==NULL) {
+ if (ft) {
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
delete ft;
}
return;
}
ft->type = FT_SI;
- for ( i=0; i<8; i++ )
- sid[i] = ( rand()%10 ) + '0';
+ for (i=0; i<8; i++)
+ sid[i] = (rand()%10) + '0';
sid[8] = '\0';
- if ( ft->sid != NULL ) mir_free( ft->sid );
- ft->sid = mir_tstrdup( sid );
+ if (ft->sid != NULL) mir_free(ft->sid);
+ ft->sid = mir_tstrdup(sid);
filename = ft->std.ptszFiles[ ft->std.currentFileNumber ];
- if (( p = _tcsrchr( filename, '\\' )) != NULL )
+ if ((p = _tcsrchr(filename, '\\')) != NULL)
filename = p+1;
TCHAR tszJid[ 512 ];
- mir_sntprintf( tszJid, SIZEOF(tszJid), _T("%s/%s"), jid, rs );
+ mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), jid, rs);
- XmlNodeIq iq( m_iqManager.AddHandler( &CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, tszJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO, -1, ft ));
- HXML si = iq << XCHILDNS( _T("si"), _T(JABBER_FEAT_SI)) << XATTR( _T("id"), sid )
- << XATTR( _T("mime-type"), _T("binary/octet-stream")) << XATTR( _T("profile"), _T(JABBER_FEAT_SI_FT));
- si << XCHILDNS( _T("file"), _T(JABBER_FEAT_SI_FT)) << XATTR( _T("name"), filename)
- << XATTRI64( _T("size"), ft->fileSize[ ft->std.currentFileNumber ] ) << XCHILD( _T("desc"), ft->szDescription);
+ XmlNodeIq iq(m_iqManager.AddHandler(&CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, tszJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO, -1, ft));
+ HXML si = iq << XCHILDNS(_T("si"), _T(JABBER_FEAT_SI)) << XATTR(_T("id"), sid)
+ << XATTR(_T("mime-type"), _T("binary/octet-stream")) << XATTR(_T("profile"), _T(JABBER_FEAT_SI_FT));
+ si << XCHILDNS(_T("file"), _T(JABBER_FEAT_SI_FT)) << XATTR(_T("name"), filename)
+ << XATTRI64(_T("size"), ft->fileSize[ ft->std.currentFileNumber ]) << XCHILD(_T("desc"), ft->szDescription);
- HXML field = si << XCHILDNS( _T("feature"), _T(JABBER_FEAT_FEATURE_NEG))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("form"))
- << XCHILD( _T("field")) << XATTR( _T("var"), _T("stream-method")) << XATTR( _T("type"), _T("list-single"));
+ HXML field = si << XCHILDNS(_T("feature"), _T(JABBER_FEAT_FEATURE_NEG))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("form"))
+ << XCHILD(_T("field")) << XATTR(_T("var"), _T("stream-method")) << XATTR(_T("type"), _T("list-single"));
BOOL bDirect = m_options.BsDirect;
BOOL bProxy = m_options.BsProxyManual;
// bytestreams support?
- if ( bDirect || bProxy )
- field << XCHILD( _T("option")) << XCHILD( _T("value"), _T(JABBER_FEAT_BYTESTREAMS));
+ if (bDirect || bProxy)
+ field << XCHILD(_T("option")) << XCHILD(_T("value"), _T(JABBER_FEAT_BYTESTREAMS));
- field << XCHILD( _T("option")) << XCHILD( _T("value"), _T(JABBER_FEAT_IBB));
- m_ThreadInfo->send( iq );
+ field << XCHILD(_T("option")) << XCHILD(_T("value"), _T(JABBER_FEAT_IBB));
+ m_ThreadInfo->send(iq);
}
-void CJabberProto::OnFtSiResult( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo* pInfo)
{
HXML siNode, featureNode, xNode, fieldNode, valueNode;
filetransfer *ft = (filetransfer *)pInfo->GetUserData();
- if ( !ft ) return;
+ if ( !ft) return;
- if (( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) && pInfo->m_szFrom && pInfo->m_szTo ) {
- if (( siNode = xmlGetChild( iqNode , "si" )) != NULL ) {
+ if ((pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) && pInfo->m_szFrom && pInfo->m_szTo) {
+ if ((siNode = xmlGetChild(iqNode , "si")) != NULL) {
// fix for very smart clients, like gajim
BOOL bDirect = m_options.BsDirect;
BOOL bProxy = m_options.BsProxyManual;
- if (( featureNode = xmlGetChild( siNode , "feature" )) != NULL ) {
- if (( xNode = xmlGetChildByTag( featureNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS))) != NULL ) {
- if (( fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("stream-method"))) != NULL ) {
- if (( valueNode = xmlGetChild( fieldNode , "value" ))!=NULL && xmlGetText( valueNode )!=NULL ) {
- if (( bDirect || bProxy ) && !_tcscmp( xmlGetText( valueNode ), _T(JABBER_FEAT_BYTESTREAMS))) {
+ if ((featureNode = xmlGetChild(siNode , "feature")) != NULL) {
+ if ((xNode = xmlGetChildByTag(featureNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS))) != NULL) {
+ if ((fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("stream-method"))) != NULL) {
+ if ((valueNode = xmlGetChild(fieldNode , "value"))!=NULL && xmlGetText(valueNode)!=NULL) {
+ if ((bDirect || bProxy) && !_tcscmp(xmlGetText(valueNode), _T(JABBER_FEAT_BYTESTREAMS))) {
// Start Bytestream session
JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER;
- ZeroMemory( jbt, sizeof( JABBER_BYTE_TRANSFER ));
- jbt->srcJID = mir_tstrdup( pInfo->m_szTo );
- jbt->dstJID = mir_tstrdup( pInfo->m_szFrom );
- jbt->sid = mir_tstrdup( ft->sid );
+ ZeroMemory(jbt, sizeof(JABBER_BYTE_TRANSFER));
+ jbt->srcJID = mir_tstrdup(pInfo->m_szTo);
+ jbt->dstJID = mir_tstrdup(pInfo->m_szFrom);
+ jbt->sid = mir_tstrdup(ft->sid);
jbt->pfnSend = &CJabberProto::FtSend;
jbt->pfnFinal = &CJabberProto::FtSendFinal;
jbt->ft = ft;
ft->type = FT_BYTESTREAM;
ft->jbt = jbt;
- JForkThread(( JThreadFunc )&CJabberProto::ByteSendThread, jbt );
- } else if ( !_tcscmp( xmlGetText( valueNode ), _T(JABBER_FEAT_IBB))) {
- JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *) mir_alloc( sizeof ( JABBER_IBB_TRANSFER ));
- ZeroMemory( jibb, sizeof( JABBER_IBB_TRANSFER ));
- jibb->srcJID = mir_tstrdup( pInfo->m_szTo );
- jibb->dstJID = mir_tstrdup( pInfo->m_szFrom );
- jibb->sid = mir_tstrdup( ft->sid );
+ JForkThread((JThreadFunc)&CJabberProto::ByteSendThread, jbt);
+ } else if ( !_tcscmp(xmlGetText(valueNode), _T(JABBER_FEAT_IBB))) {
+ JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *) mir_alloc(sizeof (JABBER_IBB_TRANSFER));
+ ZeroMemory(jibb, sizeof(JABBER_IBB_TRANSFER));
+ jibb->srcJID = mir_tstrdup(pInfo->m_szTo);
+ jibb->dstJID = mir_tstrdup(pInfo->m_szFrom);
+ jibb->sid = mir_tstrdup(ft->sid);
jibb->pfnSend = &CJabberProto::FtIbbSend;
jibb->pfnFinal = &CJabberProto::FtSendFinal;
jibb->ft = ft;
ft->type = FT_IBB;
ft->jibb = jibb;
- JForkThread(( JThreadFunc )&CJabberProto::IbbSendThread, jibb );
+ JForkThread((JThreadFunc)&CJabberProto::IbbSendThread, jibb);
} } } } } } }
else {
- Log( "File transfer stream initiation request denied or failed" );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR ? ACKRESULT_DENIED : ACKRESULT_FAILED, ft, 0 );
+ Log("File transfer stream initiation request denied or failed");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR ? ACKRESULT_DENIED : ACKRESULT_FAILED, ft, 0);
delete ft;
}
}
-BOOL CJabberProto::FtSend( HANDLE hConn, filetransfer* ft )
+BOOL CJabberProto::FtSend(HANDLE hConn, filetransfer *ft)
{
struct _stati64 statbuf;
int fd;
char* buffer;
int numRead;
- Log( "Sending [%s]", ft->std.ptszFiles[ ft->std.currentFileNumber ] );
- _tstati64( ft->std.ptszFiles[ ft->std.currentFileNumber ], &statbuf ); // file size in statbuf.st_size
- if (( fd = _topen( ft->std.ptszFiles[ ft->std.currentFileNumber ], _O_BINARY|_O_RDONLY )) < 0 ) {
- Log( "File cannot be opened" );
+ Log("Sending [%s]", ft->std.ptszFiles[ ft->std.currentFileNumber ]);
+ _tstati64(ft->std.ptszFiles[ ft->std.currentFileNumber ], &statbuf); // file size in statbuf.st_size
+ if ((fd = _topen(ft->std.ptszFiles[ ft->std.currentFileNumber ], _O_BINARY|_O_RDONLY)) < 0) {
+ Log("File cannot be opened");
return FALSE;
}
@@ -193,34 +193,34 @@ BOOL CJabberProto::FtSend( HANDLE hConn, filetransfer* ft ) ft->std.currentFileSize = statbuf.st_size;
ft->std.currentFileProgress = 0;
- if (( buffer=( char* )mir_alloc( 2048 )) != NULL ) {
- while (( numRead=_read( fd, buffer, 2048 )) > 0 ) {
- if ( Netlib_Send( hConn, buffer, numRead, 0 ) != numRead ) {
- mir_free( buffer );
- _close( fd );
+ if ((buffer=(char*)mir_alloc(2048)) != NULL) {
+ while ((numRead=_read(fd, buffer, 2048)) > 0) {
+ if (Netlib_Send(hConn, buffer, numRead, 0) != numRead) {
+ mir_free(buffer);
+ _close(fd);
return FALSE;
}
ft->std.currentFileProgress += numRead;
ft->std.totalProgress += numRead;
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, ( LPARAM )&ft->std );
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
}
- mir_free( buffer );
+ mir_free(buffer);
}
- _close( fd );
+ _close(fd);
return TRUE;
}
-BOOL CJabberProto::FtIbbSend( int blocksize, filetransfer* ft )
+BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft)
{
struct _stati64 statbuf;
int fd;
char* buffer;
int numRead;
- Log( "Sending [%s]", ft->std.ptszFiles[ ft->std.currentFileNumber ] );
- _tstati64( ft->std.ptszFiles[ ft->std.currentFileNumber ], &statbuf ); // file size in statbuf.st_size
- if (( fd = _topen( ft->std.ptszFiles[ ft->std.currentFileNumber ], _O_BINARY|_O_RDONLY )) < 0 ) {
- Log( "File cannot be opened" );
+ Log("Sending [%s]", ft->std.ptszFiles[ ft->std.currentFileNumber ]);
+ _tstati64(ft->std.ptszFiles[ ft->std.currentFileNumber ], &statbuf); // file size in statbuf.st_size
+ if ((fd = _topen(ft->std.ptszFiles[ ft->std.currentFileNumber ], _O_BINARY|_O_RDONLY)) < 0) {
+ Log("File cannot be opened");
return FALSE;
}
@@ -228,34 +228,34 @@ BOOL CJabberProto::FtIbbSend( int blocksize, filetransfer* ft ) ft->std.currentFileSize = statbuf.st_size;
ft->std.currentFileProgress = 0;
- if (( buffer=( char* )mir_alloc( blocksize )) != NULL ) {
- while (( numRead=_read( fd, buffer, blocksize )) > 0 ) {
+ if ((buffer=(char*)mir_alloc(blocksize)) != NULL) {
+ while ((numRead=_read(fd, buffer, blocksize)) > 0) {
int iqId = SerialNext();
- XmlNode msg( _T("message"));
- xmlAddAttr( msg, _T("to"), ft->jibb->dstJID );
- msg << XATTRID( iqId );
+ XmlNode msg(_T("message"));
+ xmlAddAttr(msg, _T("to"), ft->jibb->dstJID);
+ msg << XATTRID(iqId);
// let others send data too
Sleep(2);
char *encoded = JabberBase64Encode(buffer, numRead);
- msg << XCHILD( _T("data"), _A2T(encoded)) << XATTR( _T("xmlns"), _T(JABBER_FEAT_IBB))
- << XATTR( _T("sid"), ft->jibb->sid ) << XATTRI( _T("seq"), ft->jibb->wPacketId );
+ msg << XCHILD(_T("data"), _A2T(encoded)) << XATTR(_T("xmlns"), _T(JABBER_FEAT_IBB))
+ << XATTR(_T("sid"), ft->jibb->sid) << XATTRI(_T("seq"), ft->jibb->wPacketId);
- HXML ampNode = msg << XCHILDNS( _T("amp"), _T(JABBER_FEAT_AMP));
- ampNode << XCHILD( _T("rule")) << XATTR( _T("condition"), _T("deliver-at"))
- << XATTR( _T("value"), _T("stored")) << XATTR( _T("action"), _T("error"));
- ampNode << XCHILD( _T("rule")) << XATTR( _T("condition"), _T("match-resource"))
- << XATTR( _T("value"), _T("exact")) << XATTR( _T("action"), _T("error"));
+ HXML ampNode = msg << XCHILDNS(_T("amp"), _T(JABBER_FEAT_AMP));
+ ampNode << XCHILD(_T("rule")) << XATTR(_T("condition"), _T("deliver-at"))
+ << XATTR(_T("value"), _T("stored")) << XATTR(_T("action"), _T("error"));
+ ampNode << XCHILD(_T("rule")) << XATTR(_T("condition"), _T("match-resource"))
+ << XATTR(_T("value"), _T("exact")) << XATTR(_T("action"), _T("error"));
ft->jibb->wPacketId++;
- mir_free( encoded );
+ mir_free(encoded);
- if ( ft->jibb->state == JIBB_ERROR || ft->jibb->bStreamClosed || m_ThreadInfo->send( msg ) == SOCKET_ERROR ) {
- Log( "JabberFtIbbSend unsuccessful exit" );
- mir_free( buffer );
- _close( fd );
+ if (ft->jibb->state == JIBB_ERROR || ft->jibb->bStreamClosed || m_ThreadInfo->send(msg) == SOCKET_ERROR) {
+ Log("JabberFtIbbSend unsuccessful exit");
+ mir_free(buffer);
+ _close(fd);
return FALSE;
}
@@ -263,30 +263,30 @@ BOOL CJabberProto::FtIbbSend( int blocksize, filetransfer* ft ) ft->std.currentFileProgress += numRead;
ft->std.totalProgress += numRead;
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, ( LPARAM )&ft->std );
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
}
- mir_free( buffer );
+ mir_free(buffer);
}
- _close( fd );
+ _close(fd);
return TRUE;
}
-void CJabberProto::FtSendFinal( BOOL success, filetransfer* ft )
+void CJabberProto::FtSendFinal(BOOL success, filetransfer *ft)
{
- if ( !success ) {
- Log( "File transfer complete with error" );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ft->state == FT_DENIED ? ACKRESULT_DENIED : ACKRESULT_FAILED, ft, 0 );
+ if ( !success) {
+ Log("File transfer complete with error");
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ft->state == FT_DENIED ? ACKRESULT_DENIED : ACKRESULT_FAILED, ft, 0);
}
else {
- if ( ft->std.currentFileNumber < ft->std.totalFiles-1 ) {
+ if (ft->std.currentFileNumber < ft->std.totalFiles-1) {
ft->std.currentFileNumber++;
- replaceStrT( ft->std.tszCurrentFile, ft->std.ptszFiles[ ft->std.currentFileNumber ] );
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0 );
- FtInitiate( ft->jid, ft );
+ replaceStrT(ft->std.tszCurrentFile, ft->std.ptszFiles[ ft->std.currentFileNumber ]);
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0);
+ FtInitiate(ft->jid, ft);
return;
}
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0 );
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
}
delete ft;
@@ -294,258 +294,258 @@ void CJabberProto::FtSendFinal( BOOL success, filetransfer* ft ) ///////////////// File receiving through stream initiation /////////////////////////
-void CJabberProto::FtHandleSiRequest( HXML iqNode )
+void CJabberProto::FtHandleSiRequest(HXML iqNode)
{
- const TCHAR* from, *sid, *str, *szId, *filename;
+ const TCHAR *from, *sid, *str, *szId, *filename;
HXML siNode, fileNode, featureNode, xNode, fieldNode, n;
int i;
unsigned __int64 filesize;
if ( !iqNode ||
- ( from = xmlGetAttrValue( iqNode, _T("from"))) == NULL ||
- ( str = xmlGetAttrValue( iqNode, _T("type"))) == NULL || _tcscmp( str, _T("set")) ||
- ( siNode = xmlGetChildByTag( iqNode, "si", "xmlns", _T(JABBER_FEAT_SI))) == NULL )
+ (from = xmlGetAttrValue(iqNode, _T("from"))) == NULL ||
+ (str = xmlGetAttrValue(iqNode, _T("type"))) == NULL || _tcscmp(str, _T("set")) ||
+ (siNode = xmlGetChildByTag(iqNode, "si", "xmlns", _T(JABBER_FEAT_SI))) == NULL)
return;
- szId = xmlGetAttrValue( iqNode, _T("id"));
- if (( sid = xmlGetAttrValue( siNode, _T("id"))) != NULL &&
- ( fileNode = xmlGetChildByTag( siNode, "file", "xmlns", _T(JABBER_FEAT_SI_FT))) != NULL &&
- ( filename = xmlGetAttrValue( fileNode, _T("name"))) != NULL &&
- ( str = xmlGetAttrValue( fileNode, _T("size"))) != NULL ) {
+ szId = xmlGetAttrValue(iqNode, _T("id"));
+ if ((sid = xmlGetAttrValue(siNode, _T("id"))) != NULL &&
+ (fileNode = xmlGetChildByTag(siNode, "file", "xmlns", _T(JABBER_FEAT_SI_FT))) != NULL &&
+ (filename = xmlGetAttrValue(fileNode, _T("name"))) != NULL &&
+ (str = xmlGetAttrValue(fileNode, _T("size"))) != NULL) {
- filesize = _ttoi64( str );
- if (( featureNode = xmlGetChildByTag( siNode, "feature", "xmlns", _T(JABBER_FEAT_FEATURE_NEG))) != NULL &&
- ( xNode = xmlGetChildByTag( featureNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS)))!=NULL &&
- ( fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("stream-method")))!=NULL ) {
+ filesize = _ttoi64(str);
+ if ((featureNode = xmlGetChildByTag(siNode, "feature", "xmlns", _T(JABBER_FEAT_FEATURE_NEG))) != NULL &&
+ (xNode = xmlGetChildByTag(featureNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS)))!=NULL &&
+ (fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("stream-method")))!=NULL) {
BOOL bIbbOnly = m_options.BsOnlyIBB;
HXML optionNode = NULL;
JABBER_FT_TYPE ftType = FT_OOB;
- if ( !bIbbOnly ) {
- for ( i=0; ; i++ ) {
- optionNode = xmlGetChild( fieldNode ,i);
- if ( !optionNode )
+ if ( !bIbbOnly) {
+ for (i=0; ; i++) {
+ optionNode = xmlGetChild(fieldNode ,i);
+ if ( !optionNode)
break;
- if ( !lstrcmp( xmlGetName( optionNode ), _T("option"))) {
- if (( n = xmlGetChild( optionNode , "value" )) != NULL && xmlGetText( n )) {
- if ( !_tcscmp( xmlGetText( n ), _T(JABBER_FEAT_BYTESTREAMS))) {
+ if ( !lstrcmp(xmlGetName(optionNode), _T("option"))) {
+ if ((n = xmlGetChild(optionNode , "value")) != NULL && xmlGetText(n)) {
+ if ( !_tcscmp(xmlGetText(n), _T(JABBER_FEAT_BYTESTREAMS))) {
ftType = FT_BYTESTREAM;
break;
} } } } }
// try IBB only if bytestreams support not found or BsOnlyIBB flag exists
- if ( bIbbOnly || !optionNode ) {
- for ( i=0; ; i++ ) {
- optionNode = xmlGetChild( fieldNode ,i);
- if ( !optionNode )
+ if (bIbbOnly || !optionNode) {
+ for (i=0; ; i++) {
+ optionNode = xmlGetChild(fieldNode ,i);
+ if ( !optionNode)
break;
- if ( !lstrcmp( xmlGetName( optionNode ), _T("option"))) {
- if (( n = xmlGetChild( optionNode , "value" )) != NULL && xmlGetText( n )) {
- if ( !_tcscmp( xmlGetText( n ), _T(JABBER_FEAT_IBB))) {
+ if ( !lstrcmp(xmlGetName(optionNode), _T("option"))) {
+ if ((n = xmlGetChild(optionNode , "value")) != NULL && xmlGetText(n)) {
+ if ( !_tcscmp(xmlGetText(n), _T(JABBER_FEAT_IBB))) {
ftType = FT_IBB;
break;
} } } } }
- if ( optionNode != NULL ) {
+ if (optionNode != NULL) {
// Found known stream mechanism
- filetransfer* ft = new filetransfer( this );
+ filetransfer *ft = new filetransfer(this);
ft->dwExpectedRecvFileSize = filesize;
- ft->jid = mir_tstrdup( from );
- ft->std.hContact = HContactFromJID( from );
- ft->sid = mir_tstrdup( sid );
- ft->iqId = mir_tstrdup( szId );
+ ft->jid = mir_tstrdup(from);
+ ft->std.hContact = HContactFromJID(from);
+ ft->sid = mir_tstrdup(sid);
+ ft->iqId = mir_tstrdup(szId);
ft->type = ftType;
ft->std.totalFiles = 1;
- ft->std.tszCurrentFile = mir_tstrdup( filename );
+ ft->std.tszCurrentFile = mir_tstrdup(filename);
ft->std.totalBytes = ft->std.currentFileSize = filesize;
PROTORECVFILET pre = { 0 };
pre.flags = PREF_TCHAR;
pre.fileCount = 1;
- pre.timestamp = time( NULL );
- pre.ptszFiles = ( TCHAR** )&filename;
- pre.lParam = ( LPARAM )ft;
- if (( n = xmlGetChild( fileNode , "desc" )) != NULL )
- pre.tszDescription = ( TCHAR* )xmlGetText( n );
-
- CCSDATA ccs = { ft->std.hContact, PSR_FILE, 0, ( LPARAM )&pre };
- CallService( MS_PROTO_CHAINRECV, 0, ( LPARAM )&ccs );
+ pre.timestamp = time(NULL);
+ pre.ptszFiles = (TCHAR**)&filename;
+ pre.lParam = (LPARAM)ft;
+ if ((n = xmlGetChild(fileNode , "desc")) != NULL)
+ pre.tszDescription = (TCHAR*)xmlGetText(n);
+
+ CCSDATA ccs = { ft->std.hContact, PSR_FILE, 0, (LPARAM)&pre };
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
return;
}
else {
// Unknown stream mechanism
- XmlNodeIq iq( _T("error"), szId, from );
- HXML e = iq << XCHILD( _T("error")) << XATTRI( _T("code"), 400 ) << XATTR( _T("type"), _T("cancel"));
- e << XCHILDNS( _T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
- e << XCHILDNS( _T("no-valid-streams"), _T(JABBER_FEAT_SI));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), szId, from);
+ HXML e = iq << XCHILD(_T("error")) << XATTRI(_T("code"), 400) << XATTR(_T("type"), _T("cancel"));
+ e << XCHILDNS(_T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
+ e << XCHILDNS(_T("no-valid-streams"), _T(JABBER_FEAT_SI));
+ m_ThreadInfo->send(iq);
return;
} } }
// Bad stream initiation, reply with bad-profile
- XmlNodeIq iq( _T("error"), szId, from );
- HXML e = iq << XCHILD( _T("error")) << XATTRI( _T("code"), 400 ) << XATTR( _T("type"), _T("cancel"));
- e << XCHILDNS( _T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
- e << XCHILDNS( _T("bad-profile"), _T(JABBER_FEAT_SI));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), szId, from);
+ HXML e = iq << XCHILD(_T("error")) << XATTRI(_T("code"), 400) << XATTR(_T("type"), _T("cancel"));
+ e << XCHILDNS(_T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
+ e << XCHILDNS(_T("bad-profile"), _T(JABBER_FEAT_SI));
+ m_ThreadInfo->send(iq);
}
-void CJabberProto::FtAcceptSiRequest( filetransfer* ft )
+void CJabberProto::FtAcceptSiRequest(filetransfer *ft)
{
- if ( !m_bJabberOnline || ft==NULL || ft->jid==NULL || ft->sid==NULL ) return;
+ if ( !m_bJabberOnline || ft==NULL || ft->jid==NULL || ft->sid==NULL) return;
JABBER_LIST_ITEM *item;
- if (( item=ListAdd( LIST_FTRECV, ft->sid )) != NULL ) {
+ if ((item=ListAdd(LIST_FTRECV, ft->sid)) != NULL) {
item->ft = ft;
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), ft->iqId, ft->jid )
- << XCHILDNS( _T("si"), _T(JABBER_FEAT_SI))
- << XCHILDNS( _T("feature"), _T(JABBER_FEAT_FEATURE_NEG))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("submit"))
- << XCHILD( _T("field")) << XATTR( _T("var"), _T("stream-method"))
- << XCHILD( _T("value"), _T(JABBER_FEAT_BYTESTREAMS)));
+ XmlNodeIq(_T("result"), ft->iqId, ft->jid)
+ << XCHILDNS(_T("si"), _T(JABBER_FEAT_SI))
+ << XCHILDNS(_T("feature"), _T(JABBER_FEAT_FEATURE_NEG))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("submit"))
+ << XCHILD(_T("field")) << XATTR(_T("var"), _T("stream-method"))
+ << XCHILD(_T("value"), _T(JABBER_FEAT_BYTESTREAMS)));
} }
-void CJabberProto::FtAcceptIbbRequest( filetransfer* ft )
+void CJabberProto::FtAcceptIbbRequest(filetransfer *ft)
{
- if ( !m_bJabberOnline || ft==NULL || ft->jid==NULL || ft->sid==NULL ) return;
+ if ( !m_bJabberOnline || ft==NULL || ft->jid==NULL || ft->sid==NULL) return;
JABBER_LIST_ITEM *item;
- if (( item=ListAdd( LIST_FTRECV, ft->sid )) != NULL ) {
+ if ((item=ListAdd(LIST_FTRECV, ft->sid)) != NULL) {
item->ft = ft;
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), ft->iqId, ft->jid )
- << XCHILDNS( _T("si"), _T(JABBER_FEAT_SI))
- << XCHILDNS( _T("feature"), _T(JABBER_FEAT_FEATURE_NEG))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("submit"))
- << XCHILD( _T("field")) << XATTR( _T("var"), _T("stream-method"))
- << XCHILD( _T("value"), _T(JABBER_FEAT_IBB)));
+ XmlNodeIq(_T("result"), ft->iqId, ft->jid)
+ << XCHILDNS(_T("si"), _T(JABBER_FEAT_SI))
+ << XCHILDNS(_T("feature"), _T(JABBER_FEAT_FEATURE_NEG))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("submit"))
+ << XCHILD(_T("field")) << XATTR(_T("var"), _T("stream-method"))
+ << XCHILD(_T("value"), _T(JABBER_FEAT_IBB)));
} }
-BOOL CJabberProto::FtHandleBytestreamRequest( HXML iqNode, CJabberIqInfo* pInfo )
+BOOL CJabberProto::FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo* pInfo)
{
HXML queryNode = pInfo->GetChildNode();
- const TCHAR* sid;
+ const TCHAR *sid;
JABBER_LIST_ITEM *item;
- if (( sid = xmlGetAttrValue( queryNode, _T("sid"))) != NULL && ( item = ListGetItemPtr( LIST_FTRECV, sid )) != NULL ) {
+ if ((sid = xmlGetAttrValue(queryNode, _T("sid"))) != NULL && (item = ListGetItemPtr(LIST_FTRECV, sid)) != NULL) {
// Start Bytestream session
JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER;
- ZeroMemory( jbt, sizeof( JABBER_BYTE_TRANSFER ));
- jbt->iqNode = xi.copyNode( iqNode );
+ ZeroMemory(jbt, sizeof(JABBER_BYTE_TRANSFER));
+ jbt->iqNode = xi.copyNode(iqNode);
jbt->pfnRecv = &CJabberProto::FtReceive;
jbt->pfnFinal = &CJabberProto::FtReceiveFinal;
jbt->ft = item->ft;
item->ft->jbt = jbt;
- JForkThread(( JThreadFunc )&CJabberProto::ByteReceiveThread, jbt );
- ListRemove( LIST_FTRECV, sid );
+ JForkThread((JThreadFunc)&CJabberProto::ByteReceiveThread, jbt);
+ ListRemove(LIST_FTRECV, sid);
return TRUE;
}
- Log( "File transfer invalid bytestream initiation request received" );
+ Log("File transfer invalid bytestream initiation request received");
return TRUE;
}
-BOOL CJabberProto::FtHandleIbbRequest( HXML iqNode, BOOL bOpen )
+BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen)
{
- if ( !iqNode ) return FALSE;
+ if ( !iqNode) return FALSE;
- const TCHAR *id = xmlGetAttrValue( iqNode, _T("id"));
- const TCHAR *from = xmlGetAttrValue( iqNode, _T("from"));
- const TCHAR *to = xmlGetAttrValue( iqNode, _T("to"));
- if ( !id || !from || !to ) return FALSE;
+ const TCHAR *id = xmlGetAttrValue(iqNode, _T("id"));
+ const TCHAR *from = xmlGetAttrValue(iqNode, _T("from"));
+ const TCHAR *to = xmlGetAttrValue(iqNode, _T("to"));
+ if ( !id || !from || !to) return FALSE;
- HXML ibbNode = xmlGetChildByTag( iqNode, bOpen ? "open" : "close", "xmlns", _T(JABBER_FEAT_IBB));
- if ( !ibbNode ) return FALSE;
+ HXML ibbNode = xmlGetChildByTag(iqNode, bOpen ? "open" : "close", "xmlns", _T(JABBER_FEAT_IBB));
+ if ( !ibbNode) return FALSE;
- const TCHAR *sid = xmlGetAttrValue( ibbNode, _T("sid"));
- if ( !sid ) return FALSE;
+ const TCHAR *sid = xmlGetAttrValue(ibbNode, _T("sid"));
+ if ( !sid) return FALSE;
// already closed?
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_FTRECV, sid );
- if ( !item ) {
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid);
+ if ( !item) {
m_ThreadInfo->send(
- XmlNodeIq( _T("error"), id, from )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ XmlNodeIq(_T("error"), id, from)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
return FALSE;
}
// open event
- if ( bOpen ) {
- if ( !item->jibb ) {
- JABBER_IBB_TRANSFER *jibb = ( JABBER_IBB_TRANSFER * ) mir_alloc( sizeof( JABBER_IBB_TRANSFER ));
- ZeroMemory( jibb, sizeof( JABBER_IBB_TRANSFER ));
- jibb->srcJID = mir_tstrdup( from );
- jibb->dstJID = mir_tstrdup( to );
- jibb->sid = mir_tstrdup( sid );
+ if (bOpen) {
+ if ( !item->jibb) {
+ JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *) mir_alloc(sizeof(JABBER_IBB_TRANSFER));
+ ZeroMemory(jibb, sizeof(JABBER_IBB_TRANSFER));
+ jibb->srcJID = mir_tstrdup(from);
+ jibb->dstJID = mir_tstrdup(to);
+ jibb->sid = mir_tstrdup(sid);
jibb->pfnRecv = &CJabberProto::FtReceive;
jibb->pfnFinal = &CJabberProto::FtReceiveFinal;
jibb->ft = item->ft;
item->ft->jibb = jibb;
item->jibb = jibb;
- JForkThread(( JThreadFunc )&CJabberProto::IbbReceiveThread, jibb );
+ JForkThread((JThreadFunc)&CJabberProto::IbbReceiveThread, jibb);
- m_ThreadInfo->send( XmlNodeIq( _T("result"), id, from ));
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), id, from));
return TRUE;
}
// stream already open
m_ThreadInfo->send(
- XmlNodeIq( _T("error"), id, from )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ XmlNodeIq(_T("error"), id, from)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
return FALSE;
}
// close event && stream already open
- if ( item->jibb && item->jibb->hEvent ) {
+ if (item->jibb && item->jibb->hEvent) {
item->jibb->bStreamClosed = TRUE;
- SetEvent( item->jibb->hEvent );
+ SetEvent(item->jibb->hEvent);
- m_ThreadInfo->send( XmlNodeIq( _T("result"), id, from ));
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), id, from));
return TRUE;
}
- ListRemove( LIST_FTRECV, sid );
+ ListRemove(LIST_FTRECV, sid);
return FALSE;
}
-int CJabberProto::FtReceive( HANDLE, filetransfer* ft, char* buffer, int datalen )
+int CJabberProto::FtReceive(HANDLE, filetransfer *ft, char* buffer, int datalen)
{
- if ( ft->create() == -1 )
+ if (ft->create() == -1)
return -1;
__int64 remainingBytes = ft->std.currentFileSize - ft->std.currentFileProgress;
- if ( remainingBytes > 0 ) {
- int writeSize = ( remainingBytes<datalen ) ? remainingBytes : datalen;
- if ( _write( ft->fileId, buffer, writeSize ) != writeSize ) {
- Log( "_write() error" );
+ if (remainingBytes > 0) {
+ int writeSize = (remainingBytes<datalen) ? remainingBytes : datalen;
+ if (_write(ft->fileId, buffer, writeSize) != writeSize) {
+ Log("_write() error");
return -1;
}
ft->std.currentFileProgress += writeSize;
ft->std.totalProgress += writeSize;
- JSendBroadcast( ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, ( LPARAM )&ft->std );
- return ( ft->std.currentFileSize == ft->std.currentFileProgress ) ? 0 : writeSize;
+ JSendBroadcast(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->std);
+ return (ft->std.currentFileSize == ft->std.currentFileProgress) ? 0 : writeSize;
}
return 0;
}
-void CJabberProto::FtReceiveFinal( BOOL success, filetransfer* ft )
+void CJabberProto::FtReceiveFinal(BOOL success, filetransfer *ft)
{
- if ( success ) {
- Log( "File transfer complete successfully" );
+ if (success) {
+ Log("File transfer complete successfully");
ft->complete();
}
- else Log( "File transfer complete with error" );
+ else Log("File transfer complete with error");
delete ft;
}
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);
}
diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp index 51719a696b..53137d50fc 100644 --- a/protocols/JabberG/src/jabber_ibb.cpp +++ b/protocols/JabberG/src/jabber_ibb.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -28,99 +28,99 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define JABBER_IBB_BLOCK_SIZE 2048
-void JabberIbbFreeJibb( JABBER_IBB_TRANSFER *jibb )
+void JabberIbbFreeJibb(JABBER_IBB_TRANSFER *jibb)
{
- if ( jibb ) {
+ if (jibb) {
filetransfer* pft = jibb->ft;
- if ( pft )
+ if (pft)
pft->jibb = NULL;
- mir_free( jibb->srcJID );
- mir_free( jibb->dstJID );
- mir_free( jibb->sid );
+ mir_free(jibb->srcJID);
+ mir_free(jibb->dstJID);
+ mir_free(jibb->sid);
- mir_free( jibb );
+ mir_free(jibb);
} }
-BOOL CJabberProto::OnFtHandleIbbIq( HXML iqNode, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnFtHandleIbbIq(HXML iqNode, CJabberIqInfo* pInfo)
{
- if ( !_tcscmp( pInfo->GetChildNodeName(), _T("open")))
- FtHandleIbbRequest( iqNode, TRUE );
- else if ( !_tcscmp( pInfo->GetChildNodeName(), _T("close")))
- FtHandleIbbRequest( iqNode, FALSE );
- else if ( !_tcscmp( pInfo->GetChildNodeName(), _T("data"))) {
+ if ( !_tcscmp(pInfo->GetChildNodeName(), _T("open")))
+ FtHandleIbbRequest(iqNode, TRUE);
+ else if ( !_tcscmp(pInfo->GetChildNodeName(), _T("close")))
+ FtHandleIbbRequest(iqNode, FALSE);
+ else if ( !_tcscmp(pInfo->GetChildNodeName(), _T("data"))) {
BOOL bOk = FALSE;
- const TCHAR *sid = xmlGetAttrValue( pInfo->GetChildNode(), _T("sid"));
- const TCHAR *seq = xmlGetAttrValue( pInfo->GetChildNode(), _T("seq"));
- if ( sid && seq && xmlGetText( pInfo->GetChildNode()))
- bOk = OnIbbRecvdData( xmlGetText( pInfo->GetChildNode()), sid, seq );
+ const TCHAR *sid = xmlGetAttrValue(pInfo->GetChildNode(), _T("sid"));
+ const TCHAR *seq = xmlGetAttrValue(pInfo->GetChildNode(), _T("seq"));
+ if (sid && seq && xmlGetText(pInfo->GetChildNode()))
+ bOk = OnIbbRecvdData(xmlGetText(pInfo->GetChildNode()), sid, seq);
- if ( bOk )
- m_ThreadInfo->send( XmlNodeIq( _T("result"), pInfo ));
+ if (bOk)
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), pInfo));
else
- m_ThreadInfo->send(
- XmlNodeIq( _T("error"), pInfo )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ m_ThreadInfo->send(
+ XmlNodeIq(_T("error"), pInfo)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
}
return TRUE;
}
-void CJabberProto::OnIbbInitiateResult( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIbbInitiateResult(HXML, CJabberIqInfo* pInfo)
{
- JABBER_IBB_TRANSFER *jibb = ( JABBER_IBB_TRANSFER * )pInfo->GetUserData();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT )
+ JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData();
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
jibb->bStreamInitialized = TRUE;
- if ( jibb->hEvent )
- SetEvent( jibb->hEvent );
+ if (jibb->hEvent)
+ SetEvent(jibb->hEvent);
}
-void CJabberProto::OnIbbCloseResult( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIbbCloseResult(HXML, CJabberIqInfo* pInfo)
{
- JABBER_IBB_TRANSFER *jibb = ( JABBER_IBB_TRANSFER * )pInfo->GetUserData();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT )
+ JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData();
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
jibb->bStreamClosed = TRUE;
- if ( jibb->hEvent )
- SetEvent( jibb->hEvent );
+ if (jibb->hEvent)
+ SetEvent(jibb->hEvent);
}
-void CJabberProto::IbbSendThread( JABBER_IBB_TRANSFER *jibb )
+void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
{
- Log( "Thread started: type=ibb_send" );
+ Log("Thread started: type=ibb_send");
- jibb->hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jibb->bStreamInitialized = FALSE;
jibb->bStreamClosed = FALSE;
jibb->state = JIBB_SENDING;
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb ))
- << XCHILDNS( _T("open"), _T(JABBER_FEAT_IBB)) << XATTR( _T("sid"), jibb->sid ) << XATTRI( _T("block-size"), JABBER_IBB_BLOCK_SIZE )
- << XATTR( _T("stanza"), _T("message")));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ << XCHILDNS(_T("open"), _T(JABBER_FEAT_IBB)) << XATTR(_T("sid"), jibb->sid) << XATTRI(_T("block-size"), JABBER_IBB_BLOCK_SIZE)
+ << XATTR(_T("stanza"), _T("message")));
- WaitForSingleObject( jibb->hEvent, INFINITE );
- CloseHandle( jibb->hEvent );
+ WaitForSingleObject(jibb->hEvent, INFINITE);
+ CloseHandle(jibb->hEvent);
jibb->hEvent = NULL;
- if ( jibb->bStreamInitialized ) {
+ if (jibb->bStreamInitialized) {
jibb->wPacketId = 0;
- BOOL bSent = (this->*jibb->pfnSend)( JABBER_IBB_BLOCK_SIZE, jibb->ft );
+ BOOL bSent = (this->*jibb->pfnSend)(JABBER_IBB_BLOCK_SIZE, jibb->ft);
- if ( !jibb->bStreamClosed )
+ if ( !jibb->bStreamClosed)
{
- jibb->hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb ))
- << XCHILDNS( _T("close"), _T(JABBER_FEAT_IBB)) << XATTR( _T("sid"), jibb->sid ));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ << XCHILDNS(_T("close"), _T(JABBER_FEAT_IBB)) << XATTR(_T("sid"), jibb->sid));
- WaitForSingleObject( jibb->hEvent, INFINITE );
- CloseHandle( jibb->hEvent );
+ WaitForSingleObject(jibb->hEvent, INFINITE);
+ CloseHandle(jibb->hEvent);
jibb->hEvent = NULL;
- if ( jibb->bStreamClosed && bSent )
+ if (jibb->bStreamClosed && bSent)
jibb->state = JIBB_DONE;
} else {
@@ -128,66 +128,66 @@ void CJabberProto::IbbSendThread( JABBER_IBB_TRANSFER *jibb ) }
}
- (this->*jibb->pfnFinal)(( jibb->state==JIBB_DONE )?TRUE:FALSE, jibb->ft );
+ (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
jibb->ft = NULL;
- JabberIbbFreeJibb( jibb );
+ JabberIbbFreeJibb(jibb);
}
-void __cdecl CJabberProto::IbbReceiveThread( JABBER_IBB_TRANSFER *jibb )
+void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb)
{
- Log( "Thread started: type=ibb_recv" );
+ Log("Thread started: type=ibb_recv");
filetransfer *ft = jibb->ft;
- jibb->hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jibb->bStreamClosed = FALSE;
jibb->wPacketId = 0;
jibb->dwTransferredSize = 0;
jibb->state = JIBB_RECVING;
- WaitForSingleObject( jibb->hEvent, INFINITE );
+ WaitForSingleObject(jibb->hEvent, INFINITE);
- CloseHandle( jibb->hEvent );
+ CloseHandle(jibb->hEvent);
jibb->hEvent = NULL;
- if ( jibb->state == JIBB_ERROR )
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), jibb->dstJID ) << XCHILDNS( _T("close"), _T(JABBER_FEAT_IBB)) << XATTR( _T("sid"), jibb->sid ));
+ if (jibb->state == JIBB_ERROR)
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), jibb->dstJID) << XCHILDNS(_T("close"), _T(JABBER_FEAT_IBB)) << XATTR(_T("sid"), jibb->sid));
- if ( jibb->bStreamClosed && jibb->dwTransferredSize == ft->dwExpectedRecvFileSize )
+ if (jibb->bStreamClosed && jibb->dwTransferredSize == ft->dwExpectedRecvFileSize)
jibb->state = JIBB_DONE;
- (this->*jibb->pfnFinal)(( jibb->state==JIBB_DONE )?TRUE:FALSE, jibb->ft );
+ (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
jibb->ft = NULL;
- ListRemove( LIST_FTRECV, jibb->sid );
+ ListRemove(LIST_FTRECV, jibb->sid);
- JabberIbbFreeJibb( jibb );
+ JabberIbbFreeJibb(jibb);
}
-BOOL CJabberProto::OnIbbRecvdData( const TCHAR *data, const TCHAR *sid, const TCHAR *seq )
+BOOL CJabberProto::OnIbbRecvdData(const TCHAR *data, const TCHAR *sid, const TCHAR *seq)
{
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_FTRECV, sid );
- if ( !item ) return FALSE;
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid);
+ if ( !item) return FALSE;
WORD wSeq = (WORD)_ttoi(seq);
- if ( wSeq != item->jibb->wPacketId ) {
- if ( item->jibb->hEvent )
- SetEvent( item->jibb->hEvent );
+ if (wSeq != item->jibb->wPacketId) {
+ if (item->jibb->hEvent)
+ SetEvent(item->jibb->hEvent);
return FALSE;
}
item->jibb->wPacketId++;
int length = 0;
- char *decodedData = JabberBase64DecodeT( data, &length );
- if ( !decodedData )
+ char *decodedData = JabberBase64DecodeT(data, &length);
+ if ( !decodedData)
return FALSE;
- (this->*item->jibb->pfnRecv)( NULL, item->ft, decodedData, length );
+ (this->*item->jibb->pfnRecv)(NULL, item->ft, decodedData, length);
item->jibb->dwTransferredSize += (DWORD)length;
- mir_free( decodedData );
+ mir_free(decodedData);
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_ibb.h b/protocols/JabberG/src/jabber_ibb.h index 37ecfd1a2e..b73d83c71e 100644 --- a/protocols/JabberG/src/jabber_ibb.h +++ b/protocols/JabberG/src/jabber_ibb.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -36,10 +36,10 @@ typedef struct { BOOL bStreamInitialized;
BOOL bStreamClosed;
WORD wPacketId;
- BOOL ( CJabberProto::*pfnSend )( int blocksize, filetransfer* ft );
- int ( CJabberProto::*pfnRecv )( HANDLE hConn, filetransfer* ft, char* buffer, int datalen );
- void ( CJabberProto::*pfnFinal )( BOOL success, filetransfer* ft );
- filetransfer* ft;
+ BOOL (CJabberProto::*pfnSend)(int blocksize, filetransfer *ft);
+ int (CJabberProto::*pfnRecv)(HANDLE hConn, filetransfer *ft, char* buffer, int datalen);
+ void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft);
+ filetransfer *ft;
}
JABBER_IBB_TRANSFER;
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 828951e4ea..41f03a02ab 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -1,15 +1,15 @@ /*
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
Idea & portions of code by Artem Shpynov
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
@@ -190,7 +190,7 @@ static TIconListItem iconList[] = { LPGEN("%s"), "main", IDI_JABBER, NULL },
};
-void CJabberProto::IconsInit( void )
+void CJabberProto::IconsInit(void)
{
int i;
@@ -215,111 +215,111 @@ void CJabberProto::IconsInit( void ) sid.ptszSection = szSectionName;
sid.ptszDescription = szDescription;
- m_phIconLibItems = ( HANDLE* )mir_alloc( sizeof( HANDLE )*SIZEOF(iconList));
+ m_phIconLibItems = (HANDLE*)mir_alloc(sizeof(HANDLE)*SIZEOF(iconList));
- mir_sntprintf( szRootSection, SIZEOF(szRootSection), _T("%s/%s/%s"), LPGENT("Protocols"), LPGENT("Jabber"), LPGENT("Accounts"));
+ mir_sntprintf(szRootSection, SIZEOF(szRootSection), _T("%s/%s/%s"), LPGENT("Protocols"), LPGENT("Jabber"), LPGENT("Accounts"));
- for (i = 0; i < SIZEOF(iconList); i++ ) {
+ for (i = 0; i < SIZEOF(iconList); i++) {
TCHAR tmp[100];
- if ( iconList[i].szSection ) {
- mir_sntprintf( szSectionName, SIZEOF(szSectionName), _T("%s/") _T(TCHAR_STR_PARAM), szRootSection, iconList[i].szSection );
+ if (iconList[i].szSection) {
+ mir_sntprintf(szSectionName, SIZEOF(szSectionName), _T("%s/") _T(TCHAR_STR_PARAM), szRootSection, iconList[i].szSection);
if (_tcsstr(szSectionName, _T("%s"))) {
mir_sntprintf(tmp, SIZEOF(tmp), szSectionName, m_tszUserName);
lstrcpy(szSectionName, tmp);
}
}
else {
- mir_sntprintf( szSectionName, SIZEOF(szSectionName), _T("%s"), szRootSection );
+ mir_sntprintf(szSectionName, SIZEOF(szSectionName), _T("%s"), szRootSection);
}
if (strstr(iconList[i].szDescr, "%s")) {
- mir_sntprintf( tmp, SIZEOF(tmp), _T(TCHAR_STR_PARAM), iconList[i].szDescr );
- mir_sntprintf( szDescription, SIZEOF(szDescription), tmp, m_tszUserName );
+ mir_sntprintf(tmp, SIZEOF(tmp), _T(TCHAR_STR_PARAM), iconList[i].szDescr);
+ mir_sntprintf(szDescription, SIZEOF(szDescription), tmp, m_tszUserName);
}
- else mir_sntprintf( szDescription, SIZEOF(szDescription), _T(TCHAR_STR_PARAM), iconList[i].szDescr );
+ else mir_sntprintf(szDescription, SIZEOF(szDescription), _T(TCHAR_STR_PARAM), iconList[i].szDescr);
- mir_snprintf( szSettingName, SIZEOF(szSettingName), "%s_%s", m_szModuleName, iconList[i].szName );
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", m_szModuleName, iconList[i].szName);
sid.iDefaultIndex = -iconList[i].defIconID;
m_phIconLibItems[i] = Skin_AddIcon(&sid);
} }
-HANDLE CJabberProto::GetIconHandle( int iconId )
+HANDLE CJabberProto::GetIconHandle(int iconId)
{
if (HANDLE result = g_GetIconHandle(iconId))
return result;
- for ( int i=0; i < SIZEOF(iconList); i++ )
- if ( iconList[i].defIconID == iconId )
+ for (int i=0; i < SIZEOF(iconList); i++)
+ if (iconList[i].defIconID == iconId)
return m_phIconLibItems[i];
return NULL;
}
-HICON CJabberProto::LoadIconEx( const char* name, bool big )
+HICON CJabberProto::LoadIconEx(const char* name, bool big)
{
if (HICON result = g_LoadIconEx(name, big))
return result;
char szSettingName[100];
- mir_snprintf( szSettingName, sizeof( szSettingName ), "%s_%s", m_szModuleName, name );
+ mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", m_szModuleName, name);
return Skin_GetIcon(szSettingName, big);
}
/////////////////////////////////////////////////////////////////////////////////////////
// internal functions
-static inline TCHAR qtoupper( TCHAR c )
+static inline TCHAR qtoupper(TCHAR c)
{
- return ( c >= 'a' && c <= 'z' ) ? c - 'a' + 'A' : c;
+ return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c;
}
-static BOOL WildComparei( const TCHAR* name, const TCHAR* mask )
+static BOOL WildComparei(const TCHAR *name, const TCHAR *mask)
{
- const TCHAR* last='\0';
- for ( ;; mask++, name++) {
- if ( *mask != '?' && qtoupper( *mask ) != qtoupper( *name ))
+ const TCHAR *last='\0';
+ for (;; mask++, name++) {
+ if (*mask != '?' && qtoupper(*mask) != qtoupper(*name))
break;
- if ( *name == '\0' )
+ if (*name == '\0')
return ((BOOL)!*mask);
}
- if ( *mask != '*' )
+ if (*mask != '*')
return FALSE;
- for (;; mask++, name++ ) {
- while( *mask == '*' ) {
+ for (;; mask++, name++) {
+ while(*mask == '*') {
last = mask++;
- if ( *mask == '\0' )
+ if (*mask == '\0')
return ((BOOL)!*mask); /* true */
}
- if ( *name == '\0' )
+ if (*name == '\0')
return ((BOOL)!*mask); /* *mask == EOS */
- if ( *mask != '?' && qtoupper( *mask ) != qtoupper( *name ))
+ if (*mask != '?' && qtoupper(*mask) != qtoupper(*name))
name -= (size_t)(mask - last) - 1, mask = last;
} }
-static BOOL MatchMask( const TCHAR* name, const TCHAR* mask)
+static BOOL MatchMask(const TCHAR *name, const TCHAR *mask)
{
- if ( !mask || !name )
+ if ( !mask || !name)
return mask == name;
- if ( *mask != '|' )
- return WildComparei( name, mask );
+ if (*mask != '|')
+ return WildComparei(name, mask);
TCHAR* temp = NEWTSTR_ALLOCA(mask);
- for ( int e=1; mask[e] != '\0'; e++ ) {
+ for (int e=1; mask[e] != '\0'; e++) {
int s = e;
- while ( mask[e] != '\0' && mask[e] != '|')
+ while (mask[e] != '\0' && mask[e] != '|')
e++;
temp[e]= _T('\0');
- if ( WildComparei( name, temp+s ))
+ if (WildComparei(name, temp+s))
return TRUE;
- if ( mask[e] == 0 )
+ if (mask[e] == 0)
return FALSE;
}
@@ -334,7 +334,7 @@ static HICON ExtractIconFromPath(const char *path, BOOL * needFree) HICON hIcon;
lstrcpynA(file,path,sizeof(file));
comma=strrchr(file,',');
- if(comma==NULL) n=0;
+ if (comma==NULL) n=0;
else {n=atoi(comma+1); *comma=0;}
CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)file, (LPARAM)fileFull);
hIcon=NULL;
@@ -353,14 +353,14 @@ static HICON LoadTransportIcon(char *filename,int i,char *IconName,TCHAR *SectNa if (needFree) *needFree=FALSE;
GetModuleFileNameA(NULL, szPath, MAX_PATH);
str=strrchr(szPath,'\\');
- if(str!=NULL) *str=0;
+ if (str!=NULL) *str=0;
_snprintf(szMyPath, sizeof(szMyPath), "%s\\Icons\\%s", szPath, filename);
_snprintf(szFullPath, sizeof(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
BOOL nf;
HICON hi=ExtractIconFromPath(szFullPath,&nf);
if (hi) has_proto_icon=TRUE;
if (hi && nf) DestroyIcon(hi);
- if ( IconName != NULL && SectName != NULL) {
+ if (IconName != NULL && SectName != NULL) {
sid.cbSize = sizeof(sid);
sid.hDefaultIcon = (has_proto_icon)?NULL:(HICON)CallService(MS_SKIN_LOADPROTOICON,0,(LPARAM)(-internalidx));
sid.ptszSection = SectName;
@@ -396,10 +396,10 @@ int CJabberProto::LoadAdvancedIcons(int iID) mir_sntprintf(Group, SIZEOF(Group), _T("Status Icons/%s/") _T(TCHAR_STR_PARAM) _T(" %s"), m_tszUserName, proto, TranslateT("transport"));
mir_snprintf(defFile, SIZEOF(defFile), "proto_%s.dll",proto);
- if (!hAdvancedStatusIcon)
+ if ( !hAdvancedStatusIcon)
hAdvancedStatusIcon=(HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST,0,0);
- EnterCriticalSection( &m_csModeMsgMutex );
+ EnterCriticalSection(&m_csModeMsgMutex);
for (i=0; i<ID_STATUS_ONTHEPHONE-ID_STATUS_OFFLINE; i++) {
HICON hicon;
BOOL needFree;
@@ -413,16 +413,16 @@ int CJabberProto::LoadAdvancedIcons(int iID) if (hicon && needFree) DestroyIcon(hicon);
}
- if ( m_transportProtoTableStartIndex[iID] == -1 )
+ if (m_transportProtoTableStartIndex[iID] == -1)
m_transportProtoTableStartIndex[iID] = first;
- LeaveCriticalSection( &m_csModeMsgMutex );
+ LeaveCriticalSection(&m_csModeMsgMutex);
return 0;
}
-int CJabberProto::GetTransportProtoID( TCHAR* TransportDomain )
+int CJabberProto::GetTransportProtoID(TCHAR* TransportDomain)
{
- for ( int i=0; i<SIZEOF(TransportProtoTable); i++ )
- if ( MatchMask( TransportDomain, TransportProtoTable[i].mask ))
+ for (int i=0; i<SIZEOF(TransportProtoTable); i++)
+ if (MatchMask(TransportDomain, TransportProtoTable[i].mask))
return i;
return -1;
@@ -430,18 +430,18 @@ int CJabberProto::GetTransportProtoID( TCHAR* TransportDomain ) int CJabberProto::GetTransportStatusIconIndex(int iID, int Status)
{
- if ( iID < 0 || iID >= SIZEOF( TransportProtoTable ))
+ if (iID < 0 || iID >= SIZEOF(TransportProtoTable))
return -1;
//icons not loaded - loading icons
- if ( m_transportProtoTableStartIndex[iID] == -1 )
- LoadAdvancedIcons( iID );
+ if (m_transportProtoTableStartIndex[iID] == -1)
+ LoadAdvancedIcons(iID);
//some fault on loading icons
- if ( m_transportProtoTableStartIndex[iID] == -1 )
+ if (m_transportProtoTableStartIndex[iID] == -1)
return -1;
- if ( Status < ID_STATUS_OFFLINE )
+ if (Status < ID_STATUS_OFFLINE)
Status = ID_STATUS_OFFLINE;
return m_transportProtoTableStartIndex[iID] + skinStatusToJabberStatus[ Status - ID_STATUS_OFFLINE ];
@@ -452,8 +452,8 @@ int CJabberProto::GetTransportStatusIconIndex(int iID, int Status) int CJabberProto::OnReloadIcons(WPARAM, LPARAM)
{
- for ( int i=0; i < SIZEOF(TransportProtoTable); i++ )
- if ( m_transportProtoTableStartIndex[i] != -1 )
+ for (int i=0; i < SIZEOF(TransportProtoTable); i++)
+ if (m_transportProtoTableStartIndex[i] != -1)
LoadAdvancedIcons(i);
return 0;
@@ -470,27 +470,27 @@ int CJabberProto::OnReloadIcons(WPARAM, LPARAM) INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM wParam, LPARAM)
{
- HANDLE hContact=(HANDLE) wParam;
- if ( !hContact )
+ HANDLE hContact=(HANDLE)wParam;
+ if ( !hContact)
return -1;
- if ( !JGetByte( hContact, "IsTransported", 0 ))
+ if ( !JGetByte(hContact, "IsTransported", 0))
return -1;
DBVARIANT dbv;
- if ( JGetStringT( hContact, "Transport", &dbv ))
+ if (JGetStringT(hContact, "Transport", &dbv))
return -1;
- int iID = GetTransportProtoID( dbv.ptszVal );
+ int iID = GetTransportProtoID(dbv.ptszVal);
DBFreeVariant(&dbv);
- if ( iID >= 0 ) {
+ if (iID >= 0) {
WORD Status = ID_STATUS_OFFLINE;
- Status = JGetWord( hContact, "Status", ID_STATUS_OFFLINE );
- if ( Status < ID_STATUS_OFFLINE )
+ Status = JGetWord(hContact, "Status", ID_STATUS_OFFLINE);
+ if (Status < ID_STATUS_OFFLINE)
Status = ID_STATUS_OFFLINE;
- else if (Status > ID_STATUS_INVISIBLE )
+ else if (Status > ID_STATUS_INVISIBLE)
Status = ID_STATUS_ONLINE;
- return GetTransportStatusIconIndex( iID, Status );
+ return GetTransportStatusIconIndex(iID, Status);
}
return -1;
}
@@ -498,55 +498,55 @@ INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM wParam, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
// Transport check functions
-BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR* jid, HANDLE hContact)
+BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact)
{
// check if transport is already set
- if ( !jid || !hContact )
+ if ( !jid || !hContact)
return FALSE;
// strip domain part from jid
- TCHAR* domain = _tcschr(( TCHAR* )jid, '@' );
+ TCHAR* domain = _tcschr((TCHAR*)jid, '@');
BOOL isAgent = (domain == NULL) ? TRUE : FALSE;
BOOL isTransported = FALSE;
- if ( domain!=NULL )
+ if (domain!=NULL)
domain = NEWTSTR_ALLOCA(domain+1);
else
domain = NEWTSTR_ALLOCA(jid);
- TCHAR* resourcepos = _tcschr( domain, '/' );
- if ( resourcepos != NULL )
+ TCHAR* resourcepos = _tcschr(domain, '/');
+ if (resourcepos != NULL)
*resourcepos = '\0';
- for ( int i=0; i < SIZEOF(TransportProtoTable); i++ ) {
- if ( MatchMask( domain, TransportProtoTable[i].mask )) {
- GetTransportStatusIconIndex( GetTransportProtoID( domain ), ID_STATUS_OFFLINE );
+ for (int i=0; i < SIZEOF(TransportProtoTable); i++) {
+ if (MatchMask(domain, TransportProtoTable[i].mask)) {
+ GetTransportStatusIconIndex(GetTransportProtoID(domain), ID_STATUS_OFFLINE);
isTransported = TRUE;
break;
} }
- if ( m_lstTransports.getIndex( domain ) == -1 ) {
- if ( isAgent ) {
- m_lstTransports.insert( mir_tstrdup(domain));
- JSetByte( hContact, "IsTransport", 1 );
+ if (m_lstTransports.getIndex(domain) == -1) {
+ if (isAgent) {
+ m_lstTransports.insert(mir_tstrdup(domain));
+ JSetByte(hContact, "IsTransport", 1);
} }
- if ( isTransported ) {
- JSetStringT( hContact, "Transport", domain );
- JSetByte( hContact, "IsTransported", 1 );
+ if (isTransported) {
+ JSetStringT(hContact, "Transport", domain);
+ JSetByte(hContact, "IsTransported", 1);
}
return isTransported;
}
void CJabberProto::CheckAllContactsAreTransported()
{
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( !lstrcmpA( m_szModuleName, szProto )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if ( !lstrcmpA(m_szModuleName, szProto)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- DBCheckIsTransportedContact( dbv.ptszVal, hContact );
- JFreeVariant( &dbv );
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ DBCheckIsTransportedContact(dbv.ptszVal, hContact);
+ db_free(&dbv);
} }
hContact = db_find_next(hContact);
@@ -611,7 +611,7 @@ static TIconListItem sharedIconList[] = { LPGEN("Deny Queries"), "pl_iq_deny", IDI_PL_QUERY_DENY, LPGEN("Dialogs/Privacy") },
};
-static void sttProcessIcons( int iAmount )
+static void sttProcessIcons(int iAmount)
{
TCHAR szFile[MAX_PATH];
GetModuleFileName(hInst, szFile, MAX_PATH);
@@ -622,16 +622,16 @@ static void sttProcessIcons( int iAmount ) sid.flags = SIDF_PATH_TCHAR;
char szRootSection[100];
- mir_snprintf( szRootSection, SIZEOF(szRootSection), "%s/%s", LPGEN("Protocols"), LPGEN("Jabber"));
+ mir_snprintf(szRootSection, SIZEOF(szRootSection), "%s/%s", LPGEN("Protocols"), LPGEN("Jabber"));
- for ( int i = 0; i < iAmount; i++ ) {
+ for (int i = 0; i < iAmount; i++) {
char szSettingName[100], szSectionName[100];
- mir_snprintf( szSettingName, sizeof( szSettingName ), "%s_%s",
+ mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s",
GLOBAL_SETTING_PREFIX, sharedIconList[i].szName);
- if ( sharedIconList[i].szSection ) {
- mir_snprintf( szSectionName, sizeof( szSectionName ), "%s/%s", szRootSection, sharedIconList[i].szSection );
+ if (sharedIconList[i].szSection) {
+ mir_snprintf(szSectionName, sizeof(szSectionName), "%s/%s", szRootSection, sharedIconList[i].szSection);
sid.pszSection = szSectionName;
}
else sid.pszSection = szRootSection;
@@ -644,45 +644,45 @@ static void sttProcessIcons( int iAmount ) void g_IconsInit()
{
- sttProcessIcons( SIZEOF( sharedIconList ));
+ sttProcessIcons(SIZEOF(sharedIconList));
}
-HANDLE g_GetIconHandle( int iconId )
+HANDLE g_GetIconHandle(int iconId)
{
- for ( int i=0; i < SIZEOF(sharedIconList); i++ )
- if ( sharedIconList[i].defIconID == iconId )
+ for (int i=0; i < SIZEOF(sharedIconList); i++)
+ if (sharedIconList[i].defIconID == iconId)
return sharedIconList[i].hIcon;
return NULL;
}
-HICON g_LoadIconEx( const char* name, bool big )
+HICON g_LoadIconEx(const char* name, bool big)
{
char szSettingName[100];
- mir_snprintf( szSettingName, sizeof( szSettingName ), "%s_%s", GLOBAL_SETTING_PREFIX, name );
+ mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", GLOBAL_SETTING_PREFIX, name);
return Skin_GetIcon(szSettingName, big);
}
-void g_ReleaseIcon( HICON hIcon )
+void g_ReleaseIcon(HICON hIcon)
{
if (hIcon)
Skin_ReleaseIcon(hIcon);
}
-void ImageList_AddIcon_Icolib( HIMAGELIST hIml, HICON hIcon )
+void ImageList_AddIcon_Icolib(HIMAGELIST hIml, HICON hIcon)
{
- ImageList_AddIcon( hIml, hIcon );
- g_ReleaseIcon( hIcon );
+ ImageList_AddIcon(hIml, hIcon);
+ g_ReleaseIcon(hIcon);
}
void WindowSetIcon(HWND hWnd, CJabberProto *proto, const char* name)
{
- SendMessage(hWnd, WM_SETICON, ICON_BIG, ( LPARAM )proto->LoadIconEx( name, true ));
- SendMessage(hWnd, WM_SETICON, ICON_SMALL, ( LPARAM )proto->LoadIconEx( name ));
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)proto->LoadIconEx(name, true));
+ SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)proto->LoadIconEx(name));
}
void WindowFreeIcon(HWND hWnd)
{
- g_ReleaseIcon(( HICON )SendMessage(hWnd, WM_SETICON, ICON_BIG, 0));
- g_ReleaseIcon(( HICON )SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0));
+ g_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0));
+ g_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0));
}
diff --git a/protocols/JabberG/src/jabber_icolib.h b/protocols/JabberG/src/jabber_icolib.h index 62924e5bae..423e3e6228 100644 --- a/protocols/JabberG/src/jabber_icolib.h +++ b/protocols/JabberG/src/jabber_icolib.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index 43084114c2..ca6adcc25d 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CJabberProto::IqInit()
{
- InitializeCriticalSection( &m_csIqList );
+ InitializeCriticalSection(&m_csIqList);
m_ppIqList = NULL;
m_nIqCount = 0;
m_nIqAlloced = 0;
@@ -38,21 +38,21 @@ void CJabberProto::IqInit() void CJabberProto::IqUninit()
{
- if ( m_ppIqList ) mir_free( m_ppIqList );
+ if (m_ppIqList) mir_free(m_ppIqList);
m_ppIqList = NULL;
m_nIqCount = 0;
m_nIqAlloced = 0;
- DeleteCriticalSection( &m_csIqList );
+ DeleteCriticalSection(&m_csIqList);
}
-void CJabberProto::IqRemove( int index )
+void CJabberProto::IqRemove(int index)
{
- EnterCriticalSection( &m_csIqList );
- if ( index>=0 && index<m_nIqCount ) {
- memmove( m_ppIqList+index, m_ppIqList+index+1, sizeof( JABBER_IQ_FUNC )*( m_nIqCount-index-1 ));
+ EnterCriticalSection(&m_csIqList);
+ if (index>=0 && index<m_nIqCount) {
+ memmove(m_ppIqList+index, m_ppIqList+index+1, sizeof(JABBER_IQ_FUNC)*(m_nIqCount-index-1));
m_nIqCount--;
}
- LeaveCriticalSection( &m_csIqList );
+ LeaveCriticalSection(&m_csIqList);
}
void CJabberProto::IqExpire()
@@ -60,138 +60,138 @@ void CJabberProto::IqExpire() int i;
time_t expire;
- EnterCriticalSection( &m_csIqList );
- expire = time( NULL ) - 120; // 2 minute
+ EnterCriticalSection(&m_csIqList);
+ expire = time(NULL) - 120; // 2 minute
i = 0;
- while ( i < m_nIqCount ) {
- if ( m_ppIqList[i].requestTime < expire )
- IqRemove( i );
+ while (i < m_nIqCount) {
+ if (m_ppIqList[i].requestTime < expire)
+ IqRemove(i);
else
i++;
}
- LeaveCriticalSection( &m_csIqList );
+ LeaveCriticalSection(&m_csIqList);
}
-JABBER_IQ_PFUNC CJabberProto::JabberIqFetchFunc( int iqId )
+JABBER_IQ_PFUNC CJabberProto::JabberIqFetchFunc(int iqId)
{
int i;
JABBER_IQ_PFUNC res;
- EnterCriticalSection( &m_csIqList );
+ EnterCriticalSection(&m_csIqList);
IqExpire();
#ifdef _DEBUG
- for ( i=0; i<m_nIqCount; i++ )
- Log( " %04d : %02d : 0x%x", m_ppIqList[i].iqId, m_ppIqList[i].procId, m_ppIqList[i].func );
+ for (i=0; i<m_nIqCount; i++)
+ Log(" %04d : %02d : 0x%x", m_ppIqList[i].iqId, m_ppIqList[i].procId, m_ppIqList[i].func);
#endif
- for ( i=0; i<m_nIqCount && m_ppIqList[i].iqId!=iqId; i++ );
- if ( i < m_nIqCount ) {
+ for (i=0; i<m_nIqCount && m_ppIqList[i].iqId!=iqId; i++);
+ if (i < m_nIqCount) {
res = m_ppIqList[i].func;
- IqRemove( i );
+ IqRemove(i);
}
else {
- res = ( JABBER_IQ_PFUNC ) NULL;
+ res = (JABBER_IQ_PFUNC) NULL;
}
- LeaveCriticalSection( &m_csIqList );
+ LeaveCriticalSection(&m_csIqList);
return res;
}
-void CJabberProto::IqAdd( unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func )
+void CJabberProto::IqAdd(unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func)
{
int i;
- EnterCriticalSection( &m_csIqList );
- Log( "IqAdd id=%d, proc=%d, func=0x%x", iqId, procId, func );
- if ( procId == IQ_PROC_NONE )
+ EnterCriticalSection(&m_csIqList);
+ Log("IqAdd id=%d, proc=%d, func=0x%x", iqId, procId, func);
+ if (procId == IQ_PROC_NONE)
i = m_nIqCount;
else
- for ( i=0; i<m_nIqCount && m_ppIqList[i].procId!=procId; i++ );
+ for (i=0; i<m_nIqCount && m_ppIqList[i].procId!=procId; i++);
- if ( i>=m_nIqCount && m_nIqCount>=m_nIqAlloced ) {
+ if (i>=m_nIqCount && m_nIqCount>=m_nIqAlloced) {
m_nIqAlloced = m_nIqCount + 8;
- m_ppIqList = ( JABBER_IQ_FUNC * )mir_realloc( m_ppIqList, sizeof( JABBER_IQ_FUNC )*m_nIqAlloced );
+ m_ppIqList = (JABBER_IQ_FUNC *)mir_realloc(m_ppIqList, sizeof(JABBER_IQ_FUNC)*m_nIqAlloced);
}
- if ( m_ppIqList != NULL ) {
+ if (m_ppIqList != NULL) {
m_ppIqList[i].iqId = iqId;
m_ppIqList[i].procId = procId;
m_ppIqList[i].func = func;
- m_ppIqList[i].requestTime = time( NULL );
- if ( i == m_nIqCount ) m_nIqCount++;
+ m_ppIqList[i].requestTime = time(NULL);
+ if (i == m_nIqCount) m_nIqCount++;
}
- LeaveCriticalSection( &m_csIqList );
+ LeaveCriticalSection(&m_csIqList);
}
BOOL CJabberIqManager::FillPermanentHandlers()
{
// Google Shared Status (http://code.google.com/apis/talk/jep_extensions/shared_status.html)
- AddPermanentHandler( &CJabberProto::OnIqSetGoogleSharedStatus, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR, _T("google:shared-status"), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqSetGoogleSharedStatus, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR, _T("google:shared-status"), FALSE, _T("query"));
// version requests (XEP-0092)
- AddPermanentHandler( &CJabberProto::OnIqRequestVersion, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_VERSION), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestVersion, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_VERSION), FALSE, _T("query"));
// last activity (XEP-0012)
- AddPermanentHandler( &CJabberProto::OnIqRequestLastActivity, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_LAST_ACTIVITY), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestLastActivity, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_LAST_ACTIVITY), FALSE, _T("query"));
// ping requests (XEP-0199)
- AddPermanentHandler( &CJabberProto::OnIqRequestPing, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_PING), FALSE, _T("ping"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestPing, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_PING), FALSE, _T("ping"));
// entity time (XEP-0202)
- AddPermanentHandler( &CJabberProto::OnIqRequestTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_ENTITY_TIME), FALSE, _T("time"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_ENTITY_TIME), FALSE, _T("time"));
// entity time (XEP-0090)
- AddPermanentHandler( &CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_ENTITY_TIME_OLD), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_ENTITY_TIME_OLD), FALSE, _T("query"));
// old avatars support (deprecated XEP-0008)
- AddPermanentHandler( &CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_AVATAR), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_AVATAR), FALSE, _T("query"));
// privacy lists (XEP-0016)
- AddPermanentHandler( &CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_PRIVACY_LISTS), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, _T(JABBER_FEAT_PRIVACY_LISTS), FALSE, _T("query"));
// in band bytestreams (XEP-0047)
- AddPermanentHandler( &CJabberProto::OnFtHandleIbbIq, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_CHILD_TAG_NAME | JABBER_IQ_PARSE_CHILD_TAG_XMLNS, _T(JABBER_FEAT_IBB), FALSE, NULL);
+ AddPermanentHandler(&CJabberProto::OnFtHandleIbbIq, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_CHILD_TAG_NAME | JABBER_IQ_PARSE_CHILD_TAG_XMLNS, _T(JABBER_FEAT_IBB), FALSE, NULL);
// socks5-bytestreams (XEP-0065)
- AddPermanentHandler( &CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_BYTESTREAMS), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::FtHandleBytestreamRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_BYTESTREAMS), FALSE, _T("query"));
// session initiation (XEP-0095)
- AddPermanentHandler( &CJabberProto::OnSiRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_SI), FALSE, _T("si"));
+ AddPermanentHandler(&CJabberProto::OnSiRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_SI), FALSE, _T("si"));
// roster push requests
- AddPermanentHandler( &CJabberProto::OnRosterPushRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_IQ_ROSTER), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnRosterPushRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_IQ_ROSTER), FALSE, _T("query"));
// OOB file transfers
- AddPermanentHandler( &CJabberProto::OnIqRequestOOB, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_OOB), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnIqRequestOOB, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_OOB), FALSE, _T("query"));
// disco#items requests (XEP-0030, XEP-0050)
- AddPermanentHandler( &CJabberProto::OnHandleDiscoItemsRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_DISCO_ITEMS), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnHandleDiscoItemsRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_DISCO_ITEMS), FALSE, _T("query"));
// disco#info requests (XEP-0030, XEP-0050, XEP-0115)
- AddPermanentHandler( &CJabberProto::OnHandleDiscoInfoRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_DISCO_INFO), FALSE, _T("query"));
+ AddPermanentHandler(&CJabberProto::OnHandleDiscoInfoRequest, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_DISCO_INFO), FALSE, _T("query"));
// ad-hoc commands (XEP-0050) for remote controlling (XEP-0146)
- AddPermanentHandler( &CJabberProto::HandleAdhocCommandRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_COMMANDS), FALSE, _T("command"));
+ AddPermanentHandler(&CJabberProto::HandleAdhocCommandRequest, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_COMMANDS), FALSE, _T("command"));
// http auth (XEP-0070)
- AddPermanentHandler( &CJabberProto::OnIqHttpAuth, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_HTTP_AUTH), FALSE, _T("confirm"));
+ AddPermanentHandler(&CJabberProto::OnIqHttpAuth, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR | JABBER_IQ_PARSE_CHILD_TAG_NODE, _T(JABBER_FEAT_HTTP_AUTH), FALSE, _T("confirm"));
return TRUE;
}
BOOL CJabberIqManager::Start()
{
- if ( m_hExpirerThread || m_bExpirerThreadShutdownRequest )
+ if (m_hExpirerThread || m_bExpirerThreadShutdownRequest)
return FALSE;
- m_hExpirerThread = ppro->JForkThreadEx( &CJabberProto::ExpirerThread, this );
- if ( !m_hExpirerThread )
+ m_hExpirerThread = ppro->JForkThreadEx(&CJabberProto::ExpirerThread, this);
+ if ( !m_hExpirerThread)
return FALSE;
return TRUE;
}
-void __cdecl CJabberProto::ExpirerThread( void* pParam )
+void __cdecl CJabberProto::ExpirerThread(void* pParam)
{
- CJabberIqManager *pManager = ( CJabberIqManager * )pParam;
+ CJabberIqManager *pManager = (CJabberIqManager *)pParam;
pManager->ExpirerThread();
}
@@ -202,7 +202,7 @@ void CJabberIqManager::ExpirerThread() Lock();
CJabberIqInfo* pInfo = DetachExpired();
Unlock();
- if (!pInfo)
+ if ( !pInfo)
{
for (int i = 0; !m_bExpirerThreadShutdownRequest && (i < 10); i++)
Sleep(50);
@@ -211,36 +211,36 @@ void CJabberIqManager::ExpirerThread() ppro->m_adhocManager.ExpireSessions();
continue;
}
- ExpireInfo( pInfo );
+ ExpireInfo(pInfo);
delete pInfo;
}
- if ( !m_bExpirerThreadShutdownRequest ) {
- CloseHandle( m_hExpirerThread );
+ if ( !m_bExpirerThreadShutdownRequest) {
+ CloseHandle(m_hExpirerThread);
m_hExpirerThread = NULL;
}
}
-void CJabberIqManager::ExpireInfo( CJabberIqInfo* pInfo, void*)
+void CJabberIqManager::ExpireInfo(CJabberIqInfo* pInfo, void*)
{
- if ( !pInfo )
+ if ( !pInfo)
return;
- if ( pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM )
+ if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
pInfo->m_szFrom = pInfo->m_szReceiver;
- if (( pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT ) && ( pInfo->m_szFrom ))
- pInfo->m_hContact = ppro->HContactFromJID( pInfo->m_szFrom , 3);
+ if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (pInfo->m_szFrom))
+ pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom , 3);
- ppro->Log( "Expiring iq id %d, sent to " TCHAR_STR_PARAM, pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : _T("server"));
+ ppro->Log("Expiring iq id %d, sent to " TCHAR_STR_PARAM, pInfo->m_nIqId, pInfo->m_szReceiver ? pInfo->m_szReceiver : _T("server"));
pInfo->m_nIqType = JABBER_IQ_TYPE_FAIL;
- (ppro->*(pInfo->m_pHandler))( NULL, pInfo );
+ (ppro->*(pInfo->m_pHandler))(NULL, pInfo);
}
CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const TCHAR *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority)
{
CJabberIqInfo* pInfo = new CJabberIqInfo();
- if (!pInfo)
+ if ( !pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
@@ -260,19 +260,19 @@ CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqT return pInfo;
}
-BOOL CJabberIqManager::HandleIq(int nIqId, HXML pNode )
+BOOL CJabberIqManager::HandleIq(int nIqId, HXML pNode)
{
if (nIqId == -1 || pNode == NULL)
return FALSE;
- const TCHAR *szType = xmlGetAttrValue( pNode, _T("type"));
- if ( !szType )
+ const TCHAR *szType = xmlGetAttrValue(pNode, _T("type"));
+ if ( !szType)
return FALSE;
int nIqType = JABBER_IQ_TYPE_FAIL;
- if (!_tcsicmp(szType, _T("result")))
+ if ( !_tcsicmp(szType, _T("result")))
nIqType = JABBER_IQ_TYPE_RESULT;
- else if (!_tcsicmp(szType, _T("error")))
+ else if ( !_tcsicmp(szType, _T("error")))
nIqType = JABBER_IQ_TYPE_ERROR;
else
return FALSE;
@@ -285,24 +285,24 @@ BOOL CJabberIqManager::HandleIq(int nIqId, HXML pNode ) pInfo->m_nIqType = nIqType;
if (nIqType == JABBER_IQ_TYPE_RESULT) {
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NODE)
- pInfo->m_pChildNode = xmlGetChild( pNode , 0 );
+ pInfo->m_pChildNode = xmlGetChild(pNode , 0);
if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NAME))
- pInfo->m_szChildTagName = ( TCHAR* )xmlGetName( pInfo->m_pChildNode );
+ pInfo->m_szChildTagName = (TCHAR*)xmlGetName(pInfo->m_pChildNode);
if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_XMLNS))
- pInfo->m_szChildTagXmlns = ( TCHAR* )xmlGetAttrValue( pNode, _T("xmlns"));
+ pInfo->m_szChildTagXmlns = (TCHAR*)xmlGetAttrValue(pNode, _T("xmlns"));
}
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- pInfo->m_szTo = ( TCHAR* )xmlGetAttrValue( pNode, _T("to"));
+ pInfo->m_szTo = (TCHAR*)xmlGetAttrValue(pNode, _T("to"));
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
- pInfo->m_szFrom = ( TCHAR* )xmlGetAttrValue( pNode, _T("from"));
+ pInfo->m_szFrom = (TCHAR*)xmlGetAttrValue(pNode, _T("from"));
if (pInfo->m_szFrom && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT))
- pInfo->m_hContact = ppro->HContactFromJID( pInfo->m_szFrom, 3 );
+ pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom, 3);
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_ID_STR)
- pInfo->m_szId = ( TCHAR* )xmlGetAttrValue( pNode, _T("id"));
+ pInfo->m_szId = (TCHAR*)xmlGetAttrValue(pNode, _T("id"));
(ppro->*(pInfo->m_pHandler))(pNode, pInfo);
delete pInfo;
@@ -311,55 +311,55 @@ BOOL CJabberIqManager::HandleIq(int nIqId, HXML pNode ) return FALSE;
}
-BOOL CJabberIqManager::HandleIqPermanent( HXML pNode )
+BOOL CJabberIqManager::HandleIqPermanent(HXML pNode)
{
BOOL bStopHandling = FALSE;
Lock();
CJabberIqPermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo ) {
+ while (pInfo) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
- const TCHAR *szType = xmlGetAttrValue( pNode, _T("type"));
- if ( !szType )
+ const TCHAR *szType = xmlGetAttrValue(pNode, _T("type"));
+ if ( !szType)
break;
CJabberIqInfo iqInfo;
iqInfo.m_nIqType = JABBER_IQ_TYPE_FAIL;
- if ( !_tcsicmp( szType, _T("get")))
+ if ( !_tcsicmp(szType, _T("get")))
iqInfo.m_nIqType = JABBER_IQ_TYPE_GET;
- else if ( !_tcsicmp( szType, _T("set")))
+ else if ( !_tcsicmp(szType, _T("set")))
iqInfo.m_nIqType = JABBER_IQ_TYPE_SET;
else
break;
- if ( pInfo->m_nIqTypes & iqInfo.m_nIqType )
+ if (pInfo->m_nIqTypes & iqInfo.m_nIqType)
{
- HXML pFirstChild = xmlGetChild( pNode , 0 );
- if ( !pFirstChild || !xmlGetName( pFirstChild ))
+ HXML pFirstChild = xmlGetChild(pNode , 0);
+ if ( !pFirstChild || !xmlGetName(pFirstChild))
break;
- const TCHAR *szTagName = xmlGetName( pFirstChild );
- const TCHAR *szXmlns = xmlGetAttrValue( pFirstChild, _T("xmlns"));
+ const TCHAR *szTagName = xmlGetName(pFirstChild);
+ const TCHAR *szXmlns = xmlGetAttrValue(pFirstChild, _T("xmlns"));
- if ( (!pInfo->m_szXmlns || ( szXmlns && !_tcscmp( pInfo->m_szXmlns, szXmlns ))) &&
- ( !pInfo->m_szTag || !_tcscmp( pInfo->m_szTag, szTagName ))) {
+ if ((!pInfo->m_szXmlns || (szXmlns && !_tcscmp(pInfo->m_szXmlns, szXmlns))) &&
+ (!pInfo->m_szTag || !_tcscmp(pInfo->m_szTag, szTagName))) {
// node suits handler criteria, call the handler
iqInfo.m_pChildNode = pFirstChild;
- iqInfo.m_szChildTagName = ( TCHAR* )szTagName;
- iqInfo.m_szChildTagXmlns = ( TCHAR* )szXmlns;
- iqInfo.m_szId = ( TCHAR* )xmlGetAttrValue( pNode, _T("id"));
+ iqInfo.m_szChildTagName = (TCHAR*)szTagName;
+ iqInfo.m_szChildTagXmlns = (TCHAR*)szXmlns;
+ iqInfo.m_szId = (TCHAR*)xmlGetAttrValue(pNode, _T("id"));
iqInfo.m_pUserData = pInfo->m_pUserData;
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- iqInfo.m_szTo = ( TCHAR* )xmlGetAttrValue( pNode, _T("to"));
+ iqInfo.m_szTo = (TCHAR*)xmlGetAttrValue(pNode, _T("to"));
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
- iqInfo.m_szFrom = ( TCHAR* )xmlGetAttrValue( pNode, _T("from"));
+ iqInfo.m_szFrom = (TCHAR*)xmlGetAttrValue(pNode, _T("from"));
if ((pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
- iqInfo.m_hContact = ppro->HContactFromJID( iqInfo.m_szFrom, 3 );
+ iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom, 3);
- ppro->Log( "Handling iq id " TCHAR_STR_PARAM ", type " TCHAR_STR_PARAM ", from " TCHAR_STR_PARAM, iqInfo.m_szId, szType, iqInfo.m_szFrom );
+ ppro->Log("Handling iq id " TCHAR_STR_PARAM ", type " TCHAR_STR_PARAM ", from " TCHAR_STR_PARAM, iqInfo.m_szId, szType, iqInfo.m_szFrom);
if ((ppro->*(pInfo->m_pHandler))(pNode, &iqInfo)) {
bStopHandling = TRUE;
break;
diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index 6e145e7db0..b44d4997b0 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -47,8 +47,8 @@ typedef enum { } JABBER_IQ_PROCID;
struct CJabberProto;
-typedef void ( CJabberProto::*JABBER_IQ_PFUNC )( HXML iqNode );
-typedef void ( *IQ_USER_DATA_FREE_FUNC )( void *pUserData );
+typedef void (CJabberProto::*JABBER_IQ_PFUNC)(HXML iqNode);
+typedef void (*IQ_USER_DATA_FREE_FUNC)(void *pUserData);
typedef struct {
TCHAR* xmlns;
@@ -59,8 +59,8 @@ typedef struct { // 2 minutes, milliseconds
#define JABBER_DEFAULT_IQ_REQUEST_TIMEOUT 120000
-typedef void ( CJabberProto::*JABBER_IQ_HANDLER )( HXML iqNode, CJabberIqInfo* pInfo );
-typedef BOOL ( CJabberProto::*JABBER_PERMANENT_IQ_HANDLER )( HXML iqNode, CJabberIqInfo* pInfo );
+typedef void (CJabberProto::*JABBER_IQ_HANDLER)(HXML iqNode, CJabberIqInfo* pInfo);
+typedef BOOL (CJabberProto::*JABBER_PERMANENT_IQ_HANDLER)(HXML iqNode, CJabberIqInfo* pInfo);
#define JABBER_IQ_PARSE_CHILD_TAG_NODE (1)
#define JABBER_IQ_PARSE_CHILD_TAG_NAME ((1<<1)|JABBER_IQ_PARSE_CHILD_TAG_NODE)
@@ -197,7 +197,7 @@ public: }
~CJabberIqPermanentInfo()
{
- if ( m_pUserDataFree )
+ if (m_pUserDataFree)
m_pUserDataFree(m_pUserData);
mir_free(m_szXmlns);
mir_free(m_szTag);
@@ -218,7 +218,7 @@ protected: CJabberIqInfo* DetachInfo(int nIqId)
{
- if (!m_pIqs)
+ if ( !m_pIqs)
return NULL;
CJabberIqInfo* pInfo = m_pIqs;
@@ -244,7 +244,7 @@ protected: }
CJabberIqInfo* DetachInfo(void *pUserData)
{
- if (!m_pIqs)
+ if ( !m_pIqs)
return NULL;
CJabberIqInfo* pInfo = m_pIqs;
@@ -270,13 +270,13 @@ protected: }
CJabberIqInfo* DetachExpired()
{
- if (!m_pIqs)
+ if ( !m_pIqs)
return NULL;
DWORD dwCurrentTime = GetTickCount();
CJabberIqInfo* pInfo = m_pIqs;
- if (dwCurrentTime - pInfo->m_dwRequestTime > pInfo->m_dwTimeout )
+ if (dwCurrentTime - pInfo->m_dwRequestTime > pInfo->m_dwTimeout)
{
m_pIqs = pInfo->m_pNext;
pInfo->m_pNext = NULL;
@@ -285,7 +285,7 @@ protected: while (pInfo->m_pNext)
{
- if (dwCurrentTime - pInfo->m_pNext->m_dwRequestTime > pInfo->m_pNext->m_dwTimeout )
+ if (dwCurrentTime - pInfo->m_pNext->m_dwRequestTime > pInfo->m_pNext->m_dwTimeout)
{
CJabberIqInfo* pRetVal = pInfo->m_pNext;
pInfo->m_pNext = pInfo->m_pNext->m_pNext;
@@ -296,11 +296,11 @@ protected: }
return NULL;
}
- void ExpireInfo( CJabberIqInfo* pInfo, void *pUserData = NULL );
+ void ExpireInfo(CJabberIqInfo* pInfo, void *pUserData = NULL);
BOOL InsertIq(CJabberIqInfo* pInfo)
{ // inserts pInfo at a place determined by pInfo->m_iPriority
Lock();
- if (!m_pIqs)
+ if ( !m_pIqs)
m_pIqs = pInfo;
else
{
@@ -320,7 +320,7 @@ protected: return TRUE;
}
public:
- CJabberIqManager( CJabberProto* proto )
+ CJabberIqManager(CJabberProto* proto)
{
InitializeCriticalSection(&m_cs);
m_dwLastUsedHandle = 0;
@@ -334,7 +334,7 @@ public: ExpireAll();
Lock();
CJabberIqPermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo )
+ while (pInfo)
{
CJabberIqPermanentInfo *pTmp = pInfo->m_pNext;
delete pInfo;
@@ -347,13 +347,13 @@ public: BOOL Start();
BOOL Shutdown()
{
- if ( m_bExpirerThreadShutdownRequest || !m_hExpirerThread )
+ if (m_bExpirerThreadShutdownRequest || !m_hExpirerThread)
return TRUE;
m_bExpirerThreadShutdownRequest = TRUE;
- WaitForSingleObject( m_hExpirerThread, INFINITE );
- CloseHandle( m_hExpirerThread );
+ WaitForSingleObject(m_hExpirerThread, INFINITE);
+ CloseHandle(m_hExpirerThread);
m_hExpirerThread = NULL;
return TRUE;
@@ -368,24 +368,24 @@ public: }
// fucking params, maybe just return CJabberIqRequestInfo pointer ?
CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const TCHAR *szReceiver = NULL, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = NULL, int iPriority = JH_PRIORITY_DEFAULT);
- CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const TCHAR* szXmlns, BOOL bAllowPartialNs, const TCHAR* szTag, void *pUserData = NULL, IQ_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
+ CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const TCHAR *szXmlns, BOOL bAllowPartialNs, const TCHAR *szTag, void *pUserData = NULL, IQ_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
{
CJabberIqPermanentInfo* pInfo = new CJabberIqPermanentInfo();
- if (!pInfo)
+ if ( !pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
pInfo->m_nIqTypes = nIqTypes ? nIqTypes : JABBER_IQ_TYPE_ANY;
- replaceStrT( pInfo->m_szXmlns, szXmlns );
+ replaceStrT(pInfo->m_szXmlns, szXmlns);
pInfo->m_bAllowPartialNs = bAllowPartialNs;
- replaceStrT( pInfo->m_szTag, szTag );
+ replaceStrT(pInfo->m_szTag, szTag);
pInfo->m_dwParamsToParse = dwParamsToParse;
pInfo->m_pUserData = pUserData;
pInfo->m_pUserDataFree = pUserDataFree;
pInfo->m_iPriority = iPriority;
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
m_pPermanentHandlers = pInfo;
else
{
@@ -408,7 +408,7 @@ public: BOOL DeletePermanentHandler(CJabberIqPermanentInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
{
Unlock();
return FALSE;
@@ -440,7 +440,7 @@ public: BOOL DeleteHandler(CJabberIqInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
Lock();
- if (!m_pIqs)
+ if ( !m_pIqs)
{
Unlock();
return FALSE;
@@ -486,7 +486,7 @@ public: }
return FALSE;
}
- void ExpirerThread( void );
+ void ExpirerThread(void);
BOOL ExpireByUserData(void *pUserData)
{
BOOL bRetVal = FALSE;
@@ -495,7 +495,7 @@ public: Lock();
CJabberIqInfo* pInfo = DetachInfo(pUserData);
Unlock();
- if (!pInfo)
+ if ( !pInfo)
break;
ExpireInfo(pInfo, NULL);
delete pInfo;
@@ -512,7 +512,7 @@ public: if (pInfo)
m_pIqs = m_pIqs->m_pNext;
Unlock();
- if (!pInfo)
+ if ( !pInfo)
break;
pInfo->m_pNext = NULL;
ExpireInfo(pInfo, pUserData);
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 82f82b633f..11052adb22 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -139,10 +139,10 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
BOOL bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi);
- if (!bOsVersionInfoEx)
+ if ( !bOsVersionInfoEx)
{
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (!GetVersionEx((OSVERSIONINFO*)&osvi))
+ if ( !GetVersionEx((OSVERSIONINFO*)&osvi))
return FALSE;
}
@@ -188,153 +188,153 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) pGPI = (PGPI) GetProcAddress(hKernel, "GetProductInfo");
if (pGPI != NULL)
- pGPI( osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
+ pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
- switch( dwType )
+ switch(dwType)
{
case PRODUCT_ULTIMATE:
- StringCchCat(pszOS, BUFSIZE, TEXT("Ultimate Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Ultimate Edition"));
break;
case PRODUCT_PROFESSIONAL:
- StringCchCat(pszOS, BUFSIZE, TEXT("Professional Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Professional Edition"));
break;
case PRODUCT_PROFESSIONAL_WMC:
- StringCchCat(pszOS, BUFSIZE, TEXT("Professional Edition with Media Center" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Professional Edition with Media Center"));
break;
case PRODUCT_HOME_PREMIUM:
- StringCchCat(pszOS, BUFSIZE, TEXT("Home Premium Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Home Premium Edition"));
break;
case PRODUCT_HOME_BASIC:
- StringCchCat(pszOS, BUFSIZE, TEXT("Home Basic Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Home Basic Edition"));
break;
case PRODUCT_ENTERPRISE:
- StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition"));
break;
case PRODUCT_BUSINESS:
- StringCchCat(pszOS, BUFSIZE, TEXT("Business Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Business Edition"));
break;
case PRODUCT_STARTER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Starter Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Starter Edition"));
break;
case PRODUCT_CLUSTER_SERVER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Cluster Server Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Cluster Server Edition"));
break;
case PRODUCT_DATACENTER_SERVER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition"));
break;
case PRODUCT_DATACENTER_SERVER_CORE:
- StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition (core installation)" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition (core installation)"));
break;
case PRODUCT_ENTERPRISE_SERVER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition"));
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
- StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition (core installation)" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition (core installation)"));
break;
case PRODUCT_ENTERPRISE_SERVER_IA64:
- StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition for Itanium-based Systems" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition for Itanium-based Systems"));
break;
case PRODUCT_SMALLBUSINESS_SERVER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server"));
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
- StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server Premium Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server Premium Edition"));
break;
case PRODUCT_STANDARD_SERVER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition"));
break;
case PRODUCT_STANDARD_SERVER_CORE:
- StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition (core installation)" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition (core installation)"));
break;
case PRODUCT_WEB_SERVER:
- StringCchCat(pszOS, BUFSIZE, TEXT("Web Server Edition" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Web Server Edition"));
break;
}
- if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
- StringCchCat(pszOS, BUFSIZE, TEXT( ", 64-bit" ));
- else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL )
+ if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
+ StringCchCat(pszOS, BUFSIZE, TEXT(", 64-bit"));
+ else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL)
StringCchCat(pszOS, BUFSIZE, TEXT(", 32-bit"));
}
- if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
{
- if ( GetSystemMetrics(SM_SERVERR2))
- StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Server 2003 R2, "));
- else if ( osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Storage Server 2003"));
- else if ( osvi.wSuiteMask==VER_SUITE_WH_SERVER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Home Server"));
- else if ( osvi.wProductType == VER_NT_WORKSTATION &&
+ if (GetSystemMetrics(SM_SERVERR2))
+ StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003 R2, "));
+ else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Windows Storage Server 2003"));
+ else if (osvi.wSuiteMask==VER_SUITE_WH_SERVER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Windows Home Server"));
+ else if (osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
- StringCchCat(pszOS, BUFSIZE, TEXT( "Windows XP Professional x64 Edition"));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Windows XP Professional x64 Edition"));
}
else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003, "));
// Test for the server type.
- if ( osvi.wProductType != VER_NT_WORKSTATION )
+ if (osvi.wProductType != VER_NT_WORKSTATION)
{
- if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
+ if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64)
{
- if ( osvi.wSuiteMask & VER_SUITE_DATACENTER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition for Itanium-based Systems" ));
- else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition for Itanium-based Systems" ));
+ if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition for Itanium-based Systems"));
+ else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition for Itanium-based Systems"));
}
- else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
+ else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
- if ( osvi.wSuiteMask & VER_SUITE_DATACENTER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter x64 Edition" ));
- else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise x64 Edition" ));
- else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard x64 Edition" ));
+ if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter x64 Edition"));
+ else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise x64 Edition"));
+ else StringCchCat(pszOS, BUFSIZE, TEXT("Standard x64 Edition"));
}
else
{
- if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Compute Cluster Edition" ));
- else if ( osvi.wSuiteMask & VER_SUITE_DATACENTER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition" ));
- else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition" ));
- else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Web Edition" ));
- else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard Edition" ));
+ if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Compute Cluster Edition"));
+ else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition"));
+ else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition"));
+ else if (osvi.wSuiteMask & VER_SUITE_BLADE)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Web Edition"));
+ else StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition"));
}
}
}
- if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
{
StringCchCat(pszOS, BUFSIZE, TEXT("Windows XP "));
- if ( osvi.wSuiteMask & VER_SUITE_PERSONAL )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Home Edition" ));
- else StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
+ if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Home Edition"));
+ else StringCchCat(pszOS, BUFSIZE, TEXT("Professional"));
}
- if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
{
StringCchCat(pszOS, BUFSIZE, TEXT("Windows 2000 "));
- if ( osvi.wProductType == VER_NT_WORKSTATION )
+ if (osvi.wProductType == VER_NT_WORKSTATION)
{
- StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
+ StringCchCat(pszOS, BUFSIZE, TEXT("Professional"));
}
else
{
- if ( osvi.wSuiteMask & VER_SUITE_DATACENTER )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Server" ));
- else if ( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
- StringCchCat(pszOS, BUFSIZE, TEXT( "Advanced Server" ));
- else StringCchCat(pszOS, BUFSIZE, TEXT( "Server" ));
+ if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Server"));
+ else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
+ StringCchCat(pszOS, BUFSIZE, TEXT("Advanced Server"));
+ else StringCchCat(pszOS, BUFSIZE, TEXT("Server"));
}
}
// Include service pack (if any) and build number.
- if ( _tcslen(osvi.szCSDVersion) > 0 )
+ if (_tcslen(osvi.szCSDVersion) > 0)
{
StringCchCat(pszOS, BUFSIZE, TEXT(" "));
StringCchCat(pszOS, BUFSIZE, osvi.szCSDVersion);
@@ -342,7 +342,7 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) TCHAR buf[80];
- StringCchPrintf( buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
+ StringCchPrintf(buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
StringCchCat(pszOS, BUFSIZE, buf);
return TRUE;
@@ -354,44 +354,44 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) }
-BOOL CJabberProto::OnIqRequestVersion( HXML, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo* pInfo)
{
if ( !pInfo->GetFrom())
return TRUE;
- if ( !m_options.AllowVersionRequests )
+ if ( !m_options.AllowVersionRequests)
return FALSE;
- XmlNodeIq iq( _T("result"), pInfo );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_VERSION));
- query << XCHILD( _T("name"), _T("Miranda NG Jabber"));
- query << XCHILD( _T("version"), szCoreVersion);
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_VERSION));
+ query << XCHILD(_T("name"), _T("Miranda NG Jabber"));
+ query << XCHILD(_T("version"), szCoreVersion);
- if ( m_options.ShowOSVersion )
+ if (m_options.ShowOSVersion)
{
TCHAR os[256] = {0};
- if (!GetOSDisplayString(os, SIZEOF(os)))
+ if ( !GetOSDisplayString(os, SIZEOF(os)))
lstrcpyn(os, _T("Microsoft Windows"), SIZEOF(os));
- query << XCHILD( _T("os"), os );
+ query << XCHILD(_T("os"), os);
}
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return TRUE;
}
// last activity (XEP-0012) support
-BOOL CJabberProto::OnIqRequestLastActivity( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnIqRequestLastActivity(HXML, CJabberIqInfo *pInfo)
{
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo ) << XQUERY( _T(JABBER_FEAT_LAST_ACTIVITY))
- << XATTRI( _T("seconds"), m_tmJabberIdleStartTime ? time( 0 ) - m_tmJabberIdleStartTime : 0 ));
+ XmlNodeIq(_T("result"), pInfo) << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY))
+ << XATTRI(_T("seconds"), m_tmJabberIdleStartTime ? time(0) - m_tmJabberIdleStartTime : 0));
return TRUE;
}
// XEP-0199: XMPP Ping support
-BOOL CJabberProto::OnIqRequestPing( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnIqRequestPing(HXML, CJabberIqInfo *pInfo)
{
- m_ThreadInfo->send( XmlNodeIq( _T("result"), pInfo ) << XATTR( _T("from"), m_ThreadInfo->fullJID ));
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), pInfo) << XATTR(_T("from"), m_ThreadInfo->fullJID));
return TRUE;
}
@@ -423,7 +423,7 @@ int GetGMTOffset(void) }
// entity time (XEP-0202) support
-BOOL CJabberProto::OnIqRequestTime( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnIqRequestTime(HXML, CJabberIqInfo *pInfo)
{
TCHAR stime[100];
TCHAR szTZ[10];
@@ -431,55 +431,55 @@ BOOL CJabberProto::OnIqRequestTime( HXML, CJabberIqInfo *pInfo ) tmi.printDateTime(UTC_TIME_HANDLE, _T("I"), stime, SIZEOF(stime), 0);
int nGmtOffset = GetGMTOffset();
- mir_sntprintf(szTZ, SIZEOF(szTZ), _T("%+03d:%02d"), nGmtOffset / 60, nGmtOffset % 60 );
-
- XmlNodeIq iq( _T("result"), pInfo );
- HXML timeNode = iq << XCHILDNS( _T("time"), _T(JABBER_FEAT_ENTITY_TIME));
- timeNode << XCHILD( _T("utc"), stime); timeNode << XCHILD( _T("tzo"), szTZ );
- LPCTSTR szTZName = tmi.getTzName( NULL );
- if ( szTZName )
- timeNode << XCHILD( _T("tz"), szTZName );
- m_ThreadInfo->send( iq );
+ mir_sntprintf(szTZ, SIZEOF(szTZ), _T("%+03d:%02d"), nGmtOffset / 60, nGmtOffset % 60);
+
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML timeNode = iq << XCHILDNS(_T("time"), _T(JABBER_FEAT_ENTITY_TIME));
+ timeNode << XCHILD(_T("utc"), stime); timeNode << XCHILD(_T("tzo"), szTZ);
+ LPCTSTR szTZName = tmi.getTzName(NULL);
+ if (szTZName)
+ timeNode << XCHILD(_T("tz"), szTZName);
+ m_ThreadInfo->send(iq);
return TRUE;
}
-BOOL CJabberProto::OnIqProcessIqOldTime( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnIqProcessIqOldTime(HXML, CJabberIqInfo *pInfo)
{
struct tm *gmt;
time_t ltime;
TCHAR stime[ 100 ], *dtime;
_tzset();
- time( <ime );
- gmt = gmtime( <ime );
- mir_sntprintf( stime, SIZEOF(stime), _T("%.4i%.2i%.2iT%.2i:%.2i:%.2i"),
+ time(<ime);
+ gmt = gmtime(<ime);
+ mir_sntprintf(stime, SIZEOF(stime), _T("%.4i%.2i%.2iT%.2i:%.2i:%.2i"),
gmt->tm_year + 1900, gmt->tm_mon + 1,
- gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec );
- dtime = _tctime( <ime );
+ gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
+ dtime = _tctime(<ime);
dtime[ 24 ] = 0;
- XmlNodeIq iq( _T("result"), pInfo );
- HXML queryNode = iq << XQUERY( _T(JABBER_FEAT_ENTITY_TIME_OLD));
- queryNode << XCHILD( _T("utc"), stime );
- LPCTSTR szTZName = tmi.getTzName( NULL );
- if ( szTZName )
- queryNode << XCHILD( _T("tz"), szTZName );
- queryNode << XCHILD( _T("display"), dtime );
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML queryNode = iq << XQUERY(_T(JABBER_FEAT_ENTITY_TIME_OLD));
+ queryNode << XCHILD(_T("utc"), stime);
+ LPCTSTR szTZName = tmi.getTzName(NULL);
+ if (szTZName)
+ queryNode << XCHILD(_T("tz"), szTZName);
+ queryNode << XCHILD(_T("display"), dtime);
+ m_ThreadInfo->send(iq);
return TRUE;
}
-BOOL CJabberProto::OnIqRequestAvatar( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnIqRequestAvatar(HXML, CJabberIqInfo *pInfo)
{
- if ( !m_options.EnableAvatars )
+ if ( !m_options.EnableAvatars)
return TRUE;
int pictureType = m_options.AvatarType;
- if ( pictureType == PA_FORMAT_UNKNOWN )
+ if (pictureType == PA_FORMAT_UNKNOWN)
return TRUE;
TCHAR* szMimeType;
- switch( pictureType ) {
+ switch(pictureType) {
case PA_FORMAT_JPEG: szMimeType = _T("image/jpeg"); break;
case PA_FORMAT_GIF: szMimeType = _T("image/gif"); break;
case PA_FORMAT_PNG: szMimeType = _T("image/png"); break;
@@ -488,75 +488,75 @@ BOOL CJabberProto::OnIqRequestAvatar( HXML, CJabberIqInfo *pInfo ) }
TCHAR szFileName[ MAX_PATH ];
- GetAvatarFileName( NULL, szFileName, SIZEOF(szFileName));
+ GetAvatarFileName(NULL, szFileName, SIZEOF(szFileName));
- FILE* in = _tfopen( szFileName, _T("rb"));
- if ( in == NULL )
+ FILE* in = _tfopen(szFileName, _T("rb"));
+ if (in == NULL)
return TRUE;
- long bytes = _filelength( _fileno( in ));
- char* buffer = ( char* )mir_alloc( bytes*4/3 + bytes + 1000 );
- if ( buffer == NULL ) {
- fclose( in );
+ long bytes = _filelength(_fileno(in));
+ char* buffer = (char*)mir_alloc(bytes*4/3 + bytes + 1000);
+ if (buffer == NULL) {
+ fclose(in);
return TRUE;
}
- fread( buffer, bytes, 1, in );
- fclose( in );
+ fread(buffer, bytes, 1, in);
+ fclose(in);
- char* str = JabberBase64Encode( buffer, bytes );
- m_ThreadInfo->send( XmlNodeIq( _T("result"), pInfo ) << XQUERY( _T(JABBER_FEAT_AVATAR)) << XCHILD( _T("query"), _A2T(str)) << XATTR( _T("mimetype"), szMimeType ));
- mir_free( str );
- mir_free( buffer );
+ char* str = JabberBase64Encode(buffer, bytes);
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), pInfo) << XQUERY(_T(JABBER_FEAT_AVATAR)) << XCHILD(_T("query"), _A2T(str)) << XATTR(_T("mimetype"), szMimeType));
+ mir_free(str);
+ mir_free(buffer);
return TRUE;
}
-BOOL CJabberProto::OnSiRequest( HXML node, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnSiRequest(HXML node, CJabberIqInfo *pInfo)
{
- const TCHAR* szProfile = xmlGetAttrValue( pInfo->GetChildNode(), _T("profile"));
+ const TCHAR *szProfile = xmlGetAttrValue(pInfo->GetChildNode(), _T("profile"));
- if ( szProfile && !_tcscmp( szProfile, _T(JABBER_FEAT_SI_FT)))
- FtHandleSiRequest( node );
+ if (szProfile && !_tcscmp(szProfile, _T(JABBER_FEAT_SI_FT)))
+ FtHandleSiRequest(node);
else {
- XmlNodeIq iq( _T("error"), pInfo );
- HXML error = iq << XCHILD( _T("error")) << XATTRI( _T("code"), 400 ) << XATTR( _T("type"), _T("cancel"));
- error << XCHILDNS( _T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
- error << XCHILD( _T("bad-profile"));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), pInfo);
+ HXML error = iq << XCHILD(_T("error")) << XATTRI(_T("code"), 400) << XATTR(_T("type"), _T("cancel"));
+ error << XCHILDNS(_T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
+ error << XCHILD(_T("bad-profile"));
+ m_ThreadInfo->send(iq);
}
return TRUE;
}
-BOOL CJabberProto::OnRosterPushRequest( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
{
HXML queryNode = pInfo->GetChildNode();
// RFC 3921 #7.2 Business Rules
- if ( pInfo->GetFrom()) {
- TCHAR* szFrom = JabberPrepareJid( pInfo->GetFrom());
- if ( !szFrom )
+ if (pInfo->GetFrom()) {
+ TCHAR* szFrom = JabberPrepareJid(pInfo->GetFrom());
+ if ( !szFrom)
return TRUE;
- TCHAR* szTo = JabberPrepareJid( m_ThreadInfo->fullJID );
- if ( !szTo ) {
- mir_free( szFrom );
+ TCHAR* szTo = JabberPrepareJid(m_ThreadInfo->fullJID);
+ if ( !szTo) {
+ mir_free(szFrom);
return TRUE;
}
- TCHAR* pDelimiter = _tcschr( szFrom, _T('/'));
- if ( pDelimiter ) *pDelimiter = _T('\0');
+ TCHAR* pDelimiter = _tcschr(szFrom, _T('/'));
+ if (pDelimiter) *pDelimiter = _T('\0');
- pDelimiter = _tcschr( szTo, _T('/'));
- if ( pDelimiter ) *pDelimiter = _T('\0');
+ pDelimiter = _tcschr(szTo, _T('/'));
+ if (pDelimiter) *pDelimiter = _T('\0');
- BOOL bRetVal = _tcscmp( szFrom, szTo ) == 0;
+ BOOL bRetVal = _tcscmp(szFrom, szTo) == 0;
- mir_free( szFrom );
- mir_free( szTo );
+ mir_free(szFrom);
+ mir_free(szTo);
// invalid JID
- if ( !bRetVal ) {
- Log( "<iq/> attempt to hack via roster push from " TCHAR_STR_PARAM, pInfo->GetFrom());
+ if ( !bRetVal) {
+ Log("<iq/> attempt to hack via roster push from " TCHAR_STR_PARAM, pInfo->GetFrom());
return TRUE;
}
}
@@ -566,85 +566,85 @@ BOOL CJabberProto::OnRosterPushRequest( HXML, CJabberIqInfo *pInfo ) const TCHAR *jid, *str, *name;
TCHAR* nick;
- Log( "<iq/> Got roster push, query has %d children", xmlGetChildCount( queryNode ));
- for ( int i=0; ; i++ ) {
- HXML itemNode = xmlGetChild( queryNode ,i);
- if ( !itemNode )
+ Log("<iq/> Got roster push, query has %d children", xmlGetChildCount(queryNode));
+ for (int i=0; ; i++) {
+ HXML itemNode = xmlGetChild(queryNode ,i);
+ if ( !itemNode)
break;
- if ( _tcscmp( xmlGetName( itemNode ), _T("item")) != 0 )
+ if (_tcscmp(xmlGetName(itemNode), _T("item")) != 0)
continue;
- if (( jid = xmlGetAttrValue( itemNode, _T("jid"))) == NULL )
+ if ((jid = xmlGetAttrValue(itemNode, _T("jid"))) == NULL)
continue;
- if (( str = xmlGetAttrValue( itemNode, _T("subscription"))) == NULL )
+ if ((str = xmlGetAttrValue(itemNode, _T("subscription"))) == NULL)
continue;
// we will not add new account when subscription=remove
- if ( !_tcscmp( str, _T("to")) || !_tcscmp( str, _T("both")) || !_tcscmp( str, _T("from")) || !_tcscmp( str, _T("none"))) {
- if (( name = xmlGetAttrValue( itemNode, _T("name"))) != NULL )
- nick = mir_tstrdup( name );
+ if ( !_tcscmp(str, _T("to")) || !_tcscmp(str, _T("both")) || !_tcscmp(str, _T("from")) || !_tcscmp(str, _T("none"))) {
+ if ((name = xmlGetAttrValue(itemNode, _T("name"))) != NULL)
+ nick = mir_tstrdup(name);
else
- nick = JabberNickFromJID( jid );
+ nick = JabberNickFromJID(jid);
- if ( nick != NULL ) {
- if (( item=ListAdd( LIST_ROSTER, jid )) != NULL ) {
- replaceStrT( item->nick, nick );
+ if (nick != NULL) {
+ if ((item=ListAdd(LIST_ROSTER, jid)) != NULL) {
+ replaceStrT(item->nick, nick);
- HXML groupNode = xmlGetChild( itemNode , "group" );
- replaceStrT( item->group, ( groupNode ) ? xmlGetText( groupNode ) : NULL );
+ HXML groupNode = xmlGetChild(itemNode , "group");
+ replaceStrT(item->group, (groupNode) ? xmlGetText(groupNode) : NULL);
- if (( hContact=HContactFromJID( jid, 0 )) == NULL ) {
+ if ((hContact=HContactFromJID(jid, 0)) == NULL) {
// Received roster has a new JID.
- // Add the jid ( with empty resource ) to Miranda contact list.
- hContact = DBCreateContact( jid, nick, FALSE, FALSE );
+ // Add the jid (with empty resource) to Miranda contact list.
+ hContact = DBCreateContact(jid, nick, FALSE, FALSE);
}
- else JSetStringT( hContact, "jid", jid );
+ else JSetStringT(hContact, "jid", jid);
- if ( name != NULL ) {
+ if (name != NULL) {
DBVARIANT dbnick;
- if ( !JGetStringT( hContact, "Nick", &dbnick )) {
- if ( _tcscmp( nick, dbnick.ptszVal ) != 0 )
- DBWriteContactSettingTString( hContact, "CList", "MyHandle", nick );
+ if ( !JGetStringT(hContact, "Nick", &dbnick)) {
+ if (_tcscmp(nick, dbnick.ptszVal) != 0)
+ db_set_ts(hContact, "CList", "MyHandle", nick);
else
- DBDeleteContactSetting( hContact, "CList", "MyHandle" );
+ DBDeleteContactSetting(hContact, "CList", "MyHandle");
- JFreeVariant( &dbnick );
+ db_free(&dbnick);
}
- else DBWriteContactSettingTString( hContact, "CList", "MyHandle", nick );
+ else db_set_ts(hContact, "CList", "MyHandle", nick);
}
- else DBDeleteContactSetting( hContact, "CList", "MyHandle" );
+ else DBDeleteContactSetting(hContact, "CList", "MyHandle");
- if (!m_options.IgnoreRosterGroups)
+ if ( !m_options.IgnoreRosterGroups)
{
- if ( item->group != NULL ) {
- JabberContactListCreateGroup( item->group );
- DBWriteContactSettingTString( hContact, "CList", "Group", item->group );
+ if (item->group != NULL) {
+ JabberContactListCreateGroup(item->group);
+ db_set_ts(hContact, "CList", "Group", item->group);
}
else
- DBDeleteContactSetting( hContact, "CList", "Group" );
+ DBDeleteContactSetting(hContact, "CList", "Group");
}
}
- mir_free( nick );
+ mir_free(nick);
} }
- if (( item=ListGetItemPtr( LIST_ROSTER, jid )) != NULL ) {
- if ( !_tcscmp( str, _T("both"))) item->subscription = SUB_BOTH;
- else if ( !_tcscmp( str, _T("to"))) item->subscription = SUB_TO;
- else if ( !_tcscmp( str, _T("from"))) item->subscription = SUB_FROM;
+ if ((item=ListGetItemPtr(LIST_ROSTER, jid)) != NULL) {
+ if ( !_tcscmp(str, _T("both"))) item->subscription = SUB_BOTH;
+ else if ( !_tcscmp(str, _T("to"))) item->subscription = SUB_TO;
+ else if ( !_tcscmp(str, _T("from"))) item->subscription = SUB_FROM;
else item->subscription = SUB_NONE;
- Log( "Roster push for jid=" TCHAR_STR_PARAM ", set subscription to " TCHAR_STR_PARAM, jid, str );
+ Log("Roster push for jid=" TCHAR_STR_PARAM ", set subscription to " TCHAR_STR_PARAM, jid, str);
// subscription = remove is to remove from roster list
// but we will just set the contact to offline and not actually
// remove, so that history will be retained.
- if ( !_tcscmp( str, _T("remove"))) {
- if (( hContact=HContactFromJID( jid )) != NULL ) {
- SetContactOfflineStatus( hContact );
- ListRemove( LIST_ROSTER, jid );
+ if ( !_tcscmp(str, _T("remove"))) {
+ if ((hContact=HContactFromJID(jid)) != NULL) {
+ SetContactOfflineStatus(hContact);
+ ListRemove(LIST_ROSTER, jid);
} }
- else if ( JGetByte( hContact, "ChatRoom", 0 ))
- DBDeleteContactSetting( hContact, "CList", "Hidden" );
+ else if (JGetByte(hContact, "ChatRoom", 0))
+ DBDeleteContactSetting(hContact, "CList", "Hidden");
else
- UpdateSubscriptionInfo( hContact, item );
+ UpdateSubscriptionInfo(hContact, item);
} }
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
@@ -652,30 +652,30 @@ BOOL CJabberProto::OnRosterPushRequest( HXML, CJabberIqInfo *pInfo ) return TRUE;
}
-BOOL CJabberProto::OnIqRequestOOB( HXML, CJabberIqInfo *pInfo )
+BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo)
{
if ( !pInfo->GetFrom() || !pInfo->GetHContact())
return TRUE;
- HXML n = xmlGetChild( pInfo->GetChildNode(), "url" );
- if ( !n || !xmlGetText( n ))
+ HXML n = xmlGetChild(pInfo->GetChildNode(), "url");
+ if ( !n || !xmlGetText(n))
return TRUE;
- if ( m_options.BsOnlyIBB ) {
+ if (m_options.BsOnlyIBB) {
// reject
- XmlNodeIq iq( _T("error"), pInfo );
- HXML e = xmlAddChild( iq, _T("error"), _T("File transfer refused")); xmlAddAttr( e, _T("code"), 406 );
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), pInfo);
+ HXML e = xmlAddChild(iq, _T("error"), _T("File transfer refused")); xmlAddAttr(e, _T("code"), 406);
+ m_ThreadInfo->send(iq);
return TRUE;
}
TCHAR text[ 1024 ];
TCHAR *str, *p, *q;
- str = ( TCHAR* )xmlGetText( n ); // URL of the file to get
- filetransfer* ft = new filetransfer( this );
+ str = (TCHAR*)xmlGetText(n); // URL of the file to get
+ filetransfer *ft = new filetransfer(this);
ft->std.totalFiles = 1;
- ft->jid = mir_tstrdup( pInfo->GetFrom());
+ ft->jid = mir_tstrdup(pInfo->GetFrom());
ft->std.hContact = pInfo->GetHContact();
ft->type = FT_OOB;
ft->httpHostName = NULL;
@@ -683,111 +683,111 @@ BOOL CJabberProto::OnIqRequestOOB( HXML, CJabberIqInfo *pInfo ) ft->httpPath = NULL;
// Parse the URL
- if ( !_tcsnicmp( str, _T("http://"), 7 )) {
+ if ( !_tcsnicmp(str, _T("http://"), 7)) {
p = str + 7;
- if (( q = _tcschr( p, '/' )) != NULL ) {
- if ( q-p < SIZEOF( text )) {
- _tcsncpy( text, p, q-p );
+ if ((q = _tcschr(p, '/')) != NULL) {
+ if (q-p < SIZEOF(text)) {
+ _tcsncpy(text, p, q-p);
text[q-p] = '\0';
- if (( p = _tcschr( text, ':' )) != NULL ) {
- ft->httpPort = ( WORD )_ttoi( p+1 );
+ if ((p = _tcschr(text, ':')) != NULL) {
+ ft->httpPort = (WORD)_ttoi(p+1);
*p = '\0';
}
- ft->httpHostName = mir_t2a( text );
+ ft->httpHostName = mir_t2a(text);
} } }
- if ( pInfo->GetIdStr())
- ft->iqId = mir_tstrdup( pInfo->GetIdStr());
+ if (pInfo->GetIdStr())
+ ft->iqId = mir_tstrdup(pInfo->GetIdStr());
- if ( ft->httpHostName && ft->httpPath ) {
+ if (ft->httpHostName && ft->httpPath) {
TCHAR* desc = NULL;
- Log( "Host=%s Port=%d Path=%s", ft->httpHostName, ft->httpPort, ft->httpPath );
- if (( n = xmlGetChild( pInfo->GetChildNode(), "desc" )) != NULL )
- desc = ( TCHAR* )xmlGetText( n );
+ Log("Host=%s Port=%d Path=%s", ft->httpHostName, ft->httpPort, ft->httpPath);
+ if ((n = xmlGetChild(pInfo->GetChildNode(), "desc")) != NULL)
+ desc = (TCHAR*)xmlGetText(n);
TCHAR* str2;
- Log( "description = %s", desc );
- if (( str2 = _tcsrchr( ft->httpPath, '/' )) != NULL )
+ Log("description = %s", desc);
+ if ((str2 = _tcsrchr(ft->httpPath, '/')) != NULL)
str2++;
else
str2 = ft->httpPath;
- str2 = mir_tstrdup( str2 );
- JabberHttpUrlDecode( str2 );
+ str2 = mir_tstrdup(str2);
+ JabberHttpUrlDecode(str2);
PROTORECVFILET pre;
pre.flags = PREF_TCHAR;
- pre.timestamp = time( NULL );
+ pre.timestamp = time(NULL);
pre.tszDescription = desc;
pre.ptszFiles = &str2;
pre.fileCount = 1;
- pre.lParam = ( LPARAM )ft;
+ pre.lParam = (LPARAM)ft;
- CCSDATA ccs = { ft->std.hContact, PSR_FILE, 0, ( LPARAM )&pre };
- CallService( MS_PROTO_CHAINRECV, 0, ( LPARAM )&ccs );
- mir_free( str2 );
+ CCSDATA ccs = { ft->std.hContact, PSR_FILE, 0, (LPARAM)&pre };
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
+ mir_free(str2);
}
else {
// reject
- XmlNodeIq iq( _T("error"), pInfo );
- HXML e = xmlAddChild( iq, _T("error"), _T("File transfer refused")); xmlAddAttr( e, _T("code"), 406 );
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), pInfo);
+ HXML e = xmlAddChild(iq, _T("error"), _T("File transfer refused")); xmlAddAttr(e, _T("code"), 406);
+ m_ThreadInfo->send(iq);
delete ft;
}
return TRUE;
}
-BOOL CJabberProto::OnHandleDiscoInfoRequest( HXML iqNode, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo* pInfo)
{
if ( !pInfo->GetChildNode())
return TRUE;
- const TCHAR* szNode = xmlGetAttrValue( pInfo->GetChildNode(), _T("node"));
+ const TCHAR *szNode = xmlGetAttrValue(pInfo->GetChildNode(), _T("node"));
// caps hack
- if ( m_clientCapsManager.HandleInfoRequest( iqNode, pInfo, szNode ))
+ if (m_clientCapsManager.HandleInfoRequest(iqNode, pInfo, szNode))
return TRUE;
// ad-hoc hack:
- if ( szNode && m_adhocManager.HandleInfoRequest( iqNode, pInfo, szNode ))
+ if (szNode && m_adhocManager.HandleInfoRequest(iqNode, pInfo, szNode))
return TRUE;
// another request, send empty result
m_ThreadInfo->send(
- XmlNodeIq( _T("error"), pInfo )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ XmlNodeIq(_T("error"), pInfo)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
return TRUE;
}
-BOOL CJabberProto::OnHandleDiscoItemsRequest( HXML iqNode, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnHandleDiscoItemsRequest(HXML iqNode, CJabberIqInfo* pInfo)
{
if ( !pInfo->GetChildNode())
return TRUE;
// ad-hoc commands check:
- const TCHAR* szNode = xmlGetAttrValue( pInfo->GetChildNode(), _T("node"));
- if ( szNode && m_adhocManager.HandleItemsRequest( iqNode, pInfo, szNode ))
+ const TCHAR *szNode = xmlGetAttrValue(pInfo->GetChildNode(), _T("node"));
+ if (szNode && m_adhocManager.HandleItemsRequest(iqNode, pInfo, szNode))
return TRUE;
// another request, send empty result
- XmlNodeIq iq( _T("result"), pInfo );
- HXML resultQuery = iq << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS));
- if ( szNode )
- xmlAddAttr( resultQuery, _T("node"), szNode );
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML resultQuery = iq << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS));
+ if (szNode)
+ xmlAddAttr(resultQuery, _T("node"), szNode);
- if ( !szNode && m_options.EnableRemoteControl )
- resultQuery << XCHILD( _T("item")) << XATTR( _T("jid"), m_ThreadInfo->fullJID )
- << XATTR( _T("node"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("name"), _T("Ad-hoc commands"));
+ if ( !szNode && m_options.EnableRemoteControl)
+ resultQuery << XCHILD(_T("item")) << XATTR(_T("jid"), m_ThreadInfo->fullJID)
+ << XATTR(_T("node"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("name"), _T("Ad-hoc commands"));
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return TRUE;
}
-BOOL CJabberProto::AddClistHttpAuthEvent( CJabberHttpAuthParams *pParams )
+BOOL CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams)
{
CLISTEVENT cle = {0};
char szService[256];
- mir_snprintf( szService, sizeof(szService),"%s%s", m_szModuleName, JS_HTTP_AUTH );
+ mir_snprintf(szService, sizeof(szService),"%s%s", m_szModuleName, JS_HTTP_AUTH);
cle.cbSize = sizeof(CLISTEVENT);
cle.hIcon = (HICON) LoadIconEx("openid");
cle.flags = CLEF_PROTOCOLGLOBAL | CLEF_TCHAR;
@@ -800,36 +800,36 @@ BOOL CJabberProto::AddClistHttpAuthEvent( CJabberHttpAuthParams *pParams ) return TRUE;
}
-BOOL CJabberProto::OnIqHttpAuth( HXML node, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnIqHttpAuth(HXML node, CJabberIqInfo* pInfo)
{
- if ( !m_options.AcceptHttpAuth )
+ if ( !m_options.AcceptHttpAuth)
return TRUE;
if ( !node || !pInfo->GetChildNode() || !pInfo->GetFrom() || !pInfo->GetIdStr())
return TRUE;
- HXML pConfirm = xmlGetChild( node , "confirm" );
- if ( !pConfirm )
+ HXML pConfirm = xmlGetChild(node , "confirm");
+ if ( !pConfirm)
return TRUE;
- const TCHAR *szId = xmlGetAttrValue( pConfirm, _T("id"));
- const TCHAR *szMethod = xmlGetAttrValue( pConfirm, _T("method"));
- const TCHAR *szUrl = xmlGetAttrValue( pConfirm, _T("url"));
+ const TCHAR *szId = xmlGetAttrValue(pConfirm, _T("id"));
+ const TCHAR *szMethod = xmlGetAttrValue(pConfirm, _T("method"));
+ const TCHAR *szUrl = xmlGetAttrValue(pConfirm, _T("url"));
- if ( !szId || !szMethod || !szUrl )
+ if ( !szId || !szMethod || !szUrl)
return TRUE;
- CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams *)mir_alloc( sizeof( CJabberHttpAuthParams ));
- if ( !pParams )
+ CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams *)mir_alloc(sizeof(CJabberHttpAuthParams));
+ if ( !pParams)
return TRUE;
- ZeroMemory( pParams, sizeof( CJabberHttpAuthParams ));
+ ZeroMemory(pParams, sizeof(CJabberHttpAuthParams));
pParams->m_nType = CJabberHttpAuthParams::IQ;
- pParams->m_szFrom = mir_tstrdup( pInfo->GetFrom());
- pParams->m_szId = mir_tstrdup( szId );
- pParams->m_szMethod = mir_tstrdup( szMethod );
- pParams->m_szUrl = mir_tstrdup( szUrl );
+ pParams->m_szFrom = mir_tstrdup(pInfo->GetFrom());
+ pParams->m_szId = mir_tstrdup(szId);
+ pParams->m_szMethod = mir_tstrdup(szMethod);
+ pParams->m_szUrl = mir_tstrdup(szUrl);
- AddClistHttpAuthEvent( pParams );
+ AddClistHttpAuthEvent(pParams);
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 7679450d59..6d5988145c 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -30,34 +30,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_genmenu.h"
#include "m_clistint.h"
-void CJabberProto::OnIqResultServerDiscoInfo( HXML iqNode )
+void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode)
{
- if ( !iqNode )
+ if ( !iqNode)
return;
- const TCHAR *type = xmlGetAttrValue( iqNode, _T("type"));
+ const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
int i;
- if ( !_tcscmp( type, _T("result"))) {
- HXML query = xmlGetChildByTag( iqNode, "query", "xmlns", _T(JABBER_FEAT_DISCO_INFO));
- if ( !query )
+ if ( !_tcscmp(type, _T("result"))) {
+ HXML query = xmlGetChildByTag(iqNode, "query", "xmlns", _T(JABBER_FEAT_DISCO_INFO));
+ if ( !query)
return;
HXML identity;
- for ( i = 1; ( identity = xmlGetNthChild( query, _T("identity"), i )) != NULL; i++ ) {
- const TCHAR *identityCategory = xmlGetAttrValue( identity, _T("category"));
- const TCHAR *identityType = xmlGetAttrValue( identity, _T("type"));
- const TCHAR *identityName = xmlGetAttrValue( identity, _T("name"));
- if ( identityCategory && identityType && !_tcscmp( identityCategory, _T("pubsub")) && !_tcscmp( identityType, _T("pep"))) {
+ for (i = 1; (identity = xmlGetNthChild(query, _T("identity"), i)) != NULL; i++) {
+ const TCHAR *identityCategory = xmlGetAttrValue(identity, _T("category"));
+ const TCHAR *identityType = xmlGetAttrValue(identity, _T("type"));
+ const TCHAR *identityName = xmlGetAttrValue(identity, _T("name"));
+ if (identityCategory && identityType && !_tcscmp(identityCategory, _T("pubsub")) && !_tcscmp(identityType, _T("pep"))) {
m_bPepSupported = TRUE;
- EnableMenuItems( TRUE );
+ EnableMenuItems(TRUE);
RebuildInfoFrame();
}
- else if ( identityCategory && identityType && identityName &&
- !_tcscmp( identityCategory, _T("server")) &&
- !_tcscmp( identityType, _T("im")) &&
- !_tcscmp( identityName, _T("Google Talk"))) {
+ else if (identityCategory && identityType && identityName &&
+ !_tcscmp(identityCategory, _T("server")) &&
+ !_tcscmp(identityType, _T("im")) &&
+ !_tcscmp(identityName, _T("Google Talk"))) {
m_ThreadInfo->jabberServerCaps |= JABBER_CAPS_PING;
m_bGoogleTalk = true;
@@ -67,61 +67,61 @@ void CJabberProto::OnIqResultServerDiscoInfo( HXML iqNode ) << XQUERY(_T(JABBER_FEAT_GTALK_SHARED_STATUS)) << XATTR(_T("version"), _T("2")));
}
}
- if ( m_ThreadInfo ) {
+ if (m_ThreadInfo) {
HXML feature;
- for ( i = 1; ( feature = xmlGetNthChild( query, _T("feature"), i )) != NULL; i++ ) {
- const TCHAR *featureName = xmlGetAttrValue( feature, _T("var"));
- if ( featureName ) {
- for ( int j = 0; g_JabberFeatCapPairs[j].szFeature; j++ ) {
- if ( !_tcscmp( g_JabberFeatCapPairs[j].szFeature, featureName )) {
+ for (i = 1; (feature = xmlGetNthChild(query, _T("feature"), i)) != NULL; i++) {
+ const TCHAR *featureName = xmlGetAttrValue(feature, _T("var"));
+ if (featureName) {
+ for (int j = 0; g_JabberFeatCapPairs[j].szFeature; j++) {
+ if ( !_tcscmp(g_JabberFeatCapPairs[j].szFeature, featureName)) {
m_ThreadInfo->jabberServerCaps |= g_JabberFeatCapPairs[j].jcbCap;
break;
} } } } }
- OnProcessLoginRq( m_ThreadInfo, JABBER_LOGIN_SERVERINFO);
+ OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_SERVERINFO);
} }
-void CJabberProto::OnIqResultNestedRosterGroups( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo* pInfo)
{
const TCHAR *szGroupDelimeter = NULL;
BOOL bPrivateStorageSupport = FALSE;
- if ( iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
+ if (iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
bPrivateStorageSupport = TRUE;
- szGroupDelimeter = XPathFmt( iqNode, _T("query[@xmlns='%s']/roster[@xmlns='%s']"), _T(JABBER_FEAT_PRIVATE_STORAGE), _T( JABBER_FEAT_NESTED_ROSTER_GROUPS ));
- if ( szGroupDelimeter && !szGroupDelimeter[0] )
+ szGroupDelimeter = XPathFmt(iqNode, _T("query[@xmlns='%s']/roster[@xmlns='%s']"), _T(JABBER_FEAT_PRIVATE_STORAGE), _T(JABBER_FEAT_NESTED_ROSTER_GROUPS));
+ if (szGroupDelimeter && !szGroupDelimeter[0])
szGroupDelimeter = NULL; // "" as roster delimeter is not supported :)
}
// global fuckup
- if ( !m_ThreadInfo )
+ if ( !m_ThreadInfo)
return;
// is our default delimiter?
- if (( !szGroupDelimeter && bPrivateStorageSupport ) || ( szGroupDelimeter && _tcscmp( szGroupDelimeter, _T("\\"))))
+ if ((!szGroupDelimeter && bPrivateStorageSupport) || (szGroupDelimeter && _tcscmp(szGroupDelimeter, _T("\\"))))
m_ThreadInfo->send(
- XmlNodeIq( _T("set"), SerialNext()) << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE))
- << XCHILD( _T("roster"), _T("\\")) << XATTR( _T("xmlns"), _T(JABBER_FEAT_NESTED_ROSTER_GROUPS)));
+ XmlNodeIq(_T("set"), SerialNext()) << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE))
+ << XCHILD(_T("roster"), _T("\\")) << XATTR(_T("xmlns"), _T(JABBER_FEAT_NESTED_ROSTER_GROUPS)));
// roster request
- TCHAR *szUserData = mir_tstrdup( szGroupDelimeter ? szGroupDelimeter : _T("\\"));
+ TCHAR *szUserData = mir_tstrdup(szGroupDelimeter ? szGroupDelimeter : _T("\\"));
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void *)szUserData ))
- << XCHILDNS( _T("query"), _T(JABBER_FEAT_IQ_ROSTER)));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void*)szUserData))
+ << XCHILDNS(_T("query"), _T(JABBER_FEAT_IQ_ROSTER)));
}
-void CJabberProto::OnIqResultNotes( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultNotes(HXML iqNode, CJabberIqInfo* pInfo)
{
- if ( iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT ) {
- HXML hXmlData = XPathFmt( iqNode, _T("query[@xmlns='%s']/storage[@xmlns='%s']"),
+ if (iqNode && pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ HXML hXmlData = XPathFmt(iqNode, _T("query[@xmlns='%s']/storage[@xmlns='%s']"),
_T(JABBER_FEAT_PRIVATE_STORAGE), _T(JABBER_FEAT_MIRANDA_NOTES));
if (hXmlData) m_notes.LoadXml(hXmlData);
}
}
-void CJabberProto::OnProcessLoginRq( ThreadData* info, DWORD rq )
+void CJabberProto::OnProcessLoginRq(ThreadData* info, DWORD rq)
{
- if ( info == NULL )
+ if (info == NULL)
return;
info->dwLoginRqs |= rq;
@@ -129,36 +129,36 @@ void CJabberProto::OnProcessLoginRq( ThreadData* info, DWORD rq ) if ((info->dwLoginRqs & JABBER_LOGIN_ROSTER) && (info->dwLoginRqs & JABBER_LOGIN_BOOKMARKS) &&
(info->dwLoginRqs & JABBER_LOGIN_SERVERINFO) && !(info->dwLoginRqs & JABBER_LOGIN_BOOKMARKS_AJ))
{
- if ( jabberChatDllPresent && m_options.AutoJoinBookmarks) {
- LIST<JABBER_LIST_ITEM> ll( 10 );
+ if (jabberChatDllPresent && m_options.AutoJoinBookmarks) {
+ LIST<JABBER_LIST_ITEM> ll(10);
LISTFOREACH(i, this, LIST_BOOKMARK)
{
- JABBER_LIST_ITEM* item = ListGetItemPtrFromIndex( i );
- if ( item != NULL && !lstrcmp( item->type, _T("conference")) && item->bAutoJoin )
- ll.insert( item );
+ JABBER_LIST_ITEM* item = ListGetItemPtrFromIndex(i);
+ if (item != NULL && !lstrcmp(item->type, _T("conference")) && item->bAutoJoin)
+ ll.insert(item);
}
- for ( int j=0; j < ll.getCount(); j++ ) {
+ for (int j=0; j < ll.getCount(); j++) {
JABBER_LIST_ITEM* item = ll[j];
TCHAR room[256], *server, *p;
TCHAR text[128];
- _tcsncpy( text, item->jid, SIZEOF( text ));
- _tcsncpy( room, text, SIZEOF( room ));
- p = _tcstok( room, _T( "@" ));
- server = _tcstok( NULL, _T( "@" ));
- if ( item->nick && item->nick[0] != 0 )
- GroupchatJoinRoom( server, p, item->nick, item->password, true );
+ _tcsncpy(text, item->jid, SIZEOF(text));
+ _tcsncpy(room, text, SIZEOF(room));
+ p = _tcstok(room, _T("@"));
+ server = _tcstok(NULL, _T("@"));
+ if (item->nick && item->nick[0] != 0)
+ GroupchatJoinRoom(server, p, item->nick, item->password, true);
else {
- TCHAR* nick = JabberNickFromJID( m_szJabberJID );
- GroupchatJoinRoom( server, p, nick, item->password, true );
- mir_free( nick );
+ TCHAR* nick = JabberNickFromJID(m_szJabberJID);
+ GroupchatJoinRoom(server, p, nick, item->password, true);
+ mir_free(nick);
} }
ll.destroy();
}
- OnProcessLoginRq( info, JABBER_LOGIN_BOOKMARKS_AJ );
+ OnProcessLoginRq(info, JABBER_LOGIN_BOOKMARKS_AJ);
} }
void CJabberProto::OnLoggedIn()
@@ -170,217 +170,217 @@ void CJabberProto::OnLoggedIn() // XEP-0083 support
{
- CJabberIqInfo* pIqInfo = m_iqManager.AddHandler( &CJabberProto::OnIqResultNestedRosterGroups, JABBER_IQ_TYPE_GET );
+ CJabberIqInfo* pIqInfo = m_iqManager.AddHandler(&CJabberProto::OnIqResultNestedRosterGroups, JABBER_IQ_TYPE_GET);
// ugly hack to prevent hangup during login process
- pIqInfo->SetTimeout( 30000 );
+ pIqInfo->SetTimeout(30000);
m_ThreadInfo->send(
- XmlNodeIq( pIqInfo ) << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE))
- << XCHILDNS( _T("roster"), _T(JABBER_FEAT_NESTED_ROSTER_GROUPS)));
+ XmlNodeIq(pIqInfo) << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE))
+ << XCHILDNS(_T("roster"), _T(JABBER_FEAT_NESTED_ROSTER_GROUPS)));
}
// Server-side notes
{
m_ThreadInfo->send(
XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultNotes, JABBER_IQ_TYPE_GET))
- << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE))
- << XCHILDNS( _T("storage"), _T(JABBER_FEAT_MIRANDA_NOTES)));
+ << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE))
+ << XCHILDNS(_T("storage"), _T(JABBER_FEAT_MIRANDA_NOTES)));
}
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_DISCOBOOKMARKS, &CJabberProto::OnIqResultDiscoBookmarks);
+ IqAdd(iqId, IQ_PROC_DISCOBOOKMARKS, &CJabberProto::OnIqResultDiscoBookmarks);
m_ThreadInfo->send(
- XmlNodeIq( _T("get"), iqId) << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE))
- << XCHILDNS( _T("storage"), _T("storage:bookmarks")));
+ XmlNodeIq(_T("get"), iqId) << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE))
+ << XCHILDNS(_T("storage"), _T("storage:bookmarks")));
m_bPepSupported = FALSE;
m_ThreadInfo->jabberServerCaps = JABBER_RESOURCE_CAPS_NONE;
iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultServerDiscoInfo );
- m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId, _A2T(m_ThreadInfo->server)) << XQUERY( _T(JABBER_FEAT_DISCO_INFO)));
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultServerDiscoInfo);
+ m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId, _A2T(m_ThreadInfo->server)) << XQUERY(_T(JABBER_FEAT_DISCO_INFO)));
- QueryPrivacyLists( m_ThreadInfo );
+ QueryPrivacyLists(m_ThreadInfo);
char szServerName[ sizeof(m_ThreadInfo->server) ];
- if ( JGetStaticString( "LastLoggedServer", NULL, szServerName, sizeof(szServerName)))
- SendGetVcard( m_szJabberJID );
- else if ( strcmp( m_ThreadInfo->server, szServerName ))
- SendGetVcard( m_szJabberJID );
- JSetString( NULL, "LastLoggedServer", m_ThreadInfo->server );
+ if (JGetStaticString("LastLoggedServer", NULL, szServerName, sizeof(szServerName)))
+ SendGetVcard(m_szJabberJID);
+ else if (strcmp(m_ThreadInfo->server, szServerName))
+ SendGetVcard(m_szJabberJID);
+ JSetString(NULL, "LastLoggedServer", m_ThreadInfo->server);
m_pepServices.ResetPublishAll();
}
-void CJabberProto::OnIqResultGetAuth( HXML iqNode )
+void CJabberProto::OnIqResultGetAuth(HXML iqNode)
{
// RECVED: result of the request for authentication method
// ACTION: send account authentication information to log in
- Log( "<iq/> iqIdGetAuth" );
+ Log("<iq/> iqIdGetAuth");
HXML queryNode;
- const TCHAR* type;
- if (( type=xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( queryNode=xmlGetChild( iqNode , "query" )) == NULL ) return;
+ const TCHAR *type;
+ if ((type=xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((queryNode=xmlGetChild(iqNode , "query")) == NULL) return;
- if ( !lstrcmp( type, _T("result"))) {
+ if ( !lstrcmp(type, _T("result"))) {
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultSetAuth );
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultSetAuth);
- XmlNodeIq iq( _T("set"), iqId );
- HXML query = iq << XQUERY( _T("jabber:iq:auth"));
- query << XCHILD( _T("username"), m_ThreadInfo->username );
- if ( xmlGetChild( queryNode, "digest" ) != NULL && m_szStreamId ) {
- char* str = mir_utf8encodeT( m_ThreadInfo->password );
+ XmlNodeIq iq(_T("set"), iqId);
+ HXML query = iq << XQUERY(_T("jabber:iq:auth"));
+ query << XCHILD(_T("username"), m_ThreadInfo->username);
+ if (xmlGetChild(queryNode, "digest") != NULL && m_szStreamId) {
+ char* str = mir_utf8encodeT(m_ThreadInfo->password);
char text[200];
- mir_snprintf( text, SIZEOF(text), "%s%s", m_szStreamId, str );
- mir_free( str );
- if (( str=JabberSha1( text )) != NULL ) {
- query << XCHILD( _T("digest"), _A2T(str));
- mir_free( str );
+ mir_snprintf(text, SIZEOF(text), "%s%s", m_szStreamId, str);
+ mir_free(str);
+ if ((str=JabberSha1(text)) != NULL) {
+ query << XCHILD(_T("digest"), _A2T(str));
+ mir_free(str);
}
}
- else if ( xmlGetChild( queryNode, "password" ) != NULL )
- query << XCHILD( _T("password"), m_ThreadInfo->password );
+ else if (xmlGetChild(queryNode, "password") != NULL)
+ query << XCHILD(_T("password"), m_ThreadInfo->password);
else {
- Log( "No known authentication mechanism accepted by the server." );
+ Log("No known authentication mechanism accepted by the server.");
- m_ThreadInfo->send( "</stream:stream>" );
+ m_ThreadInfo->send("</stream:stream>");
return;
}
- if ( xmlGetChild( queryNode , "resource" ) != NULL )
- query << XCHILD( _T("resource"), m_ThreadInfo->resource );
+ if (xmlGetChild(queryNode , "resource") != NULL)
+ query << XCHILD(_T("resource"), m_ThreadInfo->resource);
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
- else if ( !lstrcmp( type, _T("error"))) {
- m_ThreadInfo->send( "</stream:stream>" );
+ else if ( !lstrcmp(type, _T("error"))) {
+ m_ThreadInfo->send("</stream:stream>");
TCHAR text[128];
- mir_sntprintf( text, SIZEOF( text ), _T("%s %s."), TranslateT( "Authentication failed for" ), m_ThreadInfo->username );
- MsgPopup( NULL, text, TranslateT( "Jabber Authentication" ));
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD );
+ mir_sntprintf(text, SIZEOF(text), _T("%s %s."), TranslateT("Authentication failed for"), m_ThreadInfo->username);
+ MsgPopup(NULL, text, TranslateT("Jabber Authentication"));
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
m_ThreadInfo = NULL; // To disallow auto reconnect
} }
-void CJabberProto::OnIqResultSetAuth( HXML iqNode )
+void CJabberProto::OnIqResultSetAuth(HXML iqNode)
{
- const TCHAR* type;
+ const TCHAR *type;
// RECVED: authentication result
// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
- Log( "<iq/> iqIdSetAuth" );
- if (( type=xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
+ Log("<iq/> iqIdSetAuth");
+ if ((type=xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
- if ( !lstrcmp( type, _T("result"))) {
+ if ( !lstrcmp(type, _T("result"))) {
DBVARIANT dbv;
- if ( JGetStringT( NULL, "Nick", &dbv ))
- JSetStringT( NULL, "Nick", m_ThreadInfo->username );
+ if (JGetStringT(NULL, "Nick", &dbv))
+ JSetStringT(NULL, "Nick", m_ThreadInfo->username);
else
- JFreeVariant( &dbv );
+ db_free(&dbv);
OnLoggedIn();
}
// What to do if password error? etc...
- else if ( !lstrcmp( type, _T("error"))) {
+ else if ( !lstrcmp(type, _T("error"))) {
TCHAR text[128];
- m_ThreadInfo->send( "</stream:stream>" );
- mir_sntprintf( text, SIZEOF( text ), _T("%s %s."), TranslateT( "Authentication failed for" ), m_ThreadInfo->username );
- MsgPopup( NULL, text, TranslateT( "Jabber Authentication" ));
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD );
+ m_ThreadInfo->send("</stream:stream>");
+ mir_sntprintf(text, SIZEOF(text), _T("%s %s."), TranslateT("Authentication failed for"), m_ThreadInfo->username);
+ MsgPopup(NULL, text, TranslateT("Jabber Authentication"));
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
m_ThreadInfo = NULL; // To disallow auto reconnect
} }
-void CJabberProto::OnIqResultBind( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultBind(HXML iqNode, CJabberIqInfo* pInfo)
{
- if ( !m_ThreadInfo || !iqNode )
+ if ( !m_ThreadInfo || !iqNode)
return;
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
- LPCTSTR szJid = XPathT( iqNode, "bind[@xmlns='urn:ietf:params:xml:ns:xmpp-bind']/jid" );
- if ( szJid ) {
- if ( !_tcsncmp( m_ThreadInfo->fullJID, szJid, SIZEOF( m_ThreadInfo->fullJID )))
- Log( "Result Bind: " TCHAR_STR_PARAM " confirmed ", m_ThreadInfo->fullJID );
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) {
+ LPCTSTR szJid = XPathT(iqNode, "bind[@xmlns='urn:ietf:params:xml:ns:xmpp-bind']/jid");
+ if (szJid) {
+ if ( !_tcsncmp(m_ThreadInfo->fullJID, szJid, SIZEOF(m_ThreadInfo->fullJID)))
+ Log("Result Bind: " TCHAR_STR_PARAM " confirmed ", m_ThreadInfo->fullJID);
else {
- Log( "Result Bind: " TCHAR_STR_PARAM " changed to " TCHAR_STR_PARAM, m_ThreadInfo->fullJID, szJid);
- _tcsncpy( m_ThreadInfo->fullJID, szJid, SIZEOF( m_ThreadInfo->fullJID ));
+ Log("Result Bind: " TCHAR_STR_PARAM " changed to " TCHAR_STR_PARAM, m_ThreadInfo->fullJID, szJid);
+ _tcsncpy(m_ThreadInfo->fullJID, szJid, SIZEOF(m_ThreadInfo->fullJID));
}
}
- if ( m_ThreadInfo->bIsSessionAvailable )
+ if (m_ThreadInfo->bIsSessionAvailable)
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET ))
- << XCHILDNS( _T("session"), _T("urn:ietf:params:xml:ns:xmpp-session" )));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET))
+ << XCHILDNS(_T("session"), _T("urn:ietf:params:xml:ns:xmpp-session")));
else
OnLoggedIn();
}
else {
//rfc3920 page 39
- m_ThreadInfo->send( "</stream:stream>" );
+ m_ThreadInfo->send("</stream:stream>");
m_ThreadInfo = NULL; // To disallow auto reconnect
}
}
-void CJabberProto::OnIqResultSession( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultSession(HXML iqNode, CJabberIqInfo* pInfo)
{
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
OnLoggedIn();
}
-void CJabberProto::GroupchatJoinByHContact( HANDLE hContact, bool autojoin )
+void CJabberProto::GroupchatJoinByHContact(HANDLE hContact, bool autojoin)
{
- TCHAR* roomjid = JGetStringT( hContact, "ChatRoomID" );
- if ( !roomjid ) return;
+ TCHAR* roomjid = JGetStringT(hContact, "ChatRoomID");
+ if ( !roomjid) return;
TCHAR* room = roomjid;
- TCHAR* server = _tcschr( roomjid, '@' );
- if ( !server ) {
- mir_free( roomjid );
+ TCHAR* server = _tcschr(roomjid, '@');
+ if ( !server) {
+ mir_free(roomjid);
return;
}
server[0] = 0; server++;
- TCHAR *nick = JGetStringT( hContact, "MyNick" );
- if ( !nick ) {
- nick = JabberNickFromJID( m_szJabberJID );
- if ( !nick ) {
- mir_free( roomjid );
+ TCHAR *nick = JGetStringT(hContact, "MyNick");
+ if ( !nick) {
+ nick = JabberNickFromJID(m_szJabberJID);
+ if ( !nick) {
+ mir_free(roomjid);
return;
}
}
- TCHAR *password = JGetStringCrypt( hContact, "LoginPassword" );
+ TCHAR *password = JGetStringCrypt(hContact, "LoginPassword");
- GroupchatJoinRoom( server, room, nick, password, autojoin );
+ GroupchatJoinRoom(server, room, nick, password, autojoin);
- mir_free( password );
- mir_free( nick );
- mir_free( roomjid );
+ mir_free(password);
+ mir_free(nick);
+ mir_free(roomjid);
}
/////////////////////////////////////////////////////////////////////////////////////////
// JabberIqResultGetRoster - populates LIST_ROSTER and creates contact for any new rosters
-void CJabberProto::OnIqResultGetRoster( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
{
- Log( "<iq/> iqIdGetRoster" );
+ Log("<iq/> iqIdGetRoster");
TCHAR *szGroupDelimeter = (TCHAR *)pInfo->GetUserData();
- if ( pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT ) {
- mir_free( szGroupDelimeter );
+ if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT) {
+ mir_free(szGroupDelimeter);
return;
}
- HXML queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode == NULL ) {
- mir_free( szGroupDelimeter );
+ HXML queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode == NULL) {
+ mir_free(szGroupDelimeter);
return;
}
- if ( lstrcmp( xmlGetAttrValue( queryNode, _T("xmlns")), _T(JABBER_FEAT_IQ_ROSTER))) {
- mir_free( szGroupDelimeter );
+ if (lstrcmp(xmlGetAttrValue(queryNode, _T("xmlns")), _T(JABBER_FEAT_IQ_ROSTER))) {
+ mir_free(szGroupDelimeter);
return;
}
- if ( !_tcscmp( szGroupDelimeter, _T("\\"))) {
- mir_free( szGroupDelimeter );
+ if ( !_tcscmp(szGroupDelimeter, _T("\\"))) {
+ mir_free(szGroupDelimeter);
szGroupDelimeter = NULL;
}
@@ -389,130 +389,130 @@ void CJabberProto::OnIqResultGetRoster( HXML iqNode, CJabberIqInfo* pInfo ) LIST<void> chatRooms(10);
OBJLIST<JABBER_HTTP_AVATARS> *httpavatars = new OBJLIST<JABBER_HTTP_AVATARS>(20, JABBER_HTTP_AVATARS::compare);
- for ( i=0; ; i++ ) {
+ for (i=0; ; i++) {
BOOL bIsTransport=FALSE;
- HXML itemNode = xmlGetChild( queryNode ,i);
- if ( !itemNode )
+ HXML itemNode = xmlGetChild(queryNode ,i);
+ if ( !itemNode)
break;
- if ( _tcscmp( xmlGetName( itemNode ), _T("item")))
+ if (_tcscmp(xmlGetName(itemNode), _T("item")))
continue;
- const TCHAR* str = xmlGetAttrValue( itemNode, _T("subscription")), *name;
+ const TCHAR *str = xmlGetAttrValue(itemNode, _T("subscription")), *name;
JABBER_SUBSCRIPTION sub;
- if ( str == NULL ) sub = SUB_NONE;
- else if ( !_tcscmp( str, _T("both"))) sub = SUB_BOTH;
- else if ( !_tcscmp( str, _T("to"))) sub = SUB_TO;
- else if ( !_tcscmp( str, _T("from"))) sub = SUB_FROM;
+ if (str == NULL) sub = SUB_NONE;
+ else if ( !_tcscmp(str, _T("both"))) sub = SUB_BOTH;
+ else if ( !_tcscmp(str, _T("to"))) sub = SUB_TO;
+ else if ( !_tcscmp(str, _T("from"))) sub = SUB_FROM;
else sub = SUB_NONE;
- const TCHAR* jid = xmlGetAttrValue( itemNode, _T("jid"));
- if ( jid == NULL )
+ const TCHAR *jid = xmlGetAttrValue(itemNode, _T("jid"));
+ if (jid == NULL)
continue;
- if ( _tcschr( jid, '@' ) == NULL )
+ if (_tcschr(jid, '@') == NULL)
bIsTransport = TRUE;
- if (( name = xmlGetAttrValue( itemNode, _T("name"))) != NULL )
- nick = mir_tstrdup( name );
+ if ((name = xmlGetAttrValue(itemNode, _T("name"))) != NULL)
+ nick = mir_tstrdup(name);
else
- nick = JabberNickFromJID( jid );
+ nick = JabberNickFromJID(jid);
- if ( nick == NULL )
+ if (nick == NULL)
continue;
- JABBER_LIST_ITEM* item = ListAdd( LIST_ROSTER, jid );
+ JABBER_LIST_ITEM* item = ListAdd(LIST_ROSTER, jid);
item->subscription = sub;
- mir_free( item->nick ); item->nick = nick;
+ mir_free(item->nick); item->nick = nick;
- HXML groupNode = xmlGetChild( itemNode , "group" );
- replaceStrT( item->group, ( groupNode ) ? xmlGetText( groupNode ) : NULL );
+ HXML groupNode = xmlGetChild(itemNode , "group");
+ replaceStrT(item->group, (groupNode) ? xmlGetText(groupNode) : NULL);
// check group delimiters:
- if ( item->group && szGroupDelimeter ) {
+ if (item->group && szGroupDelimeter) {
TCHAR *szPos = NULL;
- while ( szPos = _tcsstr( item->group, szGroupDelimeter )) {
+ while (szPos = _tcsstr(item->group, szGroupDelimeter)) {
*szPos = 0;
- szPos += _tcslen( szGroupDelimeter );
- TCHAR *szNewGroup = (TCHAR *)mir_alloc( sizeof(TCHAR) * ( _tcslen( item->group ) + _tcslen( szPos ) + 2));
- _tcscpy( szNewGroup, item->group );
- _tcscat( szNewGroup, _T("\\"));
- _tcscat( szNewGroup, szPos );
- mir_free( item->group );
+ szPos += _tcslen(szGroupDelimeter);
+ TCHAR *szNewGroup = (TCHAR *)mir_alloc(sizeof(TCHAR) * (_tcslen(item->group) + _tcslen(szPos) + 2));
+ _tcscpy(szNewGroup, item->group);
+ _tcscat(szNewGroup, _T("\\"));
+ _tcscat(szNewGroup, szPos);
+ mir_free(item->group);
item->group = szNewGroup;
}
}
- HANDLE hContact = HContactFromJID( jid );
- if ( hContact == NULL ) {
+ HANDLE hContact = HContactFromJID(jid);
+ if (hContact == NULL) {
// Received roster has a new JID.
- // Add the jid ( with empty resource ) to Miranda contact list.
- hContact = DBCreateContact( jid, nick, FALSE, FALSE );
+ // Add the jid (with empty resource) to Miranda contact list.
+ hContact = DBCreateContact(jid, nick, FALSE, FALSE);
}
- if ( name != NULL ) {
+ if (name != NULL) {
DBVARIANT dbNick;
- if ( !JGetStringT( hContact, "Nick", &dbNick )) {
- if ( lstrcmp( nick, dbNick.ptszVal ) != 0 )
- DBWriteContactSettingTString( hContact, "CList", "MyHandle", nick );
+ if ( !JGetStringT(hContact, "Nick", &dbNick)) {
+ if (lstrcmp(nick, dbNick.ptszVal) != 0)
+ db_set_ts(hContact, "CList", "MyHandle", nick);
else
- DBDeleteContactSetting( hContact, "CList", "MyHandle" );
+ DBDeleteContactSetting(hContact, "CList", "MyHandle");
- JFreeVariant( &dbNick );
+ db_free(&dbNick);
}
- else DBWriteContactSettingTString( hContact, "CList", "MyHandle", nick );
+ else db_set_ts(hContact, "CList", "MyHandle", nick);
}
- else DBDeleteContactSetting( hContact, "CList", "MyHandle" );
+ else DBDeleteContactSetting(hContact, "CList", "MyHandle");
- if ( JGetByte( hContact, "ChatRoom", 0 )) {
+ if (JGetByte(hContact, "ChatRoom", 0)) {
GCSESSION gcw = {0};
gcw.cbSize = sizeof(GCSESSION);
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
gcw.dwFlags = GC_TCHAR;
gcw.ptszID = jid;
- gcw.ptszName = NEWTSTR_ALLOCA( jid );
+ gcw.ptszName = NEWTSTR_ALLOCA(jid);
- TCHAR* p = (TCHAR*)_tcschr( gcw.ptszName, '@' );
- if ( p )
+ TCHAR* p = (TCHAR*)_tcschr(gcw.ptszName, '@');
+ if (p)
*p = 0;
- CallServiceSync( MS_GC_NEWSESSION, 0, ( LPARAM )&gcw );
+ CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
- DBDeleteContactSetting( hContact, "CList", "Hidden" );
- chatRooms.insert( hContact );
+ DBDeleteContactSetting(hContact, "CList", "Hidden");
+ chatRooms.insert(hContact);
} else
{
UpdateSubscriptionInfo(hContact, item);
}
- if (!m_options.IgnoreRosterGroups) {
- if ( item->group != NULL ) {
- JabberContactListCreateGroup( item->group );
+ if ( !m_options.IgnoreRosterGroups) {
+ if (item->group != NULL) {
+ JabberContactListCreateGroup(item->group);
// Don't set group again if already correct, or Miranda may show wrong group count in some case
DBVARIANT dbv;
- if ( !DBGetContactSettingTString( hContact, "CList", "Group", &dbv )) {
- if ( lstrcmp( dbv.ptszVal, item->group ))
- DBWriteContactSettingTString( hContact, "CList", "Group", item->group );
- JFreeVariant( &dbv );
+ if ( !DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) {
+ if (lstrcmp(dbv.ptszVal, item->group))
+ db_set_ts(hContact, "CList", "Group", item->group);
+ db_free(&dbv);
}
- else DBWriteContactSettingTString( hContact, "CList", "Group", item->group );
+ else db_set_ts(hContact, "CList", "Group", item->group);
}
else
- DBDeleteContactSetting( hContact, "CList", "Group" );
+ DBDeleteContactSetting(hContact, "CList", "Group");
}
- if ( hContact != NULL ) {
- if ( bIsTransport)
- JSetByte( hContact, "IsTransport", TRUE );
+ if (hContact != NULL) {
+ if (bIsTransport)
+ JSetByte(hContact, "IsTransport", TRUE);
else
- JSetByte( hContact, "IsTransport", FALSE );
+ JSetByte(hContact, "IsTransport", FALSE);
}
- const TCHAR* imagepath = xmlGetAttrValue(itemNode, _T("vz:img"));
+ const TCHAR *imagepath = xmlGetAttrValue(itemNode, _T("vz:img"));
if (imagepath)
httpavatars->insert(new JABBER_HTTP_AVATARS(imagepath, hContact));
}
@@ -522,50 +522,50 @@ void CJabberProto::OnIqResultGetRoster( HXML iqNode, CJabberIqInfo* pInfo ) else
delete httpavatars;
- // Delete orphaned contacts ( if roster sync is enabled )
- if ( m_options.RosterSync == TRUE ) {
+ // Delete orphaned contacts (if roster sync is enabled)
+ if (m_options.RosterSync == TRUE) {
int listSize = 0, listAllocSize = 0;
HANDLE* list = NULL;
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* str = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( str != NULL && !strcmp( str, m_szModuleName )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char* str = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (str != NULL && !strcmp(str, m_szModuleName)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- if ( !ListExist( LIST_ROSTER, dbv.ptszVal )) {
- Log( "Syncing roster: preparing to delete " TCHAR_STR_PARAM " ( hContact=0x%x )", dbv.ptszVal, hContact );
- if ( listSize >= listAllocSize ) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ if ( !ListExist(LIST_ROSTER, dbv.ptszVal)) {
+ Log("Syncing roster: preparing to delete " TCHAR_STR_PARAM " (hContact=0x%x)", dbv.ptszVal, hContact);
+ if (listSize >= listAllocSize) {
listAllocSize = listSize + 100;
- if (( list=( HANDLE * ) mir_realloc( list, listAllocSize * sizeof( HANDLE ))) == NULL ) {
+ if ((list=(HANDLE *) mir_realloc(list, listAllocSize * sizeof(HANDLE))) == NULL) {
listSize = 0;
break;
} }
list[listSize++] = hContact;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
} }
hContact = db_find_next(hContact);
}
- for ( i=0; i < listSize; i++ ) {
- Log( "Syncing roster: deleting 0x%x", list[i] );
- CallService( MS_DB_CONTACT_DELETE, ( WPARAM ) list[i], 0 );
+ for (i=0; i < listSize; i++) {
+ Log("Syncing roster: deleting 0x%x", list[i]);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)list[i], 0);
}
- if ( list != NULL )
- mir_free( list );
+ if (list != NULL)
+ mir_free(list);
}
- EnableMenuItems( TRUE );
+ EnableMenuItems(TRUE);
- Log( "Status changed via THREADSTART" );
+ Log("Status changed via THREADSTART");
m_bModeMsgStatusChangePending = FALSE;
- SetServerStatus( m_iDesiredStatus );
+ SetServerStatus(m_iDesiredStatus);
- if ( m_options.AutoJoinConferences ) {
- for ( i=0; i < chatRooms.getCount(); i++ )
- GroupchatJoinByHContact(( HANDLE )chatRooms[i], true);
+ if (m_options.AutoJoinConferences) {
+ for (i=0; i < chatRooms.getCount(); i++)
+ GroupchatJoinByHContact((HANDLE)chatRooms[i], true);
}
chatRooms.destroy();
@@ -576,216 +576,216 @@ void CJabberProto::OnIqResultGetRoster( HXML iqNode, CJabberIqInfo* pInfo ) UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
- if ( szGroupDelimeter )
- mir_free( szGroupDelimeter );
+ if (szGroupDelimeter)
+ mir_free(szGroupDelimeter);
OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_ROSTER);
RebuildInfoFrame();
}
-void CJabberProto::OnIqResultGetRegister( HXML iqNode )
+void CJabberProto::OnIqResultGetRegister(HXML iqNode)
{
- // RECVED: result of the request for ( agent ) registration mechanism
- // ACTION: activate ( agent ) registration input dialog
- Log( "<iq/> iqIdGetRegister" );
+ // RECVED: result of the request for (agent) registration mechanism
+ // ACTION: activate (agent) registration input dialog
+ Log("<iq/> iqIdGetRegister");
HXML queryNode;
const TCHAR *type;
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( queryNode = xmlGetChild( iqNode , "query" )) == NULL ) return;
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((queryNode = xmlGetChild(iqNode , "query")) == NULL) return;
- if ( !lstrcmp( type, _T("result"))) {
- if ( m_hwndAgentRegInput )
- SendMessage( m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 1 /*success*/, ( LPARAM )xi.copyNode( iqNode ));
+ if ( !lstrcmp(type, _T("result"))) {
+ if (m_hwndAgentRegInput)
+ SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 1 /*success*/, (LPARAM)xi.copyNode(iqNode));
}
- else if ( !lstrcmp( type, _T("error"))) {
- if ( m_hwndAgentRegInput ) {
- HXML errorNode = xmlGetChild( iqNode , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
- SendMessage( m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 0 /*error*/, ( LPARAM )str );
- mir_free( str );
+ else if ( !lstrcmp(type, _T("error"))) {
+ if (m_hwndAgentRegInput) {
+ HXML errorNode = xmlGetChild(iqNode , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
+ SendMessage(m_hwndAgentRegInput, WM_JABBER_REGINPUT_ACTIVATE, 0 /*error*/, (LPARAM)str);
+ mir_free(str);
} } }
-void CJabberProto::OnIqResultSetRegister( HXML iqNode )
+void CJabberProto::OnIqResultSetRegister(HXML iqNode)
{
// RECVED: result of registration process
// ACTION: notify of successful agent registration
- Log( "<iq/> iqIdSetRegister" );
+ Log("<iq/> iqIdSetRegister");
const TCHAR *type, *from;
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( from = xmlGetAttrValue( iqNode, _T("from"))) == NULL ) return;
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((from = xmlGetAttrValue(iqNode, _T("from"))) == NULL) return;
- if ( !lstrcmp( type, _T("result"))) {
- HANDLE hContact = HContactFromJID( from );
- if ( hContact != NULL )
- JSetByte( hContact, "IsTransport", TRUE );
+ if ( !lstrcmp(type, _T("result"))) {
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact != NULL)
+ JSetByte(hContact, "IsTransport", TRUE);
- if ( m_hwndRegProgress )
- SendMessage( m_hwndRegProgress, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )TranslateT( "Registration successful" ));
+ if (m_hwndRegProgress)
+ SendMessage(m_hwndRegProgress, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Registration successful"));
}
- else if ( !lstrcmp( type, _T("error"))) {
- if ( m_hwndRegProgress ) {
- HXML errorNode = xmlGetChild( iqNode , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
- SendMessage( m_hwndRegProgress, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )str );
- mir_free( str );
+ else if ( !lstrcmp(type, _T("error"))) {
+ if (m_hwndRegProgress) {
+ HXML errorNode = xmlGetChild(iqNode , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
+ SendMessage(m_hwndRegProgress, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)str);
+ mir_free(str);
} } }
/////////////////////////////////////////////////////////////////////////////////////////
// JabberIqResultGetVcard - processes the server-side v-card
-void CJabberProto::OnIqResultGetVcardPhoto( const TCHAR* jid, HXML n, HANDLE hContact, BOOL& hasPhoto )
+void CJabberProto::OnIqResultGetVcardPhoto(const TCHAR *jid, HXML n, HANDLE hContact, BOOL& hasPhoto)
{
- Log( "JabberIqResultGetVcardPhoto: %d", hasPhoto );
- if ( hasPhoto )
+ Log("JabberIqResultGetVcardPhoto: %d", hasPhoto);
+ if (hasPhoto)
return;
- HXML o = xmlGetChild( n , "BINVAL" );
- if ( o == NULL || xmlGetText( o ) == NULL )
+ HXML o = xmlGetChild(n , "BINVAL");
+ if (o == NULL || xmlGetText(o) == NULL)
return;
int bufferLen;
- char* buffer = JabberBase64DecodeT( xmlGetText( o ), &bufferLen );
- if ( buffer == NULL )
+ char* buffer = JabberBase64DecodeT(xmlGetText(o), &bufferLen);
+ if (buffer == NULL)
return;
- const TCHAR* szPicType;
- HXML m = xmlGetChild( n , "TYPE" );
- if ( m == NULL || xmlGetText( m ) == NULL ) {
+ const TCHAR *szPicType;
+ HXML m = xmlGetChild(n , "TYPE");
+ if (m == NULL || xmlGetText(m) == NULL) {
LBL_NoTypeSpecified:
- switch( JabberGetPictureType( buffer )) {
+ switch(JabberGetPictureType(buffer)) {
case PA_FORMAT_GIF: szPicType = _T("image/gif"); break;
case PA_FORMAT_BMP: szPicType = _T("image/bmp"); break;
case PA_FORMAT_PNG: szPicType = _T("image/png"); break;
case PA_FORMAT_JPEG: szPicType = _T("image/jpeg"); break;
default:
LBL_Ret:
- mir_free( buffer );
+ mir_free(buffer);
return;
}
}
else {
- const TCHAR* tszType = xmlGetText( m );
- if ( !_tcscmp( tszType, _T("image/jpeg")) ||
- !_tcscmp( tszType, _T("image/png")) ||
- !_tcscmp( tszType, _T("image/gif")) ||
- !_tcscmp( tszType, _T("image/bmp")))
+ const TCHAR *tszType = xmlGetText(m);
+ if ( !_tcscmp(tszType, _T("image/jpeg")) ||
+ !_tcscmp(tszType, _T("image/png")) ||
+ !_tcscmp(tszType, _T("image/gif")) ||
+ !_tcscmp(tszType, _T("image/bmp")))
szPicType = tszType;
else
goto LBL_NoTypeSpecified;
}
TCHAR szAvatarFileName[MAX_PATH];
- GetAvatarFileName( hContact, szAvatarFileName, SIZEOF( szAvatarFileName ));
+ GetAvatarFileName(hContact, szAvatarFileName, SIZEOF(szAvatarFileName));
- Log( "Picture file name set to " TCHAR_STR_PARAM, szAvatarFileName );
- HANDLE hFile = CreateFile( szAvatarFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
- if ( hFile == INVALID_HANDLE_VALUE )
+ Log("Picture file name set to " TCHAR_STR_PARAM, szAvatarFileName);
+ HANDLE hFile = CreateFile(szAvatarFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
goto LBL_Ret;
- Log( "Writing %d bytes", bufferLen );
+ Log("Writing %d bytes", bufferLen);
DWORD nWritten;
- if ( !WriteFile( hFile, buffer, bufferLen, &nWritten, NULL ))
+ if ( !WriteFile(hFile, buffer, bufferLen, &nWritten, NULL))
goto LBL_Ret;
- CloseHandle( hFile );
+ CloseHandle(hFile);
- Log( "%d bytes written", nWritten );
- if ( hContact == NULL ) {
+ Log("%d bytes written", nWritten);
+ if (hContact == NULL) {
hasPhoto = TRUE;
- CallService( MS_AV_SETMYAVATART, ( WPARAM )m_szModuleName, ( LPARAM )szAvatarFileName );
+ CallService(MS_AV_SETMYAVATART, (WPARAM)m_szModuleName, (LPARAM)szAvatarFileName);
- Log( "My picture saved to " TCHAR_STR_PARAM, szAvatarFileName );
+ Log("My picture saved to " TCHAR_STR_PARAM, szAvatarFileName);
}
else {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_ROSTER, jid );
- if ( item == NULL ) {
- item = ListAdd( LIST_VCARD_TEMP, jid ); // adding to the temp list to store information about photo
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
+ if (item == NULL) {
+ item = ListAdd(LIST_VCARD_TEMP, jid); // adding to the temp list to store information about photo
item->bUseResource = TRUE;
}
- if ( item != NULL ) {
+ if (item != NULL) {
hasPhoto = TRUE;
- if ( item->photoFileName )
- DeleteFile( item->photoFileName );
- replaceStrT( item->photoFileName, szAvatarFileName );
- Log( "Contact's picture saved to " TCHAR_STR_PARAM, szAvatarFileName );
+ if (item->photoFileName)
+ DeleteFile(item->photoFileName);
+ replaceStrT(item->photoFileName, szAvatarFileName);
+ Log("Contact's picture saved to " TCHAR_STR_PARAM, szAvatarFileName);
- if (JGetWord( hContact, "Status", ID_STATUS_OFFLINE ) == ID_STATUS_OFFLINE) {
+ if (JGetWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) {
char szHashValue[ MAX_PATH ];
- if ( JGetStaticString( "AvatarHash", hContact, szHashValue, sizeof( szHashValue )))
- OnIqResultGotAvatar( hContact, o, xmlGetText( m ));
+ if (JGetStaticString("AvatarHash", hContact, szHashValue, sizeof(szHashValue)))
+ OnIqResultGotAvatar(hContact, o, xmlGetText(m));
} }
- JFreeVariant( &dbv );
+ db_free(&dbv);
} }
- if ( !hasPhoto )
- DeleteFile( szAvatarFileName );
+ if ( !hasPhoto)
+ DeleteFile(szAvatarFileName);
goto LBL_Ret;
}
-static TCHAR* sttGetText( HXML node, char* tag )
+static TCHAR* sttGetText(HXML node, char* tag)
{
- HXML n = xmlGetChild( node , tag );
- if ( n == NULL )
+ HXML n = xmlGetChild(node , tag);
+ if (n == NULL)
return NULL;
- return ( TCHAR* )xmlGetText( n );
+ return (TCHAR*)xmlGetText(n);
}
-void CJabberProto::OnIqResultGetVcard( HXML iqNode )
+void CJabberProto::OnIqResultGetVcard(HXML iqNode)
{
HXML vCardNode, m, n, o;
- const TCHAR* type, *jid;
+ const TCHAR *type, *jid;
HANDLE hContact;
TCHAR text[128];
DBVARIANT dbv;
- Log( "<iq/> iqIdGetVcard" );
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( jid = xmlGetAttrValue( iqNode, _T("from"))) == NULL ) return;
- int id = JabberGetPacketID( iqNode );
+ Log("<iq/> iqIdGetVcard");
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((jid = xmlGetAttrValue(iqNode, _T("from"))) == NULL) return;
+ int id = JabberGetPacketID(iqNode);
- if ( id == m_nJabberSearchID ) {
+ if (id == m_nJabberSearchID) {
m_nJabberSearchID = -1;
- if (( vCardNode = xmlGetChild( iqNode , "vCard" )) != NULL ) {
- if ( !lstrcmp( type, _T("result"))) {
+ if ((vCardNode = xmlGetChild(iqNode , "vCard")) != NULL) {
+ if ( !lstrcmp(type, _T("result"))) {
JABBER_SEARCH_RESULT jsr = { 0 };
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
- jsr.hdr.nick = sttGetText( vCardNode, "NICKNAME" );
- jsr.hdr.firstName = sttGetText( vCardNode, "FN" );
+ jsr.hdr.nick = sttGetText(vCardNode, "NICKNAME");
+ jsr.hdr.firstName = sttGetText(vCardNode, "FN");
jsr.hdr.lastName = _T("");
- jsr.hdr.email = sttGetText( vCardNode, "EMAIL" );
- _tcsncpy( jsr.jid, jid, SIZEOF( jsr.jid ));
- jsr.jid[ SIZEOF( jsr.jid )-1 ] = '\0';
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, ( HANDLE )id, ( LPARAM )&jsr );
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE )id, 0 );
+ jsr.hdr.email = sttGetText(vCardNode, "EMAIL");
+ _tcsncpy(jsr.jid, jid, SIZEOF(jsr.jid));
+ jsr.jid[ SIZEOF(jsr.jid)-1 ] = '\0';
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else if ( !lstrcmp( type, _T("error")))
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE )id, 0 );
+ else if ( !lstrcmp(type, _T("error")))
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE )id, 0 );
+ else JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
return;
}
- size_t len = _tcslen( m_szJabberJID );
- if ( !_tcsnicmp( jid, m_szJabberJID, len ) && ( jid[len]=='/' || jid[len]=='\0' )) {
+ size_t len = _tcslen(m_szJabberJID);
+ if ( !_tcsnicmp(jid, m_szJabberJID, len) && (jid[len]=='/' || jid[len]=='\0')) {
hContact = NULL;
- Log( "Vcard for myself" );
+ Log("Vcard for myself");
}
else {
- if (( hContact = HContactFromJID( jid )) == NULL )
+ if ((hContact = HContactFromJID(jid)) == NULL)
return;
- Log( "Other user's vcard" );
+ Log("Other user's vcard");
}
- if ( !lstrcmp( type, _T("result"))) {
+ if ( !lstrcmp(type, _T("result"))) {
BOOL hasFn, hasNick, hasGiven, hasFamily, hasMiddle, hasBday, hasGender;
BOOL hasPhone, hasFax, hasCell, hasUrl;
BOOL hasHome, hasHomeStreet, hasHomeStreet2, hasHomeLocality, hasHomeRegion, hasHomePcode, hasHomeCtry;
@@ -802,76 +802,76 @@ void CJabberProto::OnIqResultGetVcard( HXML iqNode ) hasDesc = hasPhoto = FALSE;
nEmail = nPhone = 0;
- if (( vCardNode = xmlGetChild( iqNode , "vCard" )) != NULL ) {
- for ( int i=0; ; i++ ) {
- n = xmlGetChild( vCardNode ,i);
- if ( !n )
+ if ((vCardNode = xmlGetChild(iqNode , "vCard")) != NULL) {
+ for (int i=0; ; i++) {
+ n = xmlGetChild(vCardNode ,i);
+ if ( !n)
break;
- if ( xmlGetName( n ) == NULL ) continue;
- if ( !_tcscmp( xmlGetName( n ), _T("FN"))) {
- if ( xmlGetText( n ) != NULL ) {
+ if (xmlGetName(n) == NULL) continue;
+ if ( !_tcscmp(xmlGetName(n), _T("FN"))) {
+ if (xmlGetText(n) != NULL) {
hasFn = TRUE;
- JSetStringT( hContact, "FullName", xmlGetText( n ));
+ JSetStringT(hContact, "FullName", xmlGetText(n));
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("NICKNAME"))) {
- if ( xmlGetText( n ) != NULL ) {
+ else if ( !lstrcmp(xmlGetName(n), _T("NICKNAME"))) {
+ if (xmlGetText(n) != NULL) {
hasNick = TRUE;
- JSetStringT( hContact, "Nick", xmlGetText( n ));
+ JSetStringT(hContact, "Nick", xmlGetText(n));
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("N"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("N"))) {
// First/Last name
- if ( !hasGiven && !hasFamily && !hasMiddle ) {
- if (( m=xmlGetChild( n , "GIVEN" )) != NULL && xmlGetText( m )!=NULL ) {
+ if ( !hasGiven && !hasFamily && !hasMiddle) {
+ if ((m=xmlGetChild(n , "GIVEN")) != NULL && xmlGetText(m)!=NULL) {
hasGiven = TRUE;
- JSetStringT( hContact, "FirstName", xmlGetText( m ));
+ JSetStringT(hContact, "FirstName", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "FAMILY" )) != NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "FAMILY")) != NULL && xmlGetText(m)!=NULL) {
hasFamily = TRUE;
- JSetStringT( hContact, "LastName", xmlGetText( m ));
+ JSetStringT(hContact, "LastName", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "MIDDLE" )) != NULL && xmlGetText( m ) != NULL ) {
+ if ((m=xmlGetChild(n , "MIDDLE")) != NULL && xmlGetText(m) != NULL) {
hasMiddle = TRUE;
- JSetStringT( hContact, "MiddleName", xmlGetText( m ));
+ JSetStringT(hContact, "MiddleName", xmlGetText(m));
} }
}
- else if ( !lstrcmp( xmlGetName( n ), _T("EMAIL"))) {
- // E-mail address( es )
- if (( m=xmlGetChild( n , "USERID" )) == NULL ) // Some bad client put e-mail directly in <EMAIL/> instead of <USERID/>
+ else if ( !lstrcmp(xmlGetName(n), _T("EMAIL"))) {
+ // E-mail address(es)
+ if ((m=xmlGetChild(n , "USERID")) == NULL) // Some bad client put e-mail directly in <EMAIL/> instead of <USERID/>
m = n;
- if ( xmlGetText( m ) != NULL ) {
+ if (xmlGetText(m) != NULL) {
char text[100];
- if ( hContact != NULL ) {
- if ( nEmail == 0 )
- strcpy( text, "e-mail" );
+ if (hContact != NULL) {
+ if (nEmail == 0)
+ strcpy(text, "e-mail");
else
- sprintf( text, "e-mail%d", nEmail-1 );
+ sprintf(text, "e-mail%d", nEmail-1);
}
- else sprintf( text, "e-mail%d", nEmail );
- JSetStringT( hContact, text, xmlGetText( m ));
+ else sprintf(text, "e-mail%d", nEmail);
+ JSetStringT(hContact, text, xmlGetText(m));
- if ( hContact == NULL ) {
- sprintf( text, "e-mailFlag%d", nEmail );
+ if (hContact == NULL) {
+ sprintf(text, "e-mailFlag%d", nEmail);
int nFlag = 0;
- if ( xmlGetChild( n , "HOME" ) != NULL ) nFlag |= JABBER_VCEMAIL_HOME;
- if ( xmlGetChild( n , "WORK" ) != NULL ) nFlag |= JABBER_VCEMAIL_WORK;
- if ( xmlGetChild( n , "INTERNET" ) != NULL ) nFlag |= JABBER_VCEMAIL_INTERNET;
- if ( xmlGetChild( n , "X400" ) != NULL ) nFlag |= JABBER_VCEMAIL_X400;
- JSetWord( NULL, text, nFlag );
+ if (xmlGetChild(n , "HOME") != NULL) nFlag |= JABBER_VCEMAIL_HOME;
+ if (xmlGetChild(n , "WORK") != NULL) nFlag |= JABBER_VCEMAIL_WORK;
+ if (xmlGetChild(n , "INTERNET") != NULL) nFlag |= JABBER_VCEMAIL_INTERNET;
+ if (xmlGetChild(n , "X400") != NULL) nFlag |= JABBER_VCEMAIL_X400;
+ JSetWord(NULL, text, nFlag);
}
nEmail++;
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("BDAY"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("BDAY"))) {
// Birthday
- if ( !hasBday && xmlGetText( n )!=NULL ) {
- if ( hContact != NULL ) {
- if ( _stscanf( xmlGetText( n ), _T("%d-%d-%d"), &nYear, &nMonth, &nDay ) == 3 ) {
+ if ( !hasBday && xmlGetText(n)!=NULL) {
+ if (hContact != NULL) {
+ if (_stscanf(xmlGetText(n), _T("%d-%d-%d"), &nYear, &nMonth, &nDay) == 3) {
hasBday = TRUE;
- JSetWord( hContact, "BirthYear", ( WORD )nYear );
- JSetByte( hContact, "BirthMonth", ( BYTE ) nMonth );
- JSetByte( hContact, "BirthDay", ( BYTE ) nDay );
+ JSetWord(hContact, "BirthYear", (WORD)nYear);
+ JSetByte(hContact, "BirthMonth", (BYTE) nMonth);
+ JSetByte(hContact, "BirthDay", (BYTE) nDay);
SYSTEMTIME sToday = {0};
GetLocalTime(&sToday);
@@ -879,650 +879,650 @@ void CJabberProto::OnIqResultGetVcard( HXML iqNode ) if (sToday.wMonth < nMonth || (sToday.wMonth == nMonth && sToday.wDay < nDay))
nAge--;
if (nAge)
- JSetWord( hContact, "Age", ( WORD )nAge );
+ JSetWord(hContact, "Age", (WORD)nAge);
}
}
else {
hasBday = TRUE;
- JSetStringT( NULL, "BirthDate", xmlGetText( n ));
+ JSetStringT(NULL, "BirthDate", xmlGetText(n));
} }
}
- else if ( !lstrcmp( xmlGetName( n ), _T("GENDER"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("GENDER"))) {
// Gender
- if ( !hasGender && xmlGetText( n )!=NULL ) {
- if ( hContact != NULL ) {
- if ( xmlGetText( n )[0] && strchr( "mMfF", xmlGetText( n )[0] )!=NULL ) {
+ if ( !hasGender && xmlGetText(n)!=NULL) {
+ if (hContact != NULL) {
+ if (xmlGetText(n)[0] && strchr("mMfF", xmlGetText(n)[0])!=NULL) {
hasGender = TRUE;
- JSetByte( hContact, "Gender", ( BYTE ) toupper( xmlGetText( n )[0] ));
+ JSetByte(hContact, "Gender", (BYTE) toupper(xmlGetText(n)[0]));
}
}
else {
hasGender = TRUE;
- JSetStringT( NULL, "GenderString", xmlGetText( n ));
+ JSetStringT(NULL, "GenderString", xmlGetText(n));
} }
}
- else if ( !lstrcmp( xmlGetName( n ), _T("ADR"))) {
- if ( !hasHome && xmlGetChild( n , "HOME" )!=NULL ) {
+ else if ( !lstrcmp(xmlGetName(n), _T("ADR"))) {
+ if ( !hasHome && xmlGetChild(n , "HOME")!=NULL) {
// Home address
hasHome = TRUE;
- if (( m=xmlGetChild( n , "STREET" )) != NULL && xmlGetText( m ) != NULL ) {
+ if ((m=xmlGetChild(n , "STREET")) != NULL && xmlGetText(m) != NULL) {
hasHomeStreet = TRUE;
- if ( hContact != NULL ) {
- if (( o=xmlGetChild( n , "EXTADR" )) != NULL && xmlGetText( o ) != NULL )
- mir_sntprintf( text, SIZEOF( text ), _T("%s\r\n%s"), xmlGetText( m ), xmlGetText( o ));
- else if (( o=xmlGetChild( n , "EXTADD" ))!=NULL && xmlGetText( o )!=NULL )
- mir_sntprintf( text, SIZEOF( text ), _T("%s\r\n%s"), xmlGetText( m ), xmlGetText( o ));
+ if (hContact != NULL) {
+ if ((o=xmlGetChild(n , "EXTADR")) != NULL && xmlGetText(o) != NULL)
+ mir_sntprintf(text, SIZEOF(text), _T("%s\r\n%s"), xmlGetText(m), xmlGetText(o));
+ else if ((o=xmlGetChild(n , "EXTADD"))!=NULL && xmlGetText(o)!=NULL)
+ mir_sntprintf(text, SIZEOF(text), _T("%s\r\n%s"), xmlGetText(m), xmlGetText(o));
else
- _tcsncpy( text, xmlGetText( m ), SIZEOF( text ));
+ _tcsncpy(text, xmlGetText(m), SIZEOF(text));
text[SIZEOF(text)-1] = '\0';
- JSetStringT( hContact, "Street", text );
+ JSetStringT(hContact, "Street", text);
}
else {
- JSetStringT( hContact, "Street", xmlGetText( m ));
- if (( m=xmlGetChild( n , "EXTADR" )) == NULL )
- m = xmlGetChild( n , "EXTADD" );
- if ( m!=NULL && xmlGetText( m )!=NULL ) {
+ JSetStringT(hContact, "Street", xmlGetText(m));
+ if ((m=xmlGetChild(n , "EXTADR")) == NULL)
+ m = xmlGetChild(n , "EXTADD");
+ if (m!=NULL && xmlGetText(m)!=NULL) {
hasHomeStreet2 = TRUE;
- JSetStringT( hContact, "Street2", xmlGetText( m ));
+ JSetStringT(hContact, "Street2", xmlGetText(m));
} } }
- if (( m=xmlGetChild( n , "LOCALITY" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "LOCALITY"))!=NULL && xmlGetText(m)!=NULL) {
hasHomeLocality = TRUE;
- JSetStringT( hContact, "City", xmlGetText( m ));
+ JSetStringT(hContact, "City", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "REGION" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "REGION"))!=NULL && xmlGetText(m)!=NULL) {
hasHomeRegion = TRUE;
- JSetStringT( hContact, "State", xmlGetText( m ));
+ JSetStringT(hContact, "State", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "PCODE" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "PCODE"))!=NULL && xmlGetText(m)!=NULL) {
hasHomePcode = TRUE;
- JSetStringT( hContact, "ZIP", xmlGetText( m ));
+ JSetStringT(hContact, "ZIP", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "CTRY" ))==NULL || xmlGetText( m )==NULL ) // Some bad client use <COUNTRY/> instead of <CTRY/>
- m = xmlGetChild( n , "COUNTRY" );
- if ( m!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "CTRY"))==NULL || xmlGetText(m)==NULL) // Some bad client use <COUNTRY/> instead of <CTRY/>
+ m = xmlGetChild(n , "COUNTRY");
+ if (m!=NULL && xmlGetText(m)!=NULL) {
hasHomeCtry = TRUE;
- JSetStringT( hContact, "Country", xmlGetText( m ));
+ JSetStringT(hContact, "Country", xmlGetText(m));
} }
- if ( !hasWork && xmlGetChild( n , "WORK" )!=NULL ) {
+ if ( !hasWork && xmlGetChild(n , "WORK")!=NULL) {
// Work address
hasWork = TRUE;
- if (( m=xmlGetChild( n , "STREET" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "STREET"))!=NULL && xmlGetText(m)!=NULL) {
hasWorkStreet = TRUE;
- if ( hContact != NULL ) {
- if (( o=xmlGetChild( n , "EXTADR" ))!=NULL && xmlGetText( o )!=NULL )
- mir_sntprintf( text, SIZEOF( text ), _T("%s\r\n%s"), xmlGetText( m ), xmlGetText( o ));
- else if (( o=xmlGetChild( n , "EXTADD" ))!=NULL && xmlGetText( o )!=NULL )
- mir_sntprintf( text, SIZEOF( text ), _T("%s\r\n%s"), xmlGetText( m ), xmlGetText( o ));
+ if (hContact != NULL) {
+ if ((o=xmlGetChild(n , "EXTADR"))!=NULL && xmlGetText(o)!=NULL)
+ mir_sntprintf(text, SIZEOF(text), _T("%s\r\n%s"), xmlGetText(m), xmlGetText(o));
+ else if ((o=xmlGetChild(n , "EXTADD"))!=NULL && xmlGetText(o)!=NULL)
+ mir_sntprintf(text, SIZEOF(text), _T("%s\r\n%s"), xmlGetText(m), xmlGetText(o));
else
- _tcsncpy( text, xmlGetText( m ), SIZEOF( text ));
- text[SIZEOF( text )-1] = '\0';
- JSetStringT( hContact, "CompanyStreet", text );
+ _tcsncpy(text, xmlGetText(m), SIZEOF(text));
+ text[SIZEOF(text)-1] = '\0';
+ JSetStringT(hContact, "CompanyStreet", text);
}
else {
- JSetStringT( hContact, "CompanyStreet", xmlGetText( m ));
- if (( m=xmlGetChild( n , "EXTADR" )) == NULL )
- m = xmlGetChild( n , "EXTADD" );
- if ( m!=NULL && xmlGetText( m )!=NULL ) {
+ JSetStringT(hContact, "CompanyStreet", xmlGetText(m));
+ if ((m=xmlGetChild(n , "EXTADR")) == NULL)
+ m = xmlGetChild(n , "EXTADD");
+ if (m!=NULL && xmlGetText(m)!=NULL) {
hasWorkStreet2 = TRUE;
- JSetStringT( hContact, "CompanyStreet2", xmlGetText( m ));
+ JSetStringT(hContact, "CompanyStreet2", xmlGetText(m));
} } }
- if (( m=xmlGetChild( n , "LOCALITY" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "LOCALITY"))!=NULL && xmlGetText(m)!=NULL) {
hasWorkLocality = TRUE;
- JSetStringT( hContact, "CompanyCity", xmlGetText( m ));
+ JSetStringT(hContact, "CompanyCity", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "REGION" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "REGION"))!=NULL && xmlGetText(m)!=NULL) {
hasWorkRegion = TRUE;
- JSetStringT( hContact, "CompanyState", xmlGetText( m ));
+ JSetStringT(hContact, "CompanyState", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "PCODE" ))!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "PCODE"))!=NULL && xmlGetText(m)!=NULL) {
hasWorkPcode = TRUE;
- JSetStringT( hContact, "CompanyZIP", xmlGetText( m ));
+ JSetStringT(hContact, "CompanyZIP", xmlGetText(m));
}
- if (( m=xmlGetChild( n , "CTRY" ))==NULL || xmlGetText( m )==NULL ) // Some bad client use <COUNTRY/> instead of <CTRY/>
- m = xmlGetChild( n , "COUNTRY" );
- if ( m!=NULL && xmlGetText( m )!=NULL ) {
+ if ((m=xmlGetChild(n , "CTRY"))==NULL || xmlGetText(m)==NULL) // Some bad client use <COUNTRY/> instead of <CTRY/>
+ m = xmlGetChild(n , "COUNTRY");
+ if (m!=NULL && xmlGetText(m)!=NULL) {
hasWorkCtry = TRUE;
- JSetStringT( hContact, "CompanyCountry", xmlGetText( m ));
+ JSetStringT(hContact, "CompanyCountry", xmlGetText(m));
} }
}
- else if ( !lstrcmp( xmlGetName( n ), _T("TEL"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("TEL"))) {
// Telephone/Fax/Cellular
- if (( m=xmlGetChild( n , "NUMBER" ))!=NULL && xmlGetText( m )!=NULL ) {
- if ( hContact != NULL ) {
- if ( !hasFax && xmlGetChild( n , "FAX" )!=NULL ) {
+ if ((m=xmlGetChild(n , "NUMBER"))!=NULL && xmlGetText(m)!=NULL) {
+ if (hContact != NULL) {
+ if ( !hasFax && xmlGetChild(n , "FAX")!=NULL) {
hasFax = TRUE;
- JSetStringT( hContact, "Fax", xmlGetText( m ));
+ JSetStringT(hContact, "Fax", xmlGetText(m));
}
- else if ( !hasCell && xmlGetChild( n , "CELL" )!=NULL ) {
+ else if ( !hasCell && xmlGetChild(n , "CELL")!=NULL) {
hasCell = TRUE;
- JSetStringT( hContact, "Cellular", xmlGetText( m ));
+ JSetStringT(hContact, "Cellular", xmlGetText(m));
}
else if ( !hasPhone &&
- ( xmlGetChild( n , "HOME" )!=NULL ||
- xmlGetChild( n , "WORK" )!=NULL ||
- xmlGetChild( n , "VOICE" )!=NULL ||
- ( xmlGetChild( n , "FAX" )==NULL &&
- xmlGetChild( n , "PAGER" )==NULL &&
- xmlGetChild( n , "MSG" )==NULL &&
- xmlGetChild( n , "CELL" )==NULL &&
- xmlGetChild( n , "VIDEO" )==NULL &&
- xmlGetChild( n , "BBS" )==NULL &&
- xmlGetChild( n , "MODEM" )==NULL &&
- xmlGetChild( n , "ISDN" )==NULL &&
- xmlGetChild( n , "PCS" )==NULL ))) {
+ (xmlGetChild(n , "HOME")!=NULL ||
+ xmlGetChild(n , "WORK")!=NULL ||
+ xmlGetChild(n , "VOICE")!=NULL ||
+ (xmlGetChild(n , "FAX")==NULL &&
+ xmlGetChild(n , "PAGER")==NULL &&
+ xmlGetChild(n , "MSG")==NULL &&
+ xmlGetChild(n , "CELL")==NULL &&
+ xmlGetChild(n , "VIDEO")==NULL &&
+ xmlGetChild(n , "BBS")==NULL &&
+ xmlGetChild(n , "MODEM")==NULL &&
+ xmlGetChild(n , "ISDN")==NULL &&
+ xmlGetChild(n , "PCS")==NULL))) {
hasPhone = TRUE;
- JSetStringT( hContact, "Phone", xmlGetText( m ));
+ JSetStringT(hContact, "Phone", xmlGetText(m));
}
}
else {
char text[ 100 ];
- sprintf( text, "Phone%d", nPhone );
- JSetStringT( NULL, text, xmlGetText( m ));
+ sprintf(text, "Phone%d", nPhone);
+ JSetStringT(NULL, text, xmlGetText(m));
- sprintf( text, "PhoneFlag%d", nPhone );
+ sprintf(text, "PhoneFlag%d", nPhone);
int nFlag = 0;
- if ( xmlGetChild( n ,"HOME" ) != NULL ) nFlag |= JABBER_VCTEL_HOME;
- if ( xmlGetChild( n ,"WORK" ) != NULL ) nFlag |= JABBER_VCTEL_WORK;
- if ( xmlGetChild( n ,"VOICE" ) != NULL ) nFlag |= JABBER_VCTEL_VOICE;
- if ( xmlGetChild( n ,"FAX" ) != NULL ) nFlag |= JABBER_VCTEL_FAX;
- if ( xmlGetChild( n ,"PAGER" ) != NULL ) nFlag |= JABBER_VCTEL_PAGER;
- if ( xmlGetChild( n ,"MSG" ) != NULL ) nFlag |= JABBER_VCTEL_MSG;
- if ( xmlGetChild( n ,"CELL" ) != NULL ) nFlag |= JABBER_VCTEL_CELL;
- if ( xmlGetChild( n ,"VIDEO" ) != NULL ) nFlag |= JABBER_VCTEL_VIDEO;
- if ( xmlGetChild( n ,"BBS" ) != NULL ) nFlag |= JABBER_VCTEL_BBS;
- if ( xmlGetChild( n ,"MODEM" ) != NULL ) nFlag |= JABBER_VCTEL_MODEM;
- if ( xmlGetChild( n ,"ISDN" ) != NULL ) nFlag |= JABBER_VCTEL_ISDN;
- if ( xmlGetChild( n ,"PCS" ) != NULL ) nFlag |= JABBER_VCTEL_PCS;
- JSetWord( NULL, text, nFlag );
+ if (xmlGetChild(n ,"HOME") != NULL) nFlag |= JABBER_VCTEL_HOME;
+ if (xmlGetChild(n ,"WORK") != NULL) nFlag |= JABBER_VCTEL_WORK;
+ if (xmlGetChild(n ,"VOICE") != NULL) nFlag |= JABBER_VCTEL_VOICE;
+ if (xmlGetChild(n ,"FAX") != NULL) nFlag |= JABBER_VCTEL_FAX;
+ if (xmlGetChild(n ,"PAGER") != NULL) nFlag |= JABBER_VCTEL_PAGER;
+ if (xmlGetChild(n ,"MSG") != NULL) nFlag |= JABBER_VCTEL_MSG;
+ if (xmlGetChild(n ,"CELL") != NULL) nFlag |= JABBER_VCTEL_CELL;
+ if (xmlGetChild(n ,"VIDEO") != NULL) nFlag |= JABBER_VCTEL_VIDEO;
+ if (xmlGetChild(n ,"BBS") != NULL) nFlag |= JABBER_VCTEL_BBS;
+ if (xmlGetChild(n ,"MODEM") != NULL) nFlag |= JABBER_VCTEL_MODEM;
+ if (xmlGetChild(n ,"ISDN") != NULL) nFlag |= JABBER_VCTEL_ISDN;
+ if (xmlGetChild(n ,"PCS") != NULL) nFlag |= JABBER_VCTEL_PCS;
+ JSetWord(NULL, text, nFlag);
nPhone++;
} }
}
- else if ( !lstrcmp( xmlGetName( n ), _T("URL"))) {
+ else if ( !lstrcmp(xmlGetName(n), _T("URL"))) {
// Homepage
- if ( !hasUrl && xmlGetText( n )!=NULL ) {
+ if ( !hasUrl && xmlGetText(n)!=NULL) {
hasUrl = TRUE;
- JSetStringT( hContact, "Homepage", xmlGetText( n ));
+ JSetStringT(hContact, "Homepage", xmlGetText(n));
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("ORG"))) {
- if ( !hasOrgname && !hasOrgunit ) {
- if (( m=xmlGetChild( n ,"ORGNAME" ))!=NULL && xmlGetText( m )!=NULL ) {
+ else if ( !lstrcmp(xmlGetName(n), _T("ORG"))) {
+ if ( !hasOrgname && !hasOrgunit) {
+ if ((m=xmlGetChild(n ,"ORGNAME"))!=NULL && xmlGetText(m)!=NULL) {
hasOrgname = TRUE;
- JSetStringT( hContact, "Company", xmlGetText( m ));
+ JSetStringT(hContact, "Company", xmlGetText(m));
}
- if (( m=xmlGetChild( n ,"ORGUNIT" ))!=NULL && xmlGetText( m )!=NULL ) { // The real vCard can have multiple <ORGUNIT/> but we will only display the first one
+ if ((m=xmlGetChild(n ,"ORGUNIT"))!=NULL && xmlGetText(m)!=NULL) { // The real vCard can have multiple <ORGUNIT/> but we will only display the first one
hasOrgunit = TRUE;
- JSetStringT( hContact, "CompanyDepartment", xmlGetText( m ));
+ JSetStringT(hContact, "CompanyDepartment", xmlGetText(m));
} }
}
- else if ( !lstrcmp( xmlGetName( n ), _T("ROLE"))) {
- if ( !hasRole && xmlGetText( n )!=NULL ) {
+ else if ( !lstrcmp(xmlGetName(n), _T("ROLE"))) {
+ if ( !hasRole && xmlGetText(n)!=NULL) {
hasRole = TRUE;
- JSetStringT( hContact, "Role", xmlGetText( n ));
+ JSetStringT(hContact, "Role", xmlGetText(n));
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("TITLE"))) {
- if ( !hasTitle && xmlGetText( n )!=NULL ) {
+ else if ( !lstrcmp(xmlGetName(n), _T("TITLE"))) {
+ if ( !hasTitle && xmlGetText(n)!=NULL) {
hasTitle = TRUE;
- JSetStringT( hContact, "CompanyPosition", xmlGetText( n ));
+ JSetStringT(hContact, "CompanyPosition", xmlGetText(n));
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("DESC"))) {
- if ( !hasDesc && xmlGetText( n )!=NULL ) {
+ else if ( !lstrcmp(xmlGetName(n), _T("DESC"))) {
+ if ( !hasDesc && xmlGetText(n)!=NULL) {
hasDesc = TRUE;
- TCHAR* szMemo = JabberUnixToDosT( xmlGetText( n ));
- JSetStringT( hContact, "About", szMemo );
- mir_free( szMemo );
+ TCHAR* szMemo = JabberUnixToDosT(xmlGetText(n));
+ JSetStringT(hContact, "About", szMemo);
+ mir_free(szMemo);
}
}
- else if ( !lstrcmp( xmlGetName( n ), _T("PHOTO")))
- OnIqResultGetVcardPhoto( jid, n, hContact, hasPhoto );
+ else if ( !lstrcmp(xmlGetName(n), _T("PHOTO")))
+ OnIqResultGetVcardPhoto(jid, n, hContact, hasPhoto);
} }
- if ( hasFn && !hasNick ) {
- TCHAR *name = JGetStringT( hContact, "FullName" );
- TCHAR *nick = JGetStringT( hContact, "Nick" );
+ if (hasFn && !hasNick) {
+ TCHAR *name = JGetStringT(hContact, "FullName");
+ TCHAR *nick = JGetStringT(hContact, "Nick");
TCHAR *jidNick = JabberNickFromJID(jid);
- if ( !nick || ( jidNick && !_tcsicmp( nick, jidNick )))
- JSetStringT( hContact, "Nick", name );
+ if ( !nick || (jidNick && !_tcsicmp(nick, jidNick)))
+ JSetStringT(hContact, "Nick", name);
- mir_free( jidNick );
- mir_free( nick );
- mir_free( name );
+ mir_free(jidNick);
+ mir_free(nick);
+ mir_free(name);
}
- if ( !hasFn )
- JDeleteSetting( hContact, "FullName" );
+ if ( !hasFn)
+ JDeleteSetting(hContact, "FullName");
// We are not deleting "Nick"
-// if ( !hasNick )
-// JDeleteSetting( hContact, "Nick" );
- if ( !hasGiven )
- JDeleteSetting( hContact, "FirstName" );
- if ( !hasFamily )
- JDeleteSetting( hContact, "LastName" );
- if ( !hasMiddle )
- JDeleteSetting( hContact, "MiddleName" );
- if ( hContact != NULL ) {
- while ( true ) {
- if ( nEmail <= 0 )
- JDeleteSetting( hContact, "e-mail" );
+// if ( !hasNick)
+// JDeleteSetting(hContact, "Nick");
+ if ( !hasGiven)
+ JDeleteSetting(hContact, "FirstName");
+ if ( !hasFamily)
+ JDeleteSetting(hContact, "LastName");
+ if ( !hasMiddle)
+ JDeleteSetting(hContact, "MiddleName");
+ if (hContact != NULL) {
+ while (true) {
+ if (nEmail <= 0)
+ JDeleteSetting(hContact, "e-mail");
else {
char text[ 100 ];
- sprintf( text, "e-mail%d", nEmail-1 );
- if ( DBGetContactSettingString( hContact, m_szModuleName, text, &dbv )) break;
- JFreeVariant( &dbv );
- JDeleteSetting( hContact, text );
+ sprintf(text, "e-mail%d", nEmail-1);
+ if (DBGetContactSettingString(hContact, m_szModuleName, text, &dbv)) break;
+ db_free(&dbv);
+ JDeleteSetting(hContact, text);
}
nEmail++;
}
}
else {
- while ( true ) {
+ while (true) {
char text[ 100 ];
- sprintf( text, "e-mail%d", nEmail );
- if ( DBGetContactSettingString( NULL, m_szModuleName, text, &dbv )) break;
- JFreeVariant( &dbv );
- JDeleteSetting( NULL, text );
- sprintf( text, "e-mailFlag%d", nEmail );
- JDeleteSetting( NULL, text );
+ sprintf(text, "e-mail%d", nEmail);
+ if (DBGetContactSettingString(NULL, m_szModuleName, text, &dbv)) break;
+ db_free(&dbv);
+ JDeleteSetting(NULL, text);
+ sprintf(text, "e-mailFlag%d", nEmail);
+ JDeleteSetting(NULL, text);
nEmail++;
} }
- if ( !hasBday ) {
- JDeleteSetting( hContact, "BirthYear" );
- JDeleteSetting( hContact, "BirthMonth" );
- JDeleteSetting( hContact, "BirthDay" );
- JDeleteSetting( hContact, "BirthDate" );
- JDeleteSetting( hContact, "Age" );
+ if ( !hasBday) {
+ JDeleteSetting(hContact, "BirthYear");
+ JDeleteSetting(hContact, "BirthMonth");
+ JDeleteSetting(hContact, "BirthDay");
+ JDeleteSetting(hContact, "BirthDate");
+ JDeleteSetting(hContact, "Age");
}
- if ( !hasGender ) {
- if ( hContact != NULL )
- JDeleteSetting( hContact, "Gender" );
+ if ( !hasGender) {
+ if (hContact != NULL)
+ JDeleteSetting(hContact, "Gender");
else
- JDeleteSetting( NULL, "GenderString" );
+ JDeleteSetting(NULL, "GenderString");
}
- if ( hContact != NULL ) {
- if ( !hasPhone )
- JDeleteSetting( hContact, "Phone" );
- if ( !hasFax )
- JDeleteSetting( hContact, "Fax" );
- if ( !hasCell )
- JDeleteSetting( hContact, "Cellular" );
+ if (hContact != NULL) {
+ if ( !hasPhone)
+ JDeleteSetting(hContact, "Phone");
+ if ( !hasFax)
+ JDeleteSetting(hContact, "Fax");
+ if ( !hasCell)
+ JDeleteSetting(hContact, "Cellular");
}
else {
- while ( true ) {
+ while (true) {
char text[ 100 ];
- sprintf( text, "Phone%d", nPhone );
- if ( DBGetContactSettingString( NULL, m_szModuleName, text, &dbv )) break;
- JFreeVariant( &dbv );
- JDeleteSetting( NULL, text );
- sprintf( text, "PhoneFlag%d", nPhone );
- JDeleteSetting( NULL, text );
+ sprintf(text, "Phone%d", nPhone);
+ if (DBGetContactSettingString(NULL, m_szModuleName, text, &dbv)) break;
+ db_free(&dbv);
+ JDeleteSetting(NULL, text);
+ sprintf(text, "PhoneFlag%d", nPhone);
+ JDeleteSetting(NULL, text);
nPhone++;
} }
- if ( !hasHomeStreet )
- JDeleteSetting( hContact, "Street" );
- if ( !hasHomeStreet2 && hContact==NULL )
- JDeleteSetting( hContact, "Street2" );
- if ( !hasHomeLocality )
- JDeleteSetting( hContact, "City" );
- if ( !hasHomeRegion )
- JDeleteSetting( hContact, "State" );
- if ( !hasHomePcode )
- JDeleteSetting( hContact, "ZIP" );
- if ( !hasHomeCtry )
- JDeleteSetting( hContact, "Country" );
- if ( !hasWorkStreet )
- JDeleteSetting( hContact, "CompanyStreet" );
- if ( !hasWorkStreet2 && hContact==NULL )
- JDeleteSetting( hContact, "CompanyStreet2" );
- if ( !hasWorkLocality )
- JDeleteSetting( hContact, "CompanyCity" );
- if ( !hasWorkRegion )
- JDeleteSetting( hContact, "CompanyState" );
- if ( !hasWorkPcode )
- JDeleteSetting( hContact, "CompanyZIP" );
- if ( !hasWorkCtry )
- JDeleteSetting( hContact, "CompanyCountry" );
- if ( !hasUrl )
- JDeleteSetting( hContact, "Homepage" );
- if ( !hasOrgname )
- JDeleteSetting( hContact, "Company" );
- if ( !hasOrgunit )
- JDeleteSetting( hContact, "CompanyDepartment" );
- if ( !hasRole )
- JDeleteSetting( hContact, "Role" );
- if ( !hasTitle )
- JDeleteSetting( hContact, "CompanyPosition" );
- if ( !hasDesc )
- JDeleteSetting( hContact, "About" );
-
- if ( id == m_ThreadInfo->resolveID ) {
- const TCHAR* p = _tcschr( jid, '@' );
- ResolveTransportNicks(( p != NULL ) ? p+1 : jid );
+ if ( !hasHomeStreet)
+ JDeleteSetting(hContact, "Street");
+ if ( !hasHomeStreet2 && hContact==NULL)
+ JDeleteSetting(hContact, "Street2");
+ if ( !hasHomeLocality)
+ JDeleteSetting(hContact, "City");
+ if ( !hasHomeRegion)
+ JDeleteSetting(hContact, "State");
+ if ( !hasHomePcode)
+ JDeleteSetting(hContact, "ZIP");
+ if ( !hasHomeCtry)
+ JDeleteSetting(hContact, "Country");
+ if ( !hasWorkStreet)
+ JDeleteSetting(hContact, "CompanyStreet");
+ if ( !hasWorkStreet2 && hContact==NULL)
+ JDeleteSetting(hContact, "CompanyStreet2");
+ if ( !hasWorkLocality)
+ JDeleteSetting(hContact, "CompanyCity");
+ if ( !hasWorkRegion)
+ JDeleteSetting(hContact, "CompanyState");
+ if ( !hasWorkPcode)
+ JDeleteSetting(hContact, "CompanyZIP");
+ if ( !hasWorkCtry)
+ JDeleteSetting(hContact, "CompanyCountry");
+ if ( !hasUrl)
+ JDeleteSetting(hContact, "Homepage");
+ if ( !hasOrgname)
+ JDeleteSetting(hContact, "Company");
+ if ( !hasOrgunit)
+ JDeleteSetting(hContact, "CompanyDepartment");
+ if ( !hasRole)
+ JDeleteSetting(hContact, "Role");
+ if ( !hasTitle)
+ JDeleteSetting(hContact, "CompanyPosition");
+ if ( !hasDesc)
+ JDeleteSetting(hContact, "About");
+
+ if (id == m_ThreadInfo->resolveID) {
+ const TCHAR *p = _tcschr(jid, '@');
+ ResolveTransportNicks((p != NULL) ? p+1 : jid);
}
else {
- if (( hContact = HContactFromJID( jid )) != NULL )
- JSendBroadcast( hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, ( HANDLE ) 1, 0 );
+ if ((hContact = HContactFromJID(jid)) != NULL)
+ JSendBroadcast(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
WindowNotify(WM_JABBER_REFRESH_VCARD);
}
}
- else if ( !lstrcmp( type, _T("error"))) {
- if (( hContact = HContactFromJID( jid )) != NULL )
- JSendBroadcast( hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, ( HANDLE ) 1, 0 );
+ else if ( !lstrcmp(type, _T("error"))) {
+ if ((hContact = HContactFromJID(jid)) != NULL)
+ JSendBroadcast(hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE)1, 0);
}
}
-void CJabberProto::OnIqResultSetVcard( HXML iqNode )
+void CJabberProto::OnIqResultSetVcard(HXML iqNode)
{
- Log( "<iq/> iqIdSetVcard" );
- if ( !xmlGetAttrValue( iqNode, _T("type")))
+ Log("<iq/> iqIdSetVcard");
+ if ( !xmlGetAttrValue(iqNode, _T("type")))
return;
WindowNotify(WM_JABBER_REFRESH_VCARD);
}
-void CJabberProto::OnIqResultSetSearch( HXML iqNode )
+void CJabberProto::OnIqResultSetSearch(HXML iqNode)
{
HXML queryNode, n;
- const TCHAR* type, *jid;
+ const TCHAR *type, *jid;
int i, id;
JABBER_SEARCH_RESULT jsr;
- Log( "<iq/> iqIdGetSearch" );
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( id = JabberGetPacketID( iqNode )) == -1 ) return;
+ Log("<iq/> iqIdGetSearch");
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((id = JabberGetPacketID(iqNode)) == -1) return;
- if ( !lstrcmp( type, _T("result"))) {
- if (( queryNode=xmlGetChild( iqNode , "query" )) == NULL ) return;
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
- for ( i=0; ; i++ ) {
- HXML itemNode = xmlGetChild( queryNode ,i);
- if ( !itemNode )
+ if ( !lstrcmp(type, _T("result"))) {
+ if ((queryNode=xmlGetChild(iqNode , "query")) == NULL) return;
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
+ for (i=0; ; i++) {
+ HXML itemNode = xmlGetChild(queryNode ,i);
+ if ( !itemNode)
break;
- if ( !lstrcmp( xmlGetName( itemNode ), _T("item"))) {
- if (( jid=xmlGetAttrValue( itemNode, _T("jid"))) != NULL ) {
- _tcsncpy( jsr.jid, jid, SIZEOF( jsr.jid ));
- jsr.jid[ SIZEOF( jsr.jid )-1] = '\0';
+ if ( !lstrcmp(xmlGetName(itemNode), _T("item"))) {
+ if ((jid=xmlGetAttrValue(itemNode, _T("jid"))) != NULL) {
+ _tcsncpy(jsr.jid, jid, SIZEOF(jsr.jid));
+ jsr.jid[ SIZEOF(jsr.jid)-1] = '\0';
jsr.hdr.id = (TCHAR*)jid;
- Log( "Result jid = " TCHAR_STR_PARAM, jid );
- if (( n=xmlGetChild( itemNode , "nick" ))!=NULL && xmlGetText( n )!=NULL )
- jsr.hdr.nick = ( TCHAR* )xmlGetText( n );
+ Log("Result jid = " TCHAR_STR_PARAM, jid);
+ if ((n=xmlGetChild(itemNode , "nick"))!=NULL && xmlGetText(n)!=NULL)
+ jsr.hdr.nick = (TCHAR*)xmlGetText(n);
else
- jsr.hdr.nick = _T( "" );
- if (( n=xmlGetChild( itemNode , "first" ))!=NULL && xmlGetText( n )!=NULL )
- jsr.hdr.firstName = ( TCHAR* )xmlGetText( n );
+ jsr.hdr.nick = _T("");
+ if ((n=xmlGetChild(itemNode , "first"))!=NULL && xmlGetText(n)!=NULL)
+ jsr.hdr.firstName = (TCHAR*)xmlGetText(n);
else
- jsr.hdr.firstName = _T( "" );
- if (( n=xmlGetChild( itemNode , "last" ))!=NULL && xmlGetText( n )!=NULL )
- jsr.hdr.lastName = ( TCHAR* )xmlGetText( n );
+ jsr.hdr.firstName = _T("");
+ if ((n=xmlGetChild(itemNode , "last"))!=NULL && xmlGetText(n)!=NULL)
+ jsr.hdr.lastName = (TCHAR*)xmlGetText(n);
else
- jsr.hdr.lastName = _T( "" );
- if (( n=xmlGetChild( itemNode , "email" ))!=NULL && xmlGetText( n )!=NULL )
- jsr.hdr.email = ( TCHAR* )xmlGetText( n );
+ jsr.hdr.lastName = _T("");
+ if ((n=xmlGetChild(itemNode , "email"))!=NULL && xmlGetText(n)!=NULL)
+ jsr.hdr.email = (TCHAR*)xmlGetText(n);
else
- jsr.hdr.email = _T( "" );
+ jsr.hdr.email = _T("");
jsr.hdr.flags = PSR_TCHAR;
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, ( HANDLE ) id, ( LPARAM )&jsr );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
} } }
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else if ( !lstrcmp( type, _T("error")))
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ else if ( !lstrcmp(type, _T("error")))
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-void CJabberProto::OnIqResultExtSearch( HXML iqNode )
+void CJabberProto::OnIqResultExtSearch(HXML iqNode)
{
HXML queryNode;
- const TCHAR* type;
+ const TCHAR *type;
int id;
- Log( "<iq/> iqIdGetExtSearch" );
- if (( type=xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( id = JabberGetPacketID( iqNode )) == -1 ) return;
+ Log("<iq/> iqIdGetExtSearch");
+ if ((type=xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((id = JabberGetPacketID(iqNode)) == -1) return;
- if ( !lstrcmp( type, _T("result"))) {
- if (( queryNode=xmlGetChild( iqNode , "query" )) == NULL ) return;
- if (( queryNode=xmlGetChild( queryNode , "x" )) == NULL ) return;
- for ( int i=0; ; i++ ) {
- HXML itemNode = xmlGetChild( queryNode ,i);
- if ( !itemNode )
+ if ( !lstrcmp(type, _T("result"))) {
+ if ((queryNode=xmlGetChild(iqNode , "query")) == NULL) return;
+ if ((queryNode=xmlGetChild(queryNode , "x")) == NULL) return;
+ for (int i=0; ; i++) {
+ HXML itemNode = xmlGetChild(queryNode ,i);
+ if ( !itemNode)
break;
- if ( lstrcmp( xmlGetName( itemNode ), _T("item")))
+ if (lstrcmp(xmlGetName(itemNode), _T("item")))
continue;
JABBER_SEARCH_RESULT jsr = { 0 };
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
// jsr.hdr.firstName = "";
- for ( int j=0; ; j++ ) {
- HXML fieldNode = xmlGetChild( itemNode ,j);
- if ( !fieldNode )
+ for (int j=0; ; j++) {
+ HXML fieldNode = xmlGetChild(itemNode ,j);
+ if ( !fieldNode)
break;
- if ( lstrcmp( xmlGetName( fieldNode ), _T("field")))
+ if (lstrcmp(xmlGetName(fieldNode), _T("field")))
continue;
- const TCHAR* fieldName = xmlGetAttrValue( fieldNode, _T("var"));
- if ( fieldName == NULL )
+ const TCHAR *fieldName = xmlGetAttrValue(fieldNode, _T("var"));
+ if (fieldName == NULL)
continue;
- HXML n = xmlGetChild( fieldNode , "value" );
- if ( n == NULL )
+ HXML n = xmlGetChild(fieldNode , "value");
+ if (n == NULL)
continue;
- if ( !lstrcmp( fieldName, _T("jid"))) {
- _tcsncpy( jsr.jid, xmlGetText( n ), SIZEOF( jsr.jid ));
- jsr.jid[SIZEOF( jsr.jid )-1] = '\0';
- Log( "Result jid = " TCHAR_STR_PARAM, jsr.jid );
+ if ( !lstrcmp(fieldName, _T("jid"))) {
+ _tcsncpy(jsr.jid, xmlGetText(n), SIZEOF(jsr.jid));
+ jsr.jid[SIZEOF(jsr.jid)-1] = '\0';
+ Log("Result jid = " TCHAR_STR_PARAM, jsr.jid);
}
- else if ( !lstrcmp( fieldName, _T("nickname")))
- jsr.hdr.nick = ( xmlGetText( n ) != NULL ) ? ( TCHAR* )xmlGetText( n ) : _T( "" );
- else if ( !lstrcmp( fieldName, _T("fn")))
- jsr.hdr.firstName = ( xmlGetText( n ) != NULL ) ? ( TCHAR* )xmlGetText( n ) : _T( "" );
- else if ( !lstrcmp( fieldName, _T("given")))
- jsr.hdr.firstName = ( xmlGetText( n ) != NULL ) ? ( TCHAR* )xmlGetText( n ) : _T( "" );
- else if ( !lstrcmp( fieldName, _T("family")))
- jsr.hdr.lastName = ( xmlGetText( n ) != NULL ) ? ( TCHAR* )xmlGetText( n ) : _T( "" );
- else if ( !lstrcmp( fieldName, _T("email")))
- jsr.hdr.email = ( xmlGetText( n ) != NULL ) ? ( TCHAR* )xmlGetText( n ) : _T( "" );
+ else if ( !lstrcmp(fieldName, _T("nickname")))
+ jsr.hdr.nick = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ else if ( !lstrcmp(fieldName, _T("fn")))
+ jsr.hdr.firstName = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ else if ( !lstrcmp(fieldName, _T("given")))
+ jsr.hdr.firstName = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ else if ( !lstrcmp(fieldName, _T("family")))
+ jsr.hdr.lastName = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ else if ( !lstrcmp(fieldName, _T("email")))
+ jsr.hdr.email = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
}
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, ( HANDLE ) id, ( LPARAM )&jsr );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
}
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- else if ( !lstrcmp( type, _T("error")))
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ else if ( !lstrcmp(type, _T("error")))
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-void CJabberProto::OnIqResultSetPassword( HXML iqNode )
+void CJabberProto::OnIqResultSetPassword(HXML iqNode)
{
- Log( "<iq/> iqIdSetPassword" );
+ Log("<iq/> iqIdSetPassword");
- const TCHAR* type = xmlGetAttrValue( iqNode, _T("type"));
- if ( type == NULL )
+ const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
+ if (type == NULL)
return;
- if ( !lstrcmp( type, _T("result"))) {
- _tcsncpy( m_ThreadInfo->password, m_ThreadInfo->newPassword, SIZEOF( m_ThreadInfo->password ));
- MessageBox( NULL, TranslateT( "Password is successfully changed. Don't forget to update your password in the Jabber protocol option." ), TranslateT( "Change Password" ), MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND );
+ if ( !lstrcmp(type, _T("result"))) {
+ _tcsncpy(m_ThreadInfo->password, m_ThreadInfo->newPassword, SIZEOF(m_ThreadInfo->password));
+ MessageBox(NULL, TranslateT("Password is successfully changed. Don't forget to update your password in the Jabber protocol option."), TranslateT("Change Password"), MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND);
}
- else if ( !lstrcmp( type, _T("error")))
- MessageBox( NULL, TranslateT( "Password cannot be changed." ), TranslateT( "Change Password" ), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND );
+ else if ( !lstrcmp(type, _T("error")))
+ MessageBox(NULL, TranslateT("Password cannot be changed."), TranslateT("Change Password"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
}
/*
-void CJabberProto::OnIqResultDiscoAgentItems( HXML iqNode, void *userdata )
+void CJabberProto::OnIqResultDiscoAgentItems(HXML iqNode, void *userdata)
{
- if ( !m_options.EnableAvatars )
+ if ( !m_options.EnableAvatars)
return;
}
*/
-void CJabberProto::OnIqResultGetVCardAvatar( HXML iqNode )
+void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode)
{
- const TCHAR* type;
+ const TCHAR *type;
- Log( "<iq/> OnIqResultGetVCardAvatar" );
+ Log("<iq/> OnIqResultGetVCardAvatar");
- const TCHAR* from = xmlGetAttrValue( iqNode, _T("from"));
- if ( from == NULL )
+ const TCHAR *from = xmlGetAttrValue(iqNode, _T("from"));
+ if (from == NULL)
return;
- HANDLE hContact = HContactFromJID( from );
- if ( hContact == NULL )
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact == NULL)
return;
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if ( _tcscmp( type, _T("result"))) return;
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if (_tcscmp(type, _T("result"))) return;
- HXML vCard = xmlGetChild( iqNode , "vCard" );
+ HXML vCard = xmlGetChild(iqNode , "vCard");
if (vCard == NULL) return;
- vCard = xmlGetChild( vCard , "PHOTO" );
+ vCard = xmlGetChild(vCard , "PHOTO");
if (vCard == NULL) return;
- if ( xmlGetChildCount( vCard ) == 0 ) {
- JDeleteSetting( hContact, "AvatarHash" );
+ if (xmlGetChildCount(vCard) == 0) {
+ JDeleteSetting(hContact, "AvatarHash");
DBVARIANT dbv = {0};
- if ( !JGetStringT( hContact, "AvatarSaved", &dbv )) {
- JFreeVariant( &dbv );
- JDeleteSetting( hContact, "AvatarSaved" );
- JSendBroadcast( hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL );
+ if ( !JGetStringT(hContact, "AvatarSaved", &dbv)) {
+ db_free(&dbv);
+ JDeleteSetting(hContact, "AvatarSaved");
+ JSendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL);
}
return;
}
- HXML typeNode = xmlGetChild( vCard , "TYPE" );
- const TCHAR* mimeType = NULL;
- if (typeNode != NULL) mimeType = xmlGetText( typeNode );
- HXML n = xmlGetChild( vCard , "BINVAL" );
- if ( n == NULL )
+ HXML typeNode = xmlGetChild(vCard , "TYPE");
+ const TCHAR *mimeType = NULL;
+ if (typeNode != NULL) mimeType = xmlGetText(typeNode);
+ HXML n = xmlGetChild(vCard , "BINVAL");
+ if (n == NULL)
return;
- JSetByte( hContact, "AvatarXVcard", 1 );
- OnIqResultGotAvatar( hContact, n, mimeType);
+ JSetByte(hContact, "AvatarXVcard", 1);
+ OnIqResultGotAvatar(hContact, n, mimeType);
}
-void CJabberProto::OnIqResultGetClientAvatar( HXML iqNode )
+void CJabberProto::OnIqResultGetClientAvatar(HXML iqNode)
{
- const TCHAR* type;
+ const TCHAR *type;
- Log( "<iq/> iqIdResultGetClientAvatar" );
+ Log("<iq/> iqIdResultGetClientAvatar");
- const TCHAR* from = xmlGetAttrValue( iqNode, _T("from"));
- if ( from == NULL )
+ const TCHAR *from = xmlGetAttrValue(iqNode, _T("from"));
+ if (from == NULL)
return;
- HANDLE hContact = HContactFromJID( from );
- if ( hContact == NULL )
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact == NULL)
return;
HXML n = NULL;
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) != NULL && !_tcscmp( type, _T("result"))) {
- HXML queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode != NULL ) {
- const TCHAR* xmlns = xmlGetAttrValue( queryNode, _T("xmlns"));
- if ( !lstrcmp( xmlns, _T(JABBER_FEAT_AVATAR))) {
- n = xmlGetChild( queryNode , "data" );
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) != NULL && !_tcscmp(type, _T("result"))) {
+ HXML queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode != NULL) {
+ const TCHAR *xmlns = xmlGetAttrValue(queryNode, _T("xmlns"));
+ if ( !lstrcmp(xmlns, _T(JABBER_FEAT_AVATAR))) {
+ n = xmlGetChild(queryNode , "data");
}
}
}
- if ( n == NULL ) {
+ if (n == NULL) {
TCHAR szJid[ JABBER_MAX_JID_LEN ];
lstrcpyn(szJid, from, SIZEOF(szJid));
TCHAR *res = _tcschr(szJid, _T('/'));
- if ( res != NULL )
+ if (res != NULL)
*res = 0;
// Try server stored avatar
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetServerAvatar );
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetServerAvatar);
- XmlNodeIq iq( _T("get"), iqId, szJid );
- iq << XQUERY( _T(JABBER_FEAT_SERVER_AVATAR));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("get"), iqId, szJid);
+ iq << XQUERY(_T(JABBER_FEAT_SERVER_AVATAR));
+ m_ThreadInfo->send(iq);
return;
}
- const TCHAR* mimeType = mimeType = xmlGetAttrValue( n, _T("mimetype"));
+ const TCHAR *mimeType = mimeType = xmlGetAttrValue(n, _T("mimetype"));
- OnIqResultGotAvatar( hContact, n, mimeType);
+ OnIqResultGotAvatar(hContact, n, mimeType);
}
-void CJabberProto::OnIqResultGetServerAvatar( HXML iqNode )
+void CJabberProto::OnIqResultGetServerAvatar(HXML iqNode)
{
- const TCHAR* type;
+ const TCHAR *type;
- Log( "<iq/> iqIdResultGetServerAvatar" );
+ Log("<iq/> iqIdResultGetServerAvatar");
- const TCHAR* from = xmlGetAttrValue( iqNode, _T("from"));
- if ( from == NULL )
+ const TCHAR *from = xmlGetAttrValue(iqNode, _T("from"));
+ if (from == NULL)
return;
- HANDLE hContact = HContactFromJID( from );
- if ( hContact == NULL )
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact == NULL)
return;
HXML n = NULL;
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) != NULL && !_tcscmp( type, _T("result"))) {
- HXML queryNode = xmlGetChild( iqNode , "query" );
- if ( queryNode != NULL ) {
- const TCHAR* xmlns = xmlGetAttrValue( queryNode, _T("xmlns"));
- if ( !lstrcmp( xmlns, _T(JABBER_FEAT_SERVER_AVATAR))) {
- n = xmlGetChild( queryNode , "data" );
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) != NULL && !_tcscmp(type, _T("result"))) {
+ HXML queryNode = xmlGetChild(iqNode , "query");
+ if (queryNode != NULL) {
+ const TCHAR *xmlns = xmlGetAttrValue(queryNode, _T("xmlns"));
+ if ( !lstrcmp(xmlns, _T(JABBER_FEAT_SERVER_AVATAR))) {
+ n = xmlGetChild(queryNode , "data");
}
}
}
- if ( n == NULL ) {
+ if (n == NULL) {
TCHAR szJid[ JABBER_MAX_JID_LEN ];
lstrcpyn(szJid, from, SIZEOF(szJid));
TCHAR *res = _tcschr(szJid, _T('/'));
- if ( res != NULL )
+ if (res != NULL)
*res = 0;
// Try VCard photo
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetVCardAvatar );
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetVCardAvatar);
- XmlNodeIq iq( _T("get"), iqId, szJid );
- iq << XCHILDNS( _T("vCard"), _T(JABBER_FEAT_VCARD_TEMP));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("get"), iqId, szJid);
+ iq << XCHILDNS(_T("vCard"), _T(JABBER_FEAT_VCARD_TEMP));
+ m_ThreadInfo->send(iq);
return;
}
- const TCHAR* mimeType = xmlGetAttrValue( n, _T("mimetype"));
+ const TCHAR *mimeType = xmlGetAttrValue(n, _T("mimetype"));
- OnIqResultGotAvatar( hContact, n, mimeType);
+ OnIqResultGotAvatar(hContact, n, mimeType);
}
-void CJabberProto::OnIqResultGotAvatar( HANDLE hContact, HXML n, const TCHAR* mimeType )
+void CJabberProto::OnIqResultGotAvatar(HANDLE hContact, HXML n, const TCHAR *mimeType)
{
int resultLen = 0;
- char* body = JabberBase64DecodeT( xmlGetText( n ), &resultLen );
+ char* body = JabberBase64DecodeT(xmlGetText(n), &resultLen);
int pictureType;
- if ( mimeType != NULL ) {
- if ( !lstrcmp( mimeType, _T("image/jpeg"))) pictureType = PA_FORMAT_JPEG;
- else if ( !lstrcmp( mimeType, _T("image/png"))) pictureType = PA_FORMAT_PNG;
- else if ( !lstrcmp( mimeType, _T("image/gif"))) pictureType = PA_FORMAT_GIF;
- else if ( !lstrcmp( mimeType, _T("image/bmp"))) pictureType = PA_FORMAT_BMP;
+ if (mimeType != NULL) {
+ if ( !lstrcmp(mimeType, _T("image/jpeg"))) pictureType = PA_FORMAT_JPEG;
+ else if ( !lstrcmp(mimeType, _T("image/png"))) pictureType = PA_FORMAT_PNG;
+ else if ( !lstrcmp(mimeType, _T("image/gif"))) pictureType = PA_FORMAT_GIF;
+ else if ( !lstrcmp(mimeType, _T("image/bmp"))) pictureType = PA_FORMAT_BMP;
else {
LBL_ErrFormat:
- Log( "Invalid mime type specified for picture: " TCHAR_STR_PARAM, mimeType );
- mir_free( body );
+ Log("Invalid mime type specified for picture: " TCHAR_STR_PARAM, mimeType);
+ mir_free(body);
return;
} }
- else if (( pictureType = JabberGetPictureType( body )) == PA_FORMAT_UNKNOWN )
+ else if ((pictureType = JabberGetPictureType(body)) == PA_FORMAT_UNKNOWN)
goto LBL_ErrFormat;
TCHAR tszFileName[ MAX_PATH ];
@@ -1532,80 +1532,80 @@ LBL_ErrFormat: AI.format = pictureType;
AI.hContact = hContact;
- if ( JGetByte( hContact, "AvatarType", PA_FORMAT_UNKNOWN ) != (unsigned char)pictureType ) {
- GetAvatarFileName( hContact, tszFileName, SIZEOF(tszFileName));
- DeleteFile( tszFileName );
+ if (JGetByte(hContact, "AvatarType", PA_FORMAT_UNKNOWN) != (unsigned char)pictureType) {
+ GetAvatarFileName(hContact, tszFileName, SIZEOF(tszFileName));
+ DeleteFile(tszFileName);
}
- JSetByte( hContact, "AvatarType", pictureType );
+ JSetByte(hContact, "AvatarType", pictureType);
char buffer[ 41 ];
mir_sha1_byte_t digest[20];
mir_sha1_ctx sha;
- mir_sha1_init( &sha );
- mir_sha1_append( &sha, ( mir_sha1_byte_t* )body, resultLen );
- mir_sha1_finish( &sha, digest );
- for ( int i=0; i<20; i++ )
- sprintf( buffer+( i<<1 ), "%02x", digest[i] );
-
- GetAvatarFileName( hContact, tszFileName, SIZEOF(tszFileName));
- _tcsncpy( AI.filename, tszFileName, SIZEOF(AI.filename));
-
- FILE* out = _tfopen( tszFileName, _T("wb"));
- if ( out != NULL ) {
- fwrite( body, resultLen, 1, out );
- fclose( out );
- JSetString( hContact, "AvatarSaved", buffer );
- JSendBroadcast( hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, HANDLE( &AI ), NULL );
+ mir_sha1_init(&sha);
+ mir_sha1_append(&sha, (mir_sha1_byte_t*)body, resultLen);
+ mir_sha1_finish(&sha, digest);
+ for (int i=0; i<20; i++)
+ sprintf(buffer+(i<<1), "%02x", digest[i]);
+
+ GetAvatarFileName(hContact, tszFileName, SIZEOF(tszFileName));
+ _tcsncpy(AI.filename, tszFileName, SIZEOF(AI.filename));
+
+ FILE* out = _tfopen(tszFileName, _T("wb"));
+ if (out != NULL) {
+ fwrite(body, resultLen, 1, out);
+ fclose(out);
+ JSetString(hContact, "AvatarSaved", buffer);
+ JSendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, HANDLE(&AI), NULL);
Log("Broadcast new avatar: %s",AI.filename);
}
- else JSendBroadcast( hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, HANDLE( &AI ), NULL );
+ else JSendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, HANDLE(&AI), NULL);
- mir_free( body );
+ mir_free(body);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Bookmarks
-void CJabberProto::OnIqResultDiscoBookmarks( HXML iqNode )
+void CJabberProto::OnIqResultDiscoBookmarks(HXML iqNode)
{
HXML storageNode;//, nickNode, passNode;
- const TCHAR* type, *jid, *name;
+ const TCHAR *type, *jid, *name;
// RECVED: list of bookmarks
// ACTION: refresh bookmarks dialog
- Log( "<iq/> iqIdGetBookmarks" );
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
+ Log("<iq/> iqIdGetBookmarks");
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
- if ( !lstrcmp( type, _T("result"))) {
- if ( m_ThreadInfo && !( m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE )) {
+ if ( !lstrcmp(type, _T("result"))) {
+ if (m_ThreadInfo && !(m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)) {
m_ThreadInfo->jabberServerCaps |= JABBER_CAPS_PRIVATE_STORAGE;
- EnableMenuItems( TRUE );
+ EnableMenuItems(TRUE);
}
- if ( storageNode = XPathT( iqNode, "query/storage[@xmlns='storage:bookmarks']" )) {
- ListRemoveList( LIST_BOOKMARK );
+ if (storageNode = XPathT(iqNode, "query/storage[@xmlns='storage:bookmarks']")) {
+ ListRemoveList(LIST_BOOKMARK);
HXML itemNode;
- for ( int i = 0; itemNode = xmlGetChild( storageNode, i ); i++ ) {
- if ( name = xmlGetName( itemNode)) {
- if ( !_tcscmp( name, _T("conference")) && (jid = xmlGetAttrValue( itemNode, _T("jid")))) {
- JABBER_LIST_ITEM* item = ListAdd( LIST_BOOKMARK, jid );
- item->name = mir_tstrdup( xmlGetAttrValue( itemNode, _T("name")));
- item->type = mir_tstrdup( _T( "conference" ));
+ for (int i = 0; itemNode = xmlGetChild(storageNode, i); i++) {
+ if (name = xmlGetName(itemNode)) {
+ if ( !_tcscmp(name, _T("conference")) && (jid = xmlGetAttrValue(itemNode, _T("jid")))) {
+ JABBER_LIST_ITEM* item = ListAdd(LIST_BOOKMARK, jid);
+ item->name = mir_tstrdup(xmlGetAttrValue(itemNode, _T("name")));
+ item->type = mir_tstrdup(_T("conference"));
item->bUseResource = TRUE;
- item->nick = mir_tstrdup( XPathT( itemNode, "nick" ));
- item->password = mir_tstrdup( XPathT( itemNode, "password" ));
+ item->nick = mir_tstrdup(XPathT(itemNode, "nick"));
+ item->password = mir_tstrdup(XPathT(itemNode, "password"));
- const TCHAR* autoJ = xmlGetAttrValue( itemNode, _T("autojoin"));
- if ( autoJ != NULL )
- item->bAutoJoin = ( !lstrcmp( autoJ, _T("true")) || !lstrcmp( autoJ, _T("1"))) ? true : false;
+ const TCHAR *autoJ = xmlGetAttrValue(itemNode, _T("autojoin"));
+ if (autoJ != NULL)
+ item->bAutoJoin = (!lstrcmp(autoJ, _T("true")) || !lstrcmp(autoJ, _T("1"))) ? true : false;
}
- else if ( !_tcscmp( name, _T("url")) && (jid = xmlGetAttrValue( itemNode, _T("url") ))) {
- JABBER_LIST_ITEM* item = ListAdd( LIST_BOOKMARK, jid );
+ else if ( !_tcscmp(name, _T("url")) && (jid = xmlGetAttrValue(itemNode, _T("url") ))) {
+ JABBER_LIST_ITEM* item = ListAdd(LIST_BOOKMARK, jid);
item->bUseResource = TRUE;
- item->name = mir_tstrdup( xmlGetAttrValue( itemNode, _T("name")));
- item->type = mir_tstrdup( _T("url"));
+ item->name = mir_tstrdup(xmlGetAttrValue(itemNode, _T("name")));
+ item->type = mir_tstrdup(_T("url"));
}
}
}
@@ -1615,10 +1615,10 @@ void CJabberProto::OnIqResultDiscoBookmarks( HXML iqNode ) OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_BOOKMARKS);
}
}
- else if ( !lstrcmp( type, _T("error"))) {
- if ( m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE ) {
+ else if ( !lstrcmp(type, _T("error"))) {
+ if (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE) {
m_ThreadInfo->jabberServerCaps &= ~JABBER_CAPS_PRIVATE_STORAGE;
- EnableMenuItems( TRUE );
+ EnableMenuItems(TRUE);
UI_SAFE_NOTIFY(m_pDlgBookmarks, WM_JABBER_ACTIVATE);
return;
}
@@ -1626,77 +1626,77 @@ void CJabberProto::OnIqResultDiscoBookmarks( HXML iqNode ) void CJabberProto::SetBookmarkRequest (XmlNodeIq& iq)
{
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE));
- HXML storage = query << XCHILDNS( _T("storage"), _T("storage:bookmarks"));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE));
+ HXML storage = query << XCHILDNS(_T("storage"), _T("storage:bookmarks"));
LISTFOREACH(i, this, LIST_BOOKMARK)
{
- JABBER_LIST_ITEM* item = ListGetItemPtrFromIndex( i );
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtrFromIndex(i);
+ if (item == NULL)
continue;
- if ( item->jid == NULL )
+ if (item->jid == NULL)
continue;
- if ( !lstrcmp( item->type, _T("conference"))) {
- HXML itemNode = storage << XCHILD( _T("conference")) << XATTR( _T("jid"), item->jid );
- if ( item->name )
- itemNode << XATTR( _T("name"), item->name );
- if ( item->bAutoJoin )
- itemNode << XATTRI( _T("autojoin"), 1 );
- if ( item->nick )
- itemNode << XCHILD( _T("nick"), item->nick );
- if ( item->password )
- itemNode << XCHILD( _T("password"), item->password );
+ if ( !lstrcmp(item->type, _T("conference"))) {
+ HXML itemNode = storage << XCHILD(_T("conference")) << XATTR(_T("jid"), item->jid);
+ if (item->name)
+ itemNode << XATTR(_T("name"), item->name);
+ if (item->bAutoJoin)
+ itemNode << XATTRI(_T("autojoin"), 1);
+ if (item->nick)
+ itemNode << XCHILD(_T("nick"), item->nick);
+ if (item->password)
+ itemNode << XCHILD(_T("password"), item->password);
}
- if ( !lstrcmp( item->type, _T("url"))) {
- HXML itemNode = storage << XCHILD( _T("url")) << XATTR( _T("url"), item->jid );
- if ( item->name )
- itemNode << XATTR( _T("name"), item->name );
+ if ( !lstrcmp(item->type, _T("url"))) {
+ HXML itemNode = storage << XCHILD(_T("url")) << XATTR(_T("url"), item->jid);
+ if (item->name)
+ itemNode << XATTR(_T("name"), item->name);
}
}
}
-void CJabberProto::OnIqResultSetBookmarks( HXML iqNode )
+void CJabberProto::OnIqResultSetBookmarks(HXML iqNode)
{
// RECVED: server's response
// ACTION: refresh bookmarks list dialog
- Log( "<iq/> iqIdSetBookmarks" );
+ Log("<iq/> iqIdSetBookmarks");
- const TCHAR* type = xmlGetAttrValue( iqNode, _T("type"));
- if ( type == NULL )
+ const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
+ if (type == NULL)
return;
- if ( !lstrcmp( type, _T("result"))) {
+ if ( !lstrcmp(type, _T("result"))) {
UI_SAFE_NOTIFY(m_pDlgBookmarks, WM_JABBER_REFRESH);
}
- else if ( !lstrcmp( type, _T("error"))) {
- HXML errorNode = xmlGetChild( iqNode , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
- MessageBox( NULL, str, TranslateT( "Jabber Bookmarks Error" ), MB_OK|MB_SETFOREGROUND );
- mir_free( str );
+ else if ( !lstrcmp(type, _T("error"))) {
+ HXML errorNode = xmlGetChild(iqNode , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
+ MessageBox(NULL, str, TranslateT("Jabber Bookmarks Error"), MB_OK|MB_SETFOREGROUND);
+ mir_free(str);
UI_SAFE_NOTIFY(m_pDlgBookmarks, WM_JABBER_ACTIVATE);
} }
// last activity (XEP-0012) support
-void CJabberProto::OnIqResultLastActivity( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultLastActivity(HXML iqNode, CJabberIqInfo* pInfo)
{
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( pInfo->m_szFrom );
- if ( !r )
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->m_szFrom);
+ if ( !r)
return;
time_t lastActivity = -1;
- if ( pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT ) {
- LPCTSTR szSeconds = XPathT( iqNode, "query[@xmlns='jabber:iq:last']/@seconds" );
- if ( szSeconds ) {
- int nSeconds = _ttoi( szSeconds );
- if ( nSeconds > 0 )
- lastActivity = time( 0 ) - nSeconds;
+ if (pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT) {
+ LPCTSTR szSeconds = XPathT(iqNode, "query[@xmlns='jabber:iq:last']/@seconds");
+ if (szSeconds) {
+ int nSeconds = _ttoi(szSeconds);
+ if (nSeconds > 0)
+ lastActivity = time(0) - nSeconds;
}
- LPCTSTR szLastStatusMessage = XPathT( iqNode, "query[@xmlns='jabber:iq:last']" );
- if ( szLastStatusMessage ) // replace only if it exists
- replaceStrT( r->statusMessage, szLastStatusMessage );
+ LPCTSTR szLastStatusMessage = XPathT(iqNode, "query[@xmlns='jabber:iq:last']");
+ if (szLastStatusMessage) // replace only if it exists
+ replaceStrT(r->statusMessage, szLastStatusMessage);
}
r->idleStartTime = lastActivity;
@@ -1705,38 +1705,38 @@ void CJabberProto::OnIqResultLastActivity( HXML iqNode, CJabberIqInfo* pInfo ) }
// entity time (XEP-0202) support
-void CJabberProto::OnIqResultEntityTime( HXML pIqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultEntityTime(HXML pIqNode, CJabberIqInfo* pInfo)
{
- if ( !pInfo->m_hContact )
+ if ( !pInfo->m_hContact)
return;
- if ( pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT ) {
- LPCTSTR szTzo = XPathFmt( pIqNode, _T("time[@xmlns='%s']/tzo"), _T( JABBER_FEAT_ENTITY_TIME ));
- if ( szTzo && szTzo[0] ) {
- LPCTSTR szMin = _tcschr( szTzo, ':' );
- int nTz = _ttoi( szTzo ) * -2;
- nTz += ( nTz < 0 ? -1 : 1 ) * ( szMin ? _ttoi( szMin + 1 ) / 30 : 0 );
+ if (pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT) {
+ LPCTSTR szTzo = XPathFmt(pIqNode, _T("time[@xmlns='%s']/tzo"), _T(JABBER_FEAT_ENTITY_TIME));
+ if (szTzo && szTzo[0]) {
+ LPCTSTR szMin = _tcschr(szTzo, ':');
+ int nTz = _ttoi(szTzo) * -2;
+ nTz += (nTz < 0 ? -1 : 1) * (szMin ? _ttoi(szMin + 1) / 30 : 0);
TIME_ZONE_INFORMATION tzinfo;
- if ( GetTimeZoneInformation( &tzinfo ) == TIME_ZONE_ID_DAYLIGHT )
+ if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT)
nTz -= tzinfo.DaylightBias / 30;
- JSetByte( pInfo->m_hContact, "Timezone", (signed char)nTz );
+ JSetByte(pInfo->m_hContact, "Timezone", (signed char)nTz);
- LPCTSTR szTz = XPathFmt( pIqNode, _T("time[@xmlns='%s']/tz"), _T( JABBER_FEAT_ENTITY_TIME ));
+ LPCTSTR szTz = XPathFmt(pIqNode, _T("time[@xmlns='%s']/tz"), _T(JABBER_FEAT_ENTITY_TIME));
if (szTz)
- JSetStringT( pInfo->m_hContact, "TzName", szTz );
+ JSetStringT(pInfo->m_hContact, "TzName", szTz);
else
- JDeleteSetting( pInfo->m_hContact, "TzName" );
+ JDeleteSetting(pInfo->m_hContact, "TzName");
return;
}
}
- else if ( pInfo->m_nIqType == JABBER_IQ_TYPE_ERROR )
+ else if (pInfo->m_nIqType == JABBER_IQ_TYPE_ERROR)
{
- if ( JGetWord( pInfo->m_hContact, "Status", ID_STATUS_OFFLINE ) == ID_STATUS_OFFLINE )
+ if (JGetWord(pInfo->m_hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
return;
}
- JDeleteSetting( pInfo->m_hContact, "Timezone" );
- JDeleteSetting( pInfo->m_hContact, "TzName" );
+ JDeleteSetting(pInfo->m_hContact, "Timezone");
+ JDeleteSetting(pInfo->m_hContact, "TzName");
}
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index 3621506d29..689ce8ef54 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.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
@@ -25,44 +25,44 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_iq.h"
#include "jabber_caps.h"
-void CJabberProto::SetMucConfig( HXML node, void *from )
+void CJabberProto::SetMucConfig(HXML node, void *from)
{
- if ( m_ThreadInfo && from ) {
- XmlNodeIq iq( _T("set"), SerialNext(), ( TCHAR* )from );
- HXML query = iq << XQUERY( xmlnsOwner );
- xmlAddChild( query, node );
- m_ThreadInfo->send( iq );
+ if (m_ThreadInfo && from) {
+ XmlNodeIq iq(_T("set"), SerialNext(), (TCHAR*)from);
+ HXML query = iq << XQUERY(xmlnsOwner);
+ xmlAddChild(query, node);
+ m_ThreadInfo->send(iq);
} }
void LaunchForm(HXML node);
-void CJabberProto::OnIqResultGetMuc( HXML iqNode )
+void CJabberProto::OnIqResultGetMuc(HXML iqNode)
{
HXML queryNode, xNode;
const TCHAR *type, *from, *str;
// RECVED: room config form
// ACTION: show the form
- Log( "<iq/> iqIdGetMuc" );
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
- if (( from = xmlGetAttrValue( iqNode, _T("from"))) == NULL ) return;
-
- if ( !_tcscmp( type, _T("result"))) {
- if (( queryNode = xmlGetChild( iqNode , "query" )) != NULL ) {
- str = xmlGetAttrValue( queryNode, _T("xmlns"));
- if ( !lstrcmp( str, _T("http://jabber.org/protocol/muc#owner" ))) {
- if (( xNode = xmlGetChild( queryNode , "x" )) != NULL ) {
- str = xmlGetAttrValue( xNode, _T("xmlns"));
- if ( !lstrcmp( str, _T(JABBER_FEAT_DATA_FORMS)))
+ Log("<iq/> iqIdGetMuc");
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
+ if ((from = xmlGetAttrValue(iqNode, _T("from"))) == NULL) return;
+
+ if ( !_tcscmp(type, _T("result"))) {
+ if ((queryNode = xmlGetChild(iqNode , "query")) != NULL) {
+ str = xmlGetAttrValue(queryNode, _T("xmlns"));
+ if ( !lstrcmp(str, _T("http://jabber.org/protocol/muc#owner"))) {
+ if ((xNode = xmlGetChild(queryNode , "x")) != NULL) {
+ str = xmlGetAttrValue(xNode, _T("xmlns"));
+ if ( !lstrcmp(str, _T(JABBER_FEAT_DATA_FORMS)))
//LaunchForm(xNode);
- FormCreateDialog( xNode, _T("Jabber Conference Room Configuration"), &CJabberProto::SetMucConfig, mir_tstrdup( from ));
+ FormCreateDialog(xNode, _T("Jabber Conference Room Configuration"), &CJabberProto::SetMucConfig, mir_tstrdup(from));
} } } } }
static void sttFillJidList(HWND hwndDlg)
{
JABBER_MUC_JIDLIST_INFO *jidListInfo;
HXML iqNode, queryNode;
- const TCHAR* from, *jid, *reason, *nick;
+ const TCHAR *from, *jid, *reason, *nick;
LVITEM lvi;
HWND hwndList;
int count, i;
@@ -75,66 +75,66 @@ static void sttFillJidList(HWND hwndDlg) GetDlgItemText(hwndDlg, IDC_FILTER, filter, filterLength);
}
- jidListInfo = ( JABBER_MUC_JIDLIST_INFO * ) GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
- if ( !jidListInfo )
+ jidListInfo = (JABBER_MUC_JIDLIST_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if ( !jidListInfo)
return;
- hwndList = GetDlgItem( hwndDlg, IDC_LIST );
+ hwndList = GetDlgItem(hwndDlg, IDC_LIST);
SendMessage(hwndList, WM_SETREDRAW, FALSE, 0);
- count = ListView_GetItemCount( hwndList );
+ count = ListView_GetItemCount(hwndList);
lvi.mask = LVIF_PARAM;
lvi.iSubItem = 0;
- for ( i=0; i<count; i++ ) {
+ for (i=0; i<count; i++) {
lvi.iItem = i;
- if ( ListView_GetItem( hwndList, &lvi ) == TRUE ) {
- if ( lvi.lParam!=( LPARAM )( -1 ) && lvi.lParam!=( LPARAM )( NULL )) {
- mir_free(( void * ) lvi.lParam );
+ if (ListView_GetItem(hwndList, &lvi) == TRUE) {
+ if (lvi.lParam!=(LPARAM)(-1) && lvi.lParam!=(LPARAM)(NULL)) {
+ mir_free((void *) lvi.lParam);
}
}
}
- ListView_DeleteAllItems( hwndList );
+ ListView_DeleteAllItems(hwndList);
// Populate displayed list from iqNode
- if (( iqNode = jidListInfo->iqNode ) != NULL ) {
- if (( from = xmlGetAttrValue( iqNode, _T("from"))) != NULL ) {
- if (( queryNode = xmlGetChild( iqNode , "query" )) != NULL ) {
+ if ((iqNode = jidListInfo->iqNode) != NULL) {
+ if ((from = xmlGetAttrValue(iqNode, _T("from"))) != NULL) {
+ if ((queryNode = xmlGetChild(iqNode , "query")) != NULL) {
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iSubItem = 0;
lvi.iItem = 0;
- for ( i=0; ; i++ ) {
- HXML itemNode = xmlGetChild( queryNode ,i);
- if ( !itemNode )
+ for (i=0; ; i++) {
+ HXML itemNode = xmlGetChild(queryNode ,i);
+ if ( !itemNode)
break;
- if (( jid = xmlGetAttrValue( itemNode, _T("jid"))) != NULL ) {
- lvi.pszText = ( TCHAR* )jid;
- if ( jidListInfo->type == MUC_BANLIST ) {
- if (( reason = xmlGetText(xmlGetChild( itemNode , "reason" ))) != NULL ) {
+ if ((jid = xmlGetAttrValue(itemNode, _T("jid"))) != NULL) {
+ lvi.pszText = (TCHAR*)jid;
+ if (jidListInfo->type == MUC_BANLIST) {
+ if ((reason = xmlGetText(xmlGetChild(itemNode , "reason"))) != NULL) {
TCHAR jidreason[ JABBER_MAX_JID_LEN + 256 ];
- mir_sntprintf( jidreason, SIZEOF( jidreason ), _T("%s (%s)") , jid, reason );
+ mir_sntprintf(jidreason, SIZEOF(jidreason), _T("%s (%s)") , jid, reason);
lvi.pszText = jidreason;
} }
- if ( jidListInfo->type == MUC_VOICELIST || jidListInfo->type == MUC_MODERATORLIST ) {
- if (( nick = xmlGetAttrValue( itemNode, _T("nick"))) != NULL ) {
+ if (jidListInfo->type == MUC_VOICELIST || jidListInfo->type == MUC_MODERATORLIST) {
+ if ((nick = xmlGetAttrValue(itemNode, _T("nick"))) != NULL) {
TCHAR nickjid[ JABBER_MAX_JID_LEN + 256 ];
- mir_sntprintf( nickjid, SIZEOF( nickjid ), _T("%s (%s)") , nick, jid );
+ mir_sntprintf(nickjid, SIZEOF(nickjid), _T("%s (%s)") , nick, jid);
lvi.pszText = nickjid;
} }
if (filter && *filter && !JabberStrIStr(lvi.pszText, filter))
continue;
- lvi.lParam = ( LPARAM )mir_tstrdup( jid );
+ lvi.lParam = (LPARAM)mir_tstrdup(jid);
- ListView_InsertItem( hwndList, &lvi );
+ ListView_InsertItem(hwndList, &lvi);
lvi.iItem++;
} } } } }
lvi.mask = LVIF_PARAM;
- lvi.lParam = ( LPARAM )( -1 );
- ListView_InsertItem( hwndList, &lvi );
+ lvi.lParam = (LPARAM)(-1);
+ ListView_InsertItem(hwndList, &lvi);
SendMessage(hwndList, WM_SETREDRAW, TRUE, 0);
RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE);
@@ -155,29 +155,29 @@ static int sttJidListResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
}
-static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JABBER_MUC_JIDLIST_INFO* dat = (JABBER_MUC_JIDLIST_INFO*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JABBER_MUC_JIDLIST_INFO* dat = (JABBER_MUC_JIDLIST_INFO*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch( msg ) {
+ switch(msg) {
case WM_INITDIALOG:
{
LVCOLUMN lvc;
RECT rc;
HWND hwndList;
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
- hwndList = GetDlgItem( hwndDlg, IDC_LIST );
+ hwndList = GetDlgItem(hwndDlg, IDC_LIST);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
- GetClientRect( hwndList, &rc );
- //rc.right -= GetSystemMetrics( SM_CXVSCROLL );
+ GetClientRect(hwndList, &rc);
+ //rc.right -= GetSystemMetrics(SM_CXVSCROLL);
lvc.mask = LVCF_WIDTH;
lvc.cx = rc.right - 20;
- ListView_InsertColumn( hwndList, 0, &lvc );
+ ListView_InsertColumn(hwndList, 0, &lvc);
lvc.cx = 20;
- ListView_InsertColumn( hwndList, 1, &lvc );
- SendMessage( hwndDlg, WM_JABBER_REFRESH, 0, lParam );
+ ListView_InsertColumn(hwndList, 1, &lvc);
+ SendMessage(hwndDlg, WM_JABBER_REFRESH, 0, lParam);
dat = (JABBER_MUC_JIDLIST_INFO*)lParam;
static struct
@@ -215,10 +215,10 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM RECT listrc;
LVCOLUMN lvc;
- HWND hwndList = GetDlgItem( hwndDlg, IDC_LIST );
- GetClientRect( hwndList, &listrc );
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+ GetClientRect(hwndList, &listrc);
lvc.mask = LVCF_WIDTH;
- //listrc.right -= GetSystemMetrics( SM_CXVSCROLL );
+ //listrc.right -= GetSystemMetrics(SM_CXVSCROLL);
lvc.cx = listrc.right - 20;
SendMessage(hwndList, LVM_SETCOLUMN, 0, (LPARAM)&lvc);
break;
@@ -227,131 +227,131 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM case WM_JABBER_REFRESH:
{
- // lParam is ( JABBER_MUC_JIDLIST_INFO * )
+ // lParam is (JABBER_MUC_JIDLIST_INFO *)
HXML iqNode, queryNode;
- const TCHAR* from;
+ const TCHAR *from;
TCHAR title[256];
// Clear current GWL_USERDATA, if any
- if ( dat != NULL )
+ if (dat != NULL)
delete dat;
// Set new GWL_USERDATA
- dat = ( JABBER_MUC_JIDLIST_INFO * ) lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR ) dat );
+ dat = (JABBER_MUC_JIDLIST_INFO *) lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) dat);
// Populate displayed list from iqNode
- lstrcpyn( title, TranslateT( "JID List" ), SIZEOF( title ));
- if (( dat=( JABBER_MUC_JIDLIST_INFO * ) lParam ) != NULL ) {
- if (( iqNode = dat->iqNode ) != NULL ) {
- if (( from = xmlGetAttrValue( iqNode, _T("from"))) != NULL ) {
- dat->roomJid = mir_tstrdup( from );
-
- if (( queryNode = xmlGetChild( iqNode , "query" )) != NULL ) {
- TCHAR* localFrom = mir_tstrdup( from );
- mir_sntprintf( title, SIZEOF( title ), TranslateT("%s, %d items (%s)"),
- ( dat->type == MUC_VOICELIST ) ? TranslateT( "Voice List" ) :
- ( dat->type == MUC_MEMBERLIST ) ? TranslateT( "Member List" ) :
- ( dat->type == MUC_MODERATORLIST ) ? TranslateT( "Moderator List" ) :
- ( dat->type == MUC_BANLIST ) ? TranslateT( "Ban List" ) :
- ( dat->type == MUC_ADMINLIST ) ? TranslateT( "Admin List" ) :
- ( dat->type == MUC_OWNERLIST ) ? TranslateT( "Owner List" ) :
- TranslateT( "JID List" ), xmlGetChildCount(queryNode), localFrom );
- mir_free( localFrom );
+ lstrcpyn(title, TranslateT("JID List"), SIZEOF(title));
+ if ((dat=(JABBER_MUC_JIDLIST_INFO *) lParam) != NULL) {
+ if ((iqNode = dat->iqNode) != NULL) {
+ if ((from = xmlGetAttrValue(iqNode, _T("from"))) != NULL) {
+ dat->roomJid = mir_tstrdup(from);
+
+ if ((queryNode = xmlGetChild(iqNode , "query")) != NULL) {
+ TCHAR* localFrom = mir_tstrdup(from);
+ mir_sntprintf(title, SIZEOF(title), TranslateT("%s, %d items (%s)"),
+ (dat->type == MUC_VOICELIST) ? TranslateT("Voice List") :
+ (dat->type == MUC_MEMBERLIST) ? TranslateT("Member List") :
+ (dat->type == MUC_MODERATORLIST) ? TranslateT("Moderator List") :
+ (dat->type == MUC_BANLIST) ? TranslateT("Ban List") :
+ (dat->type == MUC_ADMINLIST) ? TranslateT("Admin List") :
+ (dat->type == MUC_OWNERLIST) ? TranslateT("Owner List") :
+ TranslateT("JID List"), xmlGetChildCount(queryNode), localFrom);
+ mir_free(localFrom);
} } } }
- SetWindowText( hwndDlg, title );
+ SetWindowText(hwndDlg, title);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 0);
sttFillJidList(hwndDlg);
}
break;
case WM_NOTIFY:
- if (( ( LPNMHDR )lParam )->idFrom == IDC_LIST ) {
- switch (( ( LPNMHDR )lParam )->code ) {
+ if (((LPNMHDR)lParam)->idFrom == IDC_LIST) {
+ switch (((LPNMHDR)lParam)->code) {
case NM_CUSTOMDRAW:
{
- NMLVCUSTOMDRAW *nm = ( NMLVCUSTOMDRAW * ) lParam;
+ NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW *) lParam;
- switch ( nm->nmcd.dwDrawStage ) {
+ switch (nm->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
case CDDS_ITEMPREPAINT:
- SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW );
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
return TRUE;
case CDDS_SUBITEM|CDDS_ITEMPREPAINT:
{
RECT rc;
HICON hIcon;
- ListView_GetSubItemRect( nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc );
- if ( nm->iSubItem == 1 ) {
- if ( nm->nmcd.lItemlParam == ( LPARAM )( -1 ))
- hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_ADDCONTACT ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
+ ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
+ if (nm->iSubItem == 1) {
+ if (nm->nmcd.lItemlParam == (LPARAM)(-1))
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
else
- hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_DELETE ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
- DrawIconEx( nm->nmcd.hdc, ( rc.left+rc.right-GetSystemMetrics( SM_CXSMICON ))/2, ( rc.top+rc.bottom-GetSystemMetrics( SM_CYSMICON ))/2,hIcon, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL );
- DestroyIcon( hIcon );
- SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT );
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2,hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL);
+ DestroyIcon(hIcon);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
return TRUE;
} } } }
break;
case NM_CLICK:
{
- NMLISTVIEW *nm = ( NMLISTVIEW * ) lParam;
+ NMLISTVIEW *nm = (NMLISTVIEW *) lParam;
LVITEM lvi;
LVHITTESTINFO hti;
TCHAR text[128];
- if ( nm->iSubItem < 1 )
+ if (nm->iSubItem < 1)
break;
- hti.pt.x = ( short ) LOWORD( GetMessagePos());
- hti.pt.y = ( short ) HIWORD( GetMessagePos());
- ScreenToClient( nm->hdr.hwndFrom, &hti.pt );
- if ( ListView_SubItemHitTest( nm->hdr.hwndFrom, &hti ) == -1 )
+ hti.pt.x = (short) LOWORD(GetMessagePos());
+ hti.pt.y = (short) HIWORD(GetMessagePos());
+ ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
+ if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1)
break;
- if ( hti.iSubItem != 1 )
+ if (hti.iSubItem != 1)
break;
lvi.mask = LVIF_PARAM | LVIF_TEXT;
lvi.iItem = hti.iItem;
lvi.iSubItem = 0;
lvi.pszText = text;
- lvi.cchTextMax = sizeof( text );
- ListView_GetItem( nm->hdr.hwndFrom, &lvi );
- if ( lvi.lParam == ( LPARAM )( -1 )) {
+ lvi.cchTextMax = sizeof(text);
+ ListView_GetItem(nm->hdr.hwndFrom, &lvi);
+ if (lvi.lParam == (LPARAM)(-1)) {
TCHAR szBuffer[ 1024 ];
- _tcscpy( szBuffer, dat->type2str());
+ _tcscpy(szBuffer, dat->type2str());
if ( !dat->ppro->EnterString(szBuffer, SIZEOF(szBuffer), NULL, JES_COMBO, "gcAddNick_"))
break;
// Trim leading and trailing whitespaces
TCHAR *p = szBuffer, *q;
- for ( p = szBuffer; *p!='\0' && isspace( BYTE( *p )); p++);
- for ( q = p; *q!='\0' && !isspace( BYTE( *q )); q++);
+ for (p = szBuffer; *p!='\0' && isspace(BYTE(*p)); p++);
+ for (q = p; *q!='\0' && !isspace(BYTE(*q)); q++);
if (*q != '\0') *q = '\0';
if (*p == '\0')
break;
TCHAR rsn[ 1024 ];
- _tcscpy( rsn, dat->type2str());
- if ( dat->type == MUC_BANLIST ) {
+ _tcscpy(rsn, dat->type2str());
+ if (dat->type == MUC_BANLIST) {
dat->ppro->EnterString(rsn, SIZEOF(rsn), TranslateT("Reason to ban") , JES_COMBO, "gcAddReason_");
- if ( szBuffer )
- dat->ppro->AddMucListItem( dat, p , rsn);
+ if (szBuffer)
+ dat->ppro->AddMucListItem(dat, p , rsn);
else
- dat->ppro->AddMucListItem( dat, p );
+ dat->ppro->AddMucListItem(dat, p);
}
- else dat->ppro->AddMucListItem( dat, p );
+ else dat->ppro->AddMucListItem(dat, p);
}
else {
//delete
TCHAR msgText[128];
- mir_sntprintf( msgText, SIZEOF( msgText ), _T("%s %s?"), TranslateT( "Removing" ), text );
- if ( MessageBox( hwndDlg, msgText, dat->type2str(), MB_YESNO|MB_SETFOREGROUND ) == IDYES ) {
- dat->ppro->DeleteMucListItem( dat, ( TCHAR* )lvi.lParam );
- mir_free(( void * )lvi.lParam );
- ListView_DeleteItem( nm->hdr.hwndFrom, hti.iItem );
+ mir_sntprintf(msgText, SIZEOF(msgText), _T("%s %s?"), TranslateT("Removing"), text);
+ if (MessageBox(hwndDlg, msgText, dat->type2str(), MB_YESNO|MB_SETFOREGROUND) == IDYES) {
+ dat->ppro->DeleteMucListItem(dat, (TCHAR*)lvi.lParam);
+ mir_free((void *)lvi.lParam);
+ ListView_DeleteItem(nm->hdr.hwndFrom, hti.iItem);
} } }
break;
}
@@ -373,12 +373,12 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM }
break;
/* case WM_SETCURSOR:
- if ( LOWORD( LPARAM )!= HTCLIENT ) break;
- if ( GetForegroundWindow() == GetParent( hwndDlg )) {
+ if (LOWORD(LPARAM)!= HTCLIENT) break;
+ if (GetForegroundWindow() == GetParent(hwndDlg)) {
POINT pt;
- GetCursorPos( &pt );
- ScreenToClient( hwndDlg,&pt );
- SetFocus( ChildWindowFromPoint( hwndDlg,pt )); //ugly hack because listviews ignore their first click
+ GetCursorPos(&pt);
+ ScreenToClient(hwndDlg,&pt);
+ SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click
}
break;
*/ case WM_CLOSE:
@@ -388,22 +388,22 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM LVITEM lvi;
// Free lParam of the displayed list items
- hwndList = GetDlgItem( hwndDlg, IDC_LIST );
- count = ListView_GetItemCount( hwndList );
+ hwndList = GetDlgItem(hwndDlg, IDC_LIST);
+ count = ListView_GetItemCount(hwndList);
lvi.mask = LVIF_PARAM;
lvi.iSubItem = 0;
- for ( i=0; i<count; i++ ) {
+ for (i=0; i<count; i++) {
lvi.iItem = i;
- if ( ListView_GetItem( hwndList, &lvi ) == TRUE ) {
- if ( lvi.lParam!=( LPARAM )( -1 ) && lvi.lParam!=( LPARAM )( NULL )) {
- mir_free(( void * ) lvi.lParam );
+ if (ListView_GetItem(hwndList, &lvi) == TRUE) {
+ if (lvi.lParam!=(LPARAM)(-1) && lvi.lParam!=(LPARAM)(NULL)) {
+ mir_free((void *) lvi.lParam);
}
}
}
- ListView_DeleteAllItems( hwndList );
+ ListView_DeleteAllItems(hwndList);
CJabberProto* ppro = dat->ppro;
- switch ( dat->type ) {
+ switch (dat->type) {
case MUC_VOICELIST:
ppro->m_hwndMucVoiceList = NULL;
break;
@@ -424,13 +424,13 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM break;
}
- DestroyWindow( hwndDlg );
+ DestroyWindow(hwndDlg);
}
break;
case WM_DESTROY:
// Clear GWL_USERDATA
- if ( dat != NULL ) {
+ if (dat != NULL) {
Utils_SaveWindowPosition(hwndDlg, NULL, dat->ppro->m_szModuleName, "jidListWnd_");
delete dat;
}
@@ -439,20 +439,20 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc( HWND hwndDlg, UINT msg, WPARAM return FALSE;
}
-static void CALLBACK JabberMucJidListCreateDialogApcProc( void* param )
+static void CALLBACK JabberMucJidListCreateDialogApcProc(void* param)
{
HXML iqNode, queryNode;
- const TCHAR* from;
+ const TCHAR *from;
HWND *pHwndJidList;
JABBER_MUC_JIDLIST_INFO *jidListInfo = (JABBER_MUC_JIDLIST_INFO *)param;
- if ( jidListInfo == NULL ) return;
- if (( iqNode = jidListInfo->iqNode ) == NULL ) return;
- if (( from = xmlGetAttrValue( iqNode, _T("from"))) == NULL ) return;
- if (( queryNode = xmlGetChild( iqNode , "query" )) == NULL ) return;
+ if (jidListInfo == NULL) return;
+ if ((iqNode = jidListInfo->iqNode) == NULL) return;
+ if ((from = xmlGetAttrValue(iqNode, _T("from"))) == NULL) return;
+ if ((queryNode = xmlGetChild(iqNode , "query")) == NULL) return;
CJabberProto* ppro = jidListInfo->ppro;
- switch ( jidListInfo->type ) {
+ switch (jidListInfo->type) {
case MUC_VOICELIST:
pHwndJidList = &ppro->m_hwndMucVoiceList;
break;
@@ -472,89 +472,89 @@ static void CALLBACK JabberMucJidListCreateDialogApcProc( void* param ) pHwndJidList = &ppro->m_hwndMucOwnerList;
break;
default:
- mir_free( jidListInfo );
+ mir_free(jidListInfo);
return;
}
- if ( *pHwndJidList!=NULL && IsWindow( *pHwndJidList )) {
- SetForegroundWindow( *pHwndJidList );
- SendMessage( *pHwndJidList, WM_JABBER_REFRESH, 0, ( LPARAM )jidListInfo );
+ if (*pHwndJidList!=NULL && IsWindow(*pHwndJidList)) {
+ SetForegroundWindow(*pHwndJidList);
+ SendMessage(*pHwndJidList, WM_JABBER_REFRESH, 0, (LPARAM)jidListInfo);
}
- else *pHwndJidList = CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_JIDLIST ), GetForegroundWindow(), JabberMucJidListDlgProc, ( LPARAM )jidListInfo );
+ else *pHwndJidList = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_JIDLIST), GetForegroundWindow(), JabberMucJidListDlgProc, (LPARAM)jidListInfo);
}
-void CJabberProto::OnIqResultMucGetJidList( HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType )
+void CJabberProto::OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType)
{
- const TCHAR* type;
+ const TCHAR *type;
JABBER_MUC_JIDLIST_INFO *jidListInfo;
- if (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL ) return;
+ if ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
- if ( !lstrcmp( type, _T("result" ))) {
- if (( jidListInfo = new JABBER_MUC_JIDLIST_INFO ) != NULL ) {
+ if ( !lstrcmp(type, _T("result"))) {
+ if ((jidListInfo = new JABBER_MUC_JIDLIST_INFO) != NULL) {
jidListInfo->type = listType;
jidListInfo->ppro = this;
jidListInfo->roomJid = NULL; // Set in the dialog procedure
- if (( jidListInfo->iqNode = xi.copyNode( iqNode )) != NULL )
- CallFunctionAsync( JabberMucJidListCreateDialogApcProc, jidListInfo );
+ if ((jidListInfo->iqNode = xi.copyNode(iqNode)) != NULL)
+ CallFunctionAsync(JabberMucJidListCreateDialogApcProc, jidListInfo);
else
- mir_free( jidListInfo );
+ mir_free(jidListInfo);
} } }
-void CJabberProto::OnIqResultMucGetVoiceList( HXML iqNode )
+void CJabberProto::OnIqResultMucGetVoiceList(HXML iqNode)
{
- Log( "<iq/> iqResultMucGetVoiceList" );
- OnIqResultMucGetJidList( iqNode, MUC_VOICELIST );
+ Log("<iq/> iqResultMucGetVoiceList");
+ OnIqResultMucGetJidList(iqNode, MUC_VOICELIST);
}
-void CJabberProto::OnIqResultMucGetMemberList( HXML iqNode )
+void CJabberProto::OnIqResultMucGetMemberList(HXML iqNode)
{
- Log( "<iq/> iqResultMucGetMemberList" );
- OnIqResultMucGetJidList( iqNode, MUC_MEMBERLIST );
+ Log("<iq/> iqResultMucGetMemberList");
+ OnIqResultMucGetJidList(iqNode, MUC_MEMBERLIST);
}
-void CJabberProto::OnIqResultMucGetModeratorList( HXML iqNode )
+void CJabberProto::OnIqResultMucGetModeratorList(HXML iqNode)
{
- Log( "<iq/> iqResultMucGetModeratorList" );
- OnIqResultMucGetJidList( iqNode, MUC_MODERATORLIST );
+ Log("<iq/> iqResultMucGetModeratorList");
+ OnIqResultMucGetJidList(iqNode, MUC_MODERATORLIST);
}
-void CJabberProto::OnIqResultMucGetBanList( HXML iqNode )
+void CJabberProto::OnIqResultMucGetBanList(HXML iqNode)
{
- Log( "<iq/> iqResultMucGetBanList" );
- OnIqResultMucGetJidList( iqNode, MUC_BANLIST );
+ Log("<iq/> iqResultMucGetBanList");
+ OnIqResultMucGetJidList(iqNode, MUC_BANLIST);
}
-void CJabberProto::OnIqResultMucGetAdminList( HXML iqNode )
+void CJabberProto::OnIqResultMucGetAdminList(HXML iqNode)
{
- Log( "<iq/> iqResultMucGetAdminList" );
- OnIqResultMucGetJidList( iqNode, MUC_ADMINLIST );
+ Log("<iq/> iqResultMucGetAdminList");
+ OnIqResultMucGetJidList(iqNode, MUC_ADMINLIST);
}
-void CJabberProto::OnIqResultMucGetOwnerList( HXML iqNode )
+void CJabberProto::OnIqResultMucGetOwnerList(HXML iqNode)
{
- Log( "<iq/> iqResultMucGetOwnerList" );
- OnIqResultMucGetJidList( iqNode, MUC_OWNERLIST );
+ Log("<iq/> iqResultMucGetOwnerList");
+ OnIqResultMucGetJidList(iqNode, MUC_OWNERLIST);
}
/////////////////////////////////////////////////////////////////////////////////////////
JABBER_MUC_JIDLIST_INFO::~JABBER_MUC_JIDLIST_INFO()
{
- xi.destroyNode( iqNode );
- mir_free( roomJid );
+ xi.destroyNode(iqNode);
+ mir_free(roomJid);
}
TCHAR* JABBER_MUC_JIDLIST_INFO::type2str() const
{
- switch( type ) {
- case MUC_VOICELIST: return TranslateT( "Voice List" );
- case MUC_MEMBERLIST: return TranslateT( "Member List" );
- case MUC_MODERATORLIST: return TranslateT( "Moderator List" );
- case MUC_BANLIST: return TranslateT( "Ban List" );
- case MUC_ADMINLIST: return TranslateT( "Admin List" );
- case MUC_OWNERLIST: return TranslateT( "Owner List" );
+ switch(type) {
+ case MUC_VOICELIST: return TranslateT("Voice List");
+ case MUC_MEMBERLIST: return TranslateT("Member List");
+ case MUC_MODERATORLIST: return TranslateT("Moderator List");
+ case MUC_BANLIST: return TranslateT("Ban List");
+ case MUC_ADMINLIST: return TranslateT("Admin List");
+ case MUC_OWNERLIST: return TranslateT("Owner List");
}
- return TranslateT( "JID List" );
+ return TranslateT("JID List");
}
diff --git a/protocols/JabberG/src/jabber_libstr.cpp b/protocols/JabberG/src/jabber_libstr.cpp index 4517d77272..58e1107051 100644 --- a/protocols/JabberG/src/jabber_libstr.cpp +++ b/protocols/JabberG/src/jabber_libstr.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
@@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int lstrcmp_null(const TCHAR *s1, const TCHAR *s2)
{
- if (!s1 && !s2) return 0;
- if (!s1) return -1;
- if (!s2) return 1;
+ if ( !s1 && !s2) return 0;
+ if ( !s1) return -1;
+ if ( !s2) return 1;
return lstrcmp(s1, s2);
}
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp index 8a956ebc47..29cc4ce200 100644 --- a/protocols/JabberG/src/jabber_list.cpp +++ b/protocols/JabberG/src/jabber_list.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -29,128 +29,128 @@ void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item); /////////////////////////////////////////////////////////////////////////////////////////
// List item freeing
-static void JabberListFreeResourceInternal( JABBER_RESOURCE_STATUS *r)
+static void JabberListFreeResourceInternal(JABBER_RESOURCE_STATUS *r)
{
- if ( r->resourceName ) mir_free( r->resourceName );
- if ( r->nick ) mir_free( r->nick );
- if ( r->statusMessage ) mir_free( r->statusMessage );
- if ( r->software ) mir_free( r->software );
- if ( r->version ) mir_free( r->version );
- if ( r->system ) mir_free( r->system );
- if ( r->szCapsNode ) mir_free( r->szCapsNode );
- if ( r->szCapsVer ) mir_free( r->szCapsVer );
- if ( r->szCapsExt ) mir_free( r->szCapsExt );
- if ( r->szRealJid ) mir_free( r->szRealJid );
- if ( r->pSoftwareInfo) delete r->pSoftwareInfo;
+ if (r->resourceName) mir_free(r->resourceName);
+ if (r->nick) mir_free(r->nick);
+ if (r->statusMessage) mir_free(r->statusMessage);
+ if (r->software) mir_free(r->software);
+ if (r->version) mir_free(r->version);
+ if (r->system) mir_free(r->system);
+ if (r->szCapsNode) mir_free(r->szCapsNode);
+ if (r->szCapsVer) mir_free(r->szCapsVer);
+ if (r->szCapsExt) mir_free(r->szCapsExt);
+ if (r->szRealJid) mir_free(r->szRealJid);
+ if (r->pSoftwareInfo) delete r->pSoftwareInfo;
}
-static void JabberListFreeItemInternal( JABBER_LIST_ITEM *item )
+static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item)
{
- if ( item == NULL )
+ if (item == NULL)
return;
- if ( item->jid ) mir_free( item->jid );
- if ( item->nick ) mir_free( item->nick );
+ if (item->jid) mir_free(item->jid);
+ if (item->nick) mir_free(item->nick);
JABBER_RESOURCE_STATUS* r = item->resource;
- for ( int i=0; i < item->resourceCount; i++, r++ )
- JabberListFreeResourceInternal( r );
- if ( item->resource ) mir_free( item->resource );
+ for (int i=0; i < item->resourceCount; i++, r++)
+ JabberListFreeResourceInternal(r);
+ if (item->resource) mir_free(item->resource);
- JabberListFreeResourceInternal( &item->itemResource );
+ JabberListFreeResourceInternal(&item->itemResource);
- if ( item->group ) mir_free( item->group );
- if ( item->photoFileName ) {
- DeleteFile( item->photoFileName );
- mir_free( item->photoFileName );
+ if (item->group) mir_free(item->group);
+ if (item->photoFileName) {
+ DeleteFile(item->photoFileName);
+ mir_free(item->photoFileName);
}
- if ( item->messageEventIdStr ) mir_free( item->messageEventIdStr );
- if ( item->name ) mir_free( item->name );
- if ( item->type ) mir_free( item->type );
- if ( item->service ) mir_free( item->service );
- if ( item->password ) mir_free( item->password );
- if ( item->list==LIST_ROSTER && item->ft ) delete item->ft;
- mir_free( item );
+ if (item->messageEventIdStr) mir_free(item->messageEventIdStr);
+ if (item->name) mir_free(item->name);
+ if (item->type) mir_free(item->type);
+ if (item->service) mir_free(item->service);
+ if (item->password) mir_free(item->password);
+ if (item->list==LIST_ROSTER && item->ft) delete item->ft;
+ mir_free(item);
}
-void CJabberProto::ListWipe( void )
+void CJabberProto::ListWipe(void)
{
int i;
- EnterCriticalSection( &m_csLists );
- for ( i=0; i < m_lstRoster.getCount(); i++ )
- JabberListFreeItemInternal( m_lstRoster[i] );
+ EnterCriticalSection(&m_csLists);
+ for (i=0; i < m_lstRoster.getCount(); i++)
+ JabberListFreeItemInternal(m_lstRoster[i]);
m_lstRoster.destroy();
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
}
-int CJabberProto::ListExist( JABBER_LIST list, const TCHAR* jid )
+int CJabberProto::ListExist(JABBER_LIST list, const TCHAR *jid)
{
JABBER_LIST_ITEM tmp;
tmp.list = list;
tmp.jid = (TCHAR*)jid;
tmp.bUseResource = FALSE;
- EnterCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
//fyr
- if ( list == LIST_ROSTER )
+ if (list == LIST_ROSTER)
{
tmp.list = LIST_CHATROOM;
- int id = m_lstRoster.getIndex( &tmp );
- if ( id != -1)
+ int id = m_lstRoster.getIndex(&tmp);
+ if (id != -1)
tmp.bUseResource = TRUE;
tmp.list = list;
}
- int idx = m_lstRoster.getIndex( &tmp );
+ int idx = m_lstRoster.getIndex(&tmp);
- if ( idx == -1 ) {
- LeaveCriticalSection( &m_csLists );
+ if (idx == -1) {
+ LeaveCriticalSection(&m_csLists);
return 0;
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return idx+1;
}
-JABBER_LIST_ITEM *CJabberProto::ListAdd( JABBER_LIST list, const TCHAR* jid )
+JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid)
{
JABBER_LIST_ITEM* item;
BOOL bUseResource=FALSE;
- EnterCriticalSection( &m_csLists );
- if (( item = ListGetItemPtr( list, jid )) != NULL ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ if ((item = ListGetItemPtr(list, jid)) != NULL) {
+ LeaveCriticalSection(&m_csLists);
return item;
}
- TCHAR *s = mir_tstrdup( jid );
+ TCHAR *s = mir_tstrdup(jid);
TCHAR *q = NULL;
// strip resource name if any
//fyr
- if ( !((list== LIST_ROSTER ) && ListExist(LIST_CHATROOM, jid))) { // but only if it is not chat room contact
- if ( list != LIST_VCARD_TEMP ) {
+ if ( !((list== LIST_ROSTER) && ListExist(LIST_CHATROOM, jid))) { // but only if it is not chat room contact
+ if (list != LIST_VCARD_TEMP) {
TCHAR *p;
- if (( p = _tcschr( s, '@' )) != NULL )
- if (( q = _tcschr( p, '/' )) != NULL )
+ if ((p = _tcschr(s, '@')) != NULL)
+ if ((q = _tcschr(p, '/')) != NULL)
*q = '\0';
}
} else {
bUseResource=TRUE;
}
- if ( !bUseResource && list== LIST_ROSTER )
+ if ( !bUseResource && list== LIST_ROSTER)
{
//if it is a chat room keep resource and made it resource sensitive
- if ( ChatRoomHContactFromJID( s ))
+ if (ChatRoomHContactFromJID(s))
{
if (q != NULL) *q='/';
bUseResource=TRUE;
}
}
- item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM ));
- ZeroMemory( item, sizeof( JABBER_LIST_ITEM ));
+ item = (JABBER_LIST_ITEM*)mir_alloc(sizeof(JABBER_LIST_ITEM));
+ ZeroMemory(item, sizeof(JABBER_LIST_ITEM));
item->list = list;
item->jid = s;
item->itemResource.status = ID_STATUS_OFFLINE;
@@ -160,211 +160,211 @@ JABBER_LIST_ITEM *CJabberProto::ListAdd( JABBER_LIST list, const TCHAR* jid ) item->manualResource = -1;
item->bUseResource = bUseResource;
- m_lstRoster.insert( item );
- LeaveCriticalSection( &m_csLists );
+ m_lstRoster.insert(item);
+ LeaveCriticalSection(&m_csLists);
MenuUpdateSrmmIcon(item);
return item;
}
-void CJabberProto::ListRemove( JABBER_LIST list, const TCHAR* jid )
+void CJabberProto::ListRemove(JABBER_LIST list, const TCHAR *jid)
{
- EnterCriticalSection( &m_csLists );
- int i = ListExist( list, jid );
- if ( i != 0 ) {
- JabberListFreeItemInternal( m_lstRoster[ --i ] );
- m_lstRoster.remove( i );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(list, jid);
+ if (i != 0) {
+ JabberListFreeItemInternal(m_lstRoster[ --i ]);
+ m_lstRoster.remove(i);
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
}
-void CJabberProto::ListRemoveList( JABBER_LIST list )
+void CJabberProto::ListRemoveList(JABBER_LIST list)
{
int i = 0;
- while (( i=ListFindNext( list, i )) >= 0 )
- ListRemoveByIndex( i );
+ while ((i=ListFindNext(list, i)) >= 0)
+ ListRemoveByIndex(i);
}
-void CJabberProto::ListRemoveByIndex( int index )
+void CJabberProto::ListRemoveByIndex(int index)
{
- EnterCriticalSection( &m_csLists );
- if ( index >= 0 && index < m_lstRoster.getCount()) {
- JabberListFreeItemInternal( m_lstRoster[index] );
- m_lstRoster.remove( index );
+ EnterCriticalSection(&m_csLists);
+ if (index >= 0 && index < m_lstRoster.getCount()) {
+ JabberListFreeItemInternal(m_lstRoster[index]);
+ m_lstRoster.remove(index);
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
}
-JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource( JABBER_LIST list, const TCHAR* jid )
+JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid)
{
JABBER_RESOURCE_STATUS *result = NULL;
- EnterCriticalSection( &m_csLists );
- int i = ListExist( list, jid );
- if ( !i ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(list, jid);
+ if ( !i) {
+ LeaveCriticalSection(&m_csLists);
return 0;
}
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
- const TCHAR* p = _tcschr( jid, '@' );
- const TCHAR* q = _tcschr(( p == NULL ) ? jid : p, '/' );
+ const TCHAR *p = _tcschr(jid, '@');
+ const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
if (q)
{
const TCHAR *resource = q+1;
if (*resource)
- for ( int j=0; j < LI->resourceCount; j++ )
- if ( !_tcscmp( LI->resource[j].resourceName, resource ))
+ for (int j=0; j < LI->resourceCount; j++)
+ if ( !_tcscmp(LI->resource[j].resourceName, resource))
{
result = LI->resource + j;
break;
}
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return result;
}
-int CJabberProto::ListAddResource( JABBER_LIST list, const TCHAR* jid, int status, const TCHAR* statusMessage, char priority, const TCHAR* nick )
+int CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority, const TCHAR *nick)
{
- EnterCriticalSection( &m_csLists );
- int i = ListExist( list, jid );
- if ( !i ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(list, jid);
+ if ( !i) {
+ LeaveCriticalSection(&m_csLists);
return 0;
}
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
int bIsNewResource = false, j;
- const TCHAR* p = _tcschr( jid, '@' );
- const TCHAR* q = _tcschr(( p == NULL ) ? jid : p, '/' );
- if ( q ) {
- const TCHAR* resource = q+1;
- if ( resource[0] ) {
+ const TCHAR *p = _tcschr(jid, '@');
+ const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
+ if (q) {
+ const TCHAR *resource = q+1;
+ if (resource[0]) {
JABBER_RESOURCE_STATUS* r = LI->resource;
- for ( j=0; j < LI->resourceCount; j++, r++ ) {
- if ( !_tcscmp( r->resourceName, resource )) {
+ for (j=0; j < LI->resourceCount; j++, r++) {
+ if ( !_tcscmp(r->resourceName, resource)) {
// Already exist, update status and statusMessage
r->status = status;
- replaceStrT( r->statusMessage, statusMessage );
+ replaceStrT(r->statusMessage, statusMessage);
r->priority = priority;
break;
} }
- if ( j >= LI->resourceCount ) {
+ if (j >= LI->resourceCount) {
// Not already exist, add new resource
- LI->resource = ( JABBER_RESOURCE_STATUS * ) mir_realloc( LI->resource, ( LI->resourceCount+1 )*sizeof( JABBER_RESOURCE_STATUS ));
+ LI->resource = (JABBER_RESOURCE_STATUS *) mir_realloc(LI->resource, (LI->resourceCount+1)*sizeof(JABBER_RESOURCE_STATUS));
bIsNewResource = true;
r = LI->resource + LI->resourceCount++;
- memset( r, 0, sizeof( JABBER_RESOURCE_STATUS ));
+ memset(r, 0, sizeof(JABBER_RESOURCE_STATUS));
r->status = status;
r->affiliation = AFFILIATION_NONE;
r->role = ROLE_NONE;
- r->resourceName = mir_tstrdup( resource );
- r->nick = mir_tstrdup( nick );
- if ( statusMessage )
- r->statusMessage = mir_tstrdup( statusMessage );
+ r->resourceName = mir_tstrdup(resource);
+ r->nick = mir_tstrdup(nick);
+ if (statusMessage)
+ r->statusMessage = mir_tstrdup(statusMessage);
r->priority = priority;
} }
}
// No resource, update the main statusMessage
else {
LI->itemResource.status = status;
- replaceStrT( LI->itemResource.statusMessage, statusMessage );
+ replaceStrT(LI->itemResource.statusMessage, statusMessage);
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
MenuUpdateSrmmIcon(LI);
return bIsNewResource;
}
-void CJabberProto::ListRemoveResource( JABBER_LIST list, const TCHAR* jid )
+void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid)
{
- EnterCriticalSection( &m_csLists );
- int i = ListExist( list, jid );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(list, jid);
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
- if ( !i || LI == NULL ) {
- LeaveCriticalSection( &m_csLists );
+ if ( !i || LI == NULL) {
+ LeaveCriticalSection(&m_csLists);
return;
}
- const TCHAR* p = _tcschr( jid, '@' );
- const TCHAR* q = _tcschr(( p == NULL ) ? jid : p, '/' );
- if ( q ) {
- const TCHAR* resource = q+1;
- if ( resource[0] ) {
+ const TCHAR *p = _tcschr(jid, '@');
+ const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
+ if (q) {
+ const TCHAR *resource = q+1;
+ if (resource[0]) {
JABBER_RESOURCE_STATUS* r = LI->resource;
int j;
- for ( j=0; j < LI->resourceCount; j++, r++ ) {
- if ( !_tcsicmp( r->resourceName, resource ))
+ for (j=0; j < LI->resourceCount; j++, r++) {
+ if ( !_tcsicmp(r->resourceName, resource))
break;
}
- if ( j < LI->resourceCount ) {
+ if (j < LI->resourceCount) {
// Found last seen resource ID to be removed
- if ( LI->lastSeenResource == j )
+ if (LI->lastSeenResource == j)
LI->lastSeenResource = -1;
- else if ( LI->lastSeenResource > j )
+ else if (LI->lastSeenResource > j)
LI->lastSeenResource--;
// update manually selected resource ID
if (LI->resourceMode == RSMODE_MANUAL)
{
- if ( LI->manualResource == j )
+ if (LI->manualResource == j)
{
LI->resourceMode = RSMODE_LASTSEEN;
LI->manualResource = -1;
- } else if ( LI->manualResource > j )
+ } else if (LI->manualResource > j)
LI->manualResource--;
}
// Update MirVer due to possible resource changes
UpdateMirVer(LI);
- JabberListFreeResourceInternal( r );
+ JabberListFreeResourceInternal(r);
- if ( LI->resourceCount-- == 1 ) {
- mir_free( r );
+ if (LI->resourceCount-- == 1) {
+ mir_free(r);
LI->resource = NULL;
}
else {
- memmove( r, r+1, ( LI->resourceCount-j )*sizeof( JABBER_RESOURCE_STATUS ));
- LI->resource = ( JABBER_RESOURCE_STATUS* )mir_realloc( LI->resource, LI->resourceCount*sizeof( JABBER_RESOURCE_STATUS ));
+ memmove(r, r+1, (LI->resourceCount-j)*sizeof(JABBER_RESOURCE_STATUS));
+ LI->resource = (JABBER_RESOURCE_STATUS*)mir_realloc(LI->resource, LI->resourceCount*sizeof(JABBER_RESOURCE_STATUS));
} } } }
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
MenuUpdateSrmmIcon(LI);
}
-TCHAR* CJabberProto::ListGetBestResourceNamePtr( const TCHAR* jid )
+TCHAR* CJabberProto::ListGetBestResourceNamePtr(const TCHAR *jid)
{
- EnterCriticalSection( &m_csLists );
- int i = ListExist( LIST_ROSTER, jid );
- if ( !i ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(LIST_ROSTER, jid);
+ if ( !i) {
+ LeaveCriticalSection(&m_csLists);
return NULL;
}
TCHAR* res = NULL;
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
- if ( LI->resourceCount > 1 ) {
- if ( LI->resourceMode == RSMODE_LASTSEEN && LI->lastSeenResource>=0 && LI->lastSeenResource < LI->resourceCount )
+ if (LI->resourceCount > 1) {
+ if (LI->resourceMode == RSMODE_LASTSEEN && LI->lastSeenResource>=0 && LI->lastSeenResource < LI->resourceCount)
res = LI->resource[ LI->lastSeenResource ].resourceName;
- else if (LI->resourceMode == RSMODE_MANUAL && LI->manualResource>=0 && LI->manualResource < LI->resourceCount )
+ else if (LI->resourceMode == RSMODE_MANUAL && LI->manualResource>=0 && LI->manualResource < LI->resourceCount)
res = LI->resource[ LI->manualResource ].resourceName;
else {
int nBestPos = -1, nBestPri = -200, j;
- for ( j = 0; j < LI->resourceCount; j++ ) {
- if ( LI->resource[ j ].priority > nBestPri ) {
+ for (j = 0; j < LI->resourceCount; j++) {
+ if (LI->resource[ j ].priority > nBestPri) {
nBestPri = LI->resource[ j ].priority;
nBestPos = j;
}
}
- if ( nBestPos != -1 )
+ if (nBestPos != -1)
res = LI->resource[ nBestPos ].resourceName;
}
}
@@ -372,103 +372,103 @@ TCHAR* CJabberProto::ListGetBestResourceNamePtr( const TCHAR* jid ) if ( !res && LI->resource)
res = LI->resource[0].resourceName;
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return res;
}
-TCHAR* CJabberProto::ListGetBestClientResourceNamePtr( const TCHAR* jid )
+TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
{
- EnterCriticalSection( &m_csLists );
- int i = ListExist( LIST_ROSTER, jid );
- if ( !i ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(LIST_ROSTER, jid);
+ if ( !i) {
+ LeaveCriticalSection(&m_csLists);
return NULL;
}
JABBER_LIST_ITEM* LI = m_lstRoster[i-1];
- TCHAR* res = ListGetBestResourceNamePtr( jid );
- if ( res == NULL ) {
+ TCHAR* res = ListGetBestResourceNamePtr(jid);
+ if (res == NULL) {
JABBER_RESOURCE_STATUS* r = LI->resource;
int status = ID_STATUS_OFFLINE;
res = NULL;
- for ( i=0; i < LI->resourceCount; i++ ) {
+ for (i=0; i < LI->resourceCount; i++) {
int s = r[i].status;
BOOL foundBetter = FALSE;
- switch ( s ) {
+ switch (s) {
case ID_STATUS_FREECHAT:
foundBetter = TRUE;
break;
case ID_STATUS_ONLINE:
- if ( status != ID_STATUS_FREECHAT )
+ if (status != ID_STATUS_FREECHAT)
foundBetter = TRUE;
break;
case ID_STATUS_DND:
- if ( status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE )
+ if (status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE)
foundBetter = TRUE;
break;
case ID_STATUS_AWAY:
- if ( status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE && status != ID_STATUS_DND )
+ if (status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE && status != ID_STATUS_DND)
foundBetter = TRUE;
break;
case ID_STATUS_NA:
- if ( status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE && status != ID_STATUS_DND && status != ID_STATUS_AWAY )
+ if (status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE && status != ID_STATUS_DND && status != ID_STATUS_AWAY)
foundBetter = TRUE;
break;
}
- if ( foundBetter ) {
+ if (foundBetter) {
res = r[i].resourceName;
status = s;
} } }
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return res;
}
-int CJabberProto::ListFindNext( JABBER_LIST list, int fromOffset )
+int CJabberProto::ListFindNext(JABBER_LIST list, int fromOffset)
{
- EnterCriticalSection( &m_csLists );
- int i = ( fromOffset >= 0 ) ? fromOffset : 0;
- for ( ; i<m_lstRoster.getCount(); i++ )
- if ( m_lstRoster[i]->list == list ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ int i = (fromOffset >= 0) ? fromOffset : 0;
+ for (; i<m_lstRoster.getCount(); i++)
+ if (m_lstRoster[i]->list == list) {
+ LeaveCriticalSection(&m_csLists);
return i;
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return -1;
}
-JABBER_LIST_ITEM *CJabberProto::ListGetItemPtr( JABBER_LIST list, const TCHAR* jid )
+JABBER_LIST_ITEM *CJabberProto::ListGetItemPtr(JABBER_LIST list, const TCHAR *jid)
{
- EnterCriticalSection( &m_csLists );
- int i = ListExist( list, jid );
- if ( !i ) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ int i = ListExist(list, jid);
+ if ( !i) {
+ LeaveCriticalSection(&m_csLists);
return NULL;
}
i--;
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return m_lstRoster[i];
}
-JABBER_LIST_ITEM *CJabberProto::ListGetItemPtrFromIndex( int index )
+JABBER_LIST_ITEM *CJabberProto::ListGetItemPtrFromIndex(int index)
{
- EnterCriticalSection( &m_csLists );
- if ( index >= 0 && index < m_lstRoster.getCount()) {
- LeaveCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
+ if (index >= 0 && index < m_lstRoster.getCount()) {
+ LeaveCriticalSection(&m_csLists);
return m_lstRoster[index];
}
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return NULL;
}
BOOL CJabberProto::ListLock()
{
- EnterCriticalSection( &m_csLists );
+ EnterCriticalSection(&m_csLists);
return TRUE;
}
BOOL CJabberProto::ListUnlock()
{
- LeaveCriticalSection( &m_csLists );
+ LeaveCriticalSection(&m_csLists);
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h index 503a479ece..24beee26c7 100644 --- a/protocols/JabberG/src/jabber_list.h +++ b/protocols/JabberG/src/jabber_list.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -61,9 +61,9 @@ typedef enum { } JABBER_GC_ROLE;
typedef enum { // initial default to RSMODE_LASTSEEN
- RSMODE_SERVER, // always let server decide ( always send correspondence without resouce name )
- RSMODE_LASTSEEN, // use the last seen resource ( or let server decide if haven't seen anything yet )
- RSMODE_MANUAL // specify resource manually ( see the defaultResource field - must not be NULL )
+ RSMODE_SERVER, // always let server decide (always send correspondence without resouce name)
+ RSMODE_LASTSEEN, // use the last seen resource (or let server decide if haven't seen anything yet)
+ RSMODE_MANUAL // specify resource manually (see the defaultResource field - must not be NULL)
} JABBER_RESOURCE_MODE;
@@ -78,7 +78,7 @@ struct JABBER_XEP0232_SOFTWARE_INFO BOOL bXMirandaIsAlpha;
BOOL bXMirandaIsDebug;
JABBER_XEP0232_SOFTWARE_INFO() {
- ZeroMemory( this, sizeof( JABBER_XEP0232_SOFTWARE_INFO ));
+ ZeroMemory(this, sizeof(JABBER_XEP0232_SOFTWARE_INFO));
}
~JABBER_XEP0232_SOFTWARE_INFO() {
mir_free(szOs);
@@ -131,7 +131,7 @@ struct JABBER_LIST_ITEM JABBER_RESOURCE_STATUS itemResource; // resource for jids without /resource node
int lastSeenResource; // index to resource[x] which was last seen active
int manualResource; // manually set index to resource[x]
-// int defaultResource; // index to resource[x] which is the default, negative ( -1 ) means no resource is chosen yet
+// int defaultResource; // index to resource[x] which is the default, negative (-1) means no resource is chosen yet
JABBER_RESOURCE_MODE resourceMode;
JABBER_SUBSCRIPTION subscription;
TCHAR* group;
@@ -150,7 +150,7 @@ struct JABBER_LIST_ITEM // LIST_CHATROOM
// jid = room JID
- // char* nick; // my nick in this chat room ( SPECIAL: in TXT )
+ // char* nick; // my nick in this chat room (SPECIAL: in TXT)
// JABBER_RESOURCE_STATUS *resource; // participant nicks in this room
BOOL bChatActive;
HWND hwndGcListBan;
@@ -161,7 +161,7 @@ struct JABBER_LIST_ITEM // LIST_FILE
// jid = string representation of port number
- filetransfer* ft;
+ filetransfer *ft;
WORD port;
// LIST_BYTE
@@ -171,7 +171,7 @@ struct JABBER_LIST_ITEM JABBER_IBB_TRANSFER *jibb;
// LIST_FTRECV
- // jid = string representation of stream id ( sid )
+ // jid = string representation of stream id (sid)
// ft = file transfer data
//LIST_BOOKMARK
@@ -190,7 +190,7 @@ struct JABBER_HTTP_AVATARS char * Url;
HANDLE hContact;
- JABBER_HTTP_AVATARS(const TCHAR* tUrl, HANDLE thContact)
+ JABBER_HTTP_AVATARS(const TCHAR *tUrl, HANDLE thContact)
: Url(mir_t2a(tUrl)), hContact(thContact) {}
~JABBER_HTTP_AVATARS() { mir_free(Url); }
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index e13a56864d..225a4fccc2 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -72,149 +72,149 @@ static struct };
static HGENMENU g_hMenuDirectPresence[SIZEOF(PresenceModeArray) + 1];
-static INT_PTR JabberMenuChooseService( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuChooseService(WPARAM wParam, LPARAM lParam)
{
- if ( lParam )
- *( void** )lParam = ( void* )wParam;
+ if (lParam)
+ *(void**)lParam = (void*)wParam;
return 0;
}
-static CJabberProto* JabberGetInstanceByHContact( HANDLE hContact )
+static CJabberProto* JabberGetInstanceByHContact(HANDLE hContact)
{
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto == NULL )
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto == NULL)
return NULL;
- for ( int i=0; i < g_Instances.getCount(); i++ )
- if ( !strcmp( szProto, g_Instances[i]->m_szModuleName ))
+ for (int i=0; i < g_Instances.getCount(); i++)
+ if ( !strcmp(szProto, g_Instances[i]->m_szModuleName))
return g_Instances[i];
return NULL;
}
-static INT_PTR JabberMenuHandleRequestAuth( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuHandleRequestAuth( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuHandleRequestAuth(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuHandleGrantAuth( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuHandleGrantAuth(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuHandleGrantAuth( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuHandleGrantAuth(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuRevokeAuth( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuRevokeAuth(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuRevokeAuth( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuRevokeAuth(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuConvertChatContact( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuConvertChatContact(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuConvertChatContact( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuConvertChatContact(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuRosterAdd( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuRosterAdd(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuRosterAdd( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuRosterAdd(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuBookmarkAdd( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuBookmarkAdd(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuBookmarkAdd( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuBookmarkAdd(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuTransportLogin( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuTransportLogin(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuTransportLogin( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuTransportLogin(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuTransportResolve( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuTransportResolve(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuTransportResolve( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuTransportResolve(wParam, lParam) : 0;
}
-static INT_PTR JabberContactMenuRunCommands( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberContactMenuRunCommands(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->ContactMenuRunCommands( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->ContactMenuRunCommands(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuSendNote( WPARAM wParam, LPARAM lParam )
+static INT_PTR JabberMenuSendNote(WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuSendNote( wParam, lParam ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuSendNote(wParam, lParam) : 0;
}
-static INT_PTR JabberMenuHandleResource( WPARAM wParam, LPARAM lParam, LPARAM lRes )
+static INT_PTR JabberMenuHandleResource(WPARAM wParam, LPARAM lParam, LPARAM lRes)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuHandleResource( wParam, lParam, lRes ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuHandleResource(wParam, lParam, lRes) : 0;
}
-static INT_PTR JabberMenuHandleDirectPresence( WPARAM wParam, LPARAM lParam, LPARAM lRes )
+static INT_PTR JabberMenuHandleDirectPresence(WPARAM wParam, LPARAM lParam, LPARAM lRes)
{
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnMenuHandleDirectPresence( wParam, lParam, lRes ) : 0;
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnMenuHandleDirectPresence(wParam, lParam, lRes) : 0;
}
-static void sttEnableMenuItem( HANDLE hMenuItem, BOOL bEnable )
+static void sttEnableMenuItem(HANDLE hMenuItem, BOOL bEnable)
{
CLISTMENUITEM clmi = {0};
clmi.cbSize = sizeof(CLISTMENUITEM);
clmi.flags = CMIM_FLAGS;
- if ( !bEnable )
+ if ( !bEnable)
clmi.flags |= CMIF_HIDDEN;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hMenuItem, ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)&clmi);
}
-static int JabberPrebuildContactMenu( WPARAM wParam, LPARAM lParam )
+static int JabberPrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
- sttEnableMenuItem( g_hMenuRequestAuth, FALSE );
- sttEnableMenuItem( g_hMenuGrantAuth, FALSE );
- sttEnableMenuItem( g_hMenuRevokeAuth, FALSE );
- sttEnableMenuItem( g_hMenuCommands, FALSE );
- sttEnableMenuItem( g_hMenuSendNote, FALSE );
- sttEnableMenuItem( g_hMenuConvert, FALSE );
- sttEnableMenuItem( g_hMenuRosterAdd, FALSE );
- sttEnableMenuItem( g_hMenuLogin, FALSE );
- sttEnableMenuItem( g_hMenuRefresh, FALSE );
- sttEnableMenuItem( g_hMenuAddBookmark, FALSE );
- sttEnableMenuItem( g_hMenuResourcesRoot, FALSE );
- sttEnableMenuItem( g_hMenuDirectPresence[0], FALSE );
-
- CJabberProto* ppro = JabberGetInstanceByHContact(( HANDLE )wParam );
- return( ppro ) ? ppro->OnPrebuildContactMenu( wParam, lParam ) : 0;
+ sttEnableMenuItem(g_hMenuRequestAuth, FALSE);
+ sttEnableMenuItem(g_hMenuGrantAuth, FALSE);
+ sttEnableMenuItem(g_hMenuRevokeAuth, FALSE);
+ sttEnableMenuItem(g_hMenuCommands, FALSE);
+ sttEnableMenuItem(g_hMenuSendNote, FALSE);
+ sttEnableMenuItem(g_hMenuConvert, FALSE);
+ sttEnableMenuItem(g_hMenuRosterAdd, FALSE);
+ sttEnableMenuItem(g_hMenuLogin, FALSE);
+ sttEnableMenuItem(g_hMenuRefresh, FALSE);
+ sttEnableMenuItem(g_hMenuAddBookmark, FALSE);
+ sttEnableMenuItem(g_hMenuResourcesRoot, FALSE);
+ sttEnableMenuItem(g_hMenuDirectPresence[0], FALSE);
+
+ CJabberProto* ppro = JabberGetInstanceByHContact((HANDLE)wParam);
+ return(ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0;
}
-void g_MenuInit( void )
+void g_MenuInit(void)
{
arServices.increment = 10;
- hPrebuildMenuHook = HookEvent( ME_CLIST_PREBUILDCONTACTMENU, JabberPrebuildContactMenu );
+ hPrebuildMenuHook = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, JabberPrebuildContactMenu);
- List_InsertPtr( &arServices, CreateServiceFunction( "Jabber/MenuChoose", JabberMenuChooseService ));
+ List_InsertPtr(&arServices, CreateServiceFunction("Jabber/MenuChoose", JabberMenuChooseService));
TMenuParam mnu = {0};
mnu.cbSize = sizeof(mnu);
mnu.name = "JabberAccountChooser";
mnu.ExecService = "Jabber/MenuChoose";
- hChooserMenu = (HANDLE)CallService( MO_CREATENEWMENUOBJECT, 0, (LPARAM)&mnu );
+ hChooserMenu = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&mnu);
TMO_MenuItem tmi = { 0 };
- tmi.cbSize = sizeof( tmi );
+ tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_ICONFROMICOLIB;
tmi.pszName = "Cancel";
tmi.position = 9999999;
tmi.hIcolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE);
- CallService( MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, ( LPARAM )&tmi );
+ CallService(MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, (LPARAM)&tmi);
//////////////////////////////////////////////////////////////////////////////////////
// Contact menu initialization
@@ -226,89 +226,89 @@ void g_MenuInit( void ) mi.pszName = LPGEN("Request authorization");
mi.flags = CMIF_ICONFROMICOLIB;
mi.position = -2000001000;
- mi.icolibItem = g_GetIconHandle( IDI_REQUEST );
+ mi.icolibItem = g_GetIconHandle(IDI_REQUEST);
mi.pszService = "Jabber/ReqAuth";
g_hMenuRequestAuth = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuHandleRequestAuth ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuHandleRequestAuth));
// "Grant authorization"
mi.pszService = "Jabber/GrantAuth";
mi.pszName = LPGEN("Grant authorization");
mi.position = -2000001001;
- mi.icolibItem = g_GetIconHandle( IDI_GRANT );
+ mi.icolibItem = g_GetIconHandle(IDI_GRANT);
g_hMenuGrantAuth = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuHandleGrantAuth ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuHandleGrantAuth));
// Revoke auth
mi.pszService = "Jabber/RevokeAuth";
mi.pszName = LPGEN("Revoke authorization");
mi.position = -2000001002;
- mi.icolibItem = g_GetIconHandle( IDI_AUTHREVOKE );
+ mi.icolibItem = g_GetIconHandle(IDI_AUTHREVOKE);
g_hMenuRevokeAuth = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuRevokeAuth ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuRevokeAuth));
// "Convert Chat/Contact"
mi.pszService = "Jabber/ConvertChatContact";
mi.pszName = LPGEN("Convert");
mi.position = -1999901004;
- mi.icolibItem = g_GetIconHandle( IDI_USER2ROOM );
+ mi.icolibItem = g_GetIconHandle(IDI_USER2ROOM);
g_hMenuConvert = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuConvertChatContact ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuConvertChatContact));
// "Add to roster"
mi.pszService = "Jabber/AddToRoster";
mi.pszName = LPGEN("Add to roster");
mi.position = -1999901005;
- mi.icolibItem = g_GetIconHandle( IDI_ADDROSTER );
+ mi.icolibItem = g_GetIconHandle(IDI_ADDROSTER);
g_hMenuRosterAdd = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuRosterAdd ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuRosterAdd));
// "Add to Bookmarks"
mi.pszService = "Jabber/AddToBookmarks";
mi.pszName = LPGEN("Add to Bookmarks");
mi.position = -1999901006;
- mi.icolibItem = g_GetIconHandle( IDI_BOOKMARKS);
+ mi.icolibItem = g_GetIconHandle(IDI_BOOKMARKS);
g_hMenuAddBookmark = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuBookmarkAdd ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuBookmarkAdd));
// Login/logout
mi.pszService = "Jabber/TransportLogin";
mi.pszName = LPGEN("Login/logout");
mi.position = -1999901007;
- mi.icolibItem = g_GetIconHandle( IDI_LOGIN );
+ mi.icolibItem = g_GetIconHandle(IDI_LOGIN);
g_hMenuLogin = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuTransportLogin ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuTransportLogin));
// Retrieve nicks
mi.pszService = "Jabber/TransportGetNicks";
mi.pszName = LPGEN("Resolve nicks");
mi.position = -1999901008;
- mi.icolibItem = g_GetIconHandle( IDI_REFRESH );
+ mi.icolibItem = g_GetIconHandle(IDI_REFRESH);
g_hMenuRefresh = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuTransportResolve ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuTransportResolve));
// Run Commands
mi.pszService = "Jabber/RunCommands";
mi.pszName = LPGEN("Commands");
mi.position = -1999901009;
- mi.icolibItem = g_GetIconHandle( IDI_COMMAND );
+ mi.icolibItem = g_GetIconHandle(IDI_COMMAND);
g_hMenuCommands = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberContactMenuRunCommands ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberContactMenuRunCommands));
// Send Note
mi.pszService = "Jabber/SendNote";
mi.pszName = LPGEN("Send Note");
mi.position = -1999901010;
- mi.icolibItem = g_GetIconHandle( IDI_SEND_NOTE);
+ mi.icolibItem = g_GetIconHandle(IDI_SEND_NOTE);
g_hMenuSendNote = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuSendNote ));
+ List_InsertPtr(&arServices, CreateServiceFunction(mi.pszService, JabberMenuSendNote));
// Direct Presence
mi.pszService = "Jabber/DirectPresenceDummySvc";
mi.pszName = LPGEN("Send Presence");
mi.position = -1999901011;
mi.pszPopupName = (char *)-1;
- mi.icolibItem = g_GetIconHandle( IDI_NOTES );
+ mi.icolibItem = g_GetIconHandle(IDI_NOTES);
g_hMenuDirectPresence[0] = Menu_AddContactMenuItem(&mi);
mi.flags |= CMIF_ROOTHANDLE;
@@ -324,7 +324,7 @@ void g_MenuInit( void ) mi.hParentMenu = g_hMenuDirectPresence[0];
mi.icolibItem = LoadSkinnedIcon(PresenceModeArray[i].icon);
g_hMenuDirectPresence[i+1] = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleDirectPresence, PresenceModeArray[i].mode ));
+ List_InsertPtr(&arServices, CreateServiceFunctionParam(mi.pszService, JabberMenuHandleDirectPresence, PresenceModeArray[i].mode));
}
mi.flags &= ~CMIF_ROOTHANDLE;
@@ -335,153 +335,153 @@ void g_MenuInit( void ) mi.pszName = LPGEN("Jabber Resource");
mi.position = -1999901011;
mi.pszPopupName = (char *)-1;
- mi.icolibItem = g_GetIconHandle( IDI_JABBER );
+ mi.icolibItem = g_GetIconHandle(IDI_JABBER);
g_hMenuResourcesRoot = Menu_AddContactMenuItem(&mi);
mi.pszService = "Jabber/UseResource_last";
mi.pszName = LPGEN("Last Active");
mi.position = -1999901000;
mi.hParentMenu = g_hMenuResourcesRoot;
- mi.icolibItem = g_GetIconHandle( IDI_JABBER );
+ mi.icolibItem = g_GetIconHandle(IDI_JABBER);
mi.flags |= CMIF_ROOTHANDLE;
g_hMenuResourcesActive = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN ));
+ List_InsertPtr(&arServices, CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN));
mi.pszService = "Jabber/UseResource_server";
mi.pszName = LPGEN("Server's Choice");
mi.position = -1999901000;
mi.pszPopupName = (char *)g_hMenuResourcesRoot;
- mi.icolibItem = g_GetIconHandle( IDI_NODE_SERVER );
+ mi.icolibItem = g_GetIconHandle(IDI_NODE_SERVER);
g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi);
- List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER ));
+ List_InsertPtr(&arServices, CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER));
}
-void g_MenuUninit( void )
+void g_MenuUninit(void)
{
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuRequestAuth, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuGrantAuth, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuRevokeAuth, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuConvert, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuRosterAdd, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuLogin, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuRefresh, 0 );
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )g_hMenuAddBookmark, 0 );
-
- UnhookEvent( hPrebuildMenuHook );
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRequestAuth, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuGrantAuth, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRevokeAuth, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuConvert, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRosterAdd, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuLogin, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuRefresh, 0);
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)g_hMenuAddBookmark, 0);
+
+ UnhookEvent(hPrebuildMenuHook);
for (int i = 0; i < arServices.realCount; i++)
- DestroyServiceFunction( arServices.items[i] );
- List_Destroy( &arServices );
+ DestroyServiceFunction(arServices.items[i]);
+ List_Destroy(&arServices);
}
/////////////////////////////////////////////////////////////////////////////////////////
// contact menu services
-int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM )
+int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
{
HANDLE hContact;
- if (( hContact=( HANDLE )wParam ) == NULL )
+ if ((hContact=(HANDLE)wParam) == NULL)
return 0;
- BYTE bIsChatRoom = (BYTE)JGetByte( hContact, "ChatRoom", 0 );
- BYTE bIsTransport = (BYTE)JGetByte( hContact, "IsTransport", 0 );
+ BYTE bIsChatRoom = (BYTE)JGetByte(hContact, "ChatRoom", 0);
+ BYTE bIsTransport = (BYTE)JGetByte(hContact, "IsTransport", 0);
- if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0 ) {
+ if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, bIsChatRoom?(char*)"ChatRoomID":(char*)"jid", &dbv )) {
- JFreeVariant( &dbv );
+ if ( !JGetStringT(hContact, bIsChatRoom?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
+ db_free(&dbv);
CLISTMENUITEM clmi = { 0 };
- sttEnableMenuItem( g_hMenuConvert, TRUE );
- clmi.cbSize = sizeof( clmi );
+ sttEnableMenuItem(g_hMenuConvert, TRUE);
+ clmi.cbSize = sizeof(clmi);
clmi.pszName = bIsChatRoom ? (char *)LPGEN("&Convert to Contact") : (char *)LPGEN("&Convert to Chat Room");
clmi.flags = CMIM_NAME | CMIM_FLAGS;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuConvert, ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hMenuConvert, (LPARAM)&clmi);
} }
- if (!m_bJabberOnline)
+ if ( !m_bJabberOnline)
return 0;
- sttEnableMenuItem( g_hMenuDirectPresence[0], TRUE );
+ sttEnableMenuItem(g_hMenuDirectPresence[0], TRUE);
for (int i = 0; i < SIZEOF(PresenceModeArray); ++i)
{
CLISTMENUITEM clmi = {0};
clmi.cbSize = sizeof(CLISTMENUITEM);
clmi.flags = CMIM_ICON|CMIM_FLAGS;
clmi.hIcon = (HICON)LoadSkinnedProtoIcon(m_szModuleName, PresenceModeArray[i].mode);
- CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuDirectPresence[i+1], ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hMenuDirectPresence[i+1], (LPARAM)&clmi);
}
- if ( bIsChatRoom ) {
+ if (bIsChatRoom) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "ChatRoomID", &dbv )) {
- sttEnableMenuItem( g_hMenuRosterAdd, FALSE );
+ if ( !JGetStringT(hContact, "ChatRoomID", &dbv)) {
+ sttEnableMenuItem(g_hMenuRosterAdd, FALSE);
- if ( ListGetItemPtr( LIST_BOOKMARK, dbv.ptszVal ) == NULL )
- if ( m_ThreadInfo && m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE )
- sttEnableMenuItem( g_hMenuAddBookmark, TRUE );
+ if (ListGetItemPtr(LIST_BOOKMARK, dbv.ptszVal) == NULL)
+ if (m_ThreadInfo && m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)
+ sttEnableMenuItem(g_hMenuAddBookmark, TRUE);
- JFreeVariant( &dbv );
+ db_free(&dbv);
} }
- if ( bIsChatRoom == GCW_CHATROOM )
+ if (bIsChatRoom == GCW_CHATROOM)
return 0;
- if ( bIsTransport ) {
- sttEnableMenuItem( g_hMenuLogin, TRUE );
- sttEnableMenuItem( g_hMenuRefresh, TRUE );
+ if (bIsTransport) {
+ sttEnableMenuItem(g_hMenuLogin, TRUE);
+ sttEnableMenuItem(g_hMenuRefresh, TRUE);
}
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- JabberCapsBits jcb = GetTotalJidCapabilites(dbv.ptszVal );
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal );
- JFreeVariant( &dbv );
- if ( item != NULL ) {
- BOOL bCtrlPressed = ( GetKeyState( VK_CONTROL)&0x8000 ) != 0;
- sttEnableMenuItem( g_hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed );
- sttEnableMenuItem( g_hMenuGrantAuth, bCtrlPressed );
- sttEnableMenuItem( g_hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed );
- sttEnableMenuItem( g_hMenuCommands, (( jcb & JABBER_CAPS_COMMANDS ) != 0) || bCtrlPressed);
- sttEnableMenuItem( g_hMenuSendNote, TRUE );
-
- if ( item->resourceCount >= 1 ) {
- sttEnableMenuItem( g_hMenuResourcesRoot, TRUE );
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ JabberCapsBits jcb = GetTotalJidCapabilites(dbv.ptszVal);
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
+ db_free(&dbv);
+ if (item != NULL) {
+ BOOL bCtrlPressed = (GetKeyState(VK_CONTROL)&0x8000) != 0;
+ sttEnableMenuItem(g_hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed);
+ sttEnableMenuItem(g_hMenuGrantAuth, bCtrlPressed);
+ sttEnableMenuItem(g_hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed);
+ sttEnableMenuItem(g_hMenuCommands, ((jcb & JABBER_CAPS_COMMANDS) != 0) || bCtrlPressed);
+ sttEnableMenuItem(g_hMenuSendNote, TRUE);
+
+ if (item->resourceCount >= 1) {
+ sttEnableMenuItem(g_hMenuResourcesRoot, TRUE);
CLISTMENUITEM mi = {0};
mi.cbSize = sizeof(CLISTMENUITEM);
mi.flags = CMIM_ICON|CMIM_FLAGS;
- mi.icolibItem = GetIconHandle( IDI_JABBER );
- CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesRoot, ( LPARAM )&mi );
- CallService(MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesActive, ( LPARAM )&mi );
+ mi.icolibItem = GetIconHandle(IDI_JABBER);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hMenuResourcesRoot, (LPARAM)&mi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hMenuResourcesActive, (LPARAM)&mi);
int nMenuResourceItemsNew = m_nMenuResourceItems;
- if ( m_nMenuResourceItems < item->resourceCount ) {
- m_phMenuResourceItems = (HANDLE *)mir_realloc( m_phMenuResourceItems, item->resourceCount * sizeof(HANDLE));
+ if (m_nMenuResourceItems < item->resourceCount) {
+ m_phMenuResourceItems = (HANDLE *)mir_realloc(m_phMenuResourceItems, item->resourceCount * sizeof(HANDLE));
nMenuResourceItemsNew = item->resourceCount;
}
char text[ 256 ];
- strcpy( text, m_szModuleName );
- size_t nModuleNameLength = strlen( text );
+ strcpy(text, m_szModuleName);
+ size_t nModuleNameLength = strlen(text);
char* tDest = text + nModuleNameLength;
mi.cbSize = sizeof(CLISTMENUITEM);
mi.flags = CMIF_CHILDPOPUP;
mi.position = 0;
- mi.icolibItem = GetIconHandle( IDI_REQUEST );
+ mi.icolibItem = GetIconHandle(IDI_REQUEST);
mi.pszService = text;
mi.pszContactOwner = m_szModuleName;
TCHAR szTmp[512];
for (int i = 0; i < nMenuResourceItemsNew; ++i) {
- mir_snprintf( tDest, SIZEOF(text) - nModuleNameLength, "/UseResource_%d", i );
- if ( i >= m_nMenuResourceItems ) {
- JCreateServiceParam( tDest, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES+i );
+ mir_snprintf(tDest, SIZEOF(text) - nModuleNameLength, "/UseResource_%d", i);
+ if (i >= m_nMenuResourceItems) {
+ JCreateServiceParam(tDest, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES+i);
mi.pszName = "";
mi.position = i;
mi.pszPopupName = (char *)g_hMenuResourcesRoot;
m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi);
}
- if ( i < item->resourceCount ) {
+ if (i < item->resourceCount) {
CLISTMENUITEM clmi = {0};
clmi.cbSize = sizeof(CLISTMENUITEM);
clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR;
@@ -490,17 +490,17 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM ) if (ServiceExists(MS_FP_GETCLIENTICONT)) {
clmi.flags |= CMIM_ICON;
FormatMirVer(&item->resource[i], szTmp, SIZEOF(szTmp));
- clmi.hIcon = (HICON)CallService( MS_FP_GETCLIENTICONT, (WPARAM)szTmp, 0 );
+ clmi.hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)szTmp, 0);
}
mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"),
item->resource[i].resourceName,
(TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, item->resource[i].status, GSMDF_TCHAR),
item->resource[i].priority);
clmi.ptszName = szTmp;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_phMenuResourceItems[i], ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_phMenuResourceItems[i], (LPARAM)&clmi);
DestroyIcon(clmi.hIcon);
}
- else sttEnableMenuItem( m_phMenuResourceItems[i], FALSE );
+ else sttEnableMenuItem(m_phMenuResourceItems[i], FALSE);
}
ZeroMemory(&mi, sizeof(mi));
@@ -508,11 +508,11 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM ) mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_ICONFROMICOLIB |
((item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0);
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesActive, ( LPARAM )&mi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hMenuResourcesActive, (LPARAM)&mi);
mi.flags = CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_ICONFROMICOLIB |
((item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0);
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )g_hMenuResourcesServer, ( LPARAM )&mi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hMenuResourcesServer, (LPARAM)&mi);
m_nMenuResourceItems = nMenuResourceItemsNew;
}
@@ -523,54 +523,54 @@ int CJabberProto::OnPrebuildContactMenu( WPARAM wParam, LPARAM ) return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM wParam, LPARAM)
{
- BYTE bIsChatRoom = (BYTE)JGetByte( (HANDLE ) wParam, "ChatRoom", 0 );
- if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0 ) {
+ BYTE bIsChatRoom = (BYTE)JGetByte((HANDLE) wParam, "ChatRoom", 0);
+ if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
DBVARIANT dbv;
- if ( !JGetStringT( (HANDLE ) wParam, (bIsChatRoom == GCW_CHATROOM)?(char*)"ChatRoomID":(char*)"jid", &dbv )) {
- JDeleteSetting( (HANDLE ) wParam, (bIsChatRoom == GCW_CHATROOM)?"ChatRoomID":"jid");
- JSetStringT( (HANDLE ) wParam, (bIsChatRoom != GCW_CHATROOM)?"ChatRoomID":"jid", dbv.ptszVal);
- JFreeVariant( &dbv );
- JSetByte((HANDLE ) wParam, "ChatRoom", (bIsChatRoom == GCW_CHATROOM)?0:GCW_CHATROOM);
+ if ( !JGetStringT((HANDLE) wParam, (bIsChatRoom == GCW_CHATROOM)?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
+ JDeleteSetting((HANDLE) wParam, (bIsChatRoom == GCW_CHATROOM)?"ChatRoomID":"jid");
+ JSetStringT((HANDLE) wParam, (bIsChatRoom != GCW_CHATROOM)?"ChatRoomID":"jid", dbv.ptszVal);
+ db_free(&dbv);
+ JSetByte((HANDLE) wParam, "ChatRoom", (bIsChatRoom == GCW_CHATROOM)?0:GCW_CHATROOM);
} }
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuRosterAdd( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM wParam, LPARAM)
{
DBVARIANT dbv;
- if ( !wParam ) return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
- if ( !JGetStringT( ( HANDLE ) wParam, "ChatRoomID", &dbv )) {
+ if ( !wParam) return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
+ if ( !JGetStringT((HANDLE)wParam, "ChatRoomID", &dbv)) {
TCHAR *roomID = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
- if ( ListGetItemPtr( LIST_ROSTER, roomID ) == NULL ) {
+ db_free(&dbv);
+ if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) {
TCHAR *nick = 0;
TCHAR *group = 0;
- if ( !DBGetContactSettingTString( ( HANDLE ) wParam, "CList", "Group", &dbv )) {
+ if ( !DBGetContactSettingTString((HANDLE)wParam, "CList", "Group", &dbv)) {
group = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- if ( !JGetStringT( ( HANDLE ) wParam, "Nick", &dbv )) {
+ if ( !JGetStringT((HANDLE)wParam, "Nick", &dbv)) {
nick = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- AddContactToRoster( roomID, nick, group );
- if ( m_options.AddRoster2Bookmarks == TRUE ) {
+ AddContactToRoster(roomID, nick, group);
+ if (m_options.AddRoster2Bookmarks == TRUE) {
JABBER_LIST_ITEM* item = NULL;
item = ListGetItemPtr(LIST_BOOKMARK, roomID);
- if (!item) {
- item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM ));
- ZeroMemory( item, sizeof( JABBER_LIST_ITEM ));
+ if ( !item) {
+ item = (JABBER_LIST_ITEM*)mir_alloc(sizeof(JABBER_LIST_ITEM));
+ ZeroMemory(item, sizeof(JABBER_LIST_ITEM));
item->jid = mir_tstrdup(roomID);
item->name = mir_tstrdup(nick);
- if ( !JGetStringT( ( HANDLE ) wParam, "MyNick", &dbv )) {
+ if ( !JGetStringT((HANDLE)wParam, "MyNick", &dbv)) {
item->nick = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- AddEditBookmark( item );
+ AddEditBookmark(item);
mir_free(item);
}
}
@@ -582,109 +582,109 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd( WPARAM wParam, LPARAM ) return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleRequestAuth( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleRequestAuth(WPARAM wParam, LPARAM)
{
HANDLE hContact;
DBVARIANT dbv;
- if (( hContact=( HANDLE ) wParam )!=NULL && m_bJabberOnline ) {
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), dbv.ptszVal ) << XATTR( _T("type"), _T("subscribe")));
- JFreeVariant( &dbv );
+ if ((hContact=(HANDLE)wParam)!=NULL && m_bJabberOnline) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), dbv.ptszVal) << XATTR(_T("type"), _T("subscribe")));
+ db_free(&dbv);
} }
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth(WPARAM wParam, LPARAM)
{
HANDLE hContact;
DBVARIANT dbv;
- if (( hContact=( HANDLE ) wParam )!=NULL && m_bJabberOnline ) {
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), dbv.ptszVal ) << XATTR( _T("type"), _T("subscribed")));
- JFreeVariant( &dbv );
+ if ((hContact=(HANDLE)wParam)!=NULL && m_bJabberOnline) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), dbv.ptszVal) << XATTR(_T("type"), _T("subscribed")));
+ db_free(&dbv);
} }
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuRevokeAuth( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuRevokeAuth(WPARAM wParam, LPARAM)
{
HANDLE hContact;
DBVARIANT dbv;
- if (( hContact=( HANDLE ) wParam ) != NULL && m_bJabberOnline ) {
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), dbv.ptszVal ) << XATTR( _T("type"), _T("unsubscribed")));
- JFreeVariant( &dbv );
+ if ((hContact=(HANDLE)wParam) != NULL && m_bJabberOnline) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), dbv.ptszVal) << XATTR(_T("type"), _T("unsubscribed")));
+ db_free(&dbv);
} }
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuTransportLogin( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuTransportLogin(WPARAM wParam, LPARAM)
{
- HANDLE hContact = ( HANDLE )wParam;
- if ( !JGetByte( hContact, "IsTransport", 0 ))
+ HANDLE hContact = (HANDLE)wParam;
+ if ( !JGetByte(hContact, "IsTransport", 0))
return 0;
DBVARIANT jid;
- if ( JGetStringT( hContact, "jid", &jid ))
+ if (JGetStringT(hContact, "jid", &jid))
return 0;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, jid.ptszVal );
- if ( item != NULL ) {
- XmlNode p( _T("presence")); xmlAddAttr( p, _T("to"), item->jid );
- if ( item->itemResource.status == ID_STATUS_ONLINE )
- xmlAddAttr( p, _T("type"), _T("unavailable"));
- m_ThreadInfo->send( p );
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, jid.ptszVal);
+ if (item != NULL) {
+ XmlNode p(_T("presence")); xmlAddAttr(p, _T("to"), item->jid);
+ if (item->itemResource.status == ID_STATUS_ONLINE)
+ xmlAddAttr(p, _T("type"), _T("unavailable"));
+ m_ThreadInfo->send(p);
}
- JFreeVariant( &jid );
+ db_free(&jid);
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuTransportResolve( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuTransportResolve(WPARAM wParam, LPARAM)
{
- HANDLE hContact = ( HANDLE )wParam;
- if ( !JGetByte( hContact, "IsTransport", 0 ))
+ HANDLE hContact = (HANDLE)wParam;
+ if ( !JGetByte(hContact, "IsTransport", 0))
return 0;
DBVARIANT jid;
- if ( !JGetStringT( hContact, "jid", &jid )) {
- ResolveTransportNicks( jid.ptszVal );
- JFreeVariant( &jid );
+ if ( !JGetStringT(hContact, "jid", &jid)) {
+ ResolveTransportNicks(jid.ptszVal);
+ db_free(&jid);
}
return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM wParam, LPARAM)
{
DBVARIANT dbv;
- if ( !wParam ) return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
- if ( !JGetStringT( ( HANDLE ) wParam, "ChatRoomID", &dbv )) {
+ if ( !wParam) return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
+ if ( !JGetStringT((HANDLE)wParam, "ChatRoomID", &dbv)) {
TCHAR *roomID = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
- if ( ListGetItemPtr( LIST_BOOKMARK, roomID ) == NULL ) {
+ db_free(&dbv);
+ if (ListGetItemPtr(LIST_BOOKMARK, roomID) == NULL) {
TCHAR *nick = 0;
- if ( !JGetStringT( ( HANDLE ) wParam, "Nick", &dbv )) {
+ if ( !JGetStringT((HANDLE)wParam, "Nick", &dbv)) {
nick = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
JABBER_LIST_ITEM* item = NULL;
- item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM ));
- ZeroMemory( item, sizeof( JABBER_LIST_ITEM ));
+ item = (JABBER_LIST_ITEM*)mir_alloc(sizeof(JABBER_LIST_ITEM));
+ ZeroMemory(item, sizeof(JABBER_LIST_ITEM));
item->jid = mir_tstrdup(roomID);
- item->name = ( TCHAR* )CallService( MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR );
+ item->name = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR);
item->type = _T("conference");
- if ( !JGetStringT(( HANDLE ) wParam, "MyNick", &dbv )) {
+ if ( !JGetStringT((HANDLE)wParam, "MyNick", &dbv)) {
item->nick = mir_tstrdup(dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- AddEditBookmark( item );
+ AddEditBookmark(item);
mir_free(item);
if (nick) mir_free(nick);
@@ -703,38 +703,38 @@ void CJabberProto::MenuInit() mi.cbSize = sizeof(CLISTMENUITEM);
char text[ 200 ];
- strcpy( text, m_szModuleName );
- char* tDest = text + strlen( text );
+ strcpy(text, m_szModuleName);
+ char* tDest = text + strlen(text);
mi.pszService = text;
- HGENMENU hJabberRoot = MO_GetProtoRootMenu( m_szModuleName );
- if ( hJabberRoot == NULL ) {
+ HGENMENU hJabberRoot = MO_GetProtoRootMenu(m_szModuleName);
+ if (hJabberRoot == NULL) {
mi.ptszName = m_tszUserName;
mi.position = -1999901006;
mi.hParentMenu = HGENMENU_ROOT;
mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.icolibItem = GetIconHandle( IDI_JABBER );
+ mi.icolibItem = GetIconHandle(IDI_JABBER);
hJabberRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&mi);
}
else {
- if ( m_hMenuRoot )
- CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )m_hMenuRoot, 0 );
+ if (m_hMenuRoot)
+ CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)m_hMenuRoot, 0);
m_hMenuRoot = NULL;
}
// "Bookmarks..."
- JCreateService( "/Bookmarks", &CJabberProto::OnMenuHandleBookmarks );
- strcpy( tDest, "/Bookmarks" );
+ JCreateService("/Bookmarks", &CJabberProto::OnMenuHandleBookmarks);
+ strcpy(tDest, "/Bookmarks");
mi.flags = CMIF_ICONFROMICOLIB | CMIF_CHILDPOPUP;
mi.hParentMenu = hJabberRoot;
mi.pszName = LPGEN("Bookmarks");
mi.position = 200001;
- mi.icolibItem = GetIconHandle( IDI_BOOKMARKS );
+ mi.icolibItem = GetIconHandle(IDI_BOOKMARKS);
m_hMenuBookmarks = Menu_AddProtoMenuItem(&mi);
// "Options..."
- JCreateService( "/Options", &CJabberProto::OnMenuOptions );
- strcpy( tDest, "/Options" );
+ JCreateService("/Options", &CJabberProto::OnMenuOptions);
+ strcpy(tDest, "/Options");
mi.pszName = LPGEN("Options...");
mi.position = 200002;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_OPTIONS);
@@ -742,83 +742,83 @@ void CJabberProto::MenuInit() // "Services..."
mi.pszName = LPGEN("Services...");
- strcpy( tDest, "/Services" );
+ strcpy(tDest, "/Services");
mi.position = 200003;
- mi.icolibItem = GetIconHandle( IDI_SERVICE_DISCOVERY );
+ mi.icolibItem = GetIconHandle(IDI_SERVICE_DISCOVERY);
HGENMENU hMenuServicesRoot = Menu_AddProtoMenuItem(&mi);
// "Service Discovery..."
- JCreateService( "/ServiceDiscovery", &CJabberProto::OnMenuHandleServiceDiscovery );
- strcpy( tDest, "/ServiceDiscovery" );
+ JCreateService("/ServiceDiscovery", &CJabberProto::OnMenuHandleServiceDiscovery);
+ strcpy(tDest, "/ServiceDiscovery");
mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Service Discovery");
mi.position = 2000050001;
- mi.icolibItem = GetIconHandle( IDI_SERVICE_DISCOVERY );
+ mi.icolibItem = GetIconHandle(IDI_SERVICE_DISCOVERY);
mi.hParentMenu = hMenuServicesRoot;
m_hMenuServiceDiscovery = Menu_AddProtoMenuItem(&mi);
- JCreateService( "/SD/MyTransports", &CJabberProto::OnMenuHandleServiceDiscoveryMyTransports );
- strcpy( tDest, "/SD/MyTransports" );
+ JCreateService("/SD/MyTransports", &CJabberProto::OnMenuHandleServiceDiscoveryMyTransports);
+ strcpy(tDest, "/SD/MyTransports");
mi.pszName = LPGEN("Registered Transports");
mi.position = 2000050003;
- mi.icolibItem = GetIconHandle( IDI_TRANSPORTL );
+ mi.icolibItem = GetIconHandle(IDI_TRANSPORTL);
m_hMenuSDMyTransports = Menu_AddProtoMenuItem(&mi);
- JCreateService( "/SD/Transports", &CJabberProto::OnMenuHandleServiceDiscoveryTransports );
- strcpy( tDest, "/SD/Transports" );
+ JCreateService("/SD/Transports", &CJabberProto::OnMenuHandleServiceDiscoveryTransports);
+ strcpy(tDest, "/SD/Transports");
mi.pszName = LPGEN("Local Server Transports");
mi.position = 2000050004;
- mi.icolibItem = GetIconHandle( IDI_TRANSPORT );
+ mi.icolibItem = GetIconHandle(IDI_TRANSPORT);
m_hMenuSDTransports = Menu_AddProtoMenuItem(&mi);
- JCreateService( "/SD/Conferences", &CJabberProto::OnMenuHandleServiceDiscoveryConferences );
- strcpy( tDest, "/SD/Conferences" );
+ JCreateService("/SD/Conferences", &CJabberProto::OnMenuHandleServiceDiscoveryConferences);
+ strcpy(tDest, "/SD/Conferences");
mi.pszName = LPGEN("Browse Chatrooms");
mi.position = 2000050005;
- mi.icolibItem = GetIconHandle( IDI_GROUP );
+ mi.icolibItem = GetIconHandle(IDI_GROUP);
m_hMenuSDConferences = Menu_AddProtoMenuItem(&mi);
- JCreateService( "/Groupchat", &CJabberProto::OnMenuHandleJoinGroupchat );
- strcpy( tDest, "/Groupchat" );
+ JCreateService("/Groupchat", &CJabberProto::OnMenuHandleJoinGroupchat);
+ strcpy(tDest, "/Groupchat");
mi.pszName = LPGEN("Create/Join groupchat");
mi.position = 2000050006;
- mi.icolibItem = GetIconHandle( IDI_GROUP );
+ mi.icolibItem = GetIconHandle(IDI_GROUP);
m_hMenuGroupchat = Menu_AddProtoMenuItem(&mi);
// "Change Password..."
- JCreateService( "/ChangePassword", &CJabberProto::OnMenuHandleChangePassword );
- strcpy( tDest, "/ChangePassword" );
+ JCreateService("/ChangePassword", &CJabberProto::OnMenuHandleChangePassword);
+ strcpy(tDest, "/ChangePassword");
mi.pszName = LPGEN("Change Password");
mi.position = 2000050007;
- mi.icolibItem = GetIconHandle( IDI_KEYS );
+ mi.icolibItem = GetIconHandle(IDI_KEYS);
m_hMenuChangePassword = Menu_AddProtoMenuItem(&mi);
// "Roster editor"
- JCreateService( "/RosterEditor", &CJabberProto::OnMenuHandleRosterControl );
- strcpy( tDest, "/RosterEditor" );
+ JCreateService("/RosterEditor", &CJabberProto::OnMenuHandleRosterControl);
+ strcpy(tDest, "/RosterEditor");
mi.pszName = LPGEN("Roster editor");
mi.position = 2000050009;
- mi.icolibItem = GetIconHandle( IDI_AGENTS );
+ mi.icolibItem = GetIconHandle(IDI_AGENTS);
m_hMenuRosterControl = Menu_AddProtoMenuItem(&mi);
// "XML Console"
- JCreateService( "/XMLConsole", &CJabberProto::OnMenuHandleConsole );
- strcpy( tDest, "/XMLConsole" );
+ JCreateService("/XMLConsole", &CJabberProto::OnMenuHandleConsole);
+ strcpy(tDest, "/XMLConsole");
mi.pszName = LPGEN("XML Console");
mi.position = 2000050010;
- mi.icolibItem = GetIconHandle( IDI_CONSOLE );
+ mi.icolibItem = GetIconHandle(IDI_CONSOLE);
Menu_AddProtoMenuItem(&mi);
- JCreateService( "/Notes", &CJabberProto::OnMenuHandleNotes );
- strcpy( tDest, "/Notes" );
+ JCreateService("/Notes", &CJabberProto::OnMenuHandleNotes);
+ strcpy(tDest, "/Notes");
mi.pszName = LPGEN("Notes");
mi.position = 2000050011;
- mi.icolibItem = GetIconHandle( IDI_NOTES);
+ mi.icolibItem = GetIconHandle(IDI_NOTES);
m_hMenuNotes = Menu_AddProtoMenuItem(&mi);
BuildPrivacyMenu();
- if ( m_menuItemsStatus )
- BuildPrivacyListsMenu( false );
+ if (m_menuItemsStatus)
+ BuildPrivacyListsMenu(false);
//////////////////////////////////////////////////////////////////////////////////////
// build priority menu
@@ -833,7 +833,7 @@ void CJabberProto::MenuInit() mi.flags = CMIF_ROOTPOPUP | CMIF_HIDDEN;
m_hMenuPriorityRoot = Menu_AddProtoMenuItem(&mi);
- char szName[128], srvFce[MAX_PATH + 64], *svcName = srvFce+strlen( m_szModuleName );
+ char szName[128], srvFce[MAX_PATH + 64], *svcName = srvFce+strlen(m_szModuleName);
mi.pszService = srvFce;
mi.pszName = szName;
mi.position = 2000040000;
@@ -842,12 +842,12 @@ void CJabberProto::MenuInit() mir_snprintf(srvFce, sizeof(srvFce), "%s/menuSetPriority/0", m_szModuleName);
bool needServices = !ServiceExists(srvFce);
- if ( needServices )
+ if (needServices)
JCreateServiceParam(svcName, &CJabberProto::OnMenuSetPriority, 0);
int steps[] = { 10, 5, 1, 0, -1, -5, -10 };
for (int i = 0; i < SIZEOF(steps); ++i) {
- if ( !steps[i] ) {
+ if ( !steps[i]) {
mi.position += 100000;
continue;
}
@@ -857,7 +857,7 @@ void CJabberProto::MenuInit() mir_snprintf(srvFce, sizeof(srvFce), "%s/menuSetPriority/%d", m_szModuleName, steps[i]);
mir_snprintf(szName, sizeof(szName), (steps[i] > 0) ? "Increase priority by %d" : "Decrease priority by %d", abs(steps[i]));
- if ( needServices )
+ if (needServices)
JCreateServiceParam(svcName, &CJabberProto::OnMenuSetPriority, (LPARAM)steps[i]);
mi.position++;
@@ -890,7 +890,7 @@ INT_PTR CJabberProto::OnMenuSetPriority(WPARAM, LPARAM, LPARAM dwDelta) void CJabberProto::UpdatePriorityMenu(short priority)
{
- if (!m_hMenuPriorityRoot || m_priorityMenuValSet && (priority == m_priorityMenuVal))
+ if ( !m_hMenuPriorityRoot || m_priorityMenuValSet && (priority == m_priorityMenuVal))
return;
TCHAR szName[128];
@@ -918,14 +918,14 @@ void CJabberProto::GlobalMenuInit() tmi.ownerdata = this;
tmi.position = iChooserMenuPos++;
tmi.ptszName = m_tszUserName;
- m_hChooseMenuItem = (HANDLE)CallService( MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, ( LPARAM )&tmi );
+ m_hChooseMenuItem = (HANDLE)CallService(MO_ADDNEWMENUITEM, (WPARAM)hChooserMenu, (LPARAM)&tmi);
//////////////////////////////////////////////////////////////////////////////////////
// Hotkeys
char text[ 200 ];
- strcpy( text, m_szModuleName );
- char* tDest = text + strlen( text );
+ strcpy(text, m_szModuleName);
+ char* tDest = text + strlen(text);
HOTKEYDESC hkd = {0};
hkd.cbSize = sizeof(hkd);
@@ -974,26 +974,26 @@ static INT_PTR g_ToolbarHandleServiceDiscovery(WPARAM w, LPARAM l) int g_OnToolbarInit(WPARAM, LPARAM)
{
- if ( g_Instances.getCount() == 0 )
+ if (g_Instances.getCount() == 0)
return 0;
TTBButton button = {0};
button.cbSize = sizeof(button);
button.dwFlags = TTBBF_SHOWTOOLTIP | TTBBF_VISIBLE;
- List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/Groupchat", g_ToolbarHandleJoinGroupchat ));
+ List_InsertPtr(&arServices, CreateServiceFunction("JABBER/*/Groupchat", g_ToolbarHandleJoinGroupchat));
button.pszService = "JABBER/*/Groupchat";
button.pszTooltipUp = button.name = LPGEN("Join conference");
button.hIconHandleUp = g_GetIconHandle(IDI_GROUP);
TopToolbar_AddButton(&button);
- List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/Bookmarks", g_ToolbarHandleBookmarks ));
+ List_InsertPtr(&arServices, CreateServiceFunction("JABBER/*/Bookmarks", g_ToolbarHandleBookmarks));
button.pszService = "JABBER/*/Bookmarks";
button.pszTooltipUp = button.name = LPGEN("Open bookmarks");
button.hIconHandleUp = g_GetIconHandle(IDI_BOOKMARKS);
TopToolbar_AddButton(&button);
- List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/ServiceDiscovery", g_ToolbarHandleServiceDiscovery ));
+ List_InsertPtr(&arServices, CreateServiceFunction("JABBER/*/ServiceDiscovery", g_ToolbarHandleServiceDiscovery));
button.pszService = "JABBER/*/ServiceDiscovery";
button.pszTooltipUp = button.name = LPGEN("Service discovery");
button.hIconHandleUp = g_GetIconHandle(IDI_SERVICE_DISCOVERY);
@@ -1003,20 +1003,20 @@ int g_OnToolbarInit(WPARAM, LPARAM) void CJabberProto::GlobalMenuUninit()
{
- if ( m_phMenuResourceItems ) {
- for ( int i=0; i < m_nMenuResourceItems; i++ )
- CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )m_phMenuResourceItems[i], 0 );
+ if (m_phMenuResourceItems) {
+ for (int i=0; i < m_nMenuResourceItems; i++)
+ CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)m_phMenuResourceItems[i], 0);
mir_free(m_phMenuResourceItems);
m_phMenuResourceItems = NULL;
}
m_nMenuResourceItems = 0;
- if ( m_hMenuRoot )
- CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )m_hMenuRoot, 0 );
+ if (m_hMenuRoot)
+ CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)m_hMenuRoot, 0);
m_hMenuRoot = NULL;
}
-void CJabberProto::EnableMenuItems( BOOL bEnable )
+void CJabberProto::EnableMenuItems(BOOL bEnable)
{
m_menuItemsStatus = bEnable;
CheckMenuItems();
@@ -1027,35 +1027,35 @@ void CJabberProto::CheckMenuItems() CLISTMENUITEM clmi = { 0 };
clmi.cbSize = sizeof(CLISTMENUITEM);
clmi.flags = CMIM_FLAGS;
- if ( !m_menuItemsStatus )
+ if ( !m_menuItemsStatus)
clmi.flags |= CMIF_GRAYED;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuChangePassword, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuGroupchat, ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuChangePassword, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuGroupchat, (LPARAM)&clmi);
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuPrivacyLists, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuRosterControl, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuServiceDiscovery, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuSDMyTransports, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuSDTransports, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuSDConferences, ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuPrivacyLists, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuRosterControl, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuServiceDiscovery, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuSDMyTransports, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuSDTransports, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuSDConferences, (LPARAM)&clmi);
- clmi.flags = CMIM_FLAGS | (( m_ThreadInfo && ( m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)) ? 0 : CMIF_HIDDEN );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuBookmarks, ( LPARAM )&clmi );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuNotes, ( LPARAM )&clmi );
+ clmi.flags = CMIM_FLAGS | ((m_ThreadInfo && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)) ? 0 : CMIF_HIDDEN);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuBookmarks, (LPARAM)&clmi);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuNotes, (LPARAM)&clmi);
- clmi.flags = CMIM_FLAGS | (( m_ThreadInfo && ( m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVACY_LISTS)) ? 0 : CMIF_HIDDEN );
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hPrivacyMenuRoot, ( LPARAM )&clmi );
+ clmi.flags = CMIM_FLAGS | ((m_ThreadInfo && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVACY_LISTS)) ? 0 : CMIF_HIDDEN);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hPrivacyMenuRoot, (LPARAM)&clmi);
- clmi.flags = CMIM_FLAGS | ( m_menuItemsStatus ? 0 : CMIF_HIDDEN);
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuPriorityRoot, ( LPARAM )&clmi );
+ clmi.flags = CMIM_FLAGS | (m_menuItemsStatus ? 0 : CMIF_HIDDEN);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuPriorityRoot, (LPARAM)&clmi);
- if ( !m_bPepSupported )
+ if ( !m_bPepSupported)
clmi.flags |= CMIF_HIDDEN;
- for ( int i=0; i < m_pepServices.getCount(); i++ )
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_pepServices[i].GetMenu(), ( LPARAM )&clmi );
+ for (int i=0; i < m_pepServices.getCount(); i++)
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_pepServices[i].GetMenu(), (LPARAM)&clmi);
- JabberUpdateDialogs( m_menuItemsStatus );
+ JabberUpdateDialogs(m_menuItemsStatus);
}
//////////////////////////////////////////////////////////////////////////
@@ -1074,11 +1074,11 @@ void CJabberProto::MenuHideSrmmIcon(HANDLE hContact) void CJabberProto::MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item)
{
- if ( item->list != LIST_ROSTER || !ServiceExists( MS_MSG_MODIFYICON ))
+ if (item->list != LIST_ROSTER || !ServiceExists(MS_MSG_MODIFYICON))
return;
HANDLE hContact = HContactFromJID(item->jid);
- if ( !hContact )
+ if ( !hContact)
return;
StatusIconData sid = {0};
@@ -1088,57 +1088,57 @@ void CJabberProto::MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item) CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
}
-int CJabberProto::OnProcessSrmmEvent( WPARAM, LPARAM lParam )
+int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
{
MessageWindowEventData *event = (MessageWindowEventData *)lParam;
- if ( event->uType == MSG_WINDOW_EVT_OPEN ) {
- if ( !hDialogsList )
+ if (event->uType == MSG_WINDOW_EVT_OPEN) {
+ if ( !hDialogsList)
hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);
}
- else if ( event->uType == MSG_WINDOW_EVT_CLOSING ) {
+ else if (event->uType == MSG_WINDOW_EVT_CLOSING) {
if (hDialogsList)
WindowList_Remove(hDialogsList, event->hwndWindow);
DBVARIANT dbv;
BOOL bSupportTyping = FALSE;
- if ( !DBGetContactSetting( event->hContact, "SRMsg", "SupportTyping", &dbv )) {
+ if ( !DBGetContactSetting(event->hContact, "SRMsg", "SupportTyping", &dbv)) {
bSupportTyping = dbv.bVal == 1;
- JFreeVariant( &dbv );
- } else if ( !DBGetContactSetting( NULL, "SRMsg", "DefaultTyping", &dbv )) {
+ db_free(&dbv);
+ } else if ( !DBGetContactSetting(NULL, "SRMsg", "DefaultTyping", &dbv)) {
bSupportTyping = dbv.bVal == 1;
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- if ( bSupportTyping && !JGetStringT( event->hContact, "jid", &dbv )) {
+ if (bSupportTyping && !JGetStringT(event->hContact, "jid", &dbv)) {
TCHAR jid[ JABBER_MAX_JID_LEN ];
- GetClientJID( dbv.ptszVal, jid, SIZEOF( jid ));
- JFreeVariant( &dbv );
+ GetClientJID(dbv.ptszVal, jid, SIZEOF(jid));
+ db_free(&dbv);
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( jid );
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(jid);
- if ( r && r->bMessageSessionActive ) {
+ if (r && r->bMessageSessionActive) {
r->bMessageSessionActive = FALSE;
- JabberCapsBits jcb = GetResourceCapabilites( jid, TRUE );
+ JabberCapsBits jcb = GetResourceCapabilites(jid, TRUE);
- if ( jcb & JABBER_CAPS_CHATSTATES ) {
+ if (jcb & JABBER_CAPS_CHATSTATES) {
int iqId = SerialNext();
m_ThreadInfo->send(
- XmlNode( _T("message")) << XATTR( _T("to"), jid ) << XATTR( _T("type"), _T("chat")) << XATTRID( iqId )
- << XCHILDNS( _T("gone"), _T(JABBER_FEAT_CHATSTATES)));
+ XmlNode(_T("message")) << XATTR(_T("to"), jid) << XATTR(_T("type"), _T("chat")) << XATTRID(iqId)
+ << XCHILDNS(_T("gone"), _T(JABBER_FEAT_CHATSTATES)));
} } } }
return 0;
}
-int CJabberProto::OnProcessSrmmIconClick( WPARAM wParam, LPARAM lParam )
+int CJabberProto::OnProcessSrmmIconClick(WPARAM wParam, LPARAM lParam)
{
StatusIconClickData *sicd = (StatusIconClickData *)lParam;
if (lstrcmpA(sicd->szModule, m_szModuleName))
return 0;
HANDLE hContact = (HANDLE)wParam;
- if (!hContact)
+ if ( !hContact)
return 0;
DBVARIANT dbv;
@@ -1146,9 +1146,9 @@ int CJabberProto::OnProcessSrmmIconClick( WPARAM wParam, LPARAM lParam ) return 0;
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
- if ( !LI )
+ if ( !LI)
return 0;
HMENU hMenu = CreatePopupMenu();
@@ -1174,7 +1174,7 @@ int CJabberProto::OnProcessSrmmIconClick( WPARAM wParam, LPARAM lParam ) int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL);
- if ( res == MENUITEM_LASTSEEN ) {
+ if (res == MENUITEM_LASTSEEN) {
LI->manualResource = -1;
LI->resourceMode = RSMODE_LASTSEEN;
}
@@ -1195,7 +1195,7 @@ int CJabberProto::OnProcessSrmmIconClick( WPARAM wParam, LPARAM lParam ) INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM res)
{
- if ( !m_bJabberOnline || !wParam )
+ if ( !m_bJabberOnline || !wParam)
return 0;
HANDLE hContact = (HANDLE)wParam;
@@ -1205,12 +1205,12 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM return 0;
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
- if ( !LI )
+ if ( !LI)
return 0;
- if ( res == MENUITEM_LASTSEEN ) {
+ if (res == MENUITEM_LASTSEEN) {
LI->manualResource = -1;
LI->resourceMode = RSMODE_LASTSEEN;
}
@@ -1230,7 +1230,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleResource(WPARAM wParam, LPARAM, LPARAM INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM wParam, LPARAM lParam, LPARAM res)
{
- if ( !m_bJabberOnline || !wParam )
+ if ( !m_bJabberOnline || !wParam)
return 0;
HANDLE hContact = (HANDLE)wParam;
@@ -1238,16 +1238,16 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM wParam, LPARAM l TCHAR *jid, text[ 1024 ];
DBVARIANT dbv;
- int result = JGetStringT( hContact, "jid", &dbv );
+ int result = JGetStringT(hContact, "jid", &dbv);
if (result)
{
- result = JGetStringT( hContact, "ChatRoomID", &dbv );
- if ( result ) return 0;
+ result = JGetStringT(hContact, "ChatRoomID", &dbv);
+ if (result) return 0;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, dbv.ptszVal );
- if ( !item ) return 0;
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, dbv.ptszVal);
+ if ( !item) return 0;
- mir_sntprintf( text, SIZEOF( text ), _T("%s/%s"), item->jid, item->nick );
+ mir_sntprintf(text, SIZEOF(text), _T("%s/%s"), item->jid, item->nick);
jid = text;
}
else
@@ -1257,7 +1257,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM wParam, LPARAM l EnterString(buf, SIZEOF(buf), TranslateT("Status Message"), JES_MULTINE);
SendPresenceTo(res, jid, NULL, buf);
- JFreeVariant(&dbv);
+ db_free(&dbv);
return 0;
}
@@ -1265,18 +1265,18 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleDirectPresence(WPARAM wParam, LPARAM l // Choose protocol instance
CJabberProto *JabberChooseInstance(bool bIsLink)
{
- if ( g_Instances.getCount() == 0 )
+ if (g_Instances.getCount() == 0)
return NULL;
- if ( g_Instances.getCount() == 1 ) {
- if ( g_Instances[0]->m_iStatus != ID_STATUS_OFFLINE && g_Instances[0]->m_iStatus != ID_STATUS_CONNECTING )
+ if (g_Instances.getCount() == 1) {
+ if (g_Instances[0]->m_iStatus != ID_STATUS_OFFLINE && g_Instances[0]->m_iStatus != ID_STATUS_CONNECTING)
return g_Instances[0];
return NULL;
}
- if ( bIsLink ) {
- for ( int i = 0; i < g_Instances.getCount(); i++ )
- if ( g_Instances[i]->m_options.ProcessXMPPLinks )
+ if (bIsLink) {
+ for (int i = 0; i < g_Instances.getCount(); i++)
+ if (g_Instances[i]->m_options.ProcessXMPPLinks)
return g_Instances[i];
}
@@ -1288,7 +1288,7 @@ CJabberProto *JabberChooseInstance(bool bIsLink) clmi.flags = CMIM_FLAGS;
CJabberProto* ppro = g_Instances[i];
- if ( ppro->m_iStatus != ID_STATUS_OFFLINE && ppro->m_iStatus != ID_STATUS_CONNECTING ) {
+ if (ppro->m_iStatus != ID_STATUS_OFFLINE && ppro->m_iStatus != ID_STATUS_CONNECTING) {
++nItems;
lastItemId = i+1;
clmi.flags |= CMIM_ICON;
@@ -1296,24 +1296,24 @@ CJabberProto *JabberChooseInstance(bool bIsLink) }
else clmi.flags |= CMIF_HIDDEN;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )ppro->m_hChooseMenuItem, ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)ppro->m_hChooseMenuItem, (LPARAM)&clmi);
}
- if ( nItems > 1 ) {
+ if (nItems > 1) {
ListParam param = { 0 };
param.MenuObjectHandle = hChooserMenu;
HMENU hMenu = CreatePopupMenu();
- CallService( MO_BUILDMENU, ( WPARAM )hMenu, ( LPARAM )¶m );
+ CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)¶m);
POINT pt;
GetCursorPos(&pt);
- int res = TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL );
- DestroyMenu( hMenu );
+ int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, pcli->hwndContactList, NULL);
+ DestroyMenu(hMenu);
- if ( res ) {
+ if (res) {
CJabberProto* pro = NULL;
- CallService( MO_PROCESSCOMMANDBYMENUIDENT, res, ( LPARAM )&pro );
+ CallService(MO_PROCESSCOMMANDBYMENUIDENT, res, (LPARAM)&pro);
return pro;
}
diff --git a/protocols/JabberG/src/jabber_message_handlers.cpp b/protocols/JabberG/src/jabber_message_handlers.cpp index a3801f274f..0edae4975c 100644 --- a/protocols/JabberG/src/jabber_message_handlers.cpp +++ b/protocols/JabberG/src/jabber_message_handlers.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -25,63 +25,63 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber.h"
#include "jabber_message_manager.h"
-BOOL CJabberProto::OnMessageError( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo )
+BOOL CJabberProto::OnMessageError(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo)
{
// we check if is message delivery failure
- int id = JabberGetPacketID( node );
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, pInfo->GetFrom());
- if ( item == NULL )
- item = ListGetItemPtr( LIST_CHATROOM, pInfo->GetFrom());
- if ( item != NULL ) { // yes, it is
- TCHAR *szErrText = JabberErrorMsg( pInfo->GetChildNode());
- if ( id != -1 ) {
+ int id = JabberGetPacketID(node);
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, pInfo->GetFrom());
+ if (item == NULL)
+ item = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom());
+ if (item != NULL) { // yes, it is
+ TCHAR *szErrText = JabberErrorMsg(pInfo->GetChildNode());
+ if (id != -1) {
char *errText = mir_t2a(szErrText);
- JSendBroadcast( pInfo->GetHContact(), ACKTYPE_MESSAGE, ACKRESULT_FAILED, ( HANDLE ) id, (LPARAM)errText );
+ JSendBroadcast(pInfo->GetHContact(), ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)errText);
mir_free(errText);
} else {
TCHAR buf[512];
- HXML bodyNode = xmlGetChild( node, "body" );
+ HXML bodyNode = xmlGetChild(node, "body");
if (bodyNode)
- mir_sntprintf( buf, SIZEOF( buf ), _T( "%s:\n%s\n%s" ), pInfo->GetFrom(), xmlGetText( bodyNode ), szErrText );
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s:\n%s\n%s"), pInfo->GetFrom(), xmlGetText(bodyNode), szErrText);
else
- mir_sntprintf( buf, SIZEOF( buf ), _T( "%s:\n%s" ), pInfo->GetFrom(), szErrText );
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s:\n%s"), pInfo->GetFrom(), szErrText);
- MsgPopup( NULL, buf, TranslateT( "Jabber Error" ));
+ MsgPopup(NULL, buf, TranslateT("Jabber Error"));
}
mir_free(szErrText);
}
return TRUE;
}
-BOOL CJabberProto::OnMessageIbb( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo )
+BOOL CJabberProto::OnMessageIbb(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo)
{
BOOL bOk = FALSE;
- const TCHAR *sid = xmlGetAttrValue( pInfo->GetChildNode(), _T("sid"));
- const TCHAR *seq = xmlGetAttrValue( pInfo->GetChildNode(), _T("seq"));
- if ( sid && seq && xmlGetText( pInfo->GetChildNode()) ) {
- bOk = OnIbbRecvdData( xmlGetText( pInfo->GetChildNode()), sid, seq );
+ const TCHAR *sid = xmlGetAttrValue(pInfo->GetChildNode(), _T("sid"));
+ const TCHAR *seq = xmlGetAttrValue(pInfo->GetChildNode(), _T("seq"));
+ if (sid && seq && xmlGetText(pInfo->GetChildNode())) {
+ bOk = OnIbbRecvdData(xmlGetText(pInfo->GetChildNode()), sid, seq);
}
return TRUE;
}
-BOOL CJabberProto::OnMessagePubsubEvent( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo )
+BOOL CJabberProto::OnMessagePubsubEvent(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo)
{
- OnProcessPubsubEvent( node );
+ OnProcessPubsubEvent(node);
return TRUE;
}
-BOOL CJabberProto::OnMessageGroupchat( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo )
+BOOL CJabberProto::OnMessageGroupchat(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo)
{
- JABBER_LIST_ITEM *chatItem = ListGetItemPtr( LIST_CHATROOM, pInfo->GetFrom());
- if ( chatItem )
+ JABBER_LIST_ITEM *chatItem = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom());
+ if (chatItem)
{ // process GC message
- GroupchatProcessMessage( node );
+ GroupchatProcessMessage(node);
} else
{ // got message from unknown conference... let's leave it :)
// TCHAR *conference = NEWTSTR_ALLOCA(from);
// if (TCHAR *s = _tcschr(conference, _T('/'))) *s = 0;
-// XmlNode p( "presence" ); xmlAddAttr( p, "to", conference ); xmlAddAttr( p, "type", "unavailable" );
-// info->send( p );
+// XmlNode p("presence"); xmlAddAttr(p, "to", conference); xmlAddAttr(p, "type", "unavailable");
+// info->send(p);
}
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_message_manager.cpp b/protocols/JabberG/src/jabber_message_manager.cpp index 67e9982eb3..0c7ad7f6d9 100644 --- a/protocols/JabberG/src/jabber_message_manager.cpp +++ b/protocols/JabberG/src/jabber_message_manager.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -27,10 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. BOOL CJabberMessageManager::FillPermanentHandlers()
{
- AddPermanentHandler( &CJabberProto::OnMessageError, JABBER_MESSAGE_TYPE_ERROR, JABBER_MESSAGE_PARSE_FROM | JABBER_MESSAGE_PARSE_HCONTACT, NULL, FALSE, _T("error"));
- AddPermanentHandler( &CJabberProto::OnMessageIbb, 0, 0, _T(JABBER_FEAT_IBB), FALSE, _T("data"));
- AddPermanentHandler( &CJabberProto::OnMessagePubsubEvent, 0, 0, _T(JABBER_FEAT_PUBSUB_EVENT), FALSE, _T("event"));
- AddPermanentHandler( &CJabberProto::OnMessageGroupchat, JABBER_MESSAGE_TYPE_GROUPCHAT, JABBER_MESSAGE_PARSE_FROM, NULL, FALSE, NULL );
+ AddPermanentHandler(&CJabberProto::OnMessageError, JABBER_MESSAGE_TYPE_ERROR, JABBER_MESSAGE_PARSE_FROM | JABBER_MESSAGE_PARSE_HCONTACT, NULL, FALSE, _T("error"));
+ AddPermanentHandler(&CJabberProto::OnMessageIbb, 0, 0, _T(JABBER_FEAT_IBB), FALSE, _T("data"));
+ AddPermanentHandler(&CJabberProto::OnMessagePubsubEvent, 0, 0, _T(JABBER_FEAT_PUBSUB_EVENT), FALSE, _T("event"));
+ AddPermanentHandler(&CJabberProto::OnMessageGroupchat, JABBER_MESSAGE_TYPE_GROUPCHAT, JABBER_MESSAGE_PARSE_FROM, NULL, FALSE, NULL);
return TRUE;
}
@@ -39,22 +39,22 @@ BOOL CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThrea BOOL bStopHandling = FALSE;
Lock();
CJabberMessagePermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo && !bStopHandling ) {
+ while (pInfo && !bStopHandling) {
// have to get all data here, in the loop, because there's always possibility that previous handler modified it
CJabberMessageInfo messageInfo;
LPCTSTR szType = xmlGetAttrValue(node, _T("type"));
- if ( szType )
+ if (szType)
{
- if ( !_tcsicmp( szType, _T("normal")))
+ if ( !_tcsicmp(szType, _T("normal")))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
- else if ( !_tcsicmp( szType, _T("error")))
+ else if ( !_tcsicmp(szType, _T("error")))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_ERROR;
- else if ( !_tcsicmp( szType, _T("chat")))
+ else if ( !_tcsicmp(szType, _T("chat")))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_CHAT;
- else if ( !_tcsicmp( szType, _T("groupchat")))
+ else if ( !_tcsicmp(szType, _T("groupchat")))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_GROUPCHAT;
- else if ( !_tcsicmp( szType, _T("headline")))
+ else if ( !_tcsicmp(szType, _T("headline")))
messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_HEADLINE;
else
break; // m_nMessageType = JABBER_MESSAGE_TYPE_FAIL;
@@ -63,35 +63,35 @@ BOOL CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThrea messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
}
- if ( (pInfo->m_nMessageTypes & messageInfo.m_nMessageType )) {
+ if ((pInfo->m_nMessageTypes & messageInfo.m_nMessageType)) {
int i;
- for ( i = xmlGetChildCount( node ) - 1; i >= 0; i-- ) {
+ for (i = xmlGetChildCount(node) - 1; i >= 0; i--) {
// enumerate all children and see whether this node suits handler criteria
- HXML child = xmlGetChild( node, i );
+ HXML child = xmlGetChild(node, i);
LPCTSTR szTagName = xmlGetName(child);
- LPCTSTR szXmlns = xmlGetAttrValue( child, _T("xmlns"));
+ LPCTSTR szXmlns = xmlGetAttrValue(child, _T("xmlns"));
- if ( (!pInfo->m_szXmlns || ( szXmlns && !_tcscmp( pInfo->m_szXmlns, szXmlns ))) &&
- ( !pInfo->m_szTag || !_tcscmp( pInfo->m_szTag, szTagName ))) {
+ if ((!pInfo->m_szXmlns || (szXmlns && !_tcscmp(pInfo->m_szXmlns, szXmlns))) &&
+ (!pInfo->m_szTag || !_tcscmp(pInfo->m_szTag, szTagName))) {
// node suits handler criteria, call the handler
messageInfo.m_hChildNode = child;
messageInfo.m_szChildTagName = szTagName;
messageInfo.m_szChildTagXmlns = szXmlns;
messageInfo.m_pUserData = pInfo->m_pUserData;
- messageInfo.m_szFrom = xmlGetAttrValue( node, _T("from")); // is necessary for ppro->Log() below, that's why we must parse it even if JABBER_MESSAGE_PARSE_FROM flag is not set
+ messageInfo.m_szFrom = xmlGetAttrValue(node, _T("from")); // is necessary for ppro->Log() below, that's why we must parse it even if JABBER_MESSAGE_PARSE_FROM flag is not set
if (pInfo->m_dwParamsToParse & JABBER_MESSAGE_PARSE_ID_STR)
- messageInfo.m_szId = xmlGetAttrValue( node, _T("id"));
+ messageInfo.m_szId = xmlGetAttrValue(node, _T("id"));
if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
- messageInfo.m_szTo = xmlGetAttrValue( node, _T("to"));
+ messageInfo.m_szTo = xmlGetAttrValue(node, _T("to"));
if (pInfo->m_dwParamsToParse & JABBER_MESSAGE_PARSE_HCONTACT)
- messageInfo.m_hContact = ppro->HContactFromJID( messageInfo.m_szFrom, 3 );
+ messageInfo.m_hContact = ppro->HContactFromJID(messageInfo.m_szFrom, 3);
if (messageInfo.m_szFrom)
- ppro->Log( "Handling message from " TCHAR_STR_PARAM, messageInfo.m_szFrom );
+ ppro->Log("Handling message from " TCHAR_STR_PARAM, messageInfo.m_szFrom);
if ((ppro->*(pInfo->m_pHandler))(node, pThreadData, &messageInfo)) {
bStopHandling = TRUE;
break;
diff --git a/protocols/JabberG/src/jabber_message_manager.h b/protocols/JabberG/src/jabber_message_manager.h index dd52b50683..f45a3227b3 100644 --- a/protocols/JabberG/src/jabber_message_manager.h +++ b/protocols/JabberG/src/jabber_message_manager.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -28,12 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_xml.h"
struct CJabberProto;
-typedef void ( CJabberProto::*JABBER_MESSAGE_PFUNC )( HXML messageNode, void *usedata );
-typedef void ( *MESSAGE_USER_DATA_FREE_FUNC )( void *pUserData );
+typedef void (CJabberProto::*JABBER_MESSAGE_PFUNC)(HXML messageNode, void *usedata);
+typedef void (*MESSAGE_USER_DATA_FREE_FUNC)(void *pUserData);
class CJabberMessageInfo;
-typedef BOOL ( CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER )( HXML messageNode, ThreadData *pThreadData, CJabberMessageInfo* pInfo );
+typedef BOOL (CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER)(HXML messageNode, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
#define JABBER_MESSAGE_PARSE_FROM (1<<3)
#define JABBER_MESSAGE_PARSE_HCONTACT ((1<<4)|JABBER_MESSAGE_PARSE_FROM)
@@ -123,7 +123,7 @@ public: }
~CJabberMessagePermanentInfo()
{
- if ( m_pUserDataFree )
+ if (m_pUserDataFree)
m_pUserDataFree(m_pUserData);
mir_free(m_szXmlns);
mir_free(m_szTag);
@@ -138,7 +138,7 @@ protected: CJabberMessagePermanentInfo* m_pPermanentHandlers;
public:
- CJabberMessageManager( CJabberProto* proto )
+ CJabberMessageManager(CJabberProto* proto)
{
InitializeCriticalSection(&m_cs);
m_pPermanentHandlers = NULL;
@@ -148,7 +148,7 @@ public: {
Lock();
CJabberMessagePermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo )
+ while (pInfo)
{
CJabberMessagePermanentInfo *pTmp = pInfo->m_pNext;
delete pInfo;
@@ -174,24 +174,24 @@ public: {
LeaveCriticalSection(&m_cs);
}
- CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const TCHAR* szXmlns, BOOL bAllowPartialNs, const TCHAR* szTag, void *pUserData = NULL, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
+ CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const TCHAR *szXmlns, BOOL bAllowPartialNs, const TCHAR *szTag, void *pUserData = NULL, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
{
CJabberMessagePermanentInfo* pInfo = new CJabberMessagePermanentInfo();
- if (!pInfo)
+ if ( !pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
pInfo->m_nMessageTypes = nMessageTypes ? nMessageTypes : JABBER_MESSAGE_TYPE_ANY;
- replaceStrT( pInfo->m_szXmlns, szXmlns );
+ replaceStrT(pInfo->m_szXmlns, szXmlns);
pInfo->m_bAllowPartialNs = bAllowPartialNs;
- replaceStrT( pInfo->m_szTag, szTag );
+ replaceStrT(pInfo->m_szTag, szTag);
pInfo->m_dwParamsToParse = dwParamsToParse;
pInfo->m_pUserData = pUserData;
pInfo->m_pUserDataFree = pUserDataFree;
pInfo->m_iPriority = iPriority;
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
m_pPermanentHandlers = pInfo;
else
{
@@ -214,7 +214,7 @@ public: BOOL DeletePermanentHandler(CJabberMessagePermanentInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
{
Unlock();
return FALSE;
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index e13c0d450d..5b1fe0da26 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -31,14 +31,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////
// JabberAddContactToRoster() - adds a contact to the roster
-void CJabberProto::AddContactToRoster( const TCHAR* jid, const TCHAR* nick, const TCHAR* grpName )
+void CJabberProto::AddContactToRoster(const TCHAR *jid, const TCHAR *nick, const TCHAR *grpName)
{
- XmlNodeIq iq( _T("set"), SerialNext());
- HXML query = iq << XQUERY( _T(JABBER_FEAT_IQ_ROSTER))
- << XCHILD( _T("item")) << XATTR( _T("jid"), jid ) << XATTR( _T("name"), nick );
- if ( grpName )
- query << XCHILD( _T("group"), grpName );
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("set"), SerialNext());
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_IQ_ROSTER))
+ << XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("name"), nick);
+ if (grpName)
+ query << XCHILD(_T("group"), grpName);
+ m_ThreadInfo->send(iq);
}
///////////////////////////////////////////////////////////////////////////////
@@ -46,198 +46,198 @@ void CJabberProto::AddContactToRoster( const TCHAR* jid, const TCHAR* nick, cons void JabberChatDllError()
{
- MessageBox( NULL,
- TranslateT( "CHAT plugin is required for conferences. Install it before chatting" ),
- TranslateT( "Jabber Error" ), MB_OK|MB_SETFOREGROUND );
+ MessageBox(NULL,
+ TranslateT("CHAT plugin is required for conferences. Install it before chatting"),
+ TranslateT("Jabber Error"), MB_OK|MB_SETFOREGROUND);
}
///////////////////////////////////////////////////////////////////////////////
// JabberCompareJids
-int JabberCompareJids( const TCHAR* jid1, const TCHAR* jid2 )
+int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2)
{
- if ( !lstrcmpi( jid1, jid2 ))
+ if ( !lstrcmpi(jid1, jid2))
return 0;
// match only node@domain part
TCHAR szTempJid1[ JABBER_MAX_JID_LEN ], szTempJid2[ JABBER_MAX_JID_LEN ];
return lstrcmpi(
- JabberStripJid( jid1, szTempJid1, SIZEOF(szTempJid1)),
- JabberStripJid( jid2, szTempJid2, SIZEOF(szTempJid2)));
+ JabberStripJid(jid1, szTempJid1, SIZEOF(szTempJid1)),
+ JabberStripJid(jid2, szTempJid2, SIZEOF(szTempJid2)));
}
///////////////////////////////////////////////////////////////////////////////
// JabberContactListCreateGroup()
-static void JabberContactListCreateClistGroup( TCHAR* groupName )
+static void JabberContactListCreateClistGroup(TCHAR* groupName)
{
char str[33];
int i;
DBVARIANT dbv;
- for ( i=0;;i++ ) {
- _itoa( i, str, 10 );
- if ( DBGetContactSettingTString( NULL, "CListGroups", str, &dbv ))
+ for (i=0;;i++) {
+ _itoa(i, str, 10);
+ if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv))
break;
TCHAR* name = dbv.ptszVal;
- if ( name[0]!='\0' && !_tcscmp( name+1, groupName )) {
+ if (name[0]!='\0' && !_tcscmp(name+1, groupName)) {
// Already exists, no need to create
- JFreeVariant( &dbv );
+ db_free(&dbv);
return;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- // Create new group with id = i ( str is the text representation of i )
+ // Create new group with id = i (str is the text representation of i)
TCHAR newName[128];
newName[0] = 1 | GROUPF_EXPANDED;
- _tcsncpy( newName+1, groupName, SIZEOF( newName )-1 );
- newName[ SIZEOF( newName )-1] = '\0';
- DBWriteContactSettingTString( NULL, "CListGroups", str, newName );
- CallService( MS_CLUI_GROUPADDED, i+1, 0 );
+ _tcsncpy(newName+1, groupName, SIZEOF(newName)-1);
+ newName[ SIZEOF(newName)-1] = '\0';
+ db_set_ts(NULL, "CListGroups", str, newName);
+ CallService(MS_CLUI_GROUPADDED, i+1, 0);
}
-void JabberContactListCreateGroup( TCHAR* groupName )
+void JabberContactListCreateGroup(TCHAR* groupName)
{
TCHAR name[128], *p;
- if ( groupName==NULL || groupName[0]=='\0' || groupName[0]=='\\' ) return;
+ if (groupName==NULL || groupName[0]=='\0' || groupName[0]=='\\') return;
- _tcsncpy( name, groupName, SIZEOF( name ));
- name[ SIZEOF( name )-1] = '\0';
- for ( p=name; *p!='\0'; p++ ) {
- if ( *p == '\\' ) {
+ _tcsncpy(name, groupName, SIZEOF(name));
+ name[ SIZEOF(name)-1] = '\0';
+ for (p=name; *p!='\0'; p++) {
+ if (*p == '\\') {
*p = '\0';
- JabberContactListCreateClistGroup( name );
+ JabberContactListCreateClistGroup(name);
*p = '\\';
}
}
- JabberContactListCreateClistGroup( name );
+ JabberContactListCreateClistGroup(name);
}
///////////////////////////////////////////////////////////////////////////////
// JabberDBAddAuthRequest()
-void CJabberProto::DBAddAuthRequest( const TCHAR* jid, const TCHAR* nick )
+void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
{
- HANDLE hContact = DBCreateContact( jid, NULL, TRUE, TRUE );
- JDeleteSetting( hContact, "Hidden" );
- //JSetStringT( hContact, "Nick", nick );
+ HANDLE hContact = DBCreateContact(jid, NULL, TRUE, TRUE);
+ JDeleteSetting(hContact, "Hidden");
+ //JSetStringT(hContact, "Nick", nick);
- char* szJid = mir_utf8encodeT( jid );
- char* szNick = mir_utf8encodeT( nick );
+ char* szJid = mir_utf8encodeT(jid);
+ char* szNick = mir_utf8encodeT(nick);
//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- //blob is: 0( DWORD ), hContact(DWORD), nick( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ ), email( ASCIIZ ), ""( ASCIIZ )
+ //blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.szModule = m_szModuleName;
- dbei.timestamp = ( DWORD )time( NULL );
+ dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_UTF;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
- dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + strlen( szNick ) + strlen( szJid ) + 5);
+ dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + strlen(szNick) + strlen(szJid) + 5);
PBYTE pCurBlob = dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
*((PDWORD)pCurBlob) = 0; pCurBlob += sizeof(DWORD);
*((PDWORD)pCurBlob) = (DWORD)hContact; pCurBlob += sizeof(DWORD);
- strcpy(( char* )pCurBlob, szNick ); pCurBlob += strlen( szNick )+1;
+ strcpy((char*)pCurBlob, szNick); pCurBlob += strlen(szNick)+1;
*pCurBlob = '\0'; pCurBlob++; //firstName
*pCurBlob = '\0'; pCurBlob++; //lastName
- strcpy(( char* )pCurBlob, szJid ); pCurBlob += strlen( szJid )+1;
+ strcpy((char*)pCurBlob, szJid); pCurBlob += strlen(szJid)+1;
*pCurBlob = '\0'; //reason
- CallService( MS_DB_EVENT_ADD, ( WPARAM ) ( HANDLE ) NULL, ( LPARAM )&dbei );
- Log( "Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid );
+ CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)NULL, (LPARAM)&dbei);
+ Log("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);
- mir_free( szJid );
- mir_free( szNick );
+ mir_free(szJid);
+ mir_free(szNick);
}
///////////////////////////////////////////////////////////////////////////////
// JabberDBCreateContact()
-HANDLE CJabberProto::DBCreateContact( const TCHAR* jid, const TCHAR* nick, BOOL temporary, BOOL stripResource )
+HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource)
{
TCHAR* s, *p, *q;
size_t len;
- char* szProto;
+ char *szProto;
- if ( jid==NULL || jid[0]=='\0' )
+ if (jid==NULL || jid[0]=='\0')
return NULL;
- s = mir_tstrdup( jid );
+ s = mir_tstrdup(jid);
q = NULL;
// strip resource if present
- if (( p = _tcschr( s, '@' )) != NULL )
- if (( q = _tcschr( p, '/' )) != NULL )
+ if ((p = _tcschr(s, '@')) != NULL)
+ if ((q = _tcschr(p, '/')) != NULL)
*q = '\0';
- if ( !stripResource && q!=NULL ) // so that resource is not stripped
+ if ( !stripResource && q!=NULL) // so that resource is not stripped
*q = '/';
- len = _tcslen( s );
+ len = _tcslen(s);
// We can't use JabberHContactFromJID() here because of the stripResource option
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto!=NULL && !strcmp( m_szModuleName, szProto )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto!=NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
p = dbv.ptszVal;
- if ( p && _tcslen( p )>=len && ( p[len]=='\0'||p[len]=='/' ) && !_tcsnicmp( p, s, len )) {
- JFreeVariant( &dbv );
+ if (p && _tcslen(p)>=len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len)) {
+ db_free(&dbv);
break;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
} }
hContact = db_find_next(hContact);
}
- if ( hContact == NULL ) {
- hContact = ( HANDLE ) CallService( MS_DB_CONTACT_ADD, 0, 0 );
- CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM ) hContact, ( LPARAM )m_szModuleName );
- JSetStringT( hContact, "jid", s );
- if ( nick != NULL && *nick != '\0' )
- JSetStringT( hContact, "Nick", nick );
- if ( temporary )
- DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 );
+ if (hContact == NULL) {
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName);
+ JSetStringT(hContact, "jid", s);
+ if (nick != NULL && *nick != '\0')
+ JSetStringT(hContact, "Nick", nick);
+ if (temporary)
+ db_set_b(hContact, "CList", "NotOnList", 1);
else
- SendGetVcard( s );
- Log( "Create Jabber contact jid=" TCHAR_STR_PARAM ", nick=" TCHAR_STR_PARAM, s, nick );
+ SendGetVcard(s);
+ Log("Create Jabber contact jid=" TCHAR_STR_PARAM ", nick=" TCHAR_STR_PARAM, s, nick);
DBCheckIsTransportedContact(s,hContact);
}
- mir_free( s );
+ mir_free(s);
return hContact;
}
BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType)
{
- if ( !hContact )
+ if ( !hContact)
return FALSE;
- switch ( btEventType ) {
+ switch (btEventType) {
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBE:
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBED:
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE:
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED:
- if ( !m_options.LogPresence )
+ if ( !m_options.LogPresence)
return FALSE;
break;
case JABBER_DB_EVENT_PRESENCE_ERROR:
- if ( !m_options.LogPresenceErrors )
+ if ( !m_options.LogPresenceErrors)
return FALSE;
break;
}
DBEVENTINFO dbei;
- dbei.cbSize = sizeof( dbei );
+ dbei.cbSize = sizeof(dbei);
dbei.pBlob = &btEventType;
- dbei.cbBlob = sizeof( btEventType );
+ dbei.cbBlob = sizeof(btEventType);
dbei.eventType = JABBER_DB_EVENT_TYPE_PRESENCE;
dbei.flags = DBEF_READ;
- dbei.timestamp = time( NULL );
+ dbei.timestamp = time(NULL);
dbei.szModule = m_szModuleName;
- CallService( MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei );
+ CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
return TRUE;
}
@@ -248,117 +248,117 @@ BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType) static HANDLE hJabberAvatarsFolder = NULL;
static bool bInitDone = false;
-void CJabberProto::InitCustomFolders( void )
+void CJabberProto::InitCustomFolders(void)
{
- if ( bInitDone )
+ if (bInitDone)
return;
bInitDone = true;
- if ( ServiceExists( MS_FOLDERS_REGISTER_PATH )) {
+ if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
TCHAR AvatarsFolder[MAX_PATH];
- mir_sntprintf( AvatarsFolder, SIZEOF( AvatarsFolder ), _T("%%miranda_avatarcache%%\\Jabber"));
- hJabberAvatarsFolder = FoldersRegisterCustomPathT( m_szModuleName, "Avatars", AvatarsFolder ); // title!!!!!!!!!!!
+ mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\Jabber"));
+ hJabberAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", AvatarsFolder); // title!!!!!!!!!!!
} }
-void CJabberProto::GetAvatarFileName( HANDLE hContact, TCHAR* pszDest, size_t cbLen )
+void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen)
{
size_t tPathLen;
- TCHAR* path = ( TCHAR* )alloca( cbLen * sizeof( TCHAR ));
+ TCHAR* path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
InitCustomFolders();
- if ( hJabberAvatarsFolder == NULL || FoldersGetCustomPathT( hJabberAvatarsFolder, path, (int)cbLen, _T(""))) {
- TCHAR *tmpPath = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- tPathLen = mir_sntprintf( pszDest, cbLen, _T("%s\\Jabber"), tmpPath );
+ if (hJabberAvatarsFolder == NULL || FoldersGetCustomPathT(hJabberAvatarsFolder, path, (int)cbLen, _T(""))) {
+ TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_avatarcache%"));
+ tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\Jabber"), tmpPath);
mir_free(tmpPath);
}
- else tPathLen = mir_sntprintf( pszDest, cbLen, _T("%s"), path );
+ else tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s"), path);
- DWORD dwAttributes = GetFileAttributes( pszDest );
- if ( dwAttributes == 0xffffffff || ( dwAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0 )
- CallService( MS_UTILS_CREATEDIRTREET, 0, ( LPARAM )pszDest );
+ DWORD dwAttributes = GetFileAttributes(pszDest);
+ if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
+ CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest);
pszDest[ tPathLen++ ] = '\\';
char* szFileType = NULL;
- switch( JGetByte( hContact, "AvatarType", PA_FORMAT_PNG )) {
+ switch(JGetByte(hContact, "AvatarType", PA_FORMAT_PNG)) {
case PA_FORMAT_JPEG: szFileType = "jpg"; break;
case PA_FORMAT_PNG: szFileType = "png"; break;
case PA_FORMAT_GIF: szFileType = "gif"; break;
case PA_FORMAT_BMP: szFileType = "bmp"; break;
}
- if ( hContact != NULL ) {
+ if (hContact != NULL) {
char str[ 256 ];
DBVARIANT dbv;
- if ( !JGetStringUtf( hContact, "jid", &dbv )) {
- strncpy( str, dbv.pszVal, sizeof str );
+ if ( !JGetStringUtf(hContact, "jid", &dbv)) {
+ strncpy(str, dbv.pszVal, sizeof str);
str[ sizeof(str)-1 ] = 0;
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- else _i64toa(( LONG_PTR )hContact, str, 10 );
+ else _i64toa((LONG_PTR)hContact, str, 10);
- char* hash = JabberSha1( str );
- mir_sntprintf( pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T(".") _T(TCHAR_STR_PARAM), hash, szFileType );
- mir_free( hash );
+ char* hash = JabberSha1(str);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T(".") _T(TCHAR_STR_PARAM), hash, szFileType);
+ mir_free(hash);
}
- else if ( m_ThreadInfo != NULL ) {
- mir_sntprintf( pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
- m_ThreadInfo->username, m_ThreadInfo->server, szFileType );
+ else if (m_ThreadInfo != NULL) {
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
+ m_ThreadInfo->username, m_ThreadInfo->server, szFileType);
}
else {
DBVARIANT dbv1, dbv2;
- BOOL res1 = DBGetContactSettingString( NULL, m_szModuleName, "LoginName", &dbv1 );
- BOOL res2 = DBGetContactSettingString( NULL, m_szModuleName, "LoginServer", &dbv2 );
- mir_sntprintf( pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T("@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
+ BOOL res1 = DBGetContactSettingString(NULL, m_szModuleName, "LoginName", &dbv1);
+ BOOL res2 = DBGetContactSettingString(NULL, m_szModuleName, "LoginServer", &dbv2);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T("@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
res1 ? "noname" : dbv1.pszVal,
res2 ? m_szModuleName : dbv2.pszVal,
- szFileType );
- if (!res1) JFreeVariant( &dbv1 );
- if (!res2) JFreeVariant( &dbv2 );
+ szFileType);
+ if ( !res1) db_free(&dbv1);
+ if ( !res2) db_free(&dbv2);
}
}
///////////////////////////////////////////////////////////////////////////////
// JabberResolveTransportNicks - massive vcard update
-void CJabberProto::ResolveTransportNicks( const TCHAR* jid )
+void CJabberProto::ResolveTransportNicks(const TCHAR *jid)
{
// Set all contacts to offline
HANDLE hContact = m_ThreadInfo->resolveContact;
- if ( hContact == NULL )
- hContact = ( HANDLE ) db_find_first();
+ if (hContact == NULL)
+ hContact = (HANDLE)db_find_first();
- for ( ; hContact != NULL; hContact = db_find_next(hContact)) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( lstrcmpA( szProto, m_szModuleName ))
+ for (; hContact != NULL; hContact = db_find_next(hContact)) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (lstrcmpA(szProto, m_szModuleName))
continue;
- if ( !JGetByte( hContact, "IsTransported", 0 ))
+ if ( !JGetByte(hContact, "IsTransported", 0))
continue;
DBVARIANT dbv, nick;
- if ( JGetStringT( hContact, "jid", &dbv ))
+ if (JGetStringT(hContact, "jid", &dbv))
continue;
- if ( JGetStringT( hContact, "Nick", &nick )) {
- JFreeVariant( &dbv );
+ if (JGetStringT(hContact, "Nick", &nick)) {
+ db_free(&dbv);
continue;
}
- TCHAR* p = _tcschr( dbv.ptszVal, '@' );
- if ( p ) {
+ TCHAR* p = _tcschr(dbv.ptszVal, '@');
+ if (p) {
*p = 0;
- if ( !lstrcmp( jid, p+1 ) && !lstrcmp( dbv.ptszVal, nick.ptszVal )) {
+ if ( !lstrcmp(jid, p+1) && !lstrcmp(dbv.ptszVal, nick.ptszVal)) {
*p = '@';
- m_ThreadInfo->resolveID = SendGetVcard( dbv.ptszVal );
+ m_ThreadInfo->resolveID = SendGetVcard(dbv.ptszVal);
m_ThreadInfo->resolveContact = hContact;
- JFreeVariant( &dbv );
- JFreeVariant( &nick );
+ db_free(&dbv);
+ db_free(&nick);
return;
} }
- JFreeVariant( &dbv );
- JFreeVariant( &nick );
+ db_free(&dbv);
+ db_free(&nick);
}
m_ThreadInfo->resolveID = -1;
@@ -368,14 +368,14 @@ void CJabberProto::ResolveTransportNicks( const TCHAR* jid ) ///////////////////////////////////////////////////////////////////////////////
// JabberSetServerStatus()
-void CJabberProto::SetServerStatus( int iNewStatus )
+void CJabberProto::SetServerStatus(int iNewStatus)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return;
// change status
int oldStatus = m_iStatus;
- switch ( iNewStatus ) {
+ switch (iNewStatus) {
case ID_STATUS_ONLINE:
case ID_STATUS_NA:
case ID_STATUS_FREECHAT:
@@ -395,12 +395,12 @@ void CJabberProto::SetServerStatus( int iNewStatus ) return;
}
- if ( m_iStatus == oldStatus )
+ if (m_iStatus == oldStatus)
return;
// send presence update
- SendPresence( m_iStatus, true );
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ SendPresence(m_iStatus, true);
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
// Process a string, and double all % characters, according to chat.dll's restrictions
@@ -408,18 +408,18 @@ void CJabberProto::SetServerStatus( int iNewStatus ) TCHAR* EscapeChatTags(TCHAR* pszText)
{
int nChars = 0;
- for ( TCHAR* p = pszText; ( p = _tcschr( p, '%' )) != NULL; p++ )
+ for (TCHAR* p = pszText; (p = _tcschr(p, '%')) != NULL; p++)
nChars++;
- if ( nChars == 0 )
- return mir_tstrdup( pszText );
+ if (nChars == 0)
+ return mir_tstrdup(pszText);
- TCHAR* pszNewText = (TCHAR*)mir_alloc( sizeof(TCHAR)*(_tcslen( pszText ) + 1 + nChars )), *s, *d;
- if ( pszNewText == NULL )
- return mir_tstrdup( pszText );
+ TCHAR* pszNewText = (TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(pszText) + 1 + nChars)), *s, *d;
+ if (pszNewText == NULL)
+ return mir_tstrdup(pszText);
- for ( s = pszText, d = pszNewText; *s; s++ ) {
- if ( *s == '%' )
+ for (s = pszText, d = pszNewText; *s; s++) {
+ if (*s == '%')
*d++ = '%';
*d++ = *s;
}
@@ -430,8 +430,8 @@ TCHAR* EscapeChatTags(TCHAR* pszText) TCHAR* UnEscapeChatTags(TCHAR* str_in)
{
TCHAR* s = str_in, *d = str_in;
- while ( *s ) {
- if ( *s == '%' && s[1] == '%' )
+ while (*s) {
+ if (*s == '%' && s[1] == '%')
s++;
*d++ = *s++;
}
@@ -460,7 +460,7 @@ static sttCapsNodeToName_Map[] = void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item)
{
HANDLE hContact = HContactFromJID(item->jid);
- if (!hContact)
+ if ( !hContact)
return;
Log("JabberUpdateMirVer: for jid " TCHAR_STR_PARAM, item->jid);
@@ -473,17 +473,17 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) if ((resource < 0) || (resource >= item->resourceCount))
return;
- UpdateMirVer( hContact, &item->resource[resource] );
+ UpdateMirVer(hContact, &item->resource[resource]);
}
void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize)
{
- if ( !buf || !bufSize ) return;
+ if ( !buf || !bufSize) return;
buf[ 0 ] = _T('\0');
- if ( !resource ) return;
+ if ( !resource) return;
// jabber:iq:version info requested and exists?
- if ( resource->dwVersionRequestTime && resource->software ) {
+ if (resource->dwVersionRequestTime && resource->software) {
Log("JabberUpdateMirVer: for iq:version rc " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM, resource->resourceName, resource->software);
if ( !resource->version || _tcsstr(resource->software, resource->version))
lstrcpyn(buf, resource->software, bufSize);
@@ -491,9 +491,9 @@ void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, in mir_sntprintf(buf, bufSize, _T("%s %s"), resource->software, resource->version);
}
// no version info and no caps info? set MirVer = resource name
- else if ( !resource->szCapsNode || !resource->szCapsVer ) {
+ else if ( !resource->szCapsNode || !resource->szCapsVer) {
Log("JabberUpdateMirVer: for rc " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM, resource->resourceName, resource->resourceName);
- if ( resource->resourceName )
+ if (resource->resourceName)
lstrcpyn(buf, resource->resourceName, bufSize);
}
// XEP-0115 caps mode
@@ -504,21 +504,21 @@ void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, in // search through known software list
for (i = 0; i < SIZEOF(sttCapsNodeToName_Map); ++i)
- if ( _tcsstr( resource->szCapsNode, sttCapsNodeToName_Map[i].node ))
+ if (_tcsstr(resource->szCapsNode, sttCapsNodeToName_Map[i].node))
{
- mir_sntprintf( buf, bufSize, _T("%s %s"), sttCapsNodeToName_Map[i].name, resource->szCapsVer );
+ mir_sntprintf(buf, bufSize, _T("%s %s"), sttCapsNodeToName_Map[i].name, resource->szCapsVer);
break;
}
// unknown software
if (i == SIZEOF(sttCapsNodeToName_Map))
- mir_sntprintf( buf, bufSize, _T("%s %s"), resource->szCapsNode, resource->szCapsVer );
+ mir_sntprintf(buf, bufSize, _T("%s %s"), resource->szCapsNode, resource->szCapsVer);
}
// attach additional info for fingerprint plguin
if (resource->resourceName && !_tcsstr(buf, resource->resourceName))
{
- if (_tcsstr(buf, _T("Miranda IM")) || _tcsstr(buf, _T("Miranda NG")) || m_options.ShowForeignResourceInMirVer )
+ if (_tcsstr(buf, _T("Miranda IM")) || _tcsstr(buf, _T("Miranda NG")) || m_options.ShowForeignResourceInMirVer)
{
int offset = lstrlen(buf);
mir_sntprintf(buf + offset, bufSize - offset, _T(" [%s]"), resource->resourceName);
@@ -537,20 +537,20 @@ void CJabberProto::UpdateMirVer(HANDLE hContact, JABBER_RESOURCE_STATUS *resourc {
TCHAR szMirVer[ 512 ];
FormatMirVer(resource, szMirVer, SIZEOF(szMirVer));
- if ( szMirVer[0] )
- JSetStringT( hContact, "MirVer", szMirVer );
+ if (szMirVer[0])
+ JSetStringT(hContact, "MirVer", szMirVer);
// else
-// JDeleteSetting( hContact, "MirVer" );
+// JDeleteSetting(hContact, "MirVer");
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
- if ( resource->resourceName )
- mir_sntprintf( szFullJid, SIZEOF( szFullJid ), _T("%s/%s"), dbv.ptszVal, resource->resourceName );
+ if (resource->resourceName)
+ mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), dbv.ptszVal, resource->resourceName);
else
- lstrcpyn( szFullJid, dbv.ptszVal, SIZEOF(szFullJid));
- JSetStringT( hContact, DBSETTING_DISPLAY_UID, szFullJid );
- JFreeVariant( &dbv );
+ lstrcpyn(szFullJid, dbv.ptszVal, SIZEOF(szFullJid));
+ JSetStringT(hContact, DBSETTING_DISPLAY_UID, szFullJid);
+ db_free(&dbv);
}
}
@@ -585,18 +585,18 @@ void CJabberProto::UpdateSubscriptionInfo(HANDLE hContact, JABBER_LIST_ITEM *ite }
}
-void CJabberProto::SetContactOfflineStatus( HANDLE hContact )
+void CJabberProto::SetContactOfflineStatus(HANDLE hContact)
{
- if ( JGetWord( hContact, "Status", ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE )
- JSetWord( hContact, "Status", ID_STATUS_OFFLINE );
+ if (JGetWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ JSetWord(hContact, "Status", ID_STATUS_OFFLINE);
- JDeleteSetting( hContact, DBSETTING_XSTATUSID );
- JDeleteSetting( hContact, DBSETTING_XSTATUSNAME );
- JDeleteSetting( hContact, DBSETTING_XSTATUSMSG );
- JDeleteSetting( hContact, DBSETTING_DISPLAY_UID );
+ JDeleteSetting(hContact, DBSETTING_XSTATUSID);
+ JDeleteSetting(hContact, DBSETTING_XSTATUSNAME);
+ JDeleteSetting(hContact, DBSETTING_XSTATUSMSG);
+ JDeleteSetting(hContact, DBSETTING_DISPLAY_UID);
- ResetAdvStatus( hContact, ADVSTATUS_MOOD );
- ResetAdvStatus( hContact, ADVSTATUS_TUNE );
+ ResetAdvStatus(hContact, ADVSTATUS_MOOD);
+ ResetAdvStatus(hContact, ADVSTATUS_TUNE);
//JabberUpdateContactExtraIcon(hContact);
}
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp index d684541f0a..86585d9823 100644 --- a/protocols/JabberG/src/jabber_notes.cpp +++ b/protocols/JabberG/src/jabber_notes.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
@@ -31,9 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static TCHAR *StrTrimCopy(TCHAR *str)
{
- if (!str) return 0;
+ if ( !str) return 0;
while (*str && _istspace(*str)) ++str;
- if (!*str) return mir_tstrdup(str);
+ if ( !*str) return mir_tstrdup(str);
TCHAR *res = mir_tstrdup(str);
for (TCHAR *p = res + lstrlen(res) - 1; p >= res; --p)
@@ -95,7 +95,7 @@ void CNoteItem::SetData(TCHAR *title, TCHAR *from, TCHAR *text, TCHAR *tags) const TCHAR *szTags = tags;
TCHAR *p = m_szTags = (TCHAR *)mir_alloc((lstrlen(szTags) + 2 /*for double zero*/) * sizeof(TCHAR));
TCHAR *q = m_szTagsStr = (TCHAR *)mir_alloc((lstrlen(szTags) + 1) * sizeof(TCHAR));
- for ( ; szTags && *szTags; ++szTags)
+ for (; szTags && *szTags; ++szTags)
{
if (_istspace(*szTags))
continue;
@@ -115,11 +115,11 @@ void CNoteItem::SetData(TCHAR *title, TCHAR *from, TCHAR *text, TCHAR *tags) bool CNoteItem::HasTag(const TCHAR *szTag)
{
- if (!szTag || !*szTag)
+ if ( !szTag || !*szTag)
return true;
for (TCHAR *p = m_szTags; p && *p; p = p + lstrlen(p) + 1)
- if (!lstrcmp(p, szTag))
+ if ( !lstrcmp(p, szTag))
return true;
return false;
@@ -248,7 +248,7 @@ CJabberDlgNoteItem::CJabberDlgNoteItem(CJabberProto *proto, CNoteItem *pNote, TF void CJabberDlgNoteItem::OnInitDialog()
{
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "notes" );
+ WindowSetIcon(m_hwnd, m_proto, "notes");
if (m_fnProcess)
{
@@ -296,7 +296,7 @@ class CCtrlNotebookList: public CCtrlListBox HFONT m_hfntNormal, m_hfntSmall, m_hfntBold;
public:
- CCtrlNotebookList( CDlgBase* dlg, int ctrlId ): CCtrlListBox( dlg, ctrlId ) {}
+ CCtrlNotebookList(CDlgBase* dlg, int ctrlId): CCtrlListBox(dlg, ctrlId) {}
void SetFonts(HFONT hfntNormal, HFONT hfntSmall, HFONT hfntBold)
{
m_hfntNormal = hfntNormal;
@@ -354,7 +354,7 @@ public: {
if (m_adding) return FALSE;
if (lps->itemID == -1) return TRUE;
- if (!lps->itemData) return TRUE;
+ if ( !lps->itemData) return TRUE;
HDC hdc = lps->hDC;
CNoteItem *pNote = (CNoteItem *)lps->itemData;
@@ -406,7 +406,7 @@ public: {
if (m_adding) return FALSE;
if (lps->itemID == -1) return TRUE;
- if (!lps->itemData) return TRUE;
+ if ( !lps->itemData) return TRUE;
HDC hdc = GetDC(m_hwnd);
CNoteItem *pNote = (CNoteItem *)lps->itemData;
@@ -499,7 +499,7 @@ private: {
TCHAR *tags = m_proto->m_notes[i].GetTags();
for (TCHAR *tag = tags; tag && *tag; tag = tag + lstrlen(tag) + 1)
- if (!tagSet.find(tag))
+ if ( !tagSet.find(tag))
tagSet.insert(tag);
}
@@ -511,7 +511,7 @@ private: InsertTag(htiRoot, tagSet[j], select);
}
- if (!selected)
+ if ( !selected)
m_tvFilter.SelectItem(htiRoot);
tagSet.destroy();
@@ -630,7 +630,7 @@ private: void btnSave_OnClick(CCtrlButton *)
{
XmlNodeIq iq(_T("set"));
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE));
HXML storage = query << XCHILDNS(_T("storage"), _T(JABBER_FEAT_MIRANDA_NOTES));
m_proto->m_notes.SaveXml(storage);
m_proto->m_ThreadInfo->send(iq);
@@ -668,7 +668,7 @@ void CJabberDlgNotes::UpdateData() void CJabberDlgNotes::OnInitDialog()
{
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "notes" );
+ WindowSetIcon(m_hwnd, m_proto, "notes");
LOGFONT lf, lfTmp;
m_hfntNormal = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
@@ -717,7 +717,7 @@ void CJabberDlgNotes::OnProtoRefresh(WPARAM, LPARAM) int CJabberDlgNotes::Resizer(UTILRESIZECONTROL *urc)
{
- switch ( urc->wId ) {
+ switch (urc->wId) {
case IDC_TV_FILTER:
return RD_ANCHORX_LEFT|RD_ANCHORY_HEIGHT;
case IDC_LST_NOTES:
@@ -743,7 +743,7 @@ void CJabberProto::ProcessIncomingNote(CNoteItem *pNote, bool ok) m_notes.insert(pNote);
XmlNodeIq iq(_T("set"));
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVATE_STORAGE));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVATE_STORAGE));
HXML storage = query << XCHILDNS(_T("storage"), _T(JABBER_FEAT_MIRANDA_NOTES));
m_notes.SaveXml(storage);
m_ThreadInfo->send(iq);
@@ -755,7 +755,7 @@ void CJabberProto::ProcessIncomingNote(CNoteItem *pNote, bool ok) void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok)
{
- if (!ok || !pNote->IsNotEmpty())
+ if ( !ok || !pNote->IsNotEmpty())
{
delete pNote;
return;
@@ -765,15 +765,15 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok) mir_sntprintf(buf, SIZEOF(buf), _T("Incoming note: %s\n\n%s\nTags: %s"),
pNote->GetTitle(), pNote->GetText(), pNote->GetTagsStr());
- JabberCapsBits jcb = GetResourceCapabilites( pNote->GetFrom(), TRUE );
+ JabberCapsBits jcb = GetResourceCapabilites(pNote->GetFrom(), TRUE);
- if ( jcb & JABBER_RESOURCE_CAPS_ERROR )
+ if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
int nMsgId = SerialNext();
XmlNode m(_T("message"));
- m << XATTR(_T("type"), _T("chat")) << XATTR( _T("to"), pNote->GetFrom()) << XATTRID( nMsgId );
+ m << XATTR(_T("type"), _T("chat")) << XATTR(_T("to"), pNote->GetFrom()) << XATTRID(nMsgId);
m << XCHILD(_T("body"), buf);
HXML hXmlItem = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MIRANDA_NOTES)) << XCHILD(_T("note"));
hXmlItem << XATTR(_T("tags"), pNote->GetTagsStr());
@@ -781,11 +781,11 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok) hXmlItem << XCHILD(_T("text"), pNote->GetText());
// message receipts XEP priority
- if ( jcb & JABBER_CAPS_MESSAGE_RECEIPTS )
- m << XCHILDNS( _T("request"), _T(JABBER_FEAT_MESSAGE_RECEIPTS));
- else if ( jcb & JABBER_CAPS_MESSAGE_EVENTS ) {
- HXML x = m << XCHILDNS( _T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
- x << XCHILD( _T("delivered")); x << XCHILD( _T("offline"));
+ if (jcb & JABBER_CAPS_MESSAGE_RECEIPTS)
+ m << XCHILDNS(_T("request"), _T(JABBER_FEAT_MESSAGE_RECEIPTS));
+ else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
+ HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
+ x << XCHILD(_T("delivered")); x << XCHILD(_T("offline"));
}
else
nMsgId = -1;
@@ -796,12 +796,12 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok) bool CJabberProto::OnIncomingNote(const TCHAR *szFrom, HXML hXml)
{
- if (!m_options.AcceptNotes)
+ if ( !m_options.AcceptNotes)
return false;
- if (!szFrom || !hXml) return true;
+ if ( !szFrom || !hXml) return true;
CNoteItem *pItem = new CNoteItem(hXml, (TCHAR *)szFrom);
- if (!pItem->IsNotEmpty())
+ if ( !pItem->IsNotEmpty())
{
delete pItem;
return true;
@@ -815,7 +815,7 @@ bool CJabberProto::OnIncomingNote(const TCHAR *szFrom, HXML hXml) CLISTEVENT cle = {0};
char szService[256];
- mir_snprintf( szService, sizeof(szService),"%s%s", m_szModuleName, JS_INCOMING_NOTE_EVENT );
+ mir_snprintf(szService, sizeof(szService),"%s%s", m_szModuleName, JS_INCOMING_NOTE_EVENT);
cle.cbSize = sizeof(CLISTEVENT);
cle.hIcon = (HICON)LoadIconEx("notes");
cle.flags = CLEF_PROTOCOLGLOBAL|CLEF_TCHAR;
@@ -832,7 +832,7 @@ INT_PTR __cdecl CJabberProto::OnIncomingNoteEvent(WPARAM, LPARAM lParam) {
CLISTEVENT *pCle = (CLISTEVENT *)lParam;
CNoteItem *pNote = (CNoteItem *)pCle->lParam;
- if ( !pNote )
+ if ( !pNote)
return 0;
CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pNote, &CJabberProto::ProcessIncomingNote);
@@ -843,7 +843,7 @@ INT_PTR __cdecl CJabberProto::OnIncomingNoteEvent(WPARAM, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// Menu handling
-INT_PTR __cdecl CJabberProto::OnMenuHandleNotes( WPARAM, LPARAM)
+INT_PTR __cdecl CJabberProto::OnMenuHandleNotes(WPARAM, LPARAM)
{
UI_SAFE_OPEN_EX(CJabberDlgNotes, m_pDlgNotes, pDlg);
pDlg->UpdateData();
@@ -852,12 +852,12 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleNotes( WPARAM, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM)
{
- if (!wParam) return 0;
+ if ( !wParam) return 0;
TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID( JGetStringT( (HANDLE)wParam, "jid"), szClientJid, SIZEOF( szClientJid ));
+ GetClientJID(JGetStringT((HANDLE)wParam, "jid"), szClientJid, SIZEOF(szClientJid));
- CNoteItem *pItem = new CNoteItem( NULL, szClientJid );
+ CNoteItem *pItem = new CNoteItem(NULL, szClientJid);
CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote);
pDlg->Show();
diff --git a/protocols/JabberG/src/jabber_notes.h b/protocols/JabberG/src/jabber_notes.h index de096943c2..1750489458 100644 --- a/protocols/JabberG/src/jabber_notes.h +++ b/protocols/JabberG/src/jabber_notes.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 2596b5d648..6e0b6537f0 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -242,25 +242,25 @@ protected: void OnInitDialog()
{
TCHAR text[256];
- mir_sntprintf( text, SIZEOF(text), STR_FORMAT, TranslateT( "Register" ), m_regInfo->username, m_regInfo->server, m_regInfo->port );
- SetDlgItemText( m_hwnd, IDC_REG_STATUS, text );
+ mir_sntprintf(text, SIZEOF(text), STR_FORMAT, TranslateT("Register"), m_regInfo->username, m_regInfo->server, m_regInfo->port);
+ SetDlgItemText(m_hwnd, IDC_REG_STATUS, text);
}
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
- case WM_JABBER_REGDLG_UPDATE: // wParam=progress ( 0-100 ), lparam=status string
- if (( TCHAR* )lParam == NULL )
- SetDlgItemText( m_hwnd, IDC_REG_STATUS, TranslateT( "No message" ));
+ switch (msg) {
+ case WM_JABBER_REGDLG_UPDATE: // wParam=progress (0-100), lparam=status string
+ if ((TCHAR*)lParam == NULL)
+ SetDlgItemText(m_hwnd, IDC_REG_STATUS, TranslateT("No message"));
else
- SetDlgItemText( m_hwnd, IDC_REG_STATUS, ( TCHAR* )lParam );
+ SetDlgItemText(m_hwnd, IDC_REG_STATUS, (TCHAR*)lParam);
- if ( wParam >= 0 )
- SendMessage( GetDlgItem( m_hwnd, IDC_PROGRESS_REG ), PBM_SETPOS, wParam, 0 );
- if ( wParam >= 100 )
+ if (wParam >= 0)
+ SendMessage(GetDlgItem(m_hwnd, IDC_PROGRESS_REG), PBM_SETPOS, wParam, 0);
+ if (wParam >= 100)
m_btnOk.SetText(TranslateT("Close"));
else
- SetFocus( GetDlgItem( m_hwnd, IDC_PROGRESS_REG ));
+ SetFocus(GetDlgItem(m_hwnd, IDC_PROGRESS_REG));
return TRUE;
}
@@ -276,22 +276,22 @@ private: void btnOk_OnClick(CCtrlButton *)
{
- if ( m_bProcessStarted ) {
+ if (m_bProcessStarted) {
Close();
return;
}
ShowWindow(GetDlgItem(m_hwnd, IDC_PROGRESS_REG), SW_SHOW);
- ThreadData *thread = new ThreadData( m_regInfo->proto, JABBER_SESSION_REGISTER );
- _tcsncpy( thread->username, m_regInfo->username, SIZEOF( thread->username ));
- _tcsncpy( thread->password, m_regInfo->password, SIZEOF( thread->password ));
- strncpy( thread->server, m_regInfo->server, SIZEOF( thread->server ));
- strncpy( thread->manualHost, m_regInfo->manualHost, SIZEOF( thread->manualHost ));
+ ThreadData *thread = new ThreadData(m_regInfo->proto, JABBER_SESSION_REGISTER);
+ _tcsncpy(thread->username, m_regInfo->username, SIZEOF(thread->username));
+ _tcsncpy(thread->password, m_regInfo->password, SIZEOF(thread->password));
+ strncpy(thread->server, m_regInfo->server, SIZEOF(thread->server));
+ strncpy(thread->manualHost, m_regInfo->manualHost, SIZEOF(thread->manualHost));
thread->port = m_regInfo->port;
thread->useSSL = m_regInfo->useSSL;
thread->reg_hwndDlg= m_hwnd;
- m_proto->JForkThread(( JThreadFunc )&CJabberProto::ServerThread, thread );
+ m_proto->JForkThread((JThreadFunc)&CJabberProto::ServerThread, thread);
m_btnOk.SetText(TranslateT("Cancel"));
m_bProcessStarted = true;
@@ -308,7 +308,7 @@ class CCtrlEditJid: public CCtrlEdit typedef CCtrlEdit CSuper;
public:
- CCtrlEditJid( CDlgBase* dlg, int ctrlId );
+ CCtrlEditJid(CDlgBase* dlg, int ctrlId);
void OnInit()
{
@@ -319,9 +319,9 @@ public: protected:
virtual LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- if ( msg == WM_CHAR )
+ if (msg == WM_CHAR)
{
- switch( wParam )
+ switch(wParam)
{
case '\"': case '&': case '\'': case '/':
case ':': case '<': case '>': case '@':
@@ -333,8 +333,8 @@ protected: }
};
-CCtrlEditJid::CCtrlEditJid( CDlgBase* dlg, int ctrlId ):
- CCtrlEdit( dlg, ctrlId )
+CCtrlEditJid::CCtrlEditJid(CDlgBase* dlg, int ctrlId):
+ CCtrlEdit(dlg, ctrlId)
{
}
@@ -380,7 +380,7 @@ class CDlgOptAccount: public CJabberDlgBase public:
CDlgOptAccount(CJabberProto *proto):
- CJabberDlgBase(proto, IDD_OPT_JABBER, NULL, false ),
+ CJabberDlgBase(proto, IDD_OPT_JABBER, NULL, false),
m_txtUsername(this, IDC_EDIT_USERNAME),
m_txtPassword(this, IDC_EDIT_PASSWORD),
m_txtPriority(this, IDC_PRIORITY),
@@ -469,24 +469,24 @@ protected: if (GetComputerName(szCompName, &dwCompNameLength))
m_cbResource.AddString(szCompName);
- if (!DBGetContactSettingTString(NULL, m_proto->m_szModuleName, "Resource", &dbv))
+ if ( !DBGetContactSettingTString(NULL, m_proto->m_szModuleName, "Resource", &dbv))
{
if (CB_ERR == m_cbResource.FindString(dbv.ptszVal, -1, true))
m_cbResource.AddString(dbv.ptszVal);
m_cbResource.SetText(dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
else m_cbResource.SetText(_T("Miranda"));
for (i = 0; g_LanguageCodes[i].szCode; ++i)
{
int iItem = m_cbLocale.AddString(TranslateTS(g_LanguageCodes[i].szDescription), (LPARAM)g_LanguageCodes[i].szCode);
- if (!_tcscmp(m_proto->m_tszSelectedLang, g_LanguageCodes[i].szCode))
+ if ( !_tcscmp(m_proto->m_tszSelectedLang, g_LanguageCodes[i].szCode))
m_cbLocale.SetCurSel(iItem);
}
- EnableWindow(GetDlgItem(m_hwnd, IDC_COMBO_RESOURCE ), m_chkUseHostnameAsResource.GetState() != BST_CHECKED);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_COMBO_RESOURCE), m_chkUseHostnameAsResource.GetState() != BST_CHECKED);
EnableWindow(GetDlgItem(m_hwnd, IDC_UNREGISTER), m_proto->m_bJabberOnline);
m_chkUseTls.Enable(!m_proto->m_options.Disable3920auth && (m_proto->m_options.UseSSL ? false : true));
@@ -521,14 +521,14 @@ protected: else m_proto->JDeleteSetting(NULL, "LoginPassword");
int index = m_cbLocale.GetCurSel();
- if ( index >= 0 )
+ if (index >= 0)
{
TCHAR *szLanguageCode = (TCHAR *)m_cbLocale.GetItemData(index);
- if ( szLanguageCode ) {
+ if (szLanguageCode) {
m_proto->JSetStringT(NULL, "XmlLang", szLanguageCode);
- mir_free( m_proto->m_tszSelectedLang );
- m_proto->m_tszSelectedLang = mir_tstrdup( szLanguageCode );
+ mir_free(m_proto->m_tszSelectedLang);
+ m_proto->m_tszSelectedLang = mir_tstrdup(szLanguageCode);
} }
sttStoreJidFromUI(m_proto, m_txtUsername, m_cbServer);
@@ -541,7 +541,7 @@ protected: {
MessageBox(m_hwnd,
TranslateT("These changes will take effect the next time you connect to the Jabber network."),
- TranslateT( "Jabber Protocol Option" ), MB_OK|MB_SETFOREGROUND );
+ TranslateT("Jabber Protocol Option"), MB_OK|MB_SETFOREGROUND);
}
m_proto->SendPresence(m_proto->m_iStatus, true);
@@ -564,7 +564,7 @@ protected: break;
case WM_JABBER_REFRESH:
- RefreshServers(( HXML )lParam );
+ RefreshServers((HXML)lParam);
break;
}
return CSuper::DlgProc(msg, wParam, lParam);
@@ -576,7 +576,7 @@ private: void btnRegister_OnClick(CCtrlButton *)
{
TCHAR buf[512] = _T(""), pass[512];
- if (!m_proto->EnterString(buf, SIZEOF(buf), TranslateT("Confirm password"), JES_PASSWORD))
+ if ( !m_proto->EnterString(buf, SIZEOF(buf), TranslateT("Confirm password"), JES_PASSWORD))
return;
m_txtPassword.GetText(pass, SIZEOF(pass));
@@ -600,7 +600,7 @@ private: regInfo.manualHost[0] = '\0';
}
- if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ( (m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0] ))
+ if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ((m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0]))
{
CJabberDlgRegister dlg(m_proto, m_hwnd, ®Info);
dlg.DoModal();
@@ -614,18 +614,18 @@ private: TranslateT("This operation will kill your account, roster and all another information stored at the server. Are you ready to do that?"),
TranslateT("Account removal warning"), MB_YESNOCANCEL);
- if ( res == IDYES )
+ if (res == IDYES)
m_proto->m_ThreadInfo->send(
- XmlNodeIq( _T("set"), m_proto->SerialNext(), m_proto->m_szJabberJID ) << XQUERY( _T(JABBER_FEAT_REGISTER))
- << XCHILD( _T("remove")));
+ XmlNodeIq(_T("set"), m_proto->SerialNext(), m_proto->m_szJabberJID) << XQUERY(_T(JABBER_FEAT_REGISTER))
+ << XCHILD(_T("remove")));
}
void btnChangePassword_OnClick(CCtrlButton *)
{
- if ( !m_proto->m_bJabberOnline ) {
- MessageBox( NULL,
+ if ( !m_proto->m_bJabberOnline) {
+ MessageBox(NULL,
TranslateT("You can change your password only when you are online"),
- TranslateT("You must be online"), MB_OK | MB_ICONSTOP );
+ TranslateT("You must be online"), MB_OK | MB_ICONSTOP);
return;
}
@@ -634,7 +634,7 @@ private: void cbServer_OnDropdown(CCtrlCombo*)
{
- if ( !m_gotservers )
+ if ( !m_gotservers)
mir_forkthread(QueryServerListThread, this);
}
@@ -690,12 +690,12 @@ private: if (m_chkUseSsl.GetState() == BST_CHECKED)
{
m_chkUseTls.Disable();
- if (!bManualHost)
+ if ( !bManualHost)
m_txtPort.SetInt(5223);
} else
{
- if (!m_proto->m_options.Disable3920auth) m_chkUseTls.Enable();
- if (!bManualHost)
+ if ( !m_proto->m_options.Disable3920auth) m_chkUseTls.Enable();
+ if ( !bManualHost)
m_txtPort.SetInt(5222);
}
}
@@ -724,13 +724,13 @@ private: regInfo.manualHost[0] = '\0';
}
- if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ( (m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0] ))
- EnableWindow( GetDlgItem( m_hwnd, IDC_BUTTON_REGISTER ), TRUE );
+ if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ((m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0]))
+ EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_REGISTER), TRUE);
else
- EnableWindow( GetDlgItem( m_hwnd, IDC_BUTTON_REGISTER ), FALSE );
+ EnableWindow(GetDlgItem(m_hwnd, IDC_BUTTON_REGISTER), FALSE);
}
- void RefreshServers( HXML node )
+ void RefreshServers(HXML node)
{
m_gotservers = node != NULL;
@@ -739,15 +739,15 @@ private: if (bDropdown) m_cbServer.ShowDropdown(false);
m_cbServer.ResetContent();
- if ( node ) {
+ if (node) {
for (int i = 0; ; ++i) {
HXML n = xmlGetChild(node, i);
- if ( !n )
+ if ( !n)
break;
- if ( !lstrcmp( xmlGetName( n ), _T("item")))
- if ( const TCHAR *jid = xmlGetAttrValue( n, _T("jid")))
- if ( m_cbServer.FindString(jid, -1, true) == CB_ERR)
+ if ( !lstrcmp(xmlGetName(n), _T("item")))
+ if (const TCHAR *jid = xmlGetAttrValue(n, _T("jid")))
+ if (m_cbServer.FindString(jid, -1, true) == CB_ERR)
m_cbServer.AddString(jid);
}
}
@@ -764,7 +764,7 @@ private: HWND hwnd = wnd->GetHwnd();
bool bIsError = true;
- if (!IsWindow(hwnd)) return;
+ if ( !IsWindow(hwnd)) return;
NETLIBHTTPREQUEST request = {0};
request.cbSize = sizeof(request);
@@ -773,21 +773,21 @@ private: request.szUrl = "http://xmpp.org/services/services.xml";
NETLIBHTTPREQUEST *result = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)wnd->GetProto()->m_hNetlibUser, (LPARAM)&request);
- if ( result ) {
- if ( result->resultCode == 200 && result->dataLength && result->pData ) {
- TCHAR* buf = mir_a2t( result->pData );
- XmlNode node( buf, NULL, NULL );
- if ( node ) {
- HXML queryNode = xmlGetChild( node, _T("query"));
+ if (result) {
+ if (result->resultCode == 200 && result->dataLength && result->pData) {
+ TCHAR* buf = mir_a2t(result->pData);
+ XmlNode node(buf, NULL, NULL);
+ if (node) {
+ HXML queryNode = xmlGetChild(node, _T("query"));
SendMessage(hwnd, WM_JABBER_REFRESH, 0, (LPARAM)queryNode);
bIsError = false;
}
- mir_free( buf );
+ mir_free(buf);
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)result);
}
- if ( bIsError )
+ if (bIsError)
SendMessage(hwnd, WM_JABBER_REFRESH, 0, 0);
}
};
@@ -868,21 +868,21 @@ public: BOOL bChecked = m_proto->m_options.ShowTransport;
LISTFOREACH(index, m_proto, LIST_ROSTER)
{
- JABBER_LIST_ITEM* item = m_proto->ListGetItemPtrFromIndex( index );
- if ( item != NULL ) {
- if ( _tcschr( item->jid, '@' ) == NULL ) {
- HANDLE hContact = m_proto->HContactFromJID( item->jid );
- if ( hContact != NULL ) {
- if ( bChecked ) {
- if ( item->itemResource.status != m_proto->JGetWord( hContact, "Status", ID_STATUS_OFFLINE )) {
- m_proto->JSetWord( hContact, "Status", ( WORD )item->itemResource.status );
+ JABBER_LIST_ITEM* item = m_proto->ListGetItemPtrFromIndex(index);
+ if (item != NULL) {
+ if (_tcschr(item->jid, '@') == NULL) {
+ HANDLE hContact = m_proto->HContactFromJID(item->jid);
+ if (hContact != NULL) {
+ if (bChecked) {
+ if (item->itemResource.status != m_proto->JGetWord(hContact, "Status", ID_STATUS_OFFLINE)) {
+ m_proto->JSetWord(hContact, "Status", (WORD)item->itemResource.status);
} }
- else if ( m_proto->JGetWord( hContact, "Status", ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE )
- m_proto->JSetWord( hContact, "Status", ID_STATUS_OFFLINE );
+ else if (m_proto->JGetWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ m_proto->JSetWord(hContact, "Status", ID_STATUS_OFFLINE);
} } }
}
- m_proto->SendPresence( m_proto->m_iStatus, true );
+ m_proto->SendPresence(m_proto->m_iStatus, true);
}
void chkDirect_OnChange(CCtrlData *)
@@ -984,19 +984,19 @@ static int _RosterInsertListItem(HWND hList, const TCHAR * jid, const TCHAR * ni item.iItem = ListView_GetItemCount(hList);
item.iSubItem = 0;
- item.pszText = ( TCHAR* )jid;
+ item.pszText = (TCHAR*)jid;
index=ListView_InsertItem(hList, &item);
- if ( index<0 )
+ if (index<0)
return index;
ListView_SetCheckState(hList, index, bChecked);
- ListView_SetItemText(hList, index, 0, ( TCHAR* )jid);
- ListView_SetItemText(hList, index, 1, ( TCHAR* )nick);
- ListView_SetItemText(hList, index, 2, ( TCHAR* )group);
- ListView_SetItemText(hList, index, 3, TranslateTS( subscr ));
+ ListView_SetItemText(hList, index, 0, (TCHAR*)jid);
+ ListView_SetItemText(hList, index, 1, (TCHAR*)nick);
+ ListView_SetItemText(hList, index, 2, (TCHAR*)group);
+ ListView_SetItemText(hList, index, 3, TranslateTS(subscr));
return index;
}
@@ -1004,9 +1004,9 @@ static int _RosterInsertListItem(HWND hList, const TCHAR * jid, const TCHAR * ni static void _RosterListClear(HWND hwndDlg)
{
HWND hList=GetDlgItem(hwndDlg, IDC_ROSTER);
- if (!hList) return;
+ if ( !hList) return;
ListView_DeleteAllItems(hList);
- while ( ListView_DeleteColumn( hList, 0));
+ while ( ListView_DeleteColumn(hList, 0));
LV_COLUMN column={0};
column.mask=LVCF_TEXT;
@@ -1034,70 +1034,70 @@ static void _RosterListClear(HWND hwndDlg) ListView_SetColumnWidth(hList,3,width*10/100);
}
-void CJabberProto::_RosterHandleGetRequest( HXML node )
+void CJabberProto::_RosterHandleGetRequest(HXML node)
{
HWND hList=GetDlgItem(rrud.hwndDlg, IDC_ROSTER);
if (rrud.bRRAction==RRA_FILLLIST)
{
_RosterListClear(rrud.hwndDlg);
- HXML query = xmlGetChild( node , "query");
- if (!query) return;
+ HXML query = xmlGetChild(node , "query");
+ if ( !query) return;
int i = 1;
while (TRUE) {
- HXML item = xmlGetNthChild( query, _T("item"), i++);
- if (!item)
+ HXML item = xmlGetNthChild(query, _T("item"), i++);
+ if ( !item)
break;
- const TCHAR *jid = xmlGetAttrValue( item, _T("jid"));
- if (!jid)
+ const TCHAR *jid = xmlGetAttrValue(item, _T("jid"));
+ if ( !jid)
continue;
- const TCHAR *name = xmlGetAttrValue( item, _T("name"));
- const TCHAR *subscription = xmlGetAttrValue( item, _T("subscription"));
+ const TCHAR *name = xmlGetAttrValue(item, _T("name"));
+ const TCHAR *subscription = xmlGetAttrValue(item, _T("subscription"));
const TCHAR *group = NULL;
- HXML groupNode = xmlGetChild( item , "group" );
- if ( groupNode )
- group = xmlGetText( groupNode );
- _RosterInsertListItem( hList, jid, name, group, subscription, TRUE );
+ HXML groupNode = xmlGetChild(item , "group");
+ if (groupNode)
+ group = xmlGetText(groupNode);
+ _RosterInsertListItem(hList, jid, name, group, subscription, TRUE);
}
// now it is require to process whole contact list to add not in roster contacts
{
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL )
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL)
{
- char* str = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( str != NULL && !strcmp( str, m_szModuleName ))
+ char* str = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (str != NULL && !strcmp(str, m_szModuleName))
{
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv ))
+ if ( !JGetStringT(hContact, "jid", &dbv))
{
LVFINDINFO lvfi={0};
lvfi.flags = LVFI_STRING;
lvfi.psz = dbv.ptszVal;
TCHAR *p = _tcschr(dbv.ptszVal,_T('@'));
- if ( p ) {
- p = _tcschr( dbv.ptszVal, _T('/'));
- if ( p ) *p = _T('\0');
+ if (p) {
+ p = _tcschr(dbv.ptszVal, _T('/'));
+ if (p) *p = _T('\0');
}
- if ( ListView_FindItem(hList, -1, &lvfi) == -1) {
- TCHAR *jid = mir_tstrdup( dbv.ptszVal );
+ if (ListView_FindItem(hList, -1, &lvfi) == -1) {
+ TCHAR *jid = mir_tstrdup(dbv.ptszVal);
TCHAR *name = NULL;
TCHAR *group = NULL;
DBVARIANT dbvtemp;
- if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbvtemp )) {
- name = mir_tstrdup( dbvtemp.ptszVal );
- DBFreeVariant( &dbvtemp );
+ if ( !DBGetContactSettingTString(hContact, "CList", "MyHandle", &dbvtemp)) {
+ name = mir_tstrdup(dbvtemp.ptszVal);
+ DBFreeVariant(&dbvtemp);
}
- if ( !DBGetContactSettingTString( hContact, "CList", "Group", &dbvtemp )) {
- group = mir_tstrdup( dbvtemp.ptszVal );
- DBFreeVariant( &dbvtemp );
+ if ( !DBGetContactSettingTString(hContact, "CList", "Group", &dbvtemp)) {
+ group = mir_tstrdup(dbvtemp.ptszVal);
+ DBFreeVariant(&dbvtemp);
}
- _RosterInsertListItem( hList, jid, name, group, NULL, FALSE );
- if ( jid ) mir_free( jid );
- if ( name ) mir_free( name );
- if ( group ) mir_free( group );
+ _RosterInsertListItem(hList, jid, name, group, NULL, FALSE);
+ if (jid) mir_free(jid);
+ if (name) mir_free(name);
+ if (group) mir_free(group);
}
- DBFreeVariant( &dbv );
+ DBFreeVariant(&dbv);
}
}
hContact = db_find_next(hContact);
@@ -1105,26 +1105,26 @@ void CJabberProto::_RosterHandleGetRequest( HXML node ) }
rrud.bReadyToDownload = FALSE;
rrud.bReadyToUpload = TRUE;
- SetDlgItemText( rrud.hwndDlg, IDC_DOWNLOAD, TranslateT( "Download" ));
- SetDlgItemText( rrud.hwndDlg, IDC_UPLOAD, TranslateT( "Upload" ));
- SendMessage( rrud.hwndDlg, JM_STATUSCHANGED, 0, 0 );
+ SetDlgItemText(rrud.hwndDlg, IDC_DOWNLOAD, TranslateT("Download"));
+ SetDlgItemText(rrud.hwndDlg, IDC_UPLOAD, TranslateT("Upload"));
+ SendMessage(rrud.hwndDlg, JM_STATUSCHANGED, 0, 0);
return;
}
- else if ( rrud.bRRAction == RRA_SYNCROSTER )
+ else if (rrud.bRRAction == RRA_SYNCROSTER)
{
SetDlgItemText(rrud.hwndDlg, IDC_UPLOAD, TranslateT("Uploading..."));
- HXML queryRoster = xmlGetChild( node , "query");
- if (!queryRoster)
+ HXML queryRoster = xmlGetChild(node , "query");
+ if ( !queryRoster)
return;
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::_RosterHandleGetRequest );
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::_RosterHandleGetRequest);
- XmlNode iq( _T("iq"));
- xmlAddAttr( iq, _T("type"), _T("set"));
- iq << XATTRID( iqId );
+ XmlNode iq(_T("iq"));
+ xmlAddAttr(iq, _T("type"), _T("set"));
+ iq << XATTRID(iqId);
- HXML query = iq << XCHILDNS( _T("query"), _T(JABBER_FEAT_IQ_ROSTER));
+ HXML query = iq << XCHILDNS(_T("query"), _T(JABBER_FEAT_IQ_ROSTER));
int itemCount=0;
int ListItemCount=ListView_GetItemCount(hList);
@@ -1138,49 +1138,49 @@ void CJabberProto::_RosterHandleGetRequest( HXML node ) ListView_GetItemText(hList, index, 1, name, SIZEOF(name));
ListView_GetItemText(hList, index, 2, group, SIZEOF(group));
ListView_GetItemText(hList, index, 3, subscr, SIZEOF(subscr));
- HXML itemRoster = xmlGetChildByTag( queryRoster, "item", "jid", jid);
+ HXML itemRoster = xmlGetChildByTag(queryRoster, "item", "jid", jid);
BOOL bRemove = !ListView_GetCheckState(hList,index);
if (itemRoster && bRemove)
{
//delete item
- query << XCHILD( _T("item")) << XATTR( _T("jid"), jid ) << XATTR( _T("subscription") ,_T("remove"));
+ query << XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("subscription") ,_T("remove"));
itemCount++;
}
- else if ( !bRemove )
+ else if ( !bRemove)
{
BOOL bPushed = itemRoster ? TRUE : FALSE;
- if ( !bPushed ) {
- const TCHAR *rosterName = xmlGetAttrValue( itemRoster, _T("name"));
- if ( (rosterName!=NULL || name[0]!=_T('\0')) && lstrcmpi(rosterName,name))
+ if ( !bPushed) {
+ const TCHAR *rosterName = xmlGetAttrValue(itemRoster, _T("name"));
+ if ((rosterName!=NULL || name[0]!=_T('\0')) && lstrcmpi(rosterName,name))
bPushed=TRUE;
- if ( !bPushed ) {
- rosterName = xmlGetAttrValue( itemRoster, _T("subscription"));
+ if ( !bPushed) {
+ rosterName = xmlGetAttrValue(itemRoster, _T("subscription"));
if ((rosterName!=NULL || subscr[0]!=_T('\0')) && lstrcmpi(rosterName,subscr))
bPushed=TRUE;
}
- if ( !bPushed ) {
- HXML groupNode = xmlGetChild( itemRoster , "group" );
- const TCHAR* rosterGroup=NULL;
+ if ( !bPushed) {
+ HXML groupNode = xmlGetChild(itemRoster , "group");
+ const TCHAR *rosterGroup=NULL;
if (groupNode != NULL)
- rosterGroup = xmlGetText( groupNode );
+ rosterGroup = xmlGetText(groupNode);
if ((rosterGroup!=NULL || group[0]!=_T('\0')) && lstrcmpi(rosterGroup,group))
bPushed=TRUE;
}
}
- if ( bPushed ) {
- HXML item = query << XCHILD( _T("item"));
- if ( group && _tcslen( group ))
- item << XCHILD( _T("group"), group );
- if ( name && _tcslen( name ))
- item << XATTR( _T("name"), name );
- item << XATTR( _T("jid"), jid ) << XATTR( _T("subscription"), subscr[0] ? subscr : _T("none"));
+ if (bPushed) {
+ HXML item = query << XCHILD(_T("item"));
+ if (group && _tcslen(group))
+ item << XCHILD(_T("group"), group);
+ if (name && _tcslen(name))
+ item << XATTR(_T("name"), name);
+ item << XATTR(_T("jid"), jid) << XATTR(_T("subscription"), subscr[0] ? subscr : _T("none"));
itemCount++;
}
}
}
rrud.bRRAction=RRA_SYNCDONE;
if (itemCount)
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
else
_RosterSendRequest(rrud.hwndDlg,RRA_FILLLIST);
}
@@ -1202,17 +1202,17 @@ void CJabberProto::_RosterSendRequest(HWND hwndDlg, BYTE rrAction) rrud.hwndDlg=hwndDlg;
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::_RosterHandleGetRequest );
- m_ThreadInfo->send( XmlNode( _T("iq")) << XATTR( _T("type"), _T("get")) << XATTRID( iqId ) << XCHILDNS( _T("query"), _T(JABBER_FEAT_IQ_ROSTER )));
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::_RosterHandleGetRequest);
+ m_ThreadInfo->send(XmlNode(_T("iq")) << XATTR(_T("type"), _T("get")) << XATTRID(iqId) << XCHILDNS(_T("query"), _T(JABBER_FEAT_IQ_ROSTER)));
}
-static void _RosterItemEditEnd( HWND hEditor, ROSTEREDITDAT * edat, BOOL bCancel )
+static void _RosterItemEditEnd(HWND hEditor, ROSTEREDITDAT * edat, BOOL bCancel)
{
- if (!bCancel)
+ if ( !bCancel)
{
int len = GetWindowTextLength(hEditor) + 1;
TCHAR *buff=(TCHAR*)mir_alloc(len*sizeof(TCHAR));
- if ( buff ) {
+ if (buff) {
GetWindowText(hEditor,buff,len);
ListView_SetItemText(edat->hList,edat->index, edat->subindex,buff);
}
@@ -1221,10 +1221,10 @@ static void _RosterItemEditEnd( HWND hEditor, ROSTEREDITDAT * edat, BOOL bCancel DestroyWindow(hEditor);
}
-static BOOL CALLBACK _RosterItemNewEditProc( HWND hEditor, UINT msg, WPARAM wParam, LPARAM lParam )
+static BOOL CALLBACK _RosterItemNewEditProc(HWND hEditor, UINT msg, WPARAM wParam, LPARAM lParam)
{
ROSTEREDITDAT * edat = (ROSTEREDITDAT *) GetWindowLongPtr(hEditor,GWLP_USERDATA);
- if (!edat) return 0;
+ if ( !edat) return 0;
switch(msg)
{
@@ -1240,7 +1240,7 @@ static BOOL CALLBACK _RosterItemNewEditProc( HWND hEditor, UINT msg, WPARAM wPar }
break;
case WM_GETDLGCODE:
- if ( lParam ) {
+ if (lParam) {
MSG *msg2 = (MSG*)lParam;
if (msg2->message==WM_KEYDOWN && msg2->wParam==VK_TAB) return 0;
if (msg2->message==WM_CHAR && msg2->wParam=='\t') return 0;
@@ -1258,7 +1258,7 @@ static BOOL CALLBACK _RosterItemNewEditProc( HWND hEditor, UINT msg, WPARAM wPar free(edat);
return 0;
}
- else return CallWindowProc( edat->OldEditProc, hEditor, msg, wParam, lParam);
+ else return CallWindowProc(edat->OldEditProc, hEditor, msg, wParam, lParam);
}
@@ -1279,10 +1279,10 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg) ofn.nMaxFile = SIZEOF(filename);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("xml");
- if (!GetSaveFileName(&ofn)) return;
+ if ( !GetSaveFileName(&ofn)) return;
FILE * fp = fopent(filename,_T("w"));
- if (!fp) return;
+ if ( !fp) return;
HWND hList=GetDlgItem(hwndDlg, IDC_ROSTER);
int ListItemCount=ListView_GetItemCount(hList);
@@ -1343,11 +1343,11 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) ofn.nMaxFile = sizeof(filename);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = "xml";
- if ( !GetOpenFileNameA( &ofn ))
+ if ( !GetOpenFileNameA(&ofn))
return;
FILE * fp=fopen(filename,"r");
- if (!fp)
+ if ( !fp)
return;
DWORD bufsize = _filelength(_fileno(fp));
@@ -1361,70 +1361,70 @@ void CJabberProto::_RosterImportFromFile(HWND hwndDlg) fclose(fp);
_RosterListClear(hwndDlg);
- TCHAR* newBuf = mir_utf8decodeT( buffer );
- mir_free( buffer );
+ TCHAR* newBuf = mir_utf8decodeT(buffer);
+ mir_free(buffer);
int nBytesProcessed = 0;
- XmlNode node( newBuf, &nBytesProcessed, NULL );
- if ( node ) {
- HXML Workbook = xmlGetChild( node, _T("Workbook"));
- if ( Workbook ) {
- HXML Worksheet = xmlGetChild( Workbook , "Worksheet");
- if ( Worksheet ) {
- HXML Table = xmlGetChild( Worksheet , "Table" );
- if ( Table ) {
+ XmlNode node(newBuf, &nBytesProcessed, NULL);
+ if (node) {
+ HXML Workbook = xmlGetChild(node, _T("Workbook"));
+ if (Workbook) {
+ HXML Worksheet = xmlGetChild(Workbook , "Worksheet");
+ if (Worksheet) {
+ HXML Table = xmlGetChild(Worksheet , "Table");
+ if (Table) {
int index=1;
HWND hList=GetDlgItem(hwndDlg, IDC_ROSTER);
while (TRUE)
{
- HXML Row = xmlGetNthChild( Table, _T("Row"), index++ );
- if (!Row)
+ HXML Row = xmlGetNthChild(Table, _T("Row"), index++);
+ if ( !Row)
break;
BOOL bAdd=FALSE;
- const TCHAR* jid=NULL;
- const TCHAR* name=NULL;
- const TCHAR* group=NULL;
- const TCHAR* subscr=NULL;
- HXML Cell = xmlGetNthChild( Row, _T("Cell"), 1 );
- HXML Data = (Cell) ? xmlGetChild( Cell , "Data") : XmlNode();
- if ( Data )
+ const TCHAR *jid=NULL;
+ const TCHAR *name=NULL;
+ const TCHAR *group=NULL;
+ const TCHAR *subscr=NULL;
+ HXML Cell = xmlGetNthChild(Row, _T("Cell"), 1);
+ HXML Data = (Cell) ? xmlGetChild(Cell , "Data") : XmlNode();
+ if (Data)
{
- if (!lstrcmpi(xmlGetText( Data ),_T("+"))) bAdd=TRUE;
- else if (lstrcmpi(xmlGetText( Data ),_T("-"))) continue;
+ if ( !lstrcmpi(xmlGetText(Data),_T("+"))) bAdd=TRUE;
+ else if (lstrcmpi(xmlGetText(Data),_T("-"))) continue;
- Cell = xmlGetNthChild( Row, _T("Cell"),2);
- if (Cell) Data=xmlGetChild( Cell , "Data");
+ Cell = xmlGetNthChild(Row, _T("Cell"),2);
+ if (Cell) Data=xmlGetChild(Cell , "Data");
else Data = NULL;
if (Data)
{
- jid=xmlGetText( Data );
- if (!jid || lstrlen(jid)==0) continue;
+ jid=xmlGetText(Data);
+ if ( !jid || lstrlen(jid)==0) continue;
}
- Cell=xmlGetNthChild( Row,_T("Cell"),3);
- if (Cell) Data=xmlGetChild( Cell , "Data");
+ Cell=xmlGetNthChild(Row,_T("Cell"),3);
+ if (Cell) Data=xmlGetChild(Cell , "Data");
else Data = NULL;
- if (Data) name=xmlGetText( Data );
+ if (Data) name=xmlGetText(Data);
- Cell=xmlGetNthChild( Row,_T("Cell"),4);
- if (Cell) Data=xmlGetChild( Cell , "Data");
+ Cell=xmlGetNthChild(Row,_T("Cell"),4);
+ if (Cell) Data=xmlGetChild(Cell , "Data");
else Data = NULL;
- if (Data) group=xmlGetText( Data );
+ if (Data) group=xmlGetText(Data);
- Cell=xmlGetNthChild( Row,_T("Cell"),5);
- if (Cell) Data=xmlGetChild( Cell , "Data");
+ Cell=xmlGetNthChild(Row,_T("Cell"),5);
+ if (Cell) Data=xmlGetChild(Cell , "Data");
else Data = NULL;
- if (Data) subscr=xmlGetText( Data );
+ if (Data) subscr=xmlGetText(Data);
}
_RosterInsertListItem(hList,jid,name,group,subscr,bAdd);
} } } } }
- mir_free( newBuf );
+ mir_free(newBuf);
SendMessage(hwndDlg, JM_STATUSCHANGED, 0, 0);
}
-static BOOL CALLBACK _RosterNewListProc( HWND hList, UINT msg, WPARAM wParam, LPARAM lParam )
+static BOOL CALLBACK _RosterNewListProc(HWND hList, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg==WM_MOUSEWHEEL || msg==WM_NCLBUTTONDOWN || msg==WM_NCRBUTTONDOWN)
{
@@ -1464,7 +1464,7 @@ static BOOL CALLBACK _RosterNewListProc( HWND hList, UINT msg, WPARAM wParam, LP SetWindowLongPtr(hEditor,GWLP_USERDATA,(LONG_PTR)edat);
}
}
- return CallWindowProc(_RosterOldListProc, hList, msg, wParam, lParam );
+ return CallWindowProc(_RosterOldListProc, hList, msg, wParam, lParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1490,17 +1490,17 @@ static int sttRosterEditorResizer(HWND /*hwndDlg*/, LPARAM, UTILRESIZECONTROL *u return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
}
-static INT_PTR CALLBACK JabberRosterOptDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberRosterOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = ( CJabberProto* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case JM_STATUSCHANGED:
{
int count = ListView_GetItemCount(GetDlgItem(hwndDlg,IDC_ROSTER));
- EnableWindow( GetDlgItem( hwndDlg, IDC_DOWNLOAD ), ppro->m_bJabberOnline );
- EnableWindow( GetDlgItem( hwndDlg, IDC_UPLOAD ), count && ppro->m_bJabberOnline );
- EnableWindow( GetDlgItem( hwndDlg, IDC_EXPORT ), count > 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DOWNLOAD), ppro->m_bJabberOnline);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_UPLOAD), count && ppro->m_bJabberOnline);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EXPORT), count > 0);
break;
}
case WM_CLOSE:
@@ -1517,22 +1517,22 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc( HWND hwndDlg, UINT msg, WPARAM w }
case WM_INITDIALOG:
{
- ppro = ( CJabberProto* )lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ ppro = (CJabberProto*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault( hwndDlg );
- WindowSetIcon( hwndDlg, ppro, "Agents" );
+ TranslateDialogDefault(hwndDlg);
+ WindowSetIcon(hwndDlg, ppro, "Agents");
Utils_RestoreWindowPosition(hwndDlg, NULL, ppro->m_szModuleName, "rosterCtrlWnd_");
- ListView_SetExtendedListViewStyle(GetDlgItem(hwndDlg,IDC_ROSTER), LVS_EX_CHECKBOXES | LVS_EX_BORDERSELECT /*| LVS_EX_FULLROWSELECT*/ | LVS_EX_GRIDLINES /*| LVS_EX_HEADERDRAGDROP*/ );
+ ListView_SetExtendedListViewStyle(GetDlgItem(hwndDlg,IDC_ROSTER), LVS_EX_CHECKBOXES | LVS_EX_BORDERSELECT /*| LVS_EX_FULLROWSELECT*/ | LVS_EX_GRIDLINES /*| LVS_EX_HEADERDRAGDROP*/);
_RosterOldListProc=(WNDPROC) GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_ROSTER), GWLP_WNDPROC);
SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_ROSTER), GWLP_WNDPROC, (LONG_PTR) _RosterNewListProc);
_RosterListClear(hwndDlg);
ppro->rrud.hwndDlg = hwndDlg;
ppro->rrud.bReadyToDownload = TRUE;
ppro->rrud.bReadyToUpload = FALSE;
- SendMessage( hwndDlg, JM_STATUSCHANGED, 0, 0 );
+ SendMessage(hwndDlg, JM_STATUSCHANGED, 0, 0);
return TRUE;
}
@@ -1555,28 +1555,28 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc( HWND hwndDlg, UINT msg, WPARAM w break;
}
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDC_DOWNLOAD:
ppro->rrud.bReadyToUpload = FALSE;
ppro->rrud.bReadyToDownload = FALSE;
- SendMessage( ppro->rrud.hwndDlg, JM_STATUSCHANGED,0,0);
- SetDlgItemText( ppro->rrud.hwndDlg, IDC_DOWNLOAD, TranslateT("Downloading..."));
+ SendMessage(ppro->rrud.hwndDlg, JM_STATUSCHANGED,0,0);
+ SetDlgItemText(ppro->rrud.hwndDlg, IDC_DOWNLOAD, TranslateT("Downloading..."));
ppro->_RosterSendRequest(hwndDlg, RRA_FILLLIST);
break;
case IDC_UPLOAD:
ppro->rrud.bReadyToUpload = FALSE;
- SendMessage( ppro->rrud.hwndDlg, JM_STATUSCHANGED, 0, 0 );
- SetDlgItemText( ppro->rrud.hwndDlg, IDC_UPLOAD, TranslateT("Connecting..."));
- ppro->_RosterSendRequest( hwndDlg, RRA_SYNCROSTER );
+ SendMessage(ppro->rrud.hwndDlg, JM_STATUSCHANGED, 0, 0);
+ SetDlgItemText(ppro->rrud.hwndDlg, IDC_UPLOAD, TranslateT("Connecting..."));
+ ppro->_RosterSendRequest(hwndDlg, RRA_SYNCROSTER);
break;
case IDC_EXPORT:
- ppro->_RosterExportToFile( hwndDlg );
+ ppro->_RosterExportToFile(hwndDlg);
break;
case IDC_IMPORT:
- ppro->_RosterImportFromFile( hwndDlg );
+ ppro->_RosterImportFromFile(hwndDlg);
break;
}
break;
@@ -1584,12 +1584,12 @@ static INT_PTR CALLBACK JabberRosterOptDlgProc( HWND hwndDlg, UINT msg, WPARAM w return FALSE;
}
-INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl(WPARAM, LPARAM)
{
- if ( rrud.hwndDlg && IsWindow( rrud.hwndDlg ))
- SetForegroundWindow( rrud.hwndDlg );
+ if (rrud.hwndDlg && IsWindow(rrud.hwndDlg))
+ SetForegroundWindow(rrud.hwndDlg);
else
- CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_OPT_JABBER3 ), NULL, JabberRosterOptDlgProc, ( LPARAM )this );
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_JABBER3), NULL, JabberRosterOptDlgProc, (LPARAM)this);
return 0;
}
@@ -1597,10 +1597,10 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleRosterControl( WPARAM, LPARAM ) /////////////////////////////////////////////////////////////////////////////////////////
// JabberOptInit - initializes all options dialogs
-int CJabberProto::OnOptionsInit( WPARAM wParam, LPARAM )
+int CJabberProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = sizeof( odp );
+ odp.cbSize = sizeof(odp);
odp.hInstance = hInst;
odp.ptszGroup = LPGENT("Network");
odp.ptszTitle = m_tszUserName;
@@ -1623,7 +1623,7 @@ int CJabberProto::OnOptionsInit( WPARAM wParam, LPARAM ) Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("Advanced");
- odp.pszTemplate = MAKEINTRESOURCEA( IDD_OPT_JABBER2 );
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_JABBER2);
odp.pfnDlgProc = CDlgBase::DynamicDlgProc;
odp.dwInitParam = (LPARAM)&OptCreateAdvanced;
OptCreateAdvanced.create = CDlgOptAdvanced::Create;
@@ -1716,13 +1716,13 @@ protected: if (GetComputerName(szCompName, &dwCompNameLength))
m_cbResource.AddString(szCompName);
- if (!DBGetContactSettingTString(NULL, m_proto->m_szModuleName, "Resource", &dbv))
+ if ( !DBGetContactSettingTString(NULL, m_proto->m_szModuleName, "Resource", &dbv))
{
- if(CB_ERR == m_cbResource.FindString(dbv.ptszVal, -1, true))
+ if (CB_ERR == m_cbResource.FindString(dbv.ptszVal, -1, true))
m_cbResource.AddString(dbv.ptszVal);
m_cbResource.SetText(dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
} else
{
m_cbResource.SetText(_T("Miranda"));
@@ -1738,34 +1738,34 @@ protected: m_cbType.AddString(TranslateT("S.ms"), ACC_SMS);
m_cbServer.GetTextA(server, SIZEOF(server));
- if (!DBGetContactSettingString(NULL, m_proto->m_szModuleName, "ManualHost", &dbv))
+ if ( !DBGetContactSettingString(NULL, m_proto->m_szModuleName, "ManualHost", &dbv))
{
lstrcpynA(manualServer, dbv.pszVal, SIZEOF(manualServer));
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
m_canregister = true;
- if (!lstrcmpA(manualServer, "talk.google.com"))
+ if ( !lstrcmpA(manualServer, "talk.google.com"))
{
m_cbType.SetCurSel(ACC_GTALK);
m_canregister = false;
}
- else if (!lstrcmpA(server, "livejournal.com"))
+ else if ( !lstrcmpA(server, "livejournal.com"))
{
m_cbType.SetCurSel(ACC_LJTALK);
m_canregister = false;
}
- else if (!lstrcmpA(server, "chat.facebook.com"))
+ else if ( !lstrcmpA(server, "chat.facebook.com"))
{
m_cbType.SetCurSel(ACC_FBOOK);
m_canregister = false;
}
- else if (!lstrcmpA(server, "vk.com"))
+ else if ( !lstrcmpA(server, "vk.com"))
{
m_cbType.SetCurSel(ACC_VK);
m_canregister = false;
}
- else if (!lstrcmpA(server, "S.ms"))
+ else if ( !lstrcmpA(server, "S.ms"))
{
m_cbType.SetCurSel(ACC_SMS);
m_canregister = false;
@@ -1788,10 +1788,10 @@ protected: m_txtManualHost.Enable();
m_txtPort.Enable();
- if (!DBGetContactSettingTString(NULL, m_proto->m_szModuleName, "ManualHost", &dbv))
+ if ( !DBGetContactSettingTString(NULL, m_proto->m_szModuleName, "ManualHost", &dbv))
{
m_txtManualHost.SetText(dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
m_txtPort.SetInt(m_proto->JGetWord(NULL, "ManualPort", m_txtPort.GetInt()));
@@ -1834,7 +1834,7 @@ protected: if (GetComputerName(szCompName, &dwCompNameLength))
{
m_cbResource.GetText(szResource, SIZEOF(szResource));
- if (!lstrcmp(szCompName, szResource))
+ if ( !lstrcmp(szCompName, szResource))
bUseHostnameAsResource = TRUE;
}
m_proto->m_options.HostNameAsResource = bUseHostnameAsResource;
@@ -1935,7 +1935,7 @@ protected: {
switch (msg) {
case WM_JABBER_REFRESH:
- RefreshServers(( HXML )lParam);
+ RefreshServers((HXML)lParam);
break;
}
return CSuper::DlgProc(msg, wParam, lParam);
@@ -1948,7 +1948,7 @@ private: void btnRegister_OnClick(CCtrlButton *)
{
TCHAR buf[512] = _T(""), pass[512];
- if (!m_proto->EnterString(buf, SIZEOF(buf), TranslateT("Confirm password"), JES_PASSWORD))
+ if ( !m_proto->EnterString(buf, SIZEOF(buf), TranslateT("Confirm password"), JES_PASSWORD))
return;
m_txtPassword.GetText(pass, SIZEOF(pass));
@@ -1971,7 +1971,7 @@ private: regInfo.manualHost[0] = '\0';
}
- if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ( (m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0] ))
+ if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ((m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0]))
{
CJabberDlgRegister dlg(m_proto, m_hwnd, ®Info);
dlg.DoModal();
@@ -1979,9 +1979,9 @@ private: }
}
- void cbServer_OnDropdown(CCtrlCombo* )
+ void cbServer_OnDropdown(CCtrlCombo*)
{
- if ( !m_gotservers )
+ if ( !m_gotservers)
mir_forkthread(QueryServerListThread, this);
}
@@ -2037,13 +2037,13 @@ private: void setupFB();
void setupVK();
void setupSMS();
- void RefreshServers( HXML node);
+ void RefreshServers(HXML node);
static void QueryServerListThread(void *arg);
};
void CJabberDlgAccMgrUI::CheckRegistration()
{
- if ( !m_canregister ) {
+ if ( !m_canregister) {
m_btnRegister.Disable();
return;
}
@@ -2058,7 +2058,7 @@ void CJabberDlgAccMgrUI::CheckRegistration() else
regInfo.manualHost[0] = '\0';
- if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port > 0 && ( (m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0] ))
+ if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port > 0 && ((m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0]))
m_btnRegister.Enable();
else
m_btnRegister.Disable();
@@ -2215,7 +2215,7 @@ void CJabberDlgAccMgrUI::setupSMS() // m_cbResource.Disable();
}
-void CJabberDlgAccMgrUI::RefreshServers( HXML node )
+void CJabberDlgAccMgrUI::RefreshServers(HXML node)
{
m_gotservers = node != NULL;
@@ -2224,15 +2224,15 @@ void CJabberDlgAccMgrUI::RefreshServers( HXML node ) if (bDropdown) m_cbServer.ShowDropdown(false);
m_cbServer.ResetContent();
- if ( node )
+ if (node)
{
for (int i = 0; ; ++i) {
HXML n = xmlGetChild(node, i);
- if ( !n )
+ if ( !n)
break;
- if ( !lstrcmp( xmlGetName( n ), _T("item")))
- if ( const TCHAR *jid = xmlGetAttrValue( n, _T("jid")))
+ if ( !lstrcmp(xmlGetName(n), _T("item")))
+ if (const TCHAR *jid = xmlGetAttrValue(n, _T("jid")))
if (m_cbServer.FindString(jid, -1, true) == CB_ERR)
m_cbServer.AddString(jid);
}
@@ -2257,22 +2257,22 @@ void CJabberDlgAccMgrUI::QueryServerListThread(void *arg) request.szUrl = "http://xmpp.org/services/services.xml";
NETLIBHTTPREQUEST *result = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)wnd->GetProto()->m_hNetlibUser, (LPARAM)&request);
- if ( result && IsWindow( hwnd )) {
+ if (result && IsWindow(hwnd)) {
if ((result->resultCode == 200) && result->dataLength && result->pData) {
- TCHAR* ptszText = mir_a2t( result->pData );
- XmlNode node( ptszText, NULL, NULL );
- if ( node ) {
- HXML queryNode = xmlGetChild( node, _T("query"));
- if ( queryNode && IsWindow(hwnd)) {
+ TCHAR* ptszText = mir_a2t(result->pData);
+ XmlNode node(ptszText, NULL, NULL);
+ if (node) {
+ HXML queryNode = xmlGetChild(node, _T("query"));
+ if (queryNode && IsWindow(hwnd)) {
SendMessage(hwnd, WM_JABBER_REFRESH, 0, (LPARAM)queryNode);
bIsError = false;
} }
- mir_free( ptszText );
+ mir_free(ptszText);
} }
- if ( result )
+ if (result)
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)result);
- if ( bIsError )
+ if (bIsError)
SendMessage(hwnd, WM_JABBER_REFRESH, 0, 0);
}
@@ -2283,13 +2283,13 @@ INT_PTR CJabberProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam) return (INT_PTR)dlg->GetHwnd();
}
-void CJabberProto::JabberUpdateDialogs( BOOL )
+void CJabberProto::JabberUpdateDialogs(BOOL)
{
- if ( rrud.hwndDlg )
+ if (rrud.hwndDlg)
SendMessage(rrud.hwndDlg, JM_STATUSCHANGED, 0,0);
}
-INT_PTR __cdecl CJabberProto::OnMenuOptions( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuOptions(WPARAM, LPARAM)
{
OPENOPTIONSDIALOG ood = {0};
ood.cbSize = sizeof(ood);
@@ -2298,11 +2298,11 @@ INT_PTR __cdecl CJabberProto::OnMenuOptions( WPARAM, LPARAM ) ood.pszTab = "Account";
Options_Open(&ood);
- mir_free((void *)ood.pszPage);
+ mir_free((void*)ood.pszPage);
return 0;
}
-int CJabberProto::OnModernOptInit( WPARAM, LPARAM )
+int CJabberProto::OnModernOptInit(WPARAM, LPARAM)
{/*
static int iBoldControls[] =
{
diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp index bd43b55a08..3184571b95 100644 --- a/protocols/JabberG/src/jabber_opttree.cpp +++ b/protocols/JabberG/src/jabber_opttree.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2007 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2007 Victor Pavlychko
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
@@ -64,8 +64,8 @@ BOOL CCtrlTreeOpts::OnNotify(int idCtrl, NMHDR *pnmh) hti.pt.x=(short)LOWORD(GetMessagePos());
hti.pt.y=(short)HIWORD(GetMessagePos());
ScreenToClient(pnmh->hwndFrom,&hti.pt);
- if(HitTest(&hti))
- if(hti.flags&TVHT_ONITEMICON)
+ if (HitTest(&hti))
+ if (hti.flags&TVHT_ONITEMICON)
ProcessItemClick(hti.hItem);
break;
}
@@ -142,9 +142,9 @@ void CCtrlTreeOpts::OnInit() }
hItem = FindNamedItem(hSection, pItemName);
- if (!sectionName || !hItem)
+ if ( !sectionName || !hItem)
{
- if (!hItem)
+ if ( !hItem)
{
TVINSERTSTRUCT tvis = {0};
@@ -174,7 +174,7 @@ void CCtrlTreeOpts::OnInit() }
}
hItem = InsertItem(&tvis);
- if (!sectionName)
+ if ( !sectionName)
m_options[i]->m_hItem = hItem;
}
}
diff --git a/protocols/JabberG/src/jabber_opttree.h b/protocols/JabberG/src/jabber_opttree.h index 3246ad74a3..ec70d5001e 100644 --- a/protocols/JabberG/src/jabber_opttree.h +++ b/protocols/JabberG/src/jabber_opttree.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2007 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2007 Victor Pavlychko
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
@@ -32,7 +32,7 @@ class CCtrlTreeOpts : public CCtrlTreeView typedef CCtrlTreeView CSuper;
public:
- CCtrlTreeOpts( CDlgBase* dlg, int ctrlId );
+ CCtrlTreeOpts(CDlgBase* dlg, int ctrlId);
~CCtrlTreeOpts();
void AddOption(TCHAR *szOption, CMOption<BYTE> &option);
diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp index 2ce5128b78..56ea34e48e 100644 --- a/protocols/JabberG/src/jabber_password.cpp +++ b/protocols/JabberG/src/jabber_password.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
@@ -24,74 +24,74 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_iq.h"
#include "jabber_caps.h"
-static INT_PTR CALLBACK JabberChangePasswordDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam );
+static INT_PTR CALLBACK JabberChangePasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-INT_PTR __cdecl CJabberProto::OnMenuHandleChangePassword( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandleChangePassword(WPARAM, LPARAM)
{
- if ( IsWindow( m_hwndJabberChangePassword ))
- SetForegroundWindow( m_hwndJabberChangePassword );
+ if (IsWindow(m_hwndJabberChangePassword))
+ SetForegroundWindow(m_hwndJabberChangePassword);
else
- m_hwndJabberChangePassword = CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_CHANGEPASSWORD ), NULL, JabberChangePasswordDlgProc, ( LPARAM )this );
+ m_hwndJabberChangePassword = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CHANGEPASSWORD), NULL, JabberChangePasswordDlgProc, (LPARAM)this);
return 0;
}
-static INT_PTR CALLBACK JabberChangePasswordDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberChangePasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
- switch ( msg ) {
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ switch (msg) {
case WM_INITDIALOG:
ppro = (CJabberProto*)lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR )lParam );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
- WindowSetIcon( hwndDlg, ppro, "key" );
- TranslateDialogDefault( hwndDlg );
- if ( ppro->m_bJabberOnline && ppro->m_ThreadInfo!=NULL ) {
+ WindowSetIcon(hwndDlg, ppro, "key");
+ TranslateDialogDefault(hwndDlg);
+ if (ppro->m_bJabberOnline && ppro->m_ThreadInfo!=NULL) {
TCHAR text[1024];
- mir_sntprintf( text, SIZEOF( text ), _T("%s %s@") _T(TCHAR_STR_PARAM), TranslateT( "Set New Password for" ), ppro->m_ThreadInfo->username, ppro->m_ThreadInfo->server );
- SetWindowText( hwndDlg, text );
+ mir_sntprintf(text, SIZEOF(text), _T("%s %s@") _T(TCHAR_STR_PARAM), TranslateT("Set New Password for"), ppro->m_ThreadInfo->username, ppro->m_ThreadInfo->server);
+ SetWindowText(hwndDlg, text);
}
return TRUE;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDOK:
- if ( ppro->m_bJabberOnline && ppro->m_ThreadInfo!=NULL ) {
+ if (ppro->m_bJabberOnline && ppro->m_ThreadInfo!=NULL) {
TCHAR newPasswd[512], text[512];
- GetDlgItemText( hwndDlg, IDC_NEWPASSWD, newPasswd, SIZEOF( newPasswd ));
- GetDlgItemText( hwndDlg, IDC_NEWPASSWD2, text, SIZEOF( text ));
- if ( _tcscmp( newPasswd, text )) {
- MessageBox( hwndDlg, TranslateT( "New password does not match." ), TranslateT( "Change Password" ), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND );
+ GetDlgItemText(hwndDlg, IDC_NEWPASSWD, newPasswd, SIZEOF(newPasswd));
+ GetDlgItemText(hwndDlg, IDC_NEWPASSWD2, text, SIZEOF(text));
+ if (_tcscmp(newPasswd, text)) {
+ MessageBox(hwndDlg, TranslateT("New password does not match."), TranslateT("Change Password"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
break;
}
- GetDlgItemText( hwndDlg, IDC_OLDPASSWD, text, SIZEOF( text ));
- if ( _tcscmp( text, ppro->m_ThreadInfo->password )) {
- MessageBox( hwndDlg, TranslateT( "Current password is incorrect." ), TranslateT( "Change Password" ), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND );
+ GetDlgItemText(hwndDlg, IDC_OLDPASSWD, text, SIZEOF(text));
+ if (_tcscmp(text, ppro->m_ThreadInfo->password)) {
+ MessageBox(hwndDlg, TranslateT("Current password is incorrect."), TranslateT("Change Password"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
break;
}
- _tcsncpy( ppro->m_ThreadInfo->newPassword, newPasswd, SIZEOF( ppro->m_ThreadInfo->newPassword ));
+ _tcsncpy(ppro->m_ThreadInfo->newPassword, newPasswd, SIZEOF(ppro->m_ThreadInfo->newPassword));
int iqId = ppro->SerialNext();
- ppro->IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultSetPassword );
+ ppro->IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultSetPassword);
- XmlNodeIq iq( _T("set"), iqId, _A2T(ppro->m_ThreadInfo->server));
- HXML q = iq << XQUERY( _T(JABBER_FEAT_REGISTER));
- q << XCHILD( _T("username"), ppro->m_ThreadInfo->username );
- q << XCHILD( _T("password"), newPasswd );
- ppro->m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("set"), iqId, _A2T(ppro->m_ThreadInfo->server));
+ HXML q = iq << XQUERY(_T(JABBER_FEAT_REGISTER));
+ q << XCHILD(_T("username"), ppro->m_ThreadInfo->username);
+ q << XCHILD(_T("password"), newPasswd);
+ ppro->m_ThreadInfo->send(iq);
}
- DestroyWindow( hwndDlg );
+ DestroyWindow(hwndDlg);
break;
case IDCANCEL:
- DestroyWindow( hwndDlg );
+ DestroyWindow(hwndDlg);
break;
}
break;
case WM_CLOSE:
- DestroyWindow( hwndDlg );
+ DestroyWindow(hwndDlg);
break;
case WM_DESTROY:
ppro->m_hwndJabberChangePassword = NULL;
- WindowFreeIcon( hwndDlg );
+ WindowFreeIcon(hwndDlg);
break;
}
diff --git a/protocols/JabberG/src/jabber_presence_manager.cpp b/protocols/JabberG/src/jabber_presence_manager.cpp index 8a8ece811d..b7e4e26376 100644 --- a/protocols/JabberG/src/jabber_presence_manager.cpp +++ b/protocols/JabberG/src/jabber_presence_manager.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -35,7 +35,7 @@ BOOL CJabberPresenceManager::HandlePresencePermanent(HXML node, ThreadData *pThr BOOL bStopHandling = FALSE;
Lock();
CJabberPresencePermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo && !bStopHandling ) {
+ while (pInfo && !bStopHandling) {
CJabberPresenceInfo presenceInfo;
presenceInfo.m_pUserData = pInfo->m_pUserData;
diff --git a/protocols/JabberG/src/jabber_presence_manager.h b/protocols/JabberG/src/jabber_presence_manager.h index be138d3b93..6e82542fd4 100644 --- a/protocols/JabberG/src/jabber_presence_manager.h +++ b/protocols/JabberG/src/jabber_presence_manager.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -28,12 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_xml.h"
struct CJabberProto;
-typedef void ( CJabberProto::*JABBER_PRESENCE_PFUNC )( HXML node, void *usedata );
-typedef void ( *PRESENCE_USER_DATA_FREE_FUNC )( void *pUserData );
+typedef void (CJabberProto::*JABBER_PRESENCE_PFUNC)(HXML node, void *usedata);
+typedef void (*PRESENCE_USER_DATA_FREE_FUNC)(void *pUserData);
class CJabberPresenceInfo;
-typedef BOOL ( CJabberProto::*JABBER_PRESENCE_HANDLER )( HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo );
+typedef BOOL (CJabberProto::*JABBER_PRESENCE_HANDLER)(HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo);
class CJabberPresenceInfo
{
@@ -75,7 +75,7 @@ public: }
~CJabberPresencePermanentInfo()
{
- if ( m_pUserDataFree )
+ if (m_pUserDataFree)
m_pUserDataFree(m_pUserData);
}
};
@@ -88,7 +88,7 @@ protected: CJabberPresencePermanentInfo* m_pPermanentHandlers;
public:
- CJabberPresenceManager( CJabberProto* proto )
+ CJabberPresenceManager(CJabberProto* proto)
{
InitializeCriticalSection(&m_cs);
m_pPermanentHandlers = NULL;
@@ -98,7 +98,7 @@ public: {
Lock();
CJabberPresencePermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo )
+ while (pInfo)
{
CJabberPresencePermanentInfo *pTmp = pInfo->m_pNext;
delete pInfo;
@@ -127,7 +127,7 @@ public: CJabberPresencePermanentInfo* AddPermanentHandler(JABBER_PRESENCE_HANDLER pHandler, void *pUserData = NULL, PRESENCE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
{
CJabberPresencePermanentInfo* pInfo = new CJabberPresencePermanentInfo();
- if (!pInfo)
+ if ( !pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
@@ -136,7 +136,7 @@ public: pInfo->m_iPriority = iPriority;
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
m_pPermanentHandlers = pInfo;
else
{
@@ -159,7 +159,7 @@ public: BOOL DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
{
Unlock();
return FALSE;
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index dd2d0b8a58..7c879920d3 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
@@ -32,111 +32,111 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define JABBER_PL_BUSY_MSG "Sending request, please wait..."
-BOOL CJabberProto::OnIqRequestPrivacyLists( HXML, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnIqRequestPrivacyLists(HXML, CJabberIqInfo* pInfo)
{
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_SET ) {
- if ( !m_pDlgPrivacyLists )
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_SET) {
+ if ( !m_pDlgPrivacyLists)
{
m_privacyListManager.RemoveAllLists();
QueryPrivacyLists();
}
else m_pDlgPrivacyLists->SetStatusText(TranslateT("Warning: privacy lists were changed on server."));
- XmlNodeIq iq( _T("result"), pInfo );
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("result"), pInfo);
+ m_ThreadInfo->send(iq);
}
return TRUE;
}
-void CJabberProto::OnIqResultPrivacyListModify( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo* pInfo)
{
- if ( !pInfo->m_pUserData )
+ if ( !pInfo->m_pUserData)
return;
- CPrivacyListModifyUserParam *pParam = ( CPrivacyListModifyUserParam * )pInfo->m_pUserData;
+ CPrivacyListModifyUserParam *pParam = (CPrivacyListModifyUserParam *)pInfo->m_pUserData;
- if ( pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT )
+ if (pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT)
pParam->m_bAllOk = FALSE;
- InterlockedDecrement( &pParam->m_dwCount );
- if ( !pParam->m_dwCount ) {
+ InterlockedDecrement(&pParam->m_dwCount);
+ if ( !pParam->m_dwCount) {
TCHAR szText[ 512 ];
- if ( !pParam->m_bAllOk )
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Error occurred while applying changes"));
+ if ( !pParam->m_bAllOk)
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Error occurred while applying changes"));
else
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Privacy lists successfully saved"));
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Privacy lists successfully saved"));
if (m_pDlgPrivacyLists)
- m_pDlgPrivacyLists->SetStatusText( szText );
+ m_pDlgPrivacyLists->SetStatusText(szText);
// FIXME: enable apply button
delete pParam;
}
}
-void CJabberProto::OnIqResultPrivacyList( HXML iqNode )
+void CJabberProto::OnIqResultPrivacyList(HXML iqNode)
{
- if ( !iqNode )
+ if ( !iqNode)
return;
- const TCHAR *type = xmlGetAttrValue( iqNode, _T("type"));
- if ( !type )
+ const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
+ if ( !type)
return;
- if ( !_tcscmp( type, _T("result"))) {
- HXML query = xmlGetChild( iqNode , "query" );
- if ( !query )
+ if ( !_tcscmp(type, _T("result"))) {
+ HXML query = xmlGetChild(iqNode , "query");
+ if ( !query)
return;
- HXML list = xmlGetChild( query , "list" );
- if ( !list )
+ HXML list = xmlGetChild(query , "list");
+ if ( !list)
return;
- TCHAR *szListName = ( TCHAR* )xmlGetAttrValue( list, _T("name"));
- if ( !szListName )
+ TCHAR *szListName = (TCHAR*)xmlGetAttrValue(list, _T("name"));
+ if ( !szListName)
return;
m_privacyListManager.Lock();
- CPrivacyList* pList = m_privacyListManager.FindList( szListName );
- if ( !pList ) {
- m_privacyListManager.AddList( szListName );
- pList = m_privacyListManager.FindList( szListName );
- if ( !pList ) {
+ CPrivacyList* pList = m_privacyListManager.FindList(szListName);
+ if ( !pList) {
+ m_privacyListManager.AddList(szListName);
+ pList = m_privacyListManager.FindList(szListName);
+ if ( !pList) {
m_privacyListManager.Unlock();
return;
} }
HXML item;
- for ( int i = 1; ( item = xmlGetNthChild( list, _T("item"), i )) != NULL; i++ ) {
- const TCHAR *itemType = xmlGetAttrValue( item, _T("type"));
+ for (int i = 1; (item = xmlGetNthChild(list, _T("item"), i)) != NULL; i++) {
+ const TCHAR *itemType = xmlGetAttrValue(item, _T("type"));
PrivacyListRuleType nItemType = Else;
- if ( itemType ) {
- if ( !_tcsicmp( itemType, _T( "jid" )))
+ if (itemType) {
+ if ( !_tcsicmp(itemType, _T("jid")))
nItemType = Jid;
- else if ( !_tcsicmp( itemType, _T( "group" )))
+ else if ( !_tcsicmp(itemType, _T("group")))
nItemType = Group;
- else if ( !_tcsicmp( itemType, _T( "subscription" )))
+ else if ( !_tcsicmp(itemType, _T("subscription")))
nItemType = Subscription;
}
- const TCHAR *itemValue = xmlGetAttrValue( item, _T("value"));
+ const TCHAR *itemValue = xmlGetAttrValue(item, _T("value"));
- const TCHAR *itemAction = xmlGetAttrValue( item, _T("action"));
+ const TCHAR *itemAction = xmlGetAttrValue(item, _T("action"));
BOOL bAllow = TRUE;
- if ( itemAction && !_tcsicmp( itemAction, _T( "deny" )))
+ if (itemAction && !_tcsicmp(itemAction, _T("deny")))
bAllow = FALSE;
- const TCHAR *itemOrder = xmlGetAttrValue( item, _T("order"));
+ const TCHAR *itemOrder = xmlGetAttrValue(item, _T("order"));
DWORD dwOrder = 0;
- if ( itemOrder )
- dwOrder = _ttoi( itemOrder );
+ if (itemOrder)
+ dwOrder = _ttoi(itemOrder);
DWORD dwPackets = 0;
- if ( xmlGetChild( item , "message" ))
+ if (xmlGetChild(item , "message"))
dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
- if ( xmlGetChild( item , "presence-in" ))
+ if (xmlGetChild(item , "presence-in"))
dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- if ( xmlGetChild( item , "presence-out" ))
+ if (xmlGetChild(item , "presence-out"))
dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- if ( xmlGetChild( item , "iq" ))
+ if (xmlGetChild(item , "iq"))
dwPackets |= JABBER_PL_RULE_TYPE_IQ;
- pList->AddRule( nItemType, itemValue, bAllow, dwOrder, dwPackets );
+ pList->AddRule(nItemType, itemValue, bAllow, dwOrder, dwPackets);
}
pList->Reorder();
pList->SetLoaded();
@@ -148,157 +148,157 @@ void CJabberProto::OnIqResultPrivacyList( HXML iqNode ) CPrivacyList* GetSelectedList(HWND hDlg)
{
- LRESULT nCurSel = SendDlgItemMessage( hDlg, IDC_LB_LISTS, LB_GETCURSEL, 0, 0 );
- if ( nCurSel == LB_ERR )
+ LRESULT nCurSel = SendDlgItemMessage(hDlg, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
+ if (nCurSel == LB_ERR)
return NULL;
- LRESULT nItemData = SendDlgItemMessage( hDlg, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0 );
- if ( nItemData == LB_ERR || nItemData == 0 )
+ LRESULT nItemData = SendDlgItemMessage(hDlg, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0);
+ if (nItemData == LB_ERR || nItemData == 0)
return NULL;
- return ( CPrivacyList* )nItemData;
+ return (CPrivacyList*)nItemData;
}
CPrivacyListRule* GetSelectedRule(HWND hDlg)
{
- LRESULT nCurSel = SendDlgItemMessage( hDlg, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0 );
- if ( nCurSel == LB_ERR)
+ LRESULT nCurSel = SendDlgItemMessage(hDlg, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ if (nCurSel == LB_ERR)
return NULL;
- LRESULT nItemData = SendDlgItemMessage( hDlg, IDC_PL_RULES_LIST, LB_GETITEMDATA, nCurSel, 0 );
- if ( nItemData == LB_ERR || nItemData == 0 )
+ LRESULT nItemData = SendDlgItemMessage(hDlg, IDC_PL_RULES_LIST, LB_GETITEMDATA, nCurSel, 0);
+ if (nItemData == LB_ERR || nItemData == 0)
return NULL;
- return (CPrivacyListRule* )nItemData;
+ return (CPrivacyListRule*)nItemData;
}
-void CJabberProto::OnIqResultPrivacyListActive( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo* pInfo)
{
CPrivacyList *pList = (CPrivacyList *)pInfo->GetUserData();
- if ( m_pDlgPrivacyLists )
- EnableWindow( GetDlgItem( m_pDlgPrivacyLists->GetHwnd(), IDC_ACTIVATE ), TRUE );
+ if (m_pDlgPrivacyLists)
+ EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_ACTIVATE), TRUE);
- if ( !iqNode )
+ if ( !iqNode)
return;
- const TCHAR *type = xmlGetAttrValue( iqNode, _T("type"));
- if ( !type )
+ const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
+ if ( !type)
return;
TCHAR szText[ 512 ];
szText[0] = _T('\0');
m_privacyListManager.Lock();
- if ( !_tcscmp( type, _T("result"))) {
- if ( pList ) {
- m_privacyListManager.SetActiveListName( pList->GetListName());
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Privacy list %s set as active"), pList->GetListName());
+ if ( !_tcscmp(type, _T("result"))) {
+ if (pList) {
+ m_privacyListManager.SetActiveListName(pList->GetListName());
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Privacy list %s set as active"), pList->GetListName());
}
else {
- m_privacyListManager.SetActiveListName( NULL );
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Active privacy list successfully declined"));
+ m_privacyListManager.SetActiveListName(NULL);
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Active privacy list successfully declined"));
}
}
- else mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Error occurred while setting active list"));
+ else mir_sntprintf(szText, SIZEOF(szText), TranslateT("Error occurred while setting active list"));
m_privacyListManager.Unlock();
- if ( m_pDlgPrivacyLists )
+ if (m_pDlgPrivacyLists)
{
- m_pDlgPrivacyLists->SetStatusText( szText );
+ m_pDlgPrivacyLists->SetStatusText(szText);
RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), NULL, NULL, RDW_INVALIDATE);
}
- BuildPrivacyListsMenu( true );
+ BuildPrivacyListsMenu(true);
}
-void CJabberProto::OnIqResultPrivacyListDefault( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo* pInfo)
{
CPrivacyList *pList = (CPrivacyList *)pInfo->GetUserData();
- if ( m_pDlgPrivacyLists )
- EnableWindow( GetDlgItem( m_pDlgPrivacyLists->GetHwnd(), IDC_SET_DEFAULT ), TRUE );
+ if (m_pDlgPrivacyLists)
+ EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_SET_DEFAULT), TRUE);
- if ( !iqNode )
+ if ( !iqNode)
return;
- const TCHAR *type = xmlGetAttrValue( iqNode, _T("type"));
- if ( !type )
+ const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
+ if ( !type)
return;
TCHAR szText[ 512 ];
szText[0] = _T('\0');
m_privacyListManager.Lock();
- if ( !_tcscmp( type, _T("result"))) {
- if ( pList ) {
- m_privacyListManager.SetDefaultListName( pList->GetListName());
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Privacy list %s set as default"), pList->GetListName());
+ if ( !_tcscmp(type, _T("result"))) {
+ if (pList) {
+ m_privacyListManager.SetDefaultListName(pList->GetListName());
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Privacy list %s set as default"), pList->GetListName());
}
else {
- m_privacyListManager.SetDefaultListName( NULL );
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Default privacy list successfully declined"));
+ m_privacyListManager.SetDefaultListName(NULL);
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Default privacy list successfully declined"));
}
}
else {
- mir_sntprintf( szText, SIZEOF( szText ), TranslateT("Error occurred while setting default list"));
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Error occurred while setting default list"));
}
m_privacyListManager.Unlock();
- if ( m_pDlgPrivacyLists )
+ if (m_pDlgPrivacyLists)
{
- m_pDlgPrivacyLists->SetStatusText( szText );
+ m_pDlgPrivacyLists->SetStatusText(szText);
RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), NULL, NULL, RDW_INVALIDATE);
}
}
-void CJabberProto::OnIqResultPrivacyLists( HXML iqNode, CJabberIqInfo* pInfo )
+void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo* pInfo)
{
- if ( pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT )
+ if (pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT)
return;
- HXML query = xmlGetChild( iqNode, "query" );
- if ( !query )
+ HXML query = xmlGetChild(iqNode, "query");
+ if ( !query)
return;
- if ( m_ThreadInfo )
+ if (m_ThreadInfo)
m_ThreadInfo->jabberServerCaps |= JABBER_CAPS_PRIVACY_LISTS;
m_privacyListManager.Lock();
m_privacyListManager.RemoveAllLists();
- for ( int i = 1; ; i++ ) {
- HXML list = xmlGetNthChild( query, _T("list"), i );
- if ( !list )
+ for (int i = 1; ; i++) {
+ HXML list = xmlGetNthChild(query, _T("list"), i);
+ if ( !list)
break;
- const TCHAR *listName = xmlGetAttrValue( list, _T("name"));
- if ( listName ) {
- m_privacyListManager.AddList(( TCHAR* )listName);
+ const TCHAR *listName = xmlGetAttrValue(list, _T("name"));
+ if (listName) {
+ m_privacyListManager.AddList((TCHAR*)listName);
// Query contents only if list editior is visible!
- if ( m_pDlgPrivacyLists ) {
+ if (m_pDlgPrivacyLists) {
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultPrivacyList);
- m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId ) << XQUERY( _T(JABBER_FEAT_PRIVACY_LISTS)) << XCHILD( _T("list")) << XATTR( _T("name"), listName ));
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultPrivacyList);
+ m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId) << XQUERY(_T(JABBER_FEAT_PRIVACY_LISTS)) << XCHILD(_T("list")) << XATTR(_T("name"), listName));
} } }
const TCHAR *szName = NULL;
- HXML node = xmlGetChild( query , "active" );
- if ( node )
- szName = xmlGetAttrValue( node, _T("name"));
- m_privacyListManager.SetActiveListName( szName );
+ HXML node = xmlGetChild(query , "active");
+ if (node)
+ szName = xmlGetAttrValue(node, _T("name"));
+ m_privacyListManager.SetActiveListName(szName);
szName = NULL;
- node = xmlGetChild( query , "default" );
- if ( node )
- szName = xmlGetAttrValue( node, _T("name"));
- m_privacyListManager.SetDefaultListName( szName );
+ node = xmlGetChild(query , "default");
+ if (node)
+ szName = xmlGetAttrValue(node, _T("name"));
+ m_privacyListManager.SetDefaultListName(szName);
m_privacyListManager.Unlock();
UI_SAFE_NOTIFY(m_pDlgPrivacyLists, WM_JABBER_REFRESH);
- BuildPrivacyListsMenu( true );
+ BuildPrivacyListsMenu(true);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -316,8 +316,8 @@ public: m_btnOk(this, IDOK),
m_btnCancel(this, IDCANCEL)
{
- m_btnOk.OnClick = Callback( this, &CJabberDlgPrivacyAddList::btnOk_OnClick );
- m_btnCancel.OnClick = Callback( this, &CJabberDlgPrivacyAddList::btnCancel_OnClick);
+ m_btnOk.OnClick = Callback(this, &CJabberDlgPrivacyAddList::btnOk_OnClick);
+ m_btnCancel.OnClick = Callback(this, &CJabberDlgPrivacyAddList::btnCancel_OnClick);
}
void btnOk_OnClick(CCtrlButton*)
@@ -375,74 +375,74 @@ public: TCHAR* szTypes[] = { _T("JID"), _T("Group"), _T("Subscription"), _T("Any") };
int i, nTypes[] = { Jid, Group, Subscription, Else };
- for ( i = 0; i < SIZEOF(szTypes); i++ )
+ for (i = 0; i < SIZEOF(szTypes); i++)
{
- LRESULT nItem = SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS( szTypes[i] ));
- SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_SETITEMDATA, nItem, nTypes[i] );
- if ( m_pRule->GetType() == nTypes[i] )
- SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_SETCURSEL, nItem, 0 );
+ LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szTypes[i]));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_SETITEMDATA, nItem, nTypes[i]);
+ if (m_pRule->GetType() == nTypes[i])
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_SETCURSEL, nItem, 0);
}
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_RESETCONTENT, 0, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_RESETCONTENT, 0, 0);
TCHAR* szSubscriptions[] = { _T("none"), _T("from"), _T("to"), _T("both") };
- for ( i = 0; i < SIZEOF(szSubscriptions); i++ )
+ for (i = 0; i < SIZEOF(szSubscriptions); i++)
{
- LRESULT nItem = SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateTS( szSubscriptions[i] ));
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)szSubscriptions[i] );
+ LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szSubscriptions[i]));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)szSubscriptions[i]);
}
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_COMBO_TYPE, CBN_SELCHANGE ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COMBO_TYPE, CBN_SELCHANGE), 0);
- SendDlgItemMessage( m_hwnd, IDC_COMBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateTS( _T("Deny" )));
- SendDlgItemMessage( m_hwnd, IDC_COMBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateTS( _T("Allow" )));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("Deny")));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("Allow")));
- SendDlgItemMessage( m_hwnd, IDC_COMBO_ACTION, CB_SETCURSEL, m_pRule->GetAction() ? 1 : 0, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_ACTION, CB_SETCURSEL, m_pRule->GetAction() ? 1 : 0, 0);
DWORD dwPackets = m_pRule->GetPackets();
- if ( !dwPackets )
+ if ( !dwPackets)
dwPackets = JABBER_PL_RULE_TYPE_ALL;
- if ( dwPackets & JABBER_PL_RULE_TYPE_IQ )
- SendDlgItemMessage( m_hwnd, IDC_CHECK_QUERIES, BM_SETCHECK, BST_CHECKED, 0 );
- if ( dwPackets & JABBER_PL_RULE_TYPE_MESSAGE )
- SendDlgItemMessage( m_hwnd, IDC_CHECK_MESSAGES, BM_SETCHECK, BST_CHECKED, 0 );
- if ( dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN )
- SendDlgItemMessage( m_hwnd, IDC_CHECK_PRESENCE_IN, BM_SETCHECK, BST_CHECKED, 0 );
- if ( dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT )
- SendDlgItemMessage( m_hwnd, IDC_CHECK_PRESENCE_OUT, BM_SETCHECK, BST_CHECKED, 0 );
-
- if ( m_pRule->GetValue() && ( m_pRule->GetType() == Jid || m_pRule->GetType() == Group ))
- SetDlgItemText( m_hwnd, IDC_EDIT_VALUE, m_pRule->GetValue());
+ if (dwPackets & JABBER_PL_RULE_TYPE_IQ)
+ SendDlgItemMessage(m_hwnd, IDC_CHECK_QUERIES, BM_SETCHECK, BST_CHECKED, 0);
+ if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
+ SendDlgItemMessage(m_hwnd, IDC_CHECK_MESSAGES, BM_SETCHECK, BST_CHECKED, 0);
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN)
+ SendDlgItemMessage(m_hwnd, IDC_CHECK_PRESENCE_IN, BM_SETCHECK, BST_CHECKED, 0);
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT)
+ SendDlgItemMessage(m_hwnd, IDC_CHECK_PRESENCE_OUT, BM_SETCHECK, BST_CHECKED, 0);
+
+ if (m_pRule->GetValue() && (m_pRule->GetType() == Jid || m_pRule->GetType() == Group))
+ SetDlgItemText(m_hwnd, IDC_EDIT_VALUE, m_pRule->GetValue());
}
void cbType_OnChange(CCtrlData*)
{
- if ( !m_pRule ) return;
+ if ( !m_pRule) return;
- LRESULT nCurSel = SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0 );
- if ( nCurSel == CB_ERR )
+ LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
+ if (nCurSel == CB_ERR)
return;
- LRESULT nItemData = SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0 );
+ LRESULT nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
switch (nItemData)
{
case Jid:
{
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUES ), SW_SHOW );
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUE ), SW_HIDE );
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL )
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL)
{
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_proto->m_szModuleName ))
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, m_proto->m_szModuleName))
{
DBVARIANT dbv;
- if ( !m_proto->JGetStringT( hContact, "jid", &dbv ))
+ if ( !m_proto->JGetStringT(hContact, "jid", &dbv))
{
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal );
- JFreeVariant( &dbv );
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
+ db_free(&dbv);
}
}
hContact = db_find_next(hContact);
@@ -452,70 +452,70 @@ public: LISTFOREACH(i, m_proto, LIST_BOOKMARK)
{
JABBER_LIST_ITEM *item = 0;
- if ( item = m_proto->ListGetItemPtrFromIndex( i ))
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)item->jid );
+ if (item = m_proto->ListGetItemPtrFromIndex(i))
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)item->jid);
}
// FIXME: ugly code :)
- if ( m_pRule->GetValue())
+ if (m_pRule->GetValue())
{
- SetDlgItemText( m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
- LRESULT nSelPos = SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
- if ( nSelPos != CB_ERR )
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0 );
+ SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
+ LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
+ if (nSelPos != CB_ERR)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
}
break;
}
case Group:
{
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUES ), SW_SHOW );
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUE ), SW_HIDE );
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
char buf[ 20 ];
DBVARIANT dbv;
- for ( int i = 0; ; i++ )
+ for (int i = 0; ; i++)
{
mir_snprintf(buf, 20, "%d", i);
- if ( DBGetContactSettingTString(NULL, "CListGroups", buf, &dbv))
+ if (DBGetContactSettingTString(NULL, "CListGroups", buf, &dbv))
break;
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)&dbv.ptszVal[1] );
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)&dbv.ptszVal[1]);
DBFreeVariant(&dbv);
}
// FIXME: ugly code :)
- if ( m_pRule->GetValue())
+ if (m_pRule->GetValue())
{
- SetDlgItemText( m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
- LRESULT nSelPos = SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
- if ( nSelPos != CB_ERR )
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0 );
+ SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
+ LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
+ if (nSelPos != CB_ERR)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
}
break;
}
case Subscription:
{
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUES ), SW_HIDE );
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUE ), SW_SHOW );
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_SHOW);
- if ( m_pRule->GetValue())
+ if (m_pRule->GetValue())
{
- LRESULT nSelected = SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_SELECTSTRING, -1, (LPARAM)TranslateTS(m_pRule->GetValue()));
- if ( nSelected == CB_ERR )
- SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0 );
+ LRESULT nSelected = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SELECTSTRING, -1, (LPARAM)TranslateTS(m_pRule->GetValue()));
+ if (nSelected == CB_ERR)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
}
- else SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0 );
+ else SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
break;
}
case Else:
{
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUES ), SW_HIDE );
- ShowWindow( GetDlgItem( m_hwnd, IDC_COMBO_VALUE ), SW_HIDE );
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
break;
}
}
@@ -526,56 +526,56 @@ public: void btnOk_OnClick(CCtrlButton *)
{
LRESULT nItemData = -1;
- LRESULT nCurSel = SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0 );
- if ( nCurSel != CB_ERR )
- nItemData = SendDlgItemMessage( m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0 );
+ LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETCURSEL, 0, 0);
+ if (nCurSel != CB_ERR)
+ nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
- switch ( nItemData )
+ switch (nItemData)
{
case Jid:
case Group:
{
TCHAR szText[ 512 ];
- GetDlgItemText( m_hwnd, IDC_COMBO_VALUES, szText, SIZEOF(szText));
- m_pRule->SetValue( szText );
+ GetDlgItemText(m_hwnd, IDC_COMBO_VALUES, szText, SIZEOF(szText));
+ m_pRule->SetValue(szText);
break;
}
case Subscription:
{
- nCurSel = SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0 );
- if ( nCurSel != CB_ERR )
- m_pRule->SetValue(( TCHAR* )SendDlgItemMessage( m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0 ));
+ nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0);
+ if (nCurSel != CB_ERR)
+ m_pRule->SetValue((TCHAR*)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
else
- m_pRule->SetValue( _T( "none" ));
+ m_pRule->SetValue(_T("none"));
break;
}
default:
- m_pRule->SetValue( NULL );
+ m_pRule->SetValue(NULL);
break;
}
- m_pRule->SetType( ( PrivacyListRuleType )nItemData );
- nCurSel = SendDlgItemMessage( m_hwnd, IDC_COMBO_ACTION, CB_GETCURSEL, 0, 0 );
- if ( nCurSel == CB_ERR )
+ m_pRule->SetType((PrivacyListRuleType)nItemData);
+ nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_ACTION, CB_GETCURSEL, 0, 0);
+ if (nCurSel == CB_ERR)
nCurSel = 1;
- m_pRule->SetAction( nCurSel ? TRUE : FALSE );
+ m_pRule->SetAction(nCurSel ? TRUE : FALSE);
DWORD dwPackets = 0;
- if ( BST_CHECKED == SendDlgItemMessage( m_hwnd, IDC_CHECK_MESSAGES, BM_GETCHECK, 0, 0 ))
+ if (BST_CHECKED == SendDlgItemMessage(m_hwnd, IDC_CHECK_MESSAGES, BM_GETCHECK, 0, 0))
dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
- if ( BST_CHECKED == SendDlgItemMessage( m_hwnd, IDC_CHECK_PRESENCE_IN, BM_GETCHECK, 0, 0 ))
+ if (BST_CHECKED == SendDlgItemMessage(m_hwnd, IDC_CHECK_PRESENCE_IN, BM_GETCHECK, 0, 0))
dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- if ( BST_CHECKED == SendDlgItemMessage( m_hwnd, IDC_CHECK_PRESENCE_OUT, BM_GETCHECK, 0, 0 ))
+ if (BST_CHECKED == SendDlgItemMessage(m_hwnd, IDC_CHECK_PRESENCE_OUT, BM_GETCHECK, 0, 0))
dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- if ( BST_CHECKED == SendDlgItemMessage( m_hwnd, IDC_CHECK_QUERIES, BM_GETCHECK, 0, 0 ))
+ if (BST_CHECKED == SendDlgItemMessage(m_hwnd, IDC_CHECK_QUERIES, BM_GETCHECK, 0, 0))
dwPackets |= JABBER_PL_RULE_TYPE_IQ;
- if ( !dwPackets )
+ if ( !dwPackets)
dwPackets = JABBER_PL_RULE_TYPE_ALL;
- m_pRule->SetPackets( dwPackets );
+ m_pRule->SetPackets(dwPackets);
- EndDialog( m_hwnd, 1 );
+ EndDialog(m_hwnd, 1);
}
void btnCancel_OnClick(CCtrlButton *)
@@ -585,10 +585,10 @@ public: void OnDestroy()
{
- g_ReleaseIcon(( HICON )SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
- g_ReleaseIcon(( HICON )SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0));
- g_ReleaseIcon(( HICON )SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0));
- g_ReleaseIcon(( HICON )SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, 0, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, 0, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, 0, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, 0, 0));
+ g_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, 0, 0));
m_proto->m_hwndPrivacyRule = NULL;
}
};
@@ -775,19 +775,19 @@ CJabberDlgPrivacyLists::CJabberDlgPrivacyLists(CJabberProto *proto): m_lbRules(this, IDC_PL_RULES_LIST),
m_clcClist(this, IDC_CLIST)
{
- m_btnSimple.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnSimple_OnClick);
- m_btnAdvanced.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnAdvanced_OnClick);
- m_btnAddJid.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnAddJid_OnClick);
- m_btnActivate.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnActivate_OnClick);
- m_btnSetDefault.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnSetDefault_OnClick);
- m_btnEditRule.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnEditRule_OnClick);
- m_btnAddRule.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnAddRule_OnClick);
- m_btnRemoveRule.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnRemoveRule_OnClick);
- m_btnUpRule.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnUpRule_OnClick);
- m_btnDownRule.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnDownRule_OnClick);
- m_btnAddList.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnAddList_OnClick);
- m_btnRemoveList.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnRemoveList_OnClick);
- m_btnApply.OnClick = Callback( this, &CJabberDlgPrivacyLists::btnApply_OnClick);
+ m_btnSimple.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSimple_OnClick);
+ m_btnAdvanced.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAdvanced_OnClick);
+ m_btnAddJid.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddJid_OnClick);
+ m_btnActivate.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnActivate_OnClick);
+ m_btnSetDefault.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnSetDefault_OnClick);
+ m_btnEditRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnEditRule_OnClick);
+ m_btnAddRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddRule_OnClick);
+ m_btnRemoveRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveRule_OnClick);
+ m_btnUpRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnUpRule_OnClick);
+ m_btnDownRule.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnDownRule_OnClick);
+ m_btnAddList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnAddList_OnClick);
+ m_btnRemoveList.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnRemoveList_OnClick);
+ m_btnApply.OnClick = Callback(this, &CJabberDlgPrivacyLists::btnApply_OnClick);
m_lbLists.OnSelChange = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnSelChange);
m_lbLists.OnDblClick = Callback(this, &CJabberDlgPrivacyLists::lbLists_OnDblClick);
@@ -804,13 +804,13 @@ void CJabberDlgPrivacyLists::OnInitDialog() {
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "privacylists" );
+ WindowSetIcon(m_hwnd, m_proto, "privacylists");
- EnableWindow( GetDlgItem( m_hwnd, IDC_ADD_RULE ), FALSE );
- EnableWindow( GetDlgItem( m_hwnd, IDC_EDIT_RULE ), FALSE );
- EnableWindow( GetDlgItem( m_hwnd, IDC_REMOVE_RULE ), FALSE );
- EnableWindow( GetDlgItem( m_hwnd, IDC_UP_RULE ), FALSE );
- EnableWindow( GetDlgItem( m_hwnd, IDC_DOWN_RULE ), FALSE );
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_UP_RULE), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DOWN_RULE), FALSE);
m_proto->QueryPrivacyLists();
@@ -860,7 +860,7 @@ void CJabberDlgPrivacyLists::OnInitDialog() CListFilter(GetDlgItem(m_hwnd, IDC_CLIST));
CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST));
- if ( DBGetContactSettingByte(NULL, m_proto->m_szModuleName, "plistsWnd_simpleMode", 1))
+ if (db_get_b(NULL, m_proto->m_szModuleName, "plistsWnd_simpleMode", 1))
{
UIShowControls(m_hwnd, idSimpleControls, SW_SHOW);
UIShowControls(m_hwnd, idAdvancedControls, SW_HIDE);
@@ -899,12 +899,12 @@ void CJabberDlgPrivacyLists::OnDestroy() // Wipe all data and query lists without contents
m_proto->m_privacyListManager.RemoveAllLists();
m_proto->QueryPrivacyLists();
- m_proto->m_privacyListManager.SetModified( FALSE );
+ m_proto->m_privacyListManager.SetModified(FALSE);
// Delete custom bold font
DeleteObject((HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_LISTS, WM_GETFONT, 0, 0));
- DBWriteContactSettingByte(NULL, m_proto->m_szModuleName, "plistsWnd_simpleMode", IsDlgButtonChecked(m_hwnd, IDC_BTN_SIMPLE));
+ db_set_b(NULL, m_proto->m_szModuleName, "plistsWnd_simpleMode", IsDlgButtonChecked(m_hwnd, IDC_BTN_SIMPLE));
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "plistsWnd_sz");
@@ -915,35 +915,35 @@ void CJabberDlgPrivacyLists::OnProtoRefresh(WPARAM, LPARAM) {
LRESULT sel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
TCHAR *szCurrentSelectedList = NULL;
- if ( sel != LB_ERR ) {
+ if (sel != LB_ERR) {
LRESULT len = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXTLEN, sel, 0) + 1;
szCurrentSelectedList = (TCHAR *)mir_alloc(len * sizeof(TCHAR));
SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETTEXT, sel, (LPARAM)szCurrentSelectedList);
}
- SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_RESETCONTENT, 0, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_RESETCONTENT, 0, 0);
- LRESULT nItemId = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)TranslateT( "<none>" ));
- SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, 0 );
+ LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<none>"));
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, 0);
m_proto->m_privacyListManager.Lock();
CPrivacyList* pList = m_proto->m_privacyListManager.GetFirstList();
- while ( pList ) {
+ while (pList) {
if ( !pList->IsDeleted()) {
- nItemId = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)pList->GetListName());
- SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, (LPARAM)pList );
+ nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)pList->GetListName());
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, (LPARAM)pList);
}
pList = pList->GetNext();
}
- if ( !szCurrentSelectedList || ( SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)szCurrentSelectedList ) == LB_ERR ))
- SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, 0, 0 );
- if ( szCurrentSelectedList )
- mir_free( szCurrentSelectedList );
+ if ( !szCurrentSelectedList || (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)szCurrentSelectedList) == LB_ERR))
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, 0, 0);
+ if (szCurrentSelectedList)
+ mir_free(szCurrentSelectedList);
m_proto->m_privacyListManager.Unlock();
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_LB_LISTS, LBN_SELCHANGE ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
EnableEditorControls();
}
@@ -995,7 +995,7 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) for (i = 0; i < SIZEOF(items); ++i)
{
SIZE sz = {0};
- if (!items[i].text) items[i].text = TranslateTS(items[i].textEng);
+ if ( !items[i].text) items[i].text = TranslateTS(items[i].textEng);
GetTextExtentPoint32(lpdis->hDC, items[i].text, lstrlen(items[i].text), &sz);
totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
}
@@ -1029,27 +1029,27 @@ BOOL CJabberDlgPrivacyLists::OnWmGetMinMaxInfo(UINT, WPARAM, LPARAM lParam) void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList)
{
int nLbSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
BOOL bListEmpty = TRUE;
CPrivacyListRule* pRule = pList->GetFirstRule();
- while ( pRule ) {
+ while (pRule) {
bListEmpty = FALSE;
TCHAR szTypeValue[ 512 ];
- switch ( pRule->GetType()) {
+ switch (pRule->GetType()) {
case Jid:
- mir_sntprintf( szTypeValue, SIZEOF( szTypeValue ), _T( "If jabber id is '%s' then" ), pRule->GetValue());
+ mir_sntprintf(szTypeValue, SIZEOF(szTypeValue), _T("If jabber id is '%s' then"), pRule->GetValue());
break;
case Group:
- mir_sntprintf( szTypeValue, SIZEOF( szTypeValue ), _T( "If group is '%s' then" ), pRule->GetValue());
+ mir_sntprintf(szTypeValue, SIZEOF(szTypeValue), _T("If group is '%s' then"), pRule->GetValue());
break;
case Subscription:
- mir_sntprintf( szTypeValue, SIZEOF( szTypeValue ), _T( "If subscription is '%s' then" ), pRule->GetValue());
+ mir_sntprintf(szTypeValue, SIZEOF(szTypeValue), _T("If subscription is '%s' then"), pRule->GetValue());
break;
case Else:
- mir_sntprintf( szTypeValue, SIZEOF( szTypeValue ), _T( "Else"));
+ mir_sntprintf(szTypeValue, SIZEOF(szTypeValue), _T("Else"));
break;
}
@@ -1057,45 +1057,45 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList) szPackets[ 0 ] = '\0';
DWORD dwPackets = pRule->GetPackets();
- if ( !dwPackets )
+ if ( !dwPackets)
dwPackets = JABBER_PL_RULE_TYPE_ALL;
- if ( dwPackets == JABBER_PL_RULE_TYPE_ALL )
- _tcscpy( szPackets, _T("all"));
+ if (dwPackets == JABBER_PL_RULE_TYPE_ALL)
+ _tcscpy(szPackets, _T("all"));
else {
- if ( dwPackets & JABBER_PL_RULE_TYPE_MESSAGE )
- _tcscat( szPackets, _T("messages"));
- if ( dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN ) {
- if ( _tcslen( szPackets ))
- _tcscat( szPackets, _T(", "));
- _tcscat( szPackets, _T("presence-in"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
+ _tcscat(szPackets, _T("messages"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN) {
+ if (_tcslen(szPackets))
+ _tcscat(szPackets, _T(", "));
+ _tcscat(szPackets, _T("presence-in"));
}
- if ( dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT ) {
- if ( _tcslen( szPackets ))
- _tcscat( szPackets, _T(", "));
- _tcscat( szPackets, _T("presence-out"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT) {
+ if (_tcslen(szPackets))
+ _tcscat(szPackets, _T(", "));
+ _tcscat(szPackets, _T("presence-out"));
}
- if ( dwPackets & JABBER_PL_RULE_TYPE_IQ ) {
- if ( _tcslen( szPackets ))
- _tcscat( szPackets, _T(", "));
- _tcscat( szPackets, _T("queries"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_IQ) {
+ if (_tcslen(szPackets))
+ _tcscat(szPackets, _T(", "));
+ _tcscat(szPackets, _T("queries"));
} }
TCHAR szListItem[ 512 ];
- mir_sntprintf( szListItem, SIZEOF( szListItem ), _T("%s %s %s"), szTypeValue, pRule->GetAction() ? _T("allow") : _T("deny"), szPackets );
+ mir_sntprintf(szListItem, SIZEOF(szListItem), _T("%s %s %s"), szTypeValue, pRule->GetAction() ? _T("allow") : _T("deny"), szPackets);
- LRESULT nItemId = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)szListItem );
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_SETITEMDATA, nItemId, (LPARAM)pRule );
+ LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)szListItem);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETITEMDATA, nItemId, (LPARAM)pRule);
pRule = pRule->GetNext();
}
- EnableWindow( GetDlgItem( m_hwnd, IDC_PL_RULES_LIST ), !bListEmpty );
- if ( bListEmpty )
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("List has no rules, empty lists will be deleted then changes applied")));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), !bListEmpty);
+ if (bListEmpty)
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("List has no rules, empty lists will be deleted then changes applied")));
else
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nLbSel, 0 );
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nLbSel, 0);
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_PL_RULES_LIST, LBN_SELCHANGE ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_PL_RULES_LIST, LBN_SELCHANGE), 0);
}
void CJabberDlgPrivacyLists::DrawNextRulePart(HDC hdc, COLORREF color, const TCHAR *text, RECT *rc)
@@ -1111,7 +1111,7 @@ void CJabberDlgPrivacyLists::DrawNextRulePart(HDC hdc, COLORREF color, const TCH void CJabberDlgPrivacyLists::DrawRuleAction(HDC hdc, COLORREF clLine1, COLORREF, CPrivacyListRule *pRule, RECT *rc)
{
DrawNextRulePart(hdc, clLine1, pRule->GetAction() ? TranslateT("allow ") : TranslateT("deny "), rc);
- if (!pRule->GetPackets() || (pRule->GetPackets() == JABBER_PL_RULE_TYPE_ALL))
+ if ( !pRule->GetPackets() || (pRule->GetPackets() == JABBER_PL_RULE_TYPE_ALL))
{
DrawNextRulePart(hdc, clLine1, TranslateT("all."), rc);
} else
@@ -1186,7 +1186,7 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) RECT rc;
- if ( !pRule ) {
+ if ( !pRule) {
rc = lpdis->rcItem;
rc.left += 25;
@@ -1207,7 +1207,7 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) rc.bottom -= (rc.bottom - rc.top) / 2;
rc.left += 25;
- switch ( pRule->GetType())
+ switch (pRule->GetType())
{
case Jid:
{
@@ -1217,7 +1217,7 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) if (HANDLE hContact = m_proto->HContactFromJID(pRule->GetValue())) {
TCHAR *szName = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
- if ( szName ) {
+ if (szName) {
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (nickname: "), &rc);
DrawNextRulePart(lpdis->hDC, clLine1, szName, &rc);
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(")"), &rc);
@@ -1303,15 +1303,15 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) bool bDefault = false;
TCHAR *szName;
- if (!pList)
+ if ( !pList)
{
- if (!szActive) bActive = true;
- if (!szDefault) bDefault = true;
+ if ( !szActive) bActive = true;
+ if ( !szDefault) bDefault = true;
szName = TranslateT("<none>");
} else
{
- if (!lstrcmp(pList->GetListName(), szActive)) bActive = true;
- if (!lstrcmp(pList->GetListName(), szDefault)) bDefault = true;
+ if ( !lstrcmp(pList->GetListName(), szActive)) bActive = true;
+ if ( !lstrcmp(pList->GetListName(), szDefault)) bDefault = true;
szName = pList->GetListName();
}
@@ -1373,7 +1373,7 @@ void CJabberDlgPrivacyLists::CListFilter(HWND) hContact = db_find_next(hContact))
{
char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (!proto || lstrcmpA(proto, m_proto->m_szModuleName))
+ if ( !proto || lstrcmpA(proto, m_proto->m_szModuleName))
if (HANDLE hItem = m_clcClist.FindContact(hContact))
m_clcClist.DeleteItem(hItem);
}
@@ -1386,7 +1386,7 @@ bool CJabberDlgPrivacyLists::CListIsGroup(HANDLE hGroup) DBVARIANT dbv;
bool result = DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv) == 0;
- if ( result )
+ if (result)
DBFreeVariant(&dbv);
return result;
@@ -1406,7 +1406,7 @@ HANDLE CJabberDlgPrivacyLists::CListFindGroupByName(TCHAR *name) if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv))
break;
- if (!_tcscmp(dbv.ptszVal + 1, name))
+ if ( !_tcscmp(dbv.ptszVal + 1, name))
hGroup = (HANDLE)(i+1);
DBFreeVariant(&dbv);
@@ -1432,9 +1432,9 @@ HANDLE CJabberDlgPrivacyLists::CListAddContact(HWND hwndList, TCHAR *jid) HANDLE hItem = 0;
HANDLE hContact = m_proto->HContactFromJID(jid);
- if ( !hContact ) {
+ if ( !hContact) {
hItem = clc_info.findJid(jid);
- if (!hItem)
+ if ( !hItem)
{
CLCINFOITEM cii = {0};
cii.cbSize = sizeof(cii);
@@ -1467,7 +1467,7 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) for (int iGroup = 1; CListIsGroup((HANDLE)iGroup); ++iGroup)
{
HANDLE hItem = m_clcClist.FindGroup((HANDLE)iGroup);
- if (!hItem) continue;
+ if ( !hItem) continue;
CListResetIcons(hwndList, hItem, bHideIcons);
}
@@ -1475,14 +1475,14 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) hContact=db_find_next(hContact))
{
HANDLE hItem = m_clcClist.FindContact(hContact);
- if (!hItem) continue;
+ if ( !hItem) continue;
CListResetIcons(hwndList, hItem, bHideIcons);
}
for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid)
CListResetIcons(hwndList, clc_info.newJids[iJid]->hItem, bHideIcons);
- if (!pList)
+ if ( !pList)
goto lbl_return;
CPrivacyListRule *pRule;
@@ -1504,10 +1504,10 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) }
case Subscription:
{
- if (!lstrcmp(pRule->GetValue(), _T("none"))) hItem = clc_info.hItemSubNone;
- else if (!lstrcmp(pRule->GetValue(), _T("from"))) hItem = clc_info.hItemSubFrom;
- else if (!lstrcmp(pRule->GetValue(), _T("to"))) hItem = clc_info.hItemSubTo;
- else if (!lstrcmp(pRule->GetValue(), _T("both"))) hItem = clc_info.hItemSubBoth;
+ if ( !lstrcmp(pRule->GetValue(), _T("none"))) hItem = clc_info.hItemSubNone;
+ else if ( !lstrcmp(pRule->GetValue(), _T("from"))) hItem = clc_info.hItemSubFrom;
+ else if ( !lstrcmp(pRule->GetValue(), _T("to"))) hItem = clc_info.hItemSubTo;
+ else if ( !lstrcmp(pRule->GetValue(), _T("both"))) hItem = clc_info.hItemSubBoth;
break;
}
case Else:
@@ -1517,10 +1517,10 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) }
}
- if (!hItem) continue;
+ if ( !hItem) continue;
DWORD dwPackets = pRule->GetPackets();
- if (!dwPackets) dwPackets = JABBER_PL_RULE_TYPE_ALL;
+ if ( !dwPackets) dwPackets = JABBER_PL_RULE_TYPE_ALL;
CListSetupIcons(hwndList, hItem, 0, dwPackets & JABBER_PL_RULE_TYPE_MESSAGE, pRule->GetAction());
CListSetupIcons(hwndList, hItem, 1, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN, pRule->GetAction());
CListSetupIcons(hwndList, hItem, 2, dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT, pRule->GetAction());
@@ -1538,29 +1538,29 @@ DWORD CJabberDlgPrivacyLists::CListGetPackets(HWND, HANDLE hItem, bool bAction) int iIcon = 0;
iIcon = m_clcClist.GetExtraImage(hItem, 0);
- if ( bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
- else if (!bAction && (iIcon == 2)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
+ if (bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
+ else if ( !bAction && (iIcon == 2)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
iIcon = m_clcClist.GetExtraImage(hItem, 1);
- if ( bAction && (iIcon == 3)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- else if (!bAction && (iIcon == 4)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ if (bAction && (iIcon == 3)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ else if ( !bAction && (iIcon == 4)) result |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
iIcon = m_clcClist.GetExtraImage(hItem, 2);
- if ( bAction && (iIcon == 5)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- else if (!bAction && (iIcon == 6)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ if (bAction && (iIcon == 5)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ else if ( !bAction && (iIcon == 6)) result |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
iIcon = m_clcClist.GetExtraImage(hItem, 3);
- if ( bAction && (iIcon == 7)) result |= JABBER_PL_RULE_TYPE_IQ;
- else if (!bAction && (iIcon == 8)) result |= JABBER_PL_RULE_TYPE_IQ;
+ if (bAction && (iIcon == 7)) result |= JABBER_PL_RULE_TYPE_IQ;
+ else if ( !bAction && (iIcon == 8)) result |= JABBER_PL_RULE_TYPE_IQ;
return result;
}
void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
{
- if (!pList) return;
+ if ( !pList) return;
- if (!clc_info.bChanged) return;
+ if ( !clc_info.bChanged) return;
clc_info.bChanged = false;
@@ -1589,8 +1589,8 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) hItem = m_clcClist.FindContact(hContact);
DBVARIANT dbv = {0};
- if ( m_proto->JGetStringT(hContact, "jid", &dbv)) {
- if ( m_proto->JGetStringT(hContact, "ChatRoomID", &dbv))
+ if (m_proto->JGetStringT(hContact, "jid", &dbv)) {
+ if (m_proto->JGetStringT(hContact, "ChatRoomID", &dbv))
continue;
}
@@ -1601,7 +1601,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) if (dwPackets = CListGetPackets(hwndList, hItem, false))
pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
// group handles start with 1 (0 is "root")
@@ -1670,27 +1670,27 @@ void CJabberDlgPrivacyLists::EnableEditorControls() BOOL bListsModified = m_proto->m_privacyListManager.IsModified() || clc_info.bChanged;
m_proto->m_privacyListManager.Unlock();
- int nCurSel = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0 );
- int nItemCount = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0 );
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
BOOL bSelected = nCurSel != CB_ERR;
- BOOL bListSelected = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_GETCOUNT, 0, 0);
- bListSelected = bListSelected && (SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0) != LB_ERR);
- bListSelected = bListSelected && SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0), 0);
-
- EnableWindow( GetDlgItem( m_hwnd, IDC_TXT_OTHERJID ), bListsLoaded && bListSelected );
- EnableWindow( GetDlgItem( m_hwnd, IDC_NEWJID ), bListsLoaded && bListSelected );
- EnableWindow( GetDlgItem( m_hwnd, IDC_ADDJID ), bListsLoaded && bListSelected );
-
- EnableWindow( GetDlgItem( m_hwnd, IDC_ADD_RULE ), bListsLoaded && bListSelected );
- EnableWindow( GetDlgItem( m_hwnd, IDC_EDIT_RULE ), bListsLoaded && bSelected );
- EnableWindow( GetDlgItem( m_hwnd, IDC_REMOVE_RULE ), bListsLoaded && bSelected );
- EnableWindow( GetDlgItem( m_hwnd, IDC_UP_RULE ), bListsLoaded && bSelected && nCurSel != 0 );
- EnableWindow( GetDlgItem( m_hwnd, IDC_DOWN_RULE ), bListsLoaded && bSelected && nCurSel != ( nItemCount - 1 ));
- EnableWindow( GetDlgItem( m_hwnd, IDC_REMOVE_LIST ), bListsLoaded && bListSelected );
- EnableWindow( GetDlgItem( m_hwnd, IDC_APPLY ), bListsLoaded && bListsModified );
+ BOOL bListSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCOUNT, 0, 0);
+ bListSelected = bListSelected && (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0) != LB_ERR);
+ bListSelected = bListSelected && SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0), 0);
+
+ EnableWindow(GetDlgItem(m_hwnd, IDC_TXT_OTHERJID), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_NEWJID), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ADDJID), bListsLoaded && bListSelected);
+
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), bListsLoaded && bSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_RULE), bListsLoaded && bSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_UP_RULE), bListsLoaded && bSelected && nCurSel != 0);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_DOWN_RULE), bListsLoaded && bSelected && nCurSel != (nItemCount - 1));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_REMOVE_LIST), bListsLoaded && bListSelected);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_APPLY), bListsLoaded && bListsModified);
if (bListsLoaded)
- SetStatusText( TranslateT("Ready."));
+ SetStatusText(TranslateT("Ready."));
}
LRESULT CALLBACK CJabberDlgPrivacyLists::LstListsSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1752,10 +1752,10 @@ BOOL CJabberDlgPrivacyLists::CanExit() if (clc_info.bChanged)
bModified = TRUE;
- if ( !bModified )
+ if ( !bModified)
return TRUE;
- if ( IDYES == MessageBox( m_hwnd, TranslateT("Privacy lists are not saved, discard any changes and exit?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 ))
+ if (IDYES == MessageBox(m_hwnd, TranslateT("Privacy lists are not saved, discard any changes and exit?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2))
return TRUE;
return FALSE;
@@ -1791,67 +1791,67 @@ void CJabberDlgPrivacyLists::btnAddJid_OnClick(CCtrlButton *) void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
{
- if ( m_proto->m_bJabberOnline )
+ if (m_proto->m_bJabberOnline)
{
m_proto->m_privacyListManager.Lock();
CPrivacyList* pList = GetSelectedList(m_hwnd);
- if ( pList && pList->IsModified()) {
+ if (pList && pList->IsModified()) {
m_proto->m_privacyListManager.Unlock();
- MessageBox( m_hwnd, TranslateT("Please save list before activating"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP );
+ MessageBox(m_hwnd, TranslateT("Please save list before activating"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
return;
}
- EnableWindow( GetDlgItem( m_hwnd, IDC_ACTIVATE ), FALSE );
- SetWindowLongPtr( GetDlgItem( m_hwnd, IDC_ACTIVATE ), GWLP_USERDATA, (LONG_PTR)pList );
- XmlNodeIq iq( m_proto->m_iqManager.AddHandler( &CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList ));
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVACY_LISTS));
- HXML active = query << XCHILD( _T("active"));
- if ( pList )
- active << XATTR( _T("name"), pList->GetListName());
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
+ XmlNodeIq iq(m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVACY_LISTS));
+ HXML active = query << XCHILD(_T("active"));
+ if (pList)
+ active << XATTR(_T("name"), pList->GetListName());
m_proto->m_privacyListManager.Unlock();
- SetStatusText(TranslateT( JABBER_PL_BUSY_MSG ));
+ SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
- m_proto->m_ThreadInfo->send( iq );
+ m_proto->m_ThreadInfo->send(iq);
}
}
void CJabberDlgPrivacyLists::btnSetDefault_OnClick(CCtrlButton *)
{
- if ( m_proto->m_bJabberOnline )
+ if (m_proto->m_bJabberOnline)
{
m_proto->m_privacyListManager.Lock();
CPrivacyList* pList = GetSelectedList(m_hwnd);
- if ( pList && pList->IsModified()) {
+ if (pList && pList->IsModified()) {
m_proto->m_privacyListManager.Unlock();
- MessageBox( m_hwnd, TranslateT("Please save list before you make it the default list"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP );
+ MessageBox(m_hwnd, TranslateT("Please save list before you make it the default list"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
return;
}
- EnableWindow( GetDlgItem( m_hwnd, IDC_SET_DEFAULT ), FALSE );
- SetWindowLongPtr( GetDlgItem( m_hwnd, IDC_SET_DEFAULT ), GWLP_USERDATA, (LONG_PTR)pList );
-
- XmlNodeIq iq( m_proto->m_iqManager.AddHandler( &CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList ));
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVACY_LISTS ));
- HXML defaultTag = query << XCHILD( _T("default"));
- if ( pList )
- xmlAddAttr( defaultTag, _T("name"), pList->GetListName());
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
+
+ XmlNodeIq iq(m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVACY_LISTS));
+ HXML defaultTag = query << XCHILD(_T("default"));
+ if (pList)
+ xmlAddAttr(defaultTag, _T("name"), pList->GetListName());
m_proto->m_privacyListManager.Unlock();
- SetStatusText(TranslateT( JABBER_PL_BUSY_MSG ));
+ SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
- m_proto->m_ThreadInfo->send( iq );
+ m_proto->m_ThreadInfo->send(iq);
}
}
void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *)
{
- LRESULT nCurSel = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0 );
- if ( nCurSel == LB_ERR )
+ LRESULT nCurSel = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETCURSEL, 0, 0);
+ if (nCurSel == LB_ERR)
return;
- LRESULT nErr = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0 );
- if ( nErr == LB_ERR )
+ LRESULT nErr = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0);
+ if (nErr == LB_ERR)
return;
- if ( nErr == 0 )
+ if (nErr == 0)
{
if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
{
@@ -1859,9 +1859,9 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *) CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), NULL);
} else
{
- EnableWindow( GetDlgItem( m_hwnd, IDC_PL_RULES_LIST ), FALSE );
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0 );
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("No list selected")));
+ EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), FALSE);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("No list selected")));
}
EnableEditorControls();
return;
@@ -1871,9 +1871,9 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *) if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
{
CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), (CPrivacyList* )nErr);
+ CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), (CPrivacyList*)nErr);
}
- else ShowAdvancedList((CPrivacyList* )nErr);
+ else ShowAdvancedList((CPrivacyList*)nErr);
m_proto->m_privacyListManager.Unlock();
@@ -1882,7 +1882,7 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *) void CJabberDlgPrivacyLists::lbLists_OnDblClick(CCtrlListBox *)
{
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_ACTIVATE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_ACTIVATE, 0), 0);
}
void CJabberDlgPrivacyLists::lbRules_OnSelChange(CCtrlListBox *)
@@ -1892,7 +1892,7 @@ void CJabberDlgPrivacyLists::lbRules_OnSelChange(CCtrlListBox *) void CJabberDlgPrivacyLists::lbRules_OnDblClick(CCtrlListBox *)
{
- PostMessage( m_hwnd, WM_COMMAND, MAKEWPARAM( IDC_EDIT_RULE, 0 ), 0 );
+ PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_EDIT_RULE, 0), 0);
}
void CJabberDlgPrivacyLists::btnEditRule_OnClick(CCtrlButton *)
@@ -1900,14 +1900,14 @@ void CJabberDlgPrivacyLists::btnEditRule_OnClick(CCtrlButton *) // FIXME: potential deadlock due to PLM lock while editing rule
m_proto->m_privacyListManager.Lock();
{
- CPrivacyListRule* pRule = GetSelectedRule( m_hwnd );
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
CPrivacyList* pList = GetSelectedList(m_hwnd);
- if ( pList && pRule ) {
+ if (pList && pRule) {
CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
int nResult = dlgPrivacyRule.DoModal();
- if ( nResult ) {
+ if (nResult) {
pList->SetModified();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
} } }
m_proto->m_privacyListManager.Unlock();
}
@@ -1918,15 +1918,15 @@ void CJabberDlgPrivacyLists::btnAddRule_OnClick(CCtrlButton *) m_proto->m_privacyListManager.Lock();
{
CPrivacyList* pList = GetSelectedList(m_hwnd);
- if ( pList ) {
- CPrivacyListRule* pRule = new CPrivacyListRule( m_proto, Jid, _T(""), FALSE );
+ if (pList) {
+ CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, _T(""), FALSE);
CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
int nResult = dlgPrivacyRule.DoModal();
- if ( nResult ) {
+ if (nResult) {
pList->AddRule(pRule);
pList->Reorder();
pList->SetModified();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
else delete pRule;
} }
@@ -1938,16 +1938,16 @@ void CJabberDlgPrivacyLists::btnRemoveRule_OnClick(CCtrlButton *) m_proto->m_privacyListManager.Lock();
{
CPrivacyList* pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule( m_hwnd );
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
- if ( pList && pRule ) {
- pList->RemoveRule( pRule );
- int nCurSel = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0 );
- int nItemCount = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0 );
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel != nItemCount - 1 ? nCurSel : nCurSel - 1, 0 );
+ if (pList && pRule) {
+ pList->RemoveRule(pRule);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel != nItemCount - 1 ? nCurSel : nCurSel - 1, 0);
pList->Reorder();
pList->SetModified();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
} }
m_proto->m_privacyListManager.Unlock();
@@ -1958,15 +1958,15 @@ void CJabberDlgPrivacyLists::btnUpRule_OnClick(CCtrlButton *) m_proto->m_privacyListManager.Lock();
{
CPrivacyList* pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule( m_hwnd );
- int nCurSel = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0 );
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- if ( pList && pRule && nCurSel ) {
- pRule->SetOrder( pRule->GetOrder() - 11 );
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel - 1, 0 );
+ if (pList && pRule && nCurSel) {
+ pRule->SetOrder(pRule->GetOrder() - 11);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel - 1, 0);
pList->Reorder();
pList->SetModified();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
} }
m_proto->m_privacyListManager.Unlock();
@@ -1977,16 +1977,16 @@ void CJabberDlgPrivacyLists::btnDownRule_OnClick(CCtrlButton *) m_proto->m_privacyListManager.Lock();
{
CPrivacyList* pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule( m_hwnd );
- int nCurSel = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0 );
- int nItemCount = SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0 );
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
- if ( pList && pRule && ( nCurSel != ( nItemCount - 1 ))) {
- pRule->SetOrder( pRule->GetOrder() + 11 );
- SendDlgItemMessage( m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel + 1, 0 );
+ if (pList && pRule && (nCurSel != (nItemCount - 1))) {
+ pRule->SetOrder(pRule->GetOrder() + 11);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel + 1, 0);
pList->Reorder();
pList->SetModified();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
} }
m_proto->m_privacyListManager.Unlock();
@@ -1997,27 +1997,27 @@ void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton *) // FIXME: line length is hard coded in dialog procedure
CJabberDlgPrivacyAddList dlgPrivacyAddList(m_proto, m_hwnd);
int nRetVal = dlgPrivacyAddList.DoModal();
- if ( nRetVal && _tcslen( dlgPrivacyAddList.szLine )) {
+ if (nRetVal && _tcslen(dlgPrivacyAddList.szLine)) {
m_proto->m_privacyListManager.Lock();
- CPrivacyList* pList = m_proto->m_privacyListManager.FindList( dlgPrivacyAddList.szLine );
- if ( !pList ) {
- m_proto->m_privacyListManager.AddList( dlgPrivacyAddList.szLine );
- pList = m_proto->m_privacyListManager.FindList( dlgPrivacyAddList.szLine );
- if ( pList ) {
- pList->SetModified( TRUE );
- pList->SetLoaded( TRUE );
+ CPrivacyList* pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
+ if ( !pList) {
+ m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine);
+ pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
+ if (pList) {
+ pList->SetModified(TRUE);
+ pList->SetLoaded(TRUE);
}
}
- if ( pList )
- pList->SetDeleted( FALSE );
- int nSelected = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)dlgPrivacyAddList.szLine );
- if ( nSelected == CB_ERR ) {
- nSelected = SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)dlgPrivacyAddList.szLine );
- SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList );
- SendDlgItemMessage( m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0 );
+ if (pList)
+ pList->SetDeleted(FALSE);
+ int nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)dlgPrivacyAddList.szLine);
+ if (nSelected == CB_ERR) {
+ nSelected = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)dlgPrivacyAddList.szLine);
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList);
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0);
}
m_proto->m_privacyListManager.Unlock();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
}
@@ -2026,12 +2026,12 @@ void CJabberDlgPrivacyLists::btnRemoveList_OnClick(CCtrlButton *) m_proto->m_privacyListManager.Lock();
{
CPrivacyList* pList = GetSelectedList(m_hwnd);
- if ( pList ) {
+ if (pList) {
TCHAR *szListName = pList->GetListName();
- if ( ( m_proto->m_privacyListManager.GetActiveListName() && !_tcscmp( szListName, m_proto->m_privacyListManager.GetActiveListName()))
- || ( m_proto->m_privacyListManager.GetDefaultListName() && !_tcscmp( szListName, m_proto->m_privacyListManager.GetDefaultListName()))) {
+ if ((m_proto->m_privacyListManager.GetActiveListName() && !_tcscmp(szListName, m_proto->m_privacyListManager.GetActiveListName()))
+ || (m_proto->m_privacyListManager.GetDefaultListName() && !_tcscmp(szListName, m_proto->m_privacyListManager.GetDefaultListName()))) {
m_proto->m_privacyListManager.Unlock();
- MessageBox( m_hwnd, TranslateTS(_T("Can't remove active or default list")), TranslateTS(_T("Sorry")), MB_OK | MB_ICONSTOP );
+ MessageBox(m_hwnd, TranslateTS(_T("Can't remove active or default list")), TranslateTS(_T("Sorry")), MB_OK | MB_ICONSTOP);
return;
}
pList->SetDeleted();
@@ -2039,12 +2039,12 @@ void CJabberDlgPrivacyLists::btnRemoveList_OnClick(CCtrlButton *) } }
m_proto->m_privacyListManager.Unlock();
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *)
{
- if ( !m_proto->m_bJabberOnline ) {
+ if ( !m_proto->m_bJabberOnline) {
SetStatusText(TranslateT("Unable to save list because you are currently offline."));
return;
}
@@ -2056,67 +2056,67 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *) CPrivacyListModifyUserParam *pUserData = NULL;
CPrivacyList* pList = m_proto->m_privacyListManager.GetFirstList();
- while ( pList ) {
- if ( pList->IsModified()) {
+ while (pList) {
+ if (pList->IsModified()) {
CPrivacyListRule* pRule = pList->GetFirstRule();
- if ( !pRule )
+ if ( !pRule)
pList->SetDeleted();
- if ( pList->IsDeleted()) {
+ if (pList->IsDeleted()) {
pList->RemoveAllRules();
pRule = NULL;
}
- pList->SetModified( FALSE );
+ pList->SetModified(FALSE);
- if ( !pUserData )
+ if ( !pUserData)
pUserData = new CPrivacyListModifyUserParam();
pUserData->m_dwCount++;
- XmlNodeIq iq( m_proto->m_iqManager.AddHandler( &CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, NULL, 0, -1, pUserData ));
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVACY_LISTS ));
- HXML listTag = query << XCHILD( _T("list")) << XATTR( _T("name"), pList->GetListName());
+ XmlNodeIq iq(m_proto->m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, NULL, 0, -1, pUserData));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVACY_LISTS));
+ HXML listTag = query << XCHILD(_T("list")) << XATTR(_T("name"), pList->GetListName());
- while ( pRule ) {
- HXML itemTag = listTag << XCHILD( _T("item"));
- switch ( pRule->GetType()) {
+ while (pRule) {
+ HXML itemTag = listTag << XCHILD(_T("item"));
+ switch (pRule->GetType()) {
case Jid:
- itemTag << XATTR( _T("type"), _T("jid"));
+ itemTag << XATTR(_T("type"), _T("jid"));
break;
case Group:
- itemTag << XATTR( _T("type"), _T("group"));
+ itemTag << XATTR(_T("type"), _T("group"));
break;
case Subscription:
- itemTag << XATTR( _T("type"), _T("subscription"));
+ itemTag << XATTR(_T("type"), _T("subscription"));
break;
}
- if ( pRule->GetType() != Else )
- itemTag << XATTR( _T("value"), pRule->GetValue());
- if ( pRule->GetAction())
- itemTag << XATTR( _T("action"), _T("allow"));
+ if (pRule->GetType() != Else)
+ itemTag << XATTR(_T("value"), pRule->GetValue());
+ if (pRule->GetAction())
+ itemTag << XATTR(_T("action"), _T("allow"));
else
- itemTag << XATTR( _T("action"), _T("deny"));
- itemTag << XATTRI( _T("order"), pRule->GetOrder());
+ itemTag << XATTR(_T("action"), _T("deny"));
+ itemTag << XATTRI(_T("order"), pRule->GetOrder());
DWORD dwPackets = pRule->GetPackets();
- if ( dwPackets != JABBER_PL_RULE_TYPE_ALL ) {
- if ( dwPackets & JABBER_PL_RULE_TYPE_IQ )
- itemTag << XCHILD( _T("iq"));
- if ( dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN )
- itemTag << XCHILD( _T("presence-in"));
- if ( dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT )
- itemTag << XCHILD( _T("presence-out"));
- if ( dwPackets & JABBER_PL_RULE_TYPE_MESSAGE )
- itemTag << XCHILD( _T("message"));
+ if (dwPackets != JABBER_PL_RULE_TYPE_ALL) {
+ if (dwPackets & JABBER_PL_RULE_TYPE_IQ)
+ itemTag << XCHILD(_T("iq"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_IN)
+ itemTag << XCHILD(_T("presence-in"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_PRESENCE_OUT)
+ itemTag << XCHILD(_T("presence-out"));
+ if (dwPackets & JABBER_PL_RULE_TYPE_MESSAGE)
+ itemTag << XCHILD(_T("message"));
}
pRule = pRule->GetNext();
}
- m_proto->m_ThreadInfo->send( iq );
+ m_proto->m_ThreadInfo->send(iq);
}
pList = pList->GetNext();
} }
m_proto->m_privacyListManager.Unlock();
- SetStatusText(TranslateT( JABBER_PL_BUSY_MSG ));
- PostMessage( m_hwnd, WM_JABBER_REFRESH, 0, 0 );
+ SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
void CJabberDlgPrivacyLists::OnCommand_Close(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/)
@@ -2146,10 +2146,10 @@ void CJabberDlgPrivacyLists::clcClist_OnClick(CCtrlClc::TEventInfo *evt) DWORD hitFlags;
int iImage;
- if(evt->info->iColumn==-1) return;
+ if (evt->info->iColumn==-1) return;
hItem = m_clcClist.HitTest(evt->info->pt.x, evt->info->pt.y, &hitFlags);
- if(hItem==NULL) return;
- if (!(hitFlags&CLCHT_ONITEMEXTRA)) return;
+ if (hItem==NULL) return;
+ if ( !(hitFlags&CLCHT_ONITEMEXTRA)) return;
iImage = m_clcClist.GetExtraImage(hItem, evt->info->iColumn);
if (iImage != EMPTY_EXTRA_ICON) {
@@ -2203,26 +2203,26 @@ int CJabberDlgPrivacyLists::Resizer(UTILRESIZECONTROL *urc) return CSuper::Resizer(urc);
}
-INT_PTR __cdecl CJabberProto::OnMenuHandlePrivacyLists( WPARAM, LPARAM )
+INT_PTR __cdecl CJabberProto::OnMenuHandlePrivacyLists(WPARAM, LPARAM)
{
UI_SAFE_OPEN(CJabberDlgPrivacyLists, m_pDlgPrivacyLists);
return 0;
}
-void CJabberProto::QueryPrivacyLists( ThreadData *pThreadInfo )
+void CJabberProto::QueryPrivacyLists(ThreadData *pThreadInfo)
{
- XmlNodeIq iq( m_iqManager.AddHandler( &CJabberProto::OnIqResultPrivacyLists ));
- iq << XQUERY( _T(JABBER_FEAT_PRIVACY_LISTS));
- if ( pThreadInfo )
- pThreadInfo->send( iq );
- else if ( m_ThreadInfo )
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyLists));
+ iq << XQUERY(_T(JABBER_FEAT_PRIVACY_LISTS));
+ if (pThreadInfo)
+ pThreadInfo->send(iq);
+ else if (m_ThreadInfo)
+ m_ThreadInfo->send(iq);
}
/////////////////////////////////////////////////////////////////////////////////////////
// builds privacy menu
-INT_PTR __cdecl CJabberProto::menuSetPrivacyList( WPARAM, LPARAM, LPARAM iList )
+INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList)
{
m_privacyListManager.Lock();
CPrivacyList *pList = NULL;
@@ -2234,14 +2234,14 @@ INT_PTR __cdecl CJabberProto::menuSetPrivacyList( WPARAM, LPARAM, LPARAM iList ) pList = pList->GetNext();
}
- XmlNodeIq iq( m_iqManager.AddHandler( &CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList ));
- HXML query = iq << XQUERY( _T(JABBER_FEAT_PRIVACY_LISTS));
- HXML active = query << XCHILD( _T("active"));
- if ( pList )
- active << XATTR( _T("name"), pList->GetListName());
+ XmlNodeIq iq(m_iqManager.AddHandler(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_PRIVACY_LISTS));
+ HXML active = query << XCHILD(_T("active"));
+ if (pList)
+ active << XATTR(_T("name"), pList->GetListName());
m_privacyListManager.Unlock();
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return 0;
}
@@ -2257,12 +2257,12 @@ void CJabberProto::BuildPrivacyMenu() mi.icolibItem = GetIconHandle(IDI_AGENTS);
mi.flags = CMIF_ROOTPOPUP | CMIF_CHILDPOPUP | CMIF_ICONFROMICOLIB | CMIF_HIDDEN;
mi.pszName = LPGEN("Privacy Lists");
- mi.hParentMenu = MO_GetProtoRootMenu( m_szModuleName );
+ mi.hParentMenu = MO_GetProtoRootMenu(m_szModuleName);
m_hPrivacyMenuRoot = Menu_AddProtoMenuItem(&mi);
- JCreateService( "/PrivacyLists", &CJabberProto::OnMenuHandlePrivacyLists );
+ JCreateService("/PrivacyLists", &CJabberProto::OnMenuHandlePrivacyLists);
char srvFce[MAX_PATH + 64];
- mir_snprintf( srvFce, SIZEOF(srvFce), "%s/PrivacyLists", m_szModuleName );
+ mir_snprintf(srvFce, SIZEOF(srvFce), "%s/PrivacyLists", m_szModuleName);
mi.pszService = srvFce;
mi.position = 3000040000;
mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR | CMIF_ICONFROMICOLIB;
@@ -2272,18 +2272,18 @@ void CJabberProto::BuildPrivacyMenu() Menu_AddProtoMenuItem(&mi);
}
-void CJabberProto::BuildPrivacyListsMenu( bool bDeleteOld )
+void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld)
{
int i;
- if ( bDeleteOld )
- for ( i=0; i < m_hPrivacyMenuItems.getCount(); i++ )
- CallService( MO_REMOVEMENUITEM, (WPARAM)m_hPrivacyMenuItems[i], 0 );
+ if (bDeleteOld)
+ for (i=0; i < m_hPrivacyMenuItems.getCount(); i++)
+ CallService(MO_REMOVEMENUITEM, (WPARAM)m_hPrivacyMenuItems[i], 0);
m_hPrivacyMenuItems.destroy();
m_privacyListManager.Lock();
i = 0;
- char srvFce[MAX_PATH + 64], *svcName = srvFce+strlen( m_szModuleName );
+ char srvFce[MAX_PATH + 64], *svcName = srvFce+strlen(m_szModuleName);
CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(mi);
@@ -2292,9 +2292,9 @@ void CJabberProto::BuildPrivacyListsMenu( bool bDeleteOld ) mi.hParentMenu = m_hPrivacyMenuRoot;
mi.pszService = srvFce;
- mir_snprintf( srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i );
- if ( i > m_privacyMenuServiceAllocated ) {
- JCreateServiceParam( svcName, &CJabberProto::menuSetPrivacyList, i );
+ mir_snprintf(srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i);
+ if (i > m_privacyMenuServiceAllocated) {
+ JCreateServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
m_privacyMenuServiceAllocated = i;
}
mi.position++;
@@ -2303,24 +2303,24 @@ void CJabberProto::BuildPrivacyListsMenu( bool bDeleteOld ) SKINICON_OTHER_SMALLDOT :
SKINICON_OTHER_EMPTYBLOB);
mi.ptszName = LPGENT("<none>");
- m_hPrivacyMenuItems.insert( Menu_AddProtoMenuItem(&mi));
+ m_hPrivacyMenuItems.insert(Menu_AddProtoMenuItem(&mi));
- for ( CPrivacyList *pList = m_privacyListManager.GetFirstList(); pList; pList = pList->GetNext()) {
+ for (CPrivacyList *pList = m_privacyListManager.GetFirstList(); pList; pList = pList->GetNext()) {
++i;
- mir_snprintf( srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i );
+ mir_snprintf(srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i);
- if ( i > m_privacyMenuServiceAllocated ) {
- JCreateServiceParam( svcName, &CJabberProto::menuSetPrivacyList, i );
+ if (i > m_privacyMenuServiceAllocated) {
+ JCreateServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
m_privacyMenuServiceAllocated = i;
}
mi.position++;
mi.icolibItem = LoadSkinnedIconHandle(
- lstrcmp( m_privacyListManager.GetActiveListName(), pList->GetListName()) ?
+ lstrcmp(m_privacyListManager.GetActiveListName(), pList->GetListName()) ?
SKINICON_OTHER_SMALLDOT :
SKINICON_OTHER_EMPTYBLOB);
mi.ptszName = pList->GetListName();
- m_hPrivacyMenuItems.insert( Menu_AddProtoMenuItem(&mi));
+ m_hPrivacyMenuItems.insert(Menu_AddProtoMenuItem(&mi));
}
m_privacyListManager.Unlock();
diff --git a/protocols/JabberG/src/jabber_privacy.h b/protocols/JabberG/src/jabber_privacy.h index 4a2cfd8f2f..398a3fbc9e 100644 --- a/protocols/JabberG/src/jabber_privacy.h +++ b/protocols/JabberG/src/jabber_privacy.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -43,8 +43,8 @@ struct CPrivacyListModifyUserParam BOOL m_bAllOk;
volatile LONG m_dwCount;
CPrivacyListModifyUserParam() :
- m_bAllOk( TRUE ),
- m_dwCount( 0 )
+ m_bAllOk(TRUE),
+ m_dwCount(0)
{
}
};
@@ -56,7 +56,7 @@ class CPrivacyListRule protected:
friend class CPrivacyList;
public:
- CPrivacyListRule( CJabberProto* ppro, PrivacyListRuleType type = Else, const TCHAR *szValue = _T(""), BOOL bAction = TRUE, DWORD dwOrder = 90, DWORD dwPackets = 0)
+ CPrivacyListRule(CJabberProto* ppro, PrivacyListRuleType type = Else, const TCHAR *szValue = _T(""), BOOL bAction = TRUE, DWORD dwOrder = 90, DWORD dwPackets = 0)
{
m_proto = ppro;
m_szValue = mir_tstrdup(szValue);
@@ -98,7 +98,7 @@ public: {
return m_nType;
}
- __inline BOOL SetType( PrivacyListRuleType type )
+ __inline BOOL SetType(PrivacyListRuleType type)
{
m_nType = type;
return TRUE;
@@ -107,16 +107,16 @@ public: {
return m_szValue;
}
- __inline BOOL SetValue( TCHAR *szValue )
+ __inline BOOL SetValue(TCHAR *szValue)
{
- replaceStrT( m_szValue, szValue );
+ replaceStrT(m_szValue, szValue);
return TRUE;
}
__inline DWORD GetPackets()
{
return m_dwPackets;
}
- __inline BOOL SetPackets( DWORD dwPackets )
+ __inline BOOL SetPackets(DWORD dwPackets)
{
m_dwPackets = dwPackets;
return TRUE;
@@ -125,7 +125,7 @@ public: {
return m_bAction;
}
- __inline BOOL SetAction( BOOL bAction )
+ __inline BOOL SetAction(BOOL bAction)
{
m_bAction = bAction;
return TRUE;
@@ -198,36 +198,36 @@ public: }
BOOL AddRule(PrivacyListRuleType type, const TCHAR *szValue, BOOL bAction, DWORD dwOrder, DWORD dwPackets)
{
- CPrivacyListRule *pRule = new CPrivacyListRule( m_proto, type, szValue, bAction, dwOrder, dwPackets );
- if ( !pRule )
+ CPrivacyListRule *pRule = new CPrivacyListRule(m_proto, type, szValue, bAction, dwOrder, dwPackets);
+ if ( !pRule)
return FALSE;
- pRule->SetNext( m_pRules );
+ pRule->SetNext(m_pRules);
m_pRules = pRule;
return TRUE;
}
BOOL AddRule(CPrivacyListRule *pRule)
{
- pRule->SetNext( m_pRules );
+ pRule->SetNext(m_pRules);
m_pRules = pRule;
return TRUE;
}
BOOL RemoveRule(CPrivacyListRule *pRuleToRemove)
{
- if ( !m_pRules )
+ if ( !m_pRules)
return FALSE;
- if ( m_pRules == pRuleToRemove ) {
+ if (m_pRules == pRuleToRemove) {
m_pRules = m_pRules->GetNext();
- pRuleToRemove->SetNext( NULL );
+ pRuleToRemove->SetNext(NULL);
delete pRuleToRemove;
return TRUE;
}
CPrivacyListRule *pRule = m_pRules;
- while ( pRule->GetNext()) {
- if ( pRule->GetNext() == pRuleToRemove ) {
- pRule->SetNext( pRule->GetNext()->GetNext());
- pRuleToRemove->SetNext( NULL );
+ while (pRule->GetNext()) {
+ if (pRule->GetNext() == pRuleToRemove) {
+ pRule->SetNext(pRule->GetNext()->GetNext());
+ pRuleToRemove->SetNext(NULL);
delete pRuleToRemove;
return TRUE;
}
@@ -238,28 +238,28 @@ public: BOOL Reorder()
{
// 0 or 1 rules?
- if ( !m_pRules )
+ if ( !m_pRules)
return TRUE;
if ( !m_pRules->GetNext()) {
- m_pRules->SetOrder( 100 );
+ m_pRules->SetOrder(100);
return TRUE;
}
// get rules count
DWORD dwCount = 0;
CPrivacyListRule *pRule = m_pRules;
- while ( pRule ) {
+ while (pRule) {
dwCount++;
pRule = pRule->GetNext();
}
// create pointer array for sort procedure
- CPrivacyListRule **pRules = ( CPrivacyListRule ** )mir_alloc( dwCount * sizeof( CPrivacyListRule * ));
- if ( !pRules )
+ CPrivacyListRule **pRules = (CPrivacyListRule **)mir_alloc(dwCount * sizeof(CPrivacyListRule *));
+ if ( !pRules)
return FALSE;
DWORD dwPos = 0;
pRule = m_pRules;
- while ( pRule ) {
+ while (pRule) {
pRules[dwPos++] = pRule;
pRule = pRule->GetNext();
}
@@ -267,9 +267,9 @@ public: // sort array of pointers, slow, but working :)
DWORD i, j;
CPrivacyListRule *pTmp;
- for ( i = 0; i < dwCount; i++ ) {
- for ( j = dwCount - 1; j > i; j-- ) {
- if ( pRules[j - 1]->GetOrder() > pRules[j]->GetOrder()) {
+ for (i = 0; i < dwCount; i++) {
+ for (j = dwCount - 1; j > i; j--) {
+ if (pRules[j - 1]->GetOrder() > pRules[j]->GetOrder()) {
pTmp = pRules[j - 1];
pRules[j - 1] = pRules[j];
pRules[j] = pTmp;
@@ -280,14 +280,14 @@ public: // reorder linked list
DWORD dwOrder = 100;
CPrivacyListRule **ppPtr = &m_pRules;
- for ( i = 0; i < dwCount; i++ ) {
+ for (i = 0; i < dwCount; i++) {
*ppPtr = pRules[ i ];
ppPtr = &pRules[ i ]->m_pNext;
- pRules[ i ]->SetOrder( dwOrder );
+ pRules[ i ]->SetOrder(dwOrder);
dwOrder += 10;
}
*ppPtr = NULL;
- mir_free( pRules );
+ mir_free(pRules);
return TRUE;
}
@@ -329,7 +329,7 @@ protected: public:
CJabberProto* m_proto;
- CPrivacyListManager( CJabberProto* ppro )
+ CPrivacyListManager(CJabberProto* ppro)
{
m_proto = ppro;
m_szActiveListName = NULL;
@@ -380,11 +380,11 @@ public: m_pLists = NULL;
return TRUE;
}
- CPrivacyList* FindList( const TCHAR *szListName )
+ CPrivacyList* FindList(const TCHAR *szListName)
{
CPrivacyList *pList = m_pLists;
- while ( pList ) {
- if ( !_tcscmp(pList->GetListName(), szListName ))
+ while (pList) {
+ if ( !_tcscmp(pList->GetListName(), szListName))
return pList;
pList = pList->GetNext();
}
@@ -394,12 +394,12 @@ public: {
return m_pLists;
}
- BOOL AddList( TCHAR *szListName )
+ BOOL AddList(TCHAR *szListName)
{
if (FindList(szListName))
return FALSE;
- CPrivacyList *pList = new CPrivacyList( m_proto, szListName );
- pList->SetNext( m_pLists );
+ CPrivacyList *pList = new CPrivacyList(m_proto, szListName);
+ pList->SetNext(m_pLists);
m_pLists = pList;
return TRUE;
}
@@ -410,11 +410,11 @@ public: }
BOOL IsModified()
{
- if ( m_bModified )
+ if (m_bModified)
return TRUE;
CPrivacyList *pList = m_pLists;
- while ( pList ) {
- if ( pList->IsModified())
+ while (pList) {
+ if (pList->IsModified())
return TRUE;
pList = pList->GetNext();
}
@@ -423,7 +423,7 @@ public: BOOL IsAllListsLoaded()
{
CPrivacyList *pList = m_pLists;
- while ( pList ) {
+ while (pList) {
if ( !pList->IsLoaded())
return FALSE;
pList = pList->GetNext();
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 6444482ee6..a1e0dcfca3 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -43,60 +43,60 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma warning(disable:4355)
-static int compareTransports( const TCHAR* p1, const TCHAR* p2 )
-{ return _tcsicmp( p1, p2 );
+static int compareTransports(const TCHAR *p1, const TCHAR *p2)
+{ return _tcsicmp(p1, p2);
}
-static int compareListItems( const JABBER_LIST_ITEM* p1, const JABBER_LIST_ITEM* p2 )
+static int compareListItems(const JABBER_LIST_ITEM *p1, const JABBER_LIST_ITEM *p2)
{
- if ( p1->list != p2->list )
+ if (p1->list != p2->list)
return p1->list - p2->list;
// for bookmarks, temporary contacts & groupchat members
// resource must be used in the comparison
- if (( p1->list == LIST_ROSTER && ( p1->bUseResource == TRUE || p2->bUseResource == TRUE ))
- || ( p1->list == LIST_BOOKMARK ) || ( p1->list == LIST_VCARD_TEMP ))
- return lstrcmpi( p1->jid, p2->jid );
-
- TCHAR szp1[ JABBER_MAX_JID_LEN ], szp2[ JABBER_MAX_JID_LEN ];
- JabberStripJid( p1->jid, szp1, SIZEOF( szp1 ));
- JabberStripJid( p2->jid, szp2, SIZEOF( szp2 ));
- return lstrcmpi( szp1, szp2 );
+ if ((p1->list == LIST_ROSTER && (p1->bUseResource == TRUE || p2->bUseResource == TRUE))
+ || (p1->list == LIST_BOOKMARK) || (p1->list == LIST_VCARD_TEMP))
+ return lstrcmpi(p1->jid, p2->jid);
+
+ TCHAR szp1[JABBER_MAX_JID_LEN], szp2[JABBER_MAX_JID_LEN];
+ JabberStripJid(p1->jid, szp1, SIZEOF(szp1));
+ JabberStripJid(p2->jid, szp2, SIZEOF(szp2));
+ return lstrcmpi(szp1, szp2);
}
-CJabberProto::CJabberProto( const char* aProtoName, const TCHAR* aUserName ) :
- m_options( this ),
- m_lstTransports( 50, compareTransports ),
- m_lstRoster( 50, compareListItems ),
- m_iqManager( this ),
- m_messageManager( this ),
- m_presenceManager( this ),
- m_sendManager( this ),
- m_adhocManager( this ),
- m_clientCapsManager( this ),
- m_privacyListManager( this ),
- m_privacyMenuServiceAllocated( -1 ),
- m_priorityMenuVal( 0 ),
- m_priorityMenuValSet( false ),
- m_hPrivacyMenuRoot( 0 ),
- m_hPrivacyMenuItems( 10 ),
- m_pLastResourceList( NULL ),
- m_lstJabberFeatCapPairsDynamic( 2 ),
- m_uEnabledFeatCapsDynamic( 0 )
+CJabberProto::CJabberProto(const char* aProtoName, const TCHAR *aUserName) :
+ m_options(this),
+ m_lstTransports(50, compareTransports),
+ m_lstRoster(50, compareListItems),
+ m_iqManager(this),
+ m_messageManager(this),
+ m_presenceManager(this),
+ m_sendManager(this),
+ m_adhocManager(this),
+ m_clientCapsManager(this),
+ m_privacyListManager(this),
+ m_privacyMenuServiceAllocated(-1),
+ m_priorityMenuVal(0),
+ m_priorityMenuValSet(false),
+ m_hPrivacyMenuRoot(0),
+ m_hPrivacyMenuItems(10),
+ m_pLastResourceList(NULL),
+ m_lstJabberFeatCapPairsDynamic(2),
+ m_uEnabledFeatCapsDynamic(0)
{
- InitializeCriticalSection( &m_csModeMsgMutex );
- InitializeCriticalSection( &m_csLists );
- InitializeCriticalSection( &m_csLastResourceMap );
+ InitializeCriticalSection(&m_csModeMsgMutex);
+ InitializeCriticalSection(&m_csLists);
+ InitializeCriticalSection(&m_csLastResourceMap);
m_szXmlStreamToBeInitialized = NULL;
m_iVersion = 2;
- m_tszUserName = mir_tstrdup( aUserName );
- m_szModuleName = mir_strdup( aProtoName );
- m_szProtoName = mir_strdup( aProtoName );
- _strlwr( m_szProtoName );
- m_szProtoName[0] = toupper( m_szProtoName[0] );
- Log( "Setting protocol/module name to '%s/%s'", m_szProtoName, m_szModuleName );
+ m_tszUserName = mir_tstrdup(aUserName);
+ m_szModuleName = mir_strdup(aProtoName);
+ m_szProtoName = mir_strdup(aProtoName);
+ _strlwr(m_szProtoName);
+ m_szProtoName[0] = toupper(m_szProtoName[0]);
+ Log("Setting protocol/module name to '%s/%s'", m_szProtoName, m_szModuleName);
// Initialize Jabber API
m_JabberApi.m_psProto = this;
@@ -107,54 +107,54 @@ CJabberProto::CJabberProto( const char* aProtoName, const TCHAR* aUserName ) : m_windowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
// Protocol services and events...
- m_hEventNudge = JCreateHookableEvent( JE_NUDGE );
- m_hEventXStatusIconChanged = JCreateHookableEvent( JE_CUSTOMSTATUS_EXTRAICON_CHANGED );
- m_hEventXStatusChanged = JCreateHookableEvent( JE_CUSTOMSTATUS_CHANGED );
+ m_hEventNudge = JCreateHookableEvent(JE_NUDGE);
+ m_hEventXStatusIconChanged = JCreateHookableEvent(JE_CUSTOMSTATUS_EXTRAICON_CHANGED);
+ m_hEventXStatusChanged = JCreateHookableEvent(JE_CUSTOMSTATUS_CHANGED);
- JCreateService( PS_CREATEACCMGRUI, &CJabberProto::SvcCreateAccMgrUI );
+ JCreateService(PS_CREATEACCMGRUI, &CJabberProto::SvcCreateAccMgrUI);
- JCreateService( PS_GETAVATARINFOT, &CJabberProto::JabberGetAvatarInfo );
- JCreateService( PS_GETMYAWAYMSG, &CJabberProto::GetMyAwayMsg );
- JCreateService( PS_SET_LISTENINGTO, &CJabberProto::OnSetListeningTo );
+ JCreateService(PS_GETAVATARINFOT, &CJabberProto::JabberGetAvatarInfo);
+ JCreateService(PS_GETMYAWAYMSG, &CJabberProto::GetMyAwayMsg);
+ JCreateService(PS_SET_LISTENINGTO, &CJabberProto::OnSetListeningTo);
- JCreateService( PS_JOINCHAT, &CJabberProto::OnJoinChat );
- JCreateService( PS_LEAVECHAT, &CJabberProto::OnLeaveChat );
+ JCreateService(PS_JOINCHAT, &CJabberProto::OnJoinChat);
+ JCreateService(PS_LEAVECHAT, &CJabberProto::OnLeaveChat);
- JCreateService( JS_GETCUSTOMSTATUSICON, &CJabberProto::OnGetXStatusIcon );
- JCreateService( JS_GETXSTATUS, &CJabberProto::OnGetXStatus );
- JCreateService( JS_SETXSTATUS, &CJabberProto::OnSetXStatus );
- JCreateService( JS_SETXSTATUSEX, &CJabberProto::OnSetXStatusEx );
+ JCreateService(JS_GETCUSTOMSTATUSICON, &CJabberProto::OnGetXStatusIcon);
+ JCreateService(JS_GETXSTATUS, &CJabberProto::OnGetXStatus);
+ JCreateService(JS_SETXSTATUS, &CJabberProto::OnSetXStatus);
+ JCreateService(JS_SETXSTATUSEX, &CJabberProto::OnSetXStatusEx);
// not needed anymore and therefore commented out
- // JCreateService( JS_GETXSTATUSEX, &CJabberProto::OnGetXStatusEx );
+ // JCreateService(JS_GETXSTATUSEX, &CJabberProto::OnGetXStatusEx);
- JCreateService( JS_HTTP_AUTH, &CJabberProto::OnHttpAuthRequest );
- JCreateService( JS_INCOMING_NOTE_EVENT, &CJabberProto::OnIncomingNoteEvent );
+ JCreateService(JS_HTTP_AUTH, &CJabberProto::OnHttpAuthRequest);
+ JCreateService(JS_INCOMING_NOTE_EVENT, &CJabberProto::OnIncomingNoteEvent);
- JCreateService( JS_SENDXML, &CJabberProto::ServiceSendXML );
- JCreateService( PS_GETMYAVATART, &CJabberProto::JabberGetAvatar );
- JCreateService( PS_GETAVATARCAPS, &CJabberProto::JabberGetAvatarCaps );
- JCreateService( PS_SETMYAVATART, &CJabberProto::JabberSetAvatar );
- JCreateService( PS_SETMYNICKNAME, &CJabberProto::JabberSetNickname );
+ JCreateService(JS_SENDXML, &CJabberProto::ServiceSendXML);
+ JCreateService(PS_GETMYAVATART, &CJabberProto::JabberGetAvatar);
+ JCreateService(PS_GETAVATARCAPS, &CJabberProto::JabberGetAvatarCaps);
+ JCreateService(PS_SETMYAVATART, &CJabberProto::JabberSetAvatar);
+ JCreateService(PS_SETMYNICKNAME, &CJabberProto::JabberSetNickname);
- JCreateService( JS_GETADVANCEDSTATUSICON, &CJabberProto::JGetAdvancedStatusIcon );
- JCreateService( JS_DB_GETEVENTTEXT_CHATSTATES, &CJabberProto::OnGetEventTextChatStates );
- JCreateService( JS_DB_GETEVENTTEXT_PRESENCE, &CJabberProto::OnGetEventTextPresence );
+ JCreateService(JS_GETADVANCEDSTATUSICON, &CJabberProto::JGetAdvancedStatusIcon);
+ JCreateService(JS_DB_GETEVENTTEXT_CHATSTATES, &CJabberProto::OnGetEventTextChatStates);
+ JCreateService(JS_DB_GETEVENTTEXT_PRESENCE, &CJabberProto::OnGetEventTextPresence);
- JCreateService( JS_GETJABBERAPI, &CJabberProto::JabberGetApi );
+ JCreateService(JS_GETJABBERAPI, &CJabberProto::JabberGetApi);
// XEP-0224 support (Attention/Nudge)
- JCreateService( JS_SEND_NUDGE, &CJabberProto::JabberSendNudge );
+ JCreateService(JS_SEND_NUDGE, &CJabberProto::JabberSendNudge);
// service to get from protocol chat buddy info
- JCreateService( MS_GC_PROTO_GETTOOLTIPTEXT, &CJabberProto::JabberGCGetToolTipText );
+ JCreateService(MS_GC_PROTO_GETTOOLTIPTEXT, &CJabberProto::JabberGCGetToolTipText);
// XMPP URI parser service for "File Association Manager" plugin
- JCreateService( JS_PARSE_XMPP_URI, &CJabberProto::JabberServiceParseXmppURI );
+ JCreateService(JS_PARSE_XMPP_URI, &CJabberProto::JabberServiceParseXmppURI);
- JHookEvent( ME_MODERNOPT_INITIALIZE, &CJabberProto::OnModernOptInit );
- JHookEvent( ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit );
- JHookEvent( ME_SKIN2_ICONSCHANGED, &CJabberProto::OnReloadIcons );
+ JHookEvent(ME_MODERNOPT_INITIALIZE, &CJabberProto::OnModernOptInit);
+ JHookEvent(ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit);
+ JHookEvent(ME_SKIN2_ICONSCHANGED, &CJabberProto::OnReloadIcons);
m_iqManager.FillPermanentHandlers();
m_iqManager.Start();
@@ -181,33 +181,33 @@ CJabberProto::CJabberProto( const char* aProtoName, const TCHAR* aUserName ) : *m_savedPassword = 0;
char text[ MAX_PATH ];
- mir_snprintf( text, sizeof( text ), "%s/Status", m_szModuleName );
- CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text );
- mir_snprintf( text, sizeof( text ), "%s/%s", m_szModuleName, DBSETTING_DISPLAY_UID );
- CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text );
-
- mir_snprintf( text, sizeof( text ), "%s/SubscriptionText", m_szModuleName );
- CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text );
- mir_snprintf( text, sizeof( text ), "%s/Subscription", m_szModuleName );
- CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text );
- mir_snprintf( text, sizeof( text ), "%s/Auth", m_szModuleName );
- CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text );
- mir_snprintf( text, sizeof( text ), "%s/Grant", m_szModuleName );
- CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text );
+ mir_snprintf(text, sizeof(text), "%s/Status", m_szModuleName);
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)text);
+ mir_snprintf(text, sizeof(text), "%s/%s", m_szModuleName, DBSETTING_DISPLAY_UID);
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)text);
+
+ mir_snprintf(text, sizeof(text), "%s/SubscriptionText", m_szModuleName);
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)text);
+ mir_snprintf(text, sizeof(text), "%s/Subscription", m_szModuleName);
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)text);
+ mir_snprintf(text, sizeof(text), "%s/Auth", m_szModuleName);
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)text);
+ mir_snprintf(text, sizeof(text), "%s/Grant", m_szModuleName);
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)text);
DBVARIANT dbv;
- if ( !JGetStringT( NULL, "XmlLang", &dbv )) {
- m_tszSelectedLang = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !JGetStringT(NULL, "XmlLang", &dbv)) {
+ m_tszSelectedLang = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
- else m_tszSelectedLang = mir_tstrdup( _T( "en" ));
+ else m_tszSelectedLang = mir_tstrdup(_T("en"));
- if (!DBGetContactSettingString(NULL, m_szModuleName, "Password", &dbv)) {
+ if ( !DBGetContactSettingString(NULL, m_szModuleName, "Password", &dbv)) {
CallService(MS_DB_CRYPT_DECODESTRING, lstrlenA(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
TCHAR *pssw = mir_a2t(dbv.pszVal);
JSetStringCrypt(NULL, "LoginPassword", pssw);
mir_free(pssw);
- JFreeVariant(&dbv);
+ db_free(&dbv);
JDeleteSetting(NULL, "Password");
}
@@ -225,48 +225,48 @@ CJabberProto::~CJabberProto() delete m_pInfoFrame;
- DestroyHookableEvent( m_hEventNudge );
- DestroyHookableEvent( m_hEventXStatusIconChanged );
- DestroyHookableEvent( m_hEventXStatusChanged );
- if ( m_hInitChat )
- DestroyHookableEvent( m_hInitChat );
+ DestroyHookableEvent(m_hEventNudge);
+ DestroyHookableEvent(m_hEventXStatusIconChanged);
+ DestroyHookableEvent(m_hEventXStatusChanged);
+ if (m_hInitChat)
+ DestroyHookableEvent(m_hInitChat);
CleanLastResourceMap();
ListWipe();
- DeleteCriticalSection( &m_csLists );
+ DeleteCriticalSection(&m_csLists);
- mir_free( m_tszSelectedLang );
- mir_free( m_phIconLibItems );
- mir_free( m_AuthMechs.m_gssapiHostName );
+ mir_free(m_tszSelectedLang);
+ mir_free(m_phIconLibItems);
+ mir_free(m_AuthMechs.m_gssapiHostName);
- DeleteCriticalSection( &m_filterInfo.csPatternLock );
- DeleteCriticalSection( &m_csModeMsgMutex );
- DeleteCriticalSection( &m_csLastResourceMap );
+ DeleteCriticalSection(&m_filterInfo.csPatternLock);
+ DeleteCriticalSection(&m_csModeMsgMutex);
+ DeleteCriticalSection(&m_csLastResourceMap);
- mir_free( m_modeMsgs.szOnline );
- mir_free( m_modeMsgs.szAway );
- mir_free( m_modeMsgs.szNa );
- mir_free( m_modeMsgs.szDnd );
- mir_free( m_modeMsgs.szFreechat );
+ mir_free(m_modeMsgs.szOnline);
+ mir_free(m_modeMsgs.szAway);
+ mir_free(m_modeMsgs.szNa);
+ mir_free(m_modeMsgs.szDnd);
+ mir_free(m_modeMsgs.szFreechat);
- mir_free( m_transportProtoTableStartIndex );
+ mir_free(m_transportProtoTableStartIndex);
- mir_free( m_szStreamId );
- mir_free( m_szProtoName );
- mir_free( m_szModuleName );
- mir_free( m_tszUserName );
+ mir_free(m_szStreamId);
+ mir_free(m_szProtoName);
+ mir_free(m_szModuleName);
+ mir_free(m_tszUserName);
int i;
- for ( i=0; i < m_lstTransports.getCount(); i++ )
- mir_free( m_lstTransports[i] );
+ for (i=0; i < m_lstTransports.getCount(); i++)
+ mir_free(m_lstTransports[i]);
m_lstTransports.destroy();
- for ( i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++ ) {
- mir_free( m_lstJabberFeatCapPairsDynamic[i]->szExt );
- mir_free( m_lstJabberFeatCapPairsDynamic[i]->szFeature );
- if ( m_lstJabberFeatCapPairsDynamic[i]->szDescription )
- mir_free( m_lstJabberFeatCapPairsDynamic[i]->szDescription );
+ for (i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ mir_free(m_lstJabberFeatCapPairsDynamic[i]->szExt);
+ mir_free(m_lstJabberFeatCapPairsDynamic[i]->szFeature);
+ if (m_lstJabberFeatCapPairsDynamic[i]->szDescription)
+ mir_free(m_lstJabberFeatCapPairsDynamic[i]->szDescription);
delete m_lstJabberFeatCapPairsDynamic[i];
}
m_lstJabberFeatCapPairsDynamic.destroy();
@@ -278,37 +278,37 @@ CJabberProto::~CJabberProto() static COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
-int CJabberProto::OnModulesLoadedEx( WPARAM, LPARAM )
+int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
{
- JHookEvent( ME_USERINFO_INITIALISE, &CJabberProto::OnUserInfoInit );
+ JHookEvent(ME_USERINFO_INITIALISE, &CJabberProto::OnUserInfoInit);
XStatusInit();
m_pepServices.InitGui();
m_pInfoFrame = new CJabberInfoFrame(this);
- if ( ServiceExists( MS_GC_REGISTER )) {
+ if (ServiceExists(MS_GC_REGISTER)) {
jabberChatDllPresent = true;
GCREGISTER gcr = {0};
- gcr.cbSize = sizeof( GCREGISTER );
+ gcr.cbSize = sizeof(GCREGISTER);
gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
gcr.iMaxText = 0;
gcr.nColors = 16;
gcr.pColors = &crCols[0];
gcr.ptszModuleDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
- CallServiceSync( MS_GC_REGISTER, NULL, ( LPARAM )&gcr );
+ CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
- JHookEvent( ME_GC_EVENT, &CJabberProto::JabberGcEventHook );
- JHookEvent( ME_GC_BUILDMENU, &CJabberProto::JabberGcMenuHook );
+ JHookEvent(ME_GC_EVENT, &CJabberProto::JabberGcEventHook);
+ JHookEvent(ME_GC_BUILDMENU, &CJabberProto::JabberGcMenuHook);
char szEvent[ 200 ];
- mir_snprintf( szEvent, sizeof szEvent, "%s\\ChatInit", m_szModuleName );
- m_hInitChat = CreateHookableEvent( szEvent );
- JHookEvent( szEvent, &CJabberProto::JabberGcInit );
+ mir_snprintf(szEvent, sizeof szEvent, "%s\\ChatInit", m_szModuleName);
+ m_hInitChat = CreateHookableEvent(szEvent);
+ JHookEvent(szEvent, &CJabberProto::JabberGcInit);
}
- if ( ServiceExists( MS_MSG_ADDICON )) {
+ if (ServiceExists(MS_MSG_ADDICON)) {
StatusIconData sid = {0};
sid.cbSize = sizeof(sid);
sid.szModule = m_szModuleName;
@@ -317,13 +317,13 @@ int CJabberProto::OnModulesLoadedEx( WPARAM, LPARAM ) sid.flags = MBF_HIDDEN;
sid.szTooltip = Translate("Jabber Resource");
CallService(MS_MSG_ADDICON, 0, (LPARAM) &sid);
- JHookEvent( ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick );
- JHookEvent( ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent );
+ JHookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
+ JHookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_szModuleName ))
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName))
MenuHideSrmmIcon(hContact);
hContact = db_find_next(hContact);
} }
@@ -333,33 +333,33 @@ int CJabberProto::OnModulesLoadedEx( WPARAM, LPARAM ) dbEventType.eventType = JABBER_DB_EVENT_TYPE_CHATSTATES;
dbEventType.module = m_szModuleName;
dbEventType.descr = "Chat state notifications";
- CallService( MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType );
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
dbEventType.eventType = JABBER_DB_EVENT_TYPE_PRESENCE;
dbEventType.module = m_szModuleName;
dbEventType.descr = "Presence notifications";
- CallService( MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType );
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
- JHookEvent( ME_IDLE_CHANGED, &CJabberProto::OnIdleChanged );
+ JHookEvent(ME_IDLE_CHANGED, &CJabberProto::OnIdleChanged);
CheckAllContactsAreTransported();
// Set all contacts to offline
HANDLE hContact = db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_szModuleName )) {
- SetContactOfflineStatus( hContact );
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
+ SetContactOfflineStatus(hContact);
- if ( JGetByte( hContact, "IsTransport", 0 )) {
+ if (JGetByte(hContact, "IsTransport", 0)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
TCHAR* domain = NEWTSTR_ALLOCA(dbv.ptszVal);
- TCHAR* resourcepos = _tcschr( domain, '/' );
- if ( resourcepos != NULL )
+ TCHAR* resourcepos = _tcschr(domain, '/');
+ if (resourcepos != NULL)
*resourcepos = '\0';
- m_lstTransports.insert( mir_tstrdup( domain ));
- JFreeVariant( &dbv );
+ m_lstTransports.insert(mir_tstrdup(domain));
+ db_free(&dbv);
} } }
hContact = db_find_next(hContact);
@@ -372,25 +372,25 @@ int CJabberProto::OnModulesLoadedEx( WPARAM, LPARAM ) ////////////////////////////////////////////////////////////////////////////////////////
// JabberAddToList - adds a contact to the contact list
-HANDLE CJabberProto::AddToListByJID( const TCHAR* newJid, DWORD flags )
+HANDLE CJabberProto::AddToListByJID(const TCHAR *newJid, DWORD flags)
{
HANDLE hContact;
TCHAR* jid, *nick;
- Log( "AddToListByJID jid = " TCHAR_STR_PARAM, newJid );
+ Log("AddToListByJID jid = " TCHAR_STR_PARAM, newJid);
- if (( hContact=HContactFromJID( newJid )) == NULL ) {
+ if ((hContact=HContactFromJID(newJid)) == NULL) {
// not already there: add
- jid = mir_tstrdup( newJid );
- Log( "Add new jid to contact jid = " TCHAR_STR_PARAM, jid );
- hContact = ( HANDLE ) CallService( MS_DB_CONTACT_ADD, 0, 0 );
- CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM ) hContact, ( LPARAM )m_szModuleName );
- JSetStringT( hContact, "jid", jid );
- if (( nick=JabberNickFromJID( newJid )) == NULL )
- nick = mir_tstrdup( newJid );
-// JSetStringT( hContact, "Nick", nick );
- mir_free( nick );
- mir_free( jid );
+ jid = mir_tstrdup(newJid);
+ Log("Add new jid to contact jid = " TCHAR_STR_PARAM, jid);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName);
+ JSetStringT(hContact, "jid", jid);
+ if ((nick=JabberNickFromJID(newJid)) == NULL)
+ nick = mir_tstrdup(newJid);
+// JSetStringT(hContact, "Nick", nick);
+ mir_free(nick);
+ mir_free(jid);
// Note that by removing or disable the "NotOnList" will trigger
// the plugin to add a particular contact to the roster list.
@@ -400,174 +400,167 @@ HANDLE CJabberProto::AddToListByJID( const TCHAR* newJid, DWORD flags ) // PS_ADDTOLIST is called but before the add dialog issue deletion of
// "NotOnList".
// If temporary add, "NotOnList" won't be deleted, and that's expected.
- DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 );
- if ( flags & PALF_TEMPORARY )
- DBWriteContactSettingByte( hContact, "CList", "Hidden", 1 );
+ db_set_b(hContact, "CList", "NotOnList", 1);
+ if (flags & PALF_TEMPORARY)
+ db_set_b(hContact, "CList", "Hidden", 1);
}
else {
// already exist
// Set up a dummy "NotOnList" when adding permanently only
- if ( !( flags & PALF_TEMPORARY ))
- DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 );
+ if ( !(flags & PALF_TEMPORARY))
+ db_set_b(hContact, "CList", "NotOnList", 1);
}
if (hContact && newJid)
- DBCheckIsTransportedContact( newJid, hContact );
+ DBCheckIsTransportedContact(newJid, hContact);
return hContact;
}
-HANDLE CJabberProto::AddToList( int flags, PROTOSEARCHRESULT* psr )
+HANDLE CJabberProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- if ( psr->cbSize != sizeof( JABBER_SEARCH_RESULT ) && psr->id == NULL )
+ if (psr->cbSize != sizeof(JABBER_SEARCH_RESULT) && psr->id == NULL)
return NULL;
- JABBER_SEARCH_RESULT* jsr = ( JABBER_SEARCH_RESULT* )psr;
+ JABBER_SEARCH_RESULT *jsr = (JABBER_SEARCH_RESULT*)psr;
TCHAR *jid = psr->id ? psr->id : jsr->jid;
- return AddToListByJID( jid, flags );
+ return AddToListByJID(jid, flags);
}
-HANDLE __cdecl CJabberProto::AddToListByEvent( int flags, int /*iContact*/, HANDLE hDbEvent )
+HANDLE __cdecl CJabberProto::AddToListByEvent(int flags, int /*iContact*/, HANDLE hDbEvent)
{
DBEVENTINFO dbei;
HANDLE hContact;
char* nick, *firstName, *lastName, *jid;
- Log( "AddToListByEvent" );
- ZeroMemory( &dbei, sizeof( dbei ));
- dbei.cbSize = sizeof( dbei );
- if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hDbEvent, 0 )) == ( DWORD )( -1 ))
+ Log("AddToListByEvent");
+ ZeroMemory(&dbei, sizeof(dbei));
+ dbei.cbSize = sizeof(dbei);
+ if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
return NULL;
- if (( dbei.pBlob=( PBYTE ) alloca( dbei.cbBlob )) == NULL )
+ if ((dbei.pBlob=(PBYTE)alloca(dbei.cbBlob)) == NULL)
return NULL;
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, ( LPARAM )&dbei ))
+ if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
return NULL;
- if ( strcmp( dbei.szModule, m_szModuleName ))
+ if (strcmp(dbei.szModule, m_szModuleName))
return NULL;
/*
- // EVENTTYPE_CONTACTS is when adding from when we receive contact list ( not used in Jabber )
- // EVENTTYPE_ADDED is when adding from when we receive "You are added" ( also not used in Jabber )
+ // EVENTTYPE_CONTACTS is when adding from when we receive contact list (not used in Jabber)
+ // EVENTTYPE_ADDED is when adding from when we receive "You are added" (also not used in Jabber)
// Jabber will only handle the case of EVENTTYPE_AUTHREQUEST
// EVENTTYPE_AUTHREQUEST is when adding from the authorization request dialog
*/
- if ( dbei.eventType != EVENTTYPE_AUTHREQUEST )
+ if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return NULL;
- nick = ( char* )( dbei.pBlob + sizeof( DWORD )*2);
- firstName = nick + strlen( nick ) + 1;
- lastName = firstName + strlen( firstName ) + 1;
- jid = lastName + strlen( lastName ) + 1;
+ nick = (char*)(dbei.pBlob + sizeof(DWORD)*2);
+ firstName = nick + strlen(nick) + 1;
+ lastName = firstName + strlen(firstName) + 1;
+ jid = lastName + strlen(lastName) + 1;
- TCHAR* newJid = dbei.flags & DBEF_UTF ? mir_utf8decodeT( jid ) : mir_a2t( jid );
- hContact = ( HANDLE ) AddToListByJID( newJid, flags );
- mir_free( newJid );
+ TCHAR *newJid = (dbei.flags & DBEF_UTF) ? mir_utf8decodeT(jid) : mir_a2t(jid);
+ hContact = (HANDLE)AddToListByJID(newJid, flags);
+ mir_free(newJid);
return hContact;
}
////////////////////////////////////////////////////////////////////////////////////////
// JabberAuthAllow - processes the successful authorization
-int CJabberProto::Authorize( HANDLE hDbEvent )
+int CJabberProto::Authorize(HANDLE hDbEvent)
{
- DBEVENTINFO dbei;
- char* nick, *firstName, *lastName, *jid;
-
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 1;
- memset( &dbei, 0, sizeof( dbei ));
- dbei.cbSize = sizeof( dbei );
- if (( dbei.cbBlob=CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hDbEvent, 0 )) == ( DWORD )( -1 ))
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
return 1;
- if (( dbei.pBlob=( PBYTE )alloca( dbei.cbBlob )) == NULL )
+ if ((dbei.pBlob = (PBYTE)alloca(dbei.cbBlob)) == NULL)
return 1;
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, ( LPARAM )&dbei ))
+ if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
return 1;
- if ( dbei.eventType != EVENTTYPE_AUTHREQUEST )
+ if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return 1;
- if ( strcmp( dbei.szModule, m_szModuleName ))
+ if (strcmp(dbei.szModule, m_szModuleName))
return 1;
- nick = ( char* )(dbei.pBlob + sizeof(DWORD)*2);
- firstName = nick + strlen( nick ) + 1;
- lastName = firstName + strlen( firstName ) + 1;
- jid = lastName + strlen( lastName ) + 1;
+ char *nick = (char*)(dbei.pBlob + sizeof(DWORD)*2);
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *jid = lastName + strlen(lastName) + 1;
- Log( "Send 'authorization allowed' to " TCHAR_STR_PARAM, jid );
+ Log("Send 'authorization allowed' to " TCHAR_STR_PARAM, jid);
- TCHAR* newJid = dbei.flags & DBEF_UTF ? mir_utf8decodeT( jid ) : mir_a2t( jid );
+ TCHAR *newJid = (dbei.flags & DBEF_UTF) ? mir_utf8decodeT(jid) : mir_a2t(jid);
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), newJid) << XATTR( _T("type"), _T("subscribed")));
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), newJid) << XATTR(_T("type"), _T("subscribed")));
// Automatically add this user to my roster if option is enabled
- if ( m_options.AutoAdd == TRUE ) {
+ if (m_options.AutoAdd == TRUE) {
HANDLE hContact;
JABBER_LIST_ITEM *item;
- if (( item = ListGetItemPtr( LIST_ROSTER, newJid )) == NULL || ( item->subscription != SUB_BOTH && item->subscription != SUB_TO )) {
- Log( "Try adding contact automatically jid = " TCHAR_STR_PARAM, jid );
- if (( hContact=AddToListByJID( newJid, 0 )) != NULL ) {
+ if ((item = ListGetItemPtr(LIST_ROSTER, newJid)) == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) {
+ Log("Try adding contact automatically jid = " TCHAR_STR_PARAM, jid);
+ if ((hContact = AddToListByJID(newJid, 0)) != NULL) {
// Trigger actual add by removing the "NotOnList" added by AddToListByJID()
// See AddToListByJID() and JabberDbSettingChanged().
- DBDeleteContactSetting( hContact, "CList", "NotOnList" );
+ DBDeleteContactSetting(hContact, "CList", "NotOnList");
} } }
- mir_free( newJid );
+ mir_free(newJid);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// JabberAuthDeny - handles the unsuccessful authorization
-int CJabberProto::AuthDeny( HANDLE hDbEvent, const TCHAR* /*szReason*/ )
+int CJabberProto::AuthDeny(HANDLE hDbEvent, const TCHAR */*szReason*/)
{
- DBEVENTINFO dbei;
- char* nick, *firstName, *lastName, *jid;
-
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 1;
- Log( "Entering AuthDeny" );
- memset( &dbei, 0, sizeof( dbei ));
- dbei.cbSize = sizeof( dbei );
- if (( dbei.cbBlob=CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hDbEvent, 0 )) == ( DWORD )( -1 ))
+ Log("Entering AuthDeny");
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ if ((dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)(-1))
return 1;
- if (( dbei.pBlob=( PBYTE ) mir_alloc( dbei.cbBlob )) == NULL )
+ if ((dbei.pBlob=(PBYTE) mir_alloc(dbei.cbBlob)) == NULL)
return 1;
- if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, ( LPARAM )&dbei )) {
- mir_free( dbei.pBlob );
+ if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei)) {
+ mir_free(dbei.pBlob);
return 1;
}
- if ( dbei.eventType != EVENTTYPE_AUTHREQUEST ) {
- mir_free( dbei.pBlob );
+ if (dbei.eventType != EVENTTYPE_AUTHREQUEST) {
+ mir_free(dbei.pBlob);
return 1;
}
- if ( strcmp( dbei.szModule, m_szModuleName )) {
- mir_free( dbei.pBlob );
+ if (strcmp(dbei.szModule, m_szModuleName)) {
+ mir_free(dbei.pBlob);
return 1;
}
- nick = ( char* )( dbei.pBlob + sizeof(DWORD)*2);
- firstName = nick + strlen( nick ) + 1;
- lastName = firstName + strlen( firstName ) + 1;
- jid = lastName + strlen( lastName ) + 1;
+ char *nick = (char*)(dbei.pBlob + sizeof(DWORD)*2);
+ char *firstName = nick + strlen(nick) + 1;
+ char *lastName = firstName + strlen(firstName) + 1;
+ char *jid = lastName + strlen(lastName) + 1;
- Log( "Send 'authorization denied' to %s" , jid );
+ Log("Send 'authorization denied' to %s", jid);
- TCHAR* newJid = dbei.flags & DBEF_UTF ? mir_utf8decodeT( jid ) : mir_a2t( jid );
+ TCHAR *newJid = dbei.flags & DBEF_UTF ? mir_utf8decodeT(jid) : mir_a2t(jid);
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), newJid) << XATTR( _T("type"), _T("unsubscribed")));
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), newJid) << XATTR(_T("type"), _T("unsubscribed")));
- mir_free( newJid );
- mir_free( dbei.pBlob );
+ mir_free(newJid);
+ mir_free(dbei.pBlob);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// PSR_AUTH
-int __cdecl CJabberProto::AuthRecv( HANDLE, PROTORECVEVENT* )
+int __cdecl CJabberProto::AuthRecv(HANDLE, PROTORECVEVENT*)
{
return 1;
}
@@ -575,7 +568,7 @@ int __cdecl CJabberProto::AuthRecv( HANDLE, PROTORECVEVENT* ) ////////////////////////////////////////////////////////////////////////////////////////
// PSS_AUTHREQUEST
-int __cdecl CJabberProto::AuthRequest( HANDLE, const TCHAR* )
+int __cdecl CJabberProto::AuthRequest(HANDLE, const TCHAR*)
{
return 1;
}
@@ -583,7 +576,7 @@ int __cdecl CJabberProto::AuthRequest( HANDLE, const TCHAR* ) ////////////////////////////////////////////////////////////////////////////////////////
// ChangeInfo
-HANDLE __cdecl CJabberProto::ChangeInfo( int /*iInfoType*/, void* )
+HANDLE __cdecl CJabberProto::ChangeInfo(int /*iInfoType*/, void*)
{
return NULL;
}
@@ -591,26 +584,26 @@ HANDLE __cdecl CJabberProto::ChangeInfo( int /*iInfoType*/, void* ) ////////////////////////////////////////////////////////////////////////////////////////
// JabberFileAllow - starts a file transfer
-HANDLE __cdecl CJabberProto::FileAllow( HANDLE /*hContact*/, HANDLE hTransfer, const TCHAR* szPath )
+HANDLE __cdecl CJabberProto::FileAllow(HANDLE /*hContact*/, HANDLE hTransfer, const TCHAR *szPath)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 0;
- filetransfer* ft = ( filetransfer* )hTransfer;
- ft->std.tszWorkingDir = mir_tstrdup( szPath );
- size_t len = _tcslen( ft->std.tszWorkingDir )-1;
- if ( ft->std.tszWorkingDir[len] == '/' || ft->std.tszWorkingDir[len] == '\\' )
+ filetransfer *ft = (filetransfer*)hTransfer;
+ ft->std.tszWorkingDir = mir_tstrdup(szPath);
+ size_t len = _tcslen(ft->std.tszWorkingDir)-1;
+ if (ft->std.tszWorkingDir[len] == '/' || ft->std.tszWorkingDir[len] == '\\')
ft->std.tszWorkingDir[len] = 0;
- switch ( ft->type ) {
+ switch (ft->type) {
case FT_OOB:
- JForkThread(( JThreadFunc )&CJabberProto::FileReceiveThread, ft );
+ JForkThread((JThreadFunc)&CJabberProto::FileReceiveThread, ft);
break;
case FT_BYTESTREAM:
- FtAcceptSiRequest( ft );
+ FtAcceptSiRequest(ft);
break;
case FT_IBB:
- FtAcceptIbbRequest( ft );
+ FtAcceptIbbRequest(ft);
break;
}
return hTransfer;
@@ -619,53 +612,53 @@ HANDLE __cdecl CJabberProto::FileAllow( HANDLE /*hContact*/, HANDLE hTransfer, c ////////////////////////////////////////////////////////////////////////////////////////
// JabberFileCancel - cancels a file transfer
-int __cdecl CJabberProto::FileCancel( HANDLE /*hContact*/, HANDLE hTransfer )
+int __cdecl CJabberProto::FileCancel(HANDLE /*hContact*/, HANDLE hTransfer)
{
- filetransfer* ft = ( filetransfer* )hTransfer;
+ filetransfer *ft = (filetransfer*)hTransfer;
HANDLE hEvent;
- Log( "Invoking FileCancel()" );
- if ( ft->type == FT_OOB ) {
- if ( ft->s ) {
- Log( "FT canceled" );
- Log( "Closing ft->s = %d", ft->s );
+ Log("Invoking FileCancel()");
+ if (ft->type == FT_OOB) {
+ if (ft->s) {
+ Log("FT canceled");
+ Log("Closing ft->s = %d", ft->s);
ft->state = FT_ERROR;
- Netlib_CloseHandle( ft->s );
+ Netlib_CloseHandle(ft->s);
ft->s = NULL;
- if ( ft->hFileEvent != NULL ) {
+ if (ft->hFileEvent != NULL) {
hEvent = ft->hFileEvent;
ft->hFileEvent = NULL;
- SetEvent( hEvent );
+ SetEvent(hEvent);
}
- Log( "ft->s is now NULL, ft->state is now FT_ERROR" );
+ Log("ft->s is now NULL, ft->state is now FT_ERROR");
}
}
- else FtCancel( ft );
+ else FtCancel(ft);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// JabberFileDeny - denies a file transfer
-int __cdecl CJabberProto::FileDeny( HANDLE /*hContact*/, HANDLE hTransfer, const TCHAR* /*reason*/ )
+int __cdecl CJabberProto::FileDeny(HANDLE /*hContact*/, HANDLE hTransfer, const TCHAR */*reason*/)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 1;
- filetransfer* ft = ( filetransfer* )hTransfer;
+ filetransfer *ft = (filetransfer*)hTransfer;
- switch ( ft->type ) {
+ switch (ft->type) {
case FT_OOB:
- m_ThreadInfo->send( XmlNodeIq( _T("error"), ft->iqId, ft->jid ) << XCHILD( _T("error"), _T("File transfer refused")) << XATTRI( _T("code"), 406 ));
+ m_ThreadInfo->send(XmlNodeIq(_T("error"), ft->iqId, ft->jid) << XCHILD(_T("error"), _T("File transfer refused")) << XATTRI(_T("code"), 406));
break;
case FT_BYTESTREAM:
case FT_IBB:
m_ThreadInfo->send(
- XmlNodeIq( _T("error"), ft->iqId, ft->jid )
- << XCHILD( _T("error"), _T("File transfer refused")) << XATTRI( _T("code"), 403 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("forbidden"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"))
- << XCHILD( _T("text"), _T("File transfer refused")) << XATTR( _T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ XmlNodeIq(_T("error"), ft->iqId, ft->jid)
+ << XCHILD(_T("error"), _T("File transfer refused")) << XATTRI(_T("code"), 403) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("forbidden"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"))
+ << XCHILD(_T("text"), _T("File transfer refused")) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
break;
}
delete ft;
@@ -675,25 +668,25 @@ int __cdecl CJabberProto::FileDeny( HANDLE /*hContact*/, HANDLE hTransfer, const ////////////////////////////////////////////////////////////////////////////////////////
// JabberFileResume - processes file renaming etc
-int __cdecl CJabberProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename )
+int __cdecl CJabberProto::FileResume(HANDLE hTransfer, int *action, const TCHAR **szFilename)
{
- filetransfer* ft = ( filetransfer* )hTransfer;
- if ( !m_bJabberOnline || ft == NULL )
+ filetransfer *ft = (filetransfer*)hTransfer;
+ if ( !m_bJabberOnline || ft == NULL)
return 1;
- if ( *action == FILERESUME_RENAME )
- replaceStrT( ft->std.tszCurrentFile, *szFilename );
+ if (*action == FILERESUME_RENAME)
+ replaceStrT(ft->std.tszCurrentFile, *szFilename);
- SetEvent( ft->hWaitEvent );
+ SetEvent(ft->hWaitEvent);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////
// GetCaps - return protocol capabilities bits
-DWORD_PTR __cdecl CJabberProto::GetCaps( int type, HANDLE hContact )
+DWORD_PTR __cdecl CJabberProto::GetCaps(int type, HANDLE hContact)
{
- switch( type ) {
+ switch(type) {
case PFLAGNUM_1:
return PF1_IM | PF1_AUTHREQ | PF1_CHAT | PF1_SERVERCLIST | PF1_MODEMSG | PF1_BASICSEARCH | PF1_EXTSEARCH | PF1_FILE | PF1_CONTACT;
case PFLAGNUM_2:
@@ -703,19 +696,19 @@ DWORD_PTR __cdecl CJabberProto::GetCaps( int type, HANDLE hContact ) case PFLAGNUM_4:
return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_IMSENDUTF | PF4_FORCEADDED;
case PFLAG_UNIQUEIDTEXT:
- return ( DWORD_PTR ) JTranslate( "JID" );
+ return (DWORD_PTR) JTranslate("JID");
case PFLAG_UNIQUEIDSETTING:
- return ( DWORD_PTR ) "jid";
+ return (DWORD_PTR) "jid";
case PFLAG_MAXCONTACTSPERPACKET:
{
DBVARIANT dbv;
- if(JGetStringT( hContact, "jid", &dbv ))
+ if (JGetStringT(hContact, "jid", &dbv))
return 0;
TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID( dbv.ptszVal, szClientJid, SIZEOF( szClientJid ));
- JFreeVariant( &dbv );
- JabberCapsBits jcb = GetResourceCapabilites( szClientJid, TRUE );
- return (( ~jcb & JABBER_CAPS_ROSTER_EXCHANGE ) ? 0 : 50);
+ GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
+ db_free(&dbv);
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ return ((~jcb & JABBER_CAPS_ROSTER_EXCHANGE) ? 0 : 50);
}
}
return 0;
@@ -724,10 +717,9 @@ DWORD_PTR __cdecl CJabberProto::GetCaps( int type, HANDLE hContact ) ////////////////////////////////////////////////////////////////////////////////////////
// GetIcon - loads an icon for the contact list
-HICON __cdecl CJabberProto::GetIcon( int iconIndex )
+HICON __cdecl CJabberProto::GetIcon(int iconIndex)
{
- if (LOWORD(iconIndex) == PLI_PROTOCOL)
- {
+ if (LOWORD(iconIndex) == PLI_PROTOCOL) {
if (iconIndex & PLIF_ICOLIBHANDLE)
return (HICON)GetIconHandle(IDI_JABBER);
@@ -747,93 +739,94 @@ HICON __cdecl CJabberProto::GetIcon( int iconIndex ) ////////////////////////////////////////////////////////////////////////////////////////
// GetInfo - retrieves a contact info
-int __cdecl CJabberProto::GetInfo( HANDLE hContact, int /*infoType*/ )
+int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 1;
int result = 1;
DBVARIANT dbv;
- if ( JGetByte( hContact, "ChatRoom" , 0))
+ if (JGetByte(hContact, "ChatRoom", 0))
return 1;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- if ( m_ThreadInfo ) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ if (m_ThreadInfo) {
TCHAR jid[ JABBER_MAX_JID_LEN ];
- GetClientJID( dbv.ptszVal, jid, SIZEOF( jid ));
+ GetClientJID(dbv.ptszVal, jid, SIZEOF(jid));
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT ))
- << XCHILDNS( _T("time"), _T(JABBER_FEAT_ENTITY_TIME)));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT))
+ << XCHILDNS(_T("time"), _T(JABBER_FEAT_ENTITY_TIME)));
// XEP-0012, last logoff time
- XmlNodeIq iq2( m_iqManager.AddHandler( &CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, dbv.ptszVal, JABBER_IQ_PARSE_FROM ));
- iq2 << XQUERY( _T(JABBER_FEAT_LAST_ACTIVITY));
- m_ThreadInfo->send( iq2 );
+ XmlNodeIq iq2(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, dbv.ptszVal, JABBER_IQ_PARSE_FROM));
+ iq2 << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY));
+ m_ThreadInfo->send(iq2);
JABBER_LIST_ITEM *item = NULL;
- if (( item = ListGetItemPtr( LIST_VCARD_TEMP, dbv.ptszVal )) == NULL)
- item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal );
+ if ((item = ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)) == NULL)
+ item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- if ( !item ) {
+ if ( !item) {
TCHAR szBareJid[ JABBER_MAX_JID_LEN ];
- _tcsncpy( szBareJid, dbv.ptszVal, SIZEOF( szBareJid ));
- TCHAR* pDelimiter = _tcschr( szBareJid, _T('/'));
- if ( pDelimiter ) {
+ _tcsncpy(szBareJid, dbv.ptszVal, SIZEOF(szBareJid));
+ TCHAR* pDelimiter = _tcschr(szBareJid, _T('/'));
+ if (pDelimiter) {
*pDelimiter = 0;
pDelimiter++;
- if ( !*pDelimiter )
+ if ( !*pDelimiter)
pDelimiter = NULL;
}
JABBER_LIST_ITEM *tmpItem = NULL;
- if ( pDelimiter && ( tmpItem = ListGetItemPtr( LIST_CHATROOM, szBareJid ))) {
+ if (pDelimiter && (tmpItem = ListGetItemPtr(LIST_CHATROOM, szBareJid))) {
JABBER_RESOURCE_STATUS *him = NULL;
- for ( int i=0; i < tmpItem->resourceCount; i++ ) {
- JABBER_RESOURCE_STATUS& p = tmpItem->resource[i];
- if ( !lstrcmp( p.resourceName, pDelimiter )) him = &p;
+ for (int i=0; i < tmpItem->resourceCount; i++) {
+ JABBER_RESOURCE_STATUS &p = tmpItem->resource[i];
+ if ( !lstrcmp(p.resourceName, pDelimiter))
+ him = &p;
}
- if ( him ) {
- item = ListAdd( LIST_VCARD_TEMP, dbv.ptszVal );
- ListAddResource( LIST_VCARD_TEMP, dbv.ptszVal, him->status, him->statusMessage, him->priority );
+ if (him) {
+ item = ListAdd(LIST_VCARD_TEMP, dbv.ptszVal);
+ ListAddResource(LIST_VCARD_TEMP, dbv.ptszVal, him->status, him->statusMessage, him->priority);
}
}
else
- item = ListAdd( LIST_VCARD_TEMP, dbv.ptszVal );
+ item = ListAdd(LIST_VCARD_TEMP, dbv.ptszVal);
}
- if ( item ) {
- if ( item->resource ) {
- for ( int i = 0; i < item->resourceCount; i++ ) {
+ if (item) {
+ if (item->resource) {
+ for (int i = 0; i < item->resourceCount; i++) {
TCHAR szp1[ JABBER_MAX_JID_LEN ];
- JabberStripJid( dbv.ptszVal, szp1, SIZEOF( szp1 ));
- mir_sntprintf( jid, 256, _T("%s/%s"), szp1, item->resource[i].resourceName );
+ JabberStripJid(dbv.ptszVal, szp1, SIZEOF(szp1));
+ mir_sntprintf(jid, 256, _T("%s/%s"), szp1, item->resource[i].resourceName);
- XmlNodeIq iq3( m_iqManager.AddHandler( &CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM ));
- iq3 << XQUERY( _T(JABBER_FEAT_LAST_ACTIVITY));
- m_ThreadInfo->send( iq3 );
+ XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM));
+ iq3 << XQUERY(_T(JABBER_FEAT_LAST_ACTIVITY));
+ m_ThreadInfo->send(iq3);
- if ( !item->resource[i].dwVersionRequestTime ) {
- XmlNodeIq iq4( m_iqManager.AddHandler( &CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE ));
- iq4 << XQUERY( _T(JABBER_FEAT_VERSION));
- m_ThreadInfo->send( iq4 );
+ if ( !item->resource[i].dwVersionRequestTime) {
+ XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ iq4 << XQUERY(_T(JABBER_FEAT_VERSION));
+ m_ThreadInfo->send(iq4);
}
- if ( !item->resource[i].pSoftwareInfo ) {
- XmlNodeIq iq5( m_iqManager.AddHandler( &CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT ));
- iq5 << XQUERY( _T(JABBER_FEAT_DISCO_INFO ));
- m_ThreadInfo->send( iq5 );
+ if ( !item->resource[i].pSoftwareInfo) {
+ XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
+ iq5 << XQUERY(_T(JABBER_FEAT_DISCO_INFO));
+ m_ThreadInfo->send(iq5);
}
}
}
- else if ( !item->itemResource.dwVersionRequestTime ) {
- XmlNodeIq iq4( m_iqManager.AddHandler( &CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE ));
- iq4 << XQUERY( _T(JABBER_FEAT_VERSION));
- m_ThreadInfo->send( iq4 );
+ else if ( !item->itemResource.dwVersionRequestTime) {
+ XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ iq4 << XQUERY(_T(JABBER_FEAT_VERSION));
+ m_ThreadInfo->send(iq4);
} } }
- SendGetVcard( dbv.ptszVal );
- JFreeVariant( &dbv );
+ SendGetVcard(dbv.ptszVal);
+ db_free(&dbv);
result = 0;
}
@@ -844,143 +837,141 @@ int __cdecl CJabberProto::GetInfo( HANDLE hContact, int /*infoType*/ ) // SearchBasic - searches the contact by JID
struct JABBER_SEARCH_BASIC
-{ int hSearch;
+{
+ int hSearch;
TCHAR jid[128];
};
-void __cdecl CJabberProto::BasicSearchThread( JABBER_SEARCH_BASIC *jsb )
+void __cdecl CJabberProto::BasicSearchThread(JABBER_SEARCH_BASIC *jsb)
{
- Sleep( 100 );
+ Sleep(100);
JABBER_SEARCH_RESULT jsr = { 0 };
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
jsr.hdr.nick = jsb->jid;
jsr.hdr.firstName = _T("");
jsr.hdr.lastName = _T("");
jsr.hdr.id = jsb->jid;
- _tcsncpy( jsr.jid, jsb->jid, SIZEOF( jsr.jid ));
+ _tcsncpy(jsr.jid, jsb->jid, SIZEOF(jsr.jid));
- jsr.jid[SIZEOF( jsr.jid )-1] = '\0';
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, ( HANDLE ) jsb->hSearch, ( LPARAM )&jsr );
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) jsb->hSearch, 0 );
- mir_free( jsb );
+ jsr.jid[SIZEOF(jsr.jid)-1] = '\0';
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)jsb->hSearch, (LPARAM)&jsr);
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)jsb->hSearch, 0);
+ mir_free(jsb);
}
-HANDLE __cdecl CJabberProto::SearchBasic( const TCHAR* szJid )
+HANDLE __cdecl CJabberProto::SearchBasic(const TCHAR *szJid)
{
- Log( "JabberBasicSearch called with lParam = '%s'", szJid );
+ Log("JabberBasicSearch called with lParam = '%s'", szJid);
JABBER_SEARCH_BASIC *jsb;
- if ( !m_bJabberOnline || ( jsb=( JABBER_SEARCH_BASIC * ) mir_alloc( sizeof( JABBER_SEARCH_BASIC )))==NULL )
+ if ( !m_bJabberOnline || (jsb=(JABBER_SEARCH_BASIC*)mir_alloc(sizeof(JABBER_SEARCH_BASIC))) == NULL)
return 0;
- if ( _tcschr( szJid, '@' ) == NULL ) {
- TCHAR *szServer = mir_a2t( m_ThreadInfo->server );
- const TCHAR* p = _tcsstr( szJid, szServer );
- if ( !p )
- {
+ if (_tcschr(szJid, '@') == NULL) {
+ TCHAR *szServer = mir_a2t(m_ThreadInfo->server);
+ const TCHAR *p = _tcsstr(szJid, szServer);
+ if (p == NULL) {
bool numericjid = true;
- for (const TCHAR * i = szJid; *i && numericjid; ++i)
+ for (const TCHAR *i = szJid; *i && numericjid; ++i)
numericjid = (*i >= '0') && (*i <= '9');
- mir_free( szServer );
- szServer = JGetStringT( NULL, "LoginServer" );
- if ( !szServer )
- {
- szServer = mir_tstrdup( _T( "jabber.org" ));
- } else if (numericjid && !_tcsicmp(szServer, _T("S.ms")))
- {
+ mir_free(szServer);
+ szServer = JGetStringT(NULL, "LoginServer");
+ if (szServer == NULL)
+ szServer = mir_tstrdup(_T("jabber.org"));
+ else if (numericjid && !_tcsicmp(szServer, _T("S.ms"))) {
mir_free(szServer);
szServer = mir_tstrdup(_T("sms"));
}
- mir_sntprintf( jsb->jid, SIZEOF(jsb->jid), _T("%s@%s"), szJid, szServer );
+ mir_sntprintf(jsb->jid, SIZEOF(jsb->jid), _T("%s@%s"), szJid, szServer);
}
- else _tcsncpy( jsb->jid, szJid, SIZEOF(jsb->jid));
- mir_free( szServer );
+ else _tcsncpy(jsb->jid, szJid, SIZEOF(jsb->jid));
+ mir_free(szServer);
}
- else _tcsncpy( jsb->jid, szJid, SIZEOF(jsb->jid));
+ else _tcsncpy(jsb->jid, szJid, SIZEOF(jsb->jid));
- Log( "Adding '%s' without validation", jsb->jid );
+ Log("Adding '%s' without validation", jsb->jid);
jsb->hSearch = SerialNext();
- JForkThread(( JThreadFunc )&CJabberProto::BasicSearchThread, jsb );
- return ( HANDLE )jsb->hSearch;
+ JForkThread((JThreadFunc)&CJabberProto::BasicSearchThread, jsb);
+ return (HANDLE)jsb->hSearch;
}
////////////////////////////////////////////////////////////////////////////////////////
// SearchByEmail - searches the contact by its e-mail
-HANDLE __cdecl CJabberProto::SearchByEmail( const TCHAR* email )
+HANDLE __cdecl CJabberProto::SearchByEmail(const TCHAR *email)
{
- if ( !m_bJabberOnline ) return 0;
- if ( email == NULL ) return 0;
+ if ( !m_bJabberOnline || email == NULL)
+ return 0;
char szServerName[100];
- if ( JGetStaticString( "Jud", NULL, szServerName, sizeof szServerName ))
- strcpy( szServerName, "users.jabber.org" );
+ if (JGetStaticString("Jud", NULL, szServerName, sizeof(szServerName)))
+ strcpy(szServerName, "users.jabber.org");
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultSetSearch );
- m_ThreadInfo->send( XmlNodeIq( _T("set"), iqId, _A2T(szServerName)) << XQUERY( _T("jabber:iq:search"))
- << XCHILD( _T("email"), email));
- return ( HANDLE )iqId;
+ IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultSetSearch);
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), iqId, _A2T(szServerName)) << XQUERY(_T("jabber:iq:search"))
+ << XCHILD(_T("email"), email));
+ return (HANDLE)iqId;
}
////////////////////////////////////////////////////////////////////////////////////////
// JabberSearchByName - searches the contact by its first or last name, or by a nickname
-HANDLE __cdecl CJabberProto::SearchByName( const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName )
+HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstName, const TCHAR *lastName)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return NULL;
BOOL bIsExtFormat = m_options.ExtendedSearch;
char szServerName[100];
- if ( JGetStaticString( "Jud", NULL, szServerName, sizeof szServerName ))
- strcpy( szServerName, "users.jabber.org" );
+ if (JGetStaticString("Jud", NULL, szServerName, sizeof(szServerName)))
+ strcpy(szServerName, "users.jabber.org");
int iqId = SerialNext();
- XmlNodeIq iq( _T("set"), iqId, _A2T(szServerName));
- HXML query = iq << XQUERY( _T("jabber:iq:search"));
+ XmlNodeIq iq(_T("set"), iqId, _A2T(szServerName));
+ HXML query = iq << XQUERY(_T("jabber:iq:search"));
- if ( bIsExtFormat ) {
- IqAdd( iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultExtSearch );
+ if (bIsExtFormat) {
+ IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultExtSearch);
- if ( m_tszSelectedLang )
- iq << XATTR( _T("xml:lang"), m_tszSelectedLang );
+ if (m_tszSelectedLang)
+ iq << XATTR(_T("xml:lang"), m_tszSelectedLang);
- HXML x = query << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("submit"));
- if ( nick[0] != '\0' )
- x << XCHILD( _T("field")) << XATTR( _T("var"), _T("user")) << XATTR( _T("value"), nick);
+ HXML x = query << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("submit"));
+ if (nick[0] != '\0')
+ x << XCHILD(_T("field")) << XATTR(_T("var"), _T("user")) << XATTR(_T("value"), nick);
- if ( firstName[0] != '\0' )
- x << XCHILD( _T("field")) << XATTR( _T("var"), _T("fn")) << XATTR( _T("value"), firstName);
+ if (firstName[0] != '\0')
+ x << XCHILD(_T("field")) << XATTR(_T("var"), _T("fn")) << XATTR(_T("value"), firstName);
- if ( lastName[0] != '\0' )
- x << XCHILD( _T("field")) << XATTR( _T("var"), _T("given")) << XATTR( _T("value"), lastName);
+ if (lastName[0] != '\0')
+ x << XCHILD(_T("field")) << XATTR(_T("var"), _T("given")) << XATTR(_T("value"), lastName);
}
else {
- IqAdd( iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultSetSearch );
- if ( nick[0] != '\0' )
- query << XCHILD( _T("nick"), nick);
+ IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultSetSearch);
+ if (nick[0] != '\0')
+ query << XCHILD(_T("nick"), nick);
- if ( firstName[0] != '\0' )
- query << XCHILD( _T("first"), firstName);
+ if (firstName[0] != '\0')
+ query << XCHILD(_T("first"), firstName);
- if ( lastName[0] != '\0' )
- query << XCHILD( _T("last"), lastName);
+ if (lastName[0] != '\0')
+ query << XCHILD(_T("last"), lastName);
}
- m_ThreadInfo->send( iq );
- return ( HANDLE )iqId;
+ m_ThreadInfo->send(iq);
+ return (HANDLE)iqId;
}
////////////////////////////////////////////////////////////////////////////////////////
// RecvContacts
-int __cdecl CJabberProto::RecvContacts( HANDLE /*hContact*/, PROTORECVEVENT* )
+int __cdecl CJabberProto::RecvContacts(HANDLE /*hContact*/, PROTORECVEVENT*)
{
return 1;
}
@@ -988,7 +979,7 @@ int __cdecl CJabberProto::RecvContacts( HANDLE /*hContact*/, PROTORECVEVENT* ) ////////////////////////////////////////////////////////////////////////////////////////
// RecvFile
-int __cdecl CJabberProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt )
+int __cdecl CJabberProto::RecvFile(HANDLE hContact, PROTORECVFILET* evt)
{
return Proto_RecvFile(hContact, evt);
}
@@ -996,18 +987,18 @@ int __cdecl CJabberProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt ) ////////////////////////////////////////////////////////////////////////////////////////
// RecvMsg
-int __cdecl CJabberProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* evt )
+int __cdecl CJabberProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* evt)
{
INT_PTR nDbEvent = Proto_RecvMessage(hContact, evt);
- EnterCriticalSection( &m_csLastResourceMap );
- if (IsLastResourceExists( (void *)evt->lParam)) {
+ EnterCriticalSection(&m_csLastResourceMap);
+ if (IsLastResourceExists((void*)evt->lParam)) {
m_ulpResourceToDbEventMap[ m_dwResourceMapPointer++ ] = nDbEvent;
m_ulpResourceToDbEventMap[ m_dwResourceMapPointer++ ] = evt->lParam;
- if ( m_dwResourceMapPointer >= SIZEOF( m_ulpResourceToDbEventMap ))
+ if (m_dwResourceMapPointer >= SIZEOF(m_ulpResourceToDbEventMap))
m_dwResourceMapPointer = 0;
}
- LeaveCriticalSection( &m_csLastResourceMap );
+ LeaveCriticalSection(&m_csLastResourceMap);
return 0;
}
@@ -1015,7 +1006,7 @@ int __cdecl CJabberProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* evt ) ////////////////////////////////////////////////////////////////////////////////////////
// RecvUrl
-int __cdecl CJabberProto::RecvUrl( HANDLE /*hContact*/, PROTORECVEVENT* )
+int __cdecl CJabberProto::RecvUrl(HANDLE /*hContact*/, PROTORECVEVENT*)
{
return 1;
}
@@ -1023,131 +1014,127 @@ int __cdecl CJabberProto::RecvUrl( HANDLE /*hContact*/, PROTORECVEVENT* ) ////////////////////////////////////////////////////////////////////////////////////////
// SendContacts
-int __cdecl CJabberProto::SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList )
+int __cdecl CJabberProto::SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList)
{
DBVARIANT dbv;
- if ( !m_bJabberOnline || JGetStringT( hContact, "jid", &dbv )) {
-// JSendBroadcast( hContact, ACKTYPE_CONTACTS, ACKRESULT_FAILED, ( HANDLE ) 1, 0 );
+ if ( !m_bJabberOnline || JGetStringT(hContact, "jid", &dbv))
return 0;
- }
TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID( dbv.ptszVal, szClientJid, SIZEOF( szClientJid ));
- JFreeVariant( &dbv );
+ GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
+ db_free(&dbv);
- JabberCapsBits jcb = GetResourceCapabilites( szClientJid, TRUE );
- if ( ~jcb & JABBER_CAPS_ROSTER_EXCHANGE )
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ if (~jcb & JABBER_CAPS_ROSTER_EXCHANGE)
return 0;
- XmlNode m( _T("message"));
-// m << XCHILD( _T("body"), msg );
- HXML x = m << XCHILDNS( _T("x"), _T(JABBER_FEAT_ROSTER_EXCHANGE));
+ XmlNode m(_T("message"));
+// m << XCHILD(_T("body"), msg);
+ HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_ROSTER_EXCHANGE));
- for ( int i = 0; i < nContacts; ++i ) {
- if (!JGetStringT( hContactsList[i], "jid", &dbv )) {
- x << XCHILD( _T("item")) << XATTR( _T("action"), _T("add")) <<
- XATTR( _T("jid"), dbv.ptszVal);
- JFreeVariant( &dbv );
+ for (int i = 0; i < nContacts; ++i) {
+ if ( !JGetStringT(hContactsList[i], "jid", &dbv)) {
+ x << XCHILD(_T("item")) << XATTR(_T("action"), _T("add")) <<
+ XATTR(_T("jid"), dbv.ptszVal);
+ db_free(&dbv);
}
}
int id = SerialNext();
- m << XATTR( _T("to"), szClientJid ) << XATTRID( id );
-
- m_ThreadInfo->send( m );
-// mir_free( msg );
+ m << XATTR(_T("to"), szClientJid) << XATTRID(id);
+ m_ThreadInfo->send(m);
return 1;
}
////////////////////////////////////////////////////////////////////////////////////////
// SendFile - sends a file
-HANDLE __cdecl CJabberProto::SendFile( HANDLE hContact, const TCHAR* szDescription, TCHAR** ppszFiles )
+HANDLE __cdecl CJabberProto::SendFile(HANDLE hContact, const TCHAR *szDescription, TCHAR** ppszFiles)
{
- if ( !m_bJabberOnline ) return 0;
+ if ( !m_bJabberOnline) return 0;
- if ( JGetWord( hContact, "Status", ID_STATUS_OFFLINE ) == ID_STATUS_OFFLINE )
+ if (JGetWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
return 0;
DBVARIANT dbv;
- if ( JGetStringT( hContact, "jid", &dbv ))
+ if (JGetStringT(hContact, "jid", &dbv))
return 0;
int i, j;
struct _stati64 statbuf;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal );
- if ( item == NULL ) {
- JFreeVariant( &dbv );
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
+ if (item == NULL) {
+ db_free(&dbv);
return 0;
}
- // Check if another file transfer session request is pending ( waiting for disco result )
- if ( item->ft != NULL ) {
- JFreeVariant( &dbv );
+ // Check if another file transfer session request is pending (waiting for disco result)
+ if (item->ft != NULL) {
+ db_free(&dbv);
return 0;
}
- JabberCapsBits jcb = GetResourceCapabilites( item->jid, TRUE );
- if ( jcb == JABBER_RESOURCE_CAPS_IN_PROGRESS ) {
+ JabberCapsBits jcb = GetResourceCapabilites(item->jid, TRUE);
+ if (jcb == JABBER_RESOURCE_CAPS_IN_PROGRESS) {
Sleep(600);
- jcb = GetResourceCapabilites( item->jid, TRUE );
+ jcb = GetResourceCapabilites(item->jid, TRUE);
}
// fix for very smart clients, like gajim
- if ( !m_options.BsDirect && !m_options.BsProxyManual ) {
+ if ( !m_options.BsDirect && !m_options.BsProxyManual) {
// disable bytestreams
jcb &= ~JABBER_CAPS_BYTESTREAMS;
}
// if only JABBER_CAPS_SI_FT feature set (without BS or IBB), disable JABBER_CAPS_SI_FT
- if (( jcb & (JABBER_CAPS_SI_FT | JABBER_CAPS_IBB | JABBER_CAPS_BYTESTREAMS)) == JABBER_CAPS_SI_FT)
+ if ((jcb & (JABBER_CAPS_SI_FT | JABBER_CAPS_IBB | JABBER_CAPS_BYTESTREAMS)) == JABBER_CAPS_SI_FT)
jcb &= ~JABBER_CAPS_SI_FT;
if (
// can't get caps
- ( jcb & JABBER_RESOURCE_CAPS_ERROR )
+ (jcb & JABBER_RESOURCE_CAPS_ERROR)
// caps not already received
- || ( jcb == JABBER_RESOURCE_CAPS_NONE )
+ || (jcb == JABBER_RESOURCE_CAPS_NONE)
// XEP-0096 and OOB not supported?
- || !(jcb & ( JABBER_CAPS_SI_FT | JABBER_CAPS_OOB ))
- ) {
- JFreeVariant( &dbv );
- MsgPopup( hContact, TranslateT("No compatible file transfer machanism exist"), item->jid );
+ || !(jcb & (JABBER_CAPS_SI_FT | JABBER_CAPS_OOB)))
+ {
+ db_free(&dbv);
+ MsgPopup(hContact, TranslateT("No compatible file transfer machanism exist"), item->jid);
return 0;
}
- filetransfer* ft = new filetransfer(this);
+ filetransfer *ft = new filetransfer(this);
ft->std.hContact = hContact;
- while( ppszFiles[ ft->std.totalFiles ] != NULL )
+ while(ppszFiles[ ft->std.totalFiles ] != NULL)
ft->std.totalFiles++;
- ft->std.ptszFiles = ( TCHAR** ) mir_calloc( sizeof( TCHAR* )* ft->std.totalFiles );
- ft->fileSize = ( unsigned __int64* ) mir_calloc( sizeof( unsigned __int64 ) * ft->std.totalFiles );
- for ( i=j=0; i < ft->std.totalFiles; i++ ) {
- if ( _tstati64( ppszFiles[i], &statbuf ))
- Log( "'%s' is an invalid filename", ppszFiles[i] );
+ ft->std.ptszFiles = (TCHAR**) mir_calloc(sizeof(TCHAR*)* ft->std.totalFiles);
+ ft->fileSize = (unsigned __int64*) mir_calloc(sizeof(unsigned __int64) * ft->std.totalFiles);
+ for (i=j=0; i < ft->std.totalFiles; i++) {
+ if (_tstati64(ppszFiles[i], &statbuf))
+ Log("'%s' is an invalid filename", ppszFiles[i]);
else {
- ft->std.ptszFiles[j] = mir_tstrdup( ppszFiles[i] );
+ ft->std.ptszFiles[j] = mir_tstrdup(ppszFiles[i]);
ft->fileSize[j] = statbuf.st_size;
j++;
ft->std.totalBytes += statbuf.st_size;
} }
- if ( j == 0 ) {
+ if (j == 0) {
delete ft;
- JFreeVariant( &dbv );
+ db_free(&dbv);
return NULL;
}
- ft->std.tszCurrentFile = mir_tstrdup( ppszFiles[0] );
- ft->szDescription = mir_tstrdup( szDescription );
- ft->jid = mir_tstrdup( dbv.ptszVal );
- JFreeVariant( &dbv );
+ ft->std.tszCurrentFile = mir_tstrdup(ppszFiles[0]);
+ ft->szDescription = mir_tstrdup(szDescription);
+ ft->jid = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
- if ( jcb & JABBER_CAPS_SI_FT )
- FtInitiate( item->jid, ft );
- else if ( jcb & JABBER_CAPS_OOB )
- JForkThread(( JThreadFunc )&CJabberProto::FileServerThread, ft );
+ if (jcb & JABBER_CAPS_SI_FT)
+ FtInitiate(item->jid, ft);
+ else if (jcb & JABBER_CAPS_OOB)
+ JForkThread((JThreadFunc)&CJabberProto::FileServerThread, ft);
return ft;
}
@@ -1157,47 +1144,47 @@ HANDLE __cdecl CJabberProto::SendFile( HANDLE hContact, const TCHAR* szDescripti struct TFakeAckParams
{
- inline TFakeAckParams( HANDLE p1, const char* p2 )
- : hContact( p1 ), msg( p2 ) {}
+ inline TFakeAckParams(HANDLE p1, const char* p2)
+ : hContact(p1), msg(p2) {}
- HANDLE hContact;
- const char* msg;
+ HANDLE hContact;
+ const char *msg;
};
-void __cdecl CJabberProto::SendMessageAckThread( void* param )
+void __cdecl CJabberProto::SendMessageAckThread(void* param)
{
- TFakeAckParams *par = ( TFakeAckParams* )param;
- Sleep( 100 );
- Log( "Broadcast ACK" );
- JSendBroadcast( par->hContact, ACKTYPE_MESSAGE,
+ TFakeAckParams *par = (TFakeAckParams*)param;
+ Sleep(100);
+ Log("Broadcast ACK");
+ JSendBroadcast(par->hContact, ACKTYPE_MESSAGE,
par->msg ? ACKRESULT_FAILED : ACKRESULT_SUCCESS,
- ( HANDLE ) 1, ( LPARAM ) par->msg );
- Log( "Returning from thread" );
+ (HANDLE)1, (LPARAM) par->msg);
+ Log("Returning from thread");
delete par;
}
static char PGP_PROLOG[] = "-----BEGIN PGP MESSAGE-----\r\n\r\n";
static char PGP_EPILOG[] = "\r\n-----END PGP MESSAGE-----\r\n";
-int __cdecl CJabberProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc )
+int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
{
int id;
DBVARIANT dbv;
- if ( !m_bJabberOnline || JGetStringT( hContact, "jid", &dbv )) {
- TFakeAckParams *param = new TFakeAckParams( hContact, Translate( "Protocol is offline or no jid" ));
- JForkThread( &CJabberProto::SendMessageAckThread, param );
+ if ( !m_bJabberOnline || JGetStringT(hContact, "jid", &dbv)) {
+ TFakeAckParams *param = new TFakeAckParams(hContact, Translate("Protocol is offline or no jid"));
+ JForkThread(&CJabberProto::SendMessageAckThread, param);
return 1;
}
TCHAR *msg;
int isEncrypted;
- if ( !strncmp( pszSrc, PGP_PROLOG, strlen( PGP_PROLOG ))) {
- const char* szEnd = strstr( pszSrc, PGP_EPILOG );
- char* tempstring = ( char* )alloca( strlen( pszSrc ) + 1 );
+ if ( !strncmp(pszSrc, PGP_PROLOG, strlen(PGP_PROLOG))) {
+ const char* szEnd = strstr(pszSrc, PGP_EPILOG);
+ char* tempstring = (char*)alloca(strlen(pszSrc) + 1);
size_t nStrippedLength = strlen(pszSrc) - strlen(PGP_PROLOG) - (szEnd ? strlen(szEnd) : 0);
- strncpy( tempstring, pszSrc + strlen(PGP_PROLOG), nStrippedLength );
+ strncpy(tempstring, pszSrc + strlen(PGP_PROLOG), nStrippedLength);
tempstring[ nStrippedLength ] = 0;
pszSrc = tempstring;
isEncrypted = 1;
@@ -1205,96 +1192,92 @@ int __cdecl CJabberProto::SendMsg( HANDLE hContact, int flags, const char* pszSr }
else isEncrypted = 0;
- if ( flags & PREF_UTF ) {
-
- mir_utf8decode( NEWSTR_ALLOCA( pszSrc ), &msg );
-
- }
- else if ( flags & PREF_UNICODE )
- msg = mir_u2t(( wchar_t* )&pszSrc[ strlen( pszSrc )+1 ] );
+ if (flags & PREF_UTF)
+ mir_utf8decode(NEWSTR_ALLOCA(pszSrc), &msg);
+ else if (flags & PREF_UNICODE)
+ msg = mir_u2t((wchar_t*)&pszSrc[ strlen(pszSrc)+1 ]);
else
- msg = mir_a2t( pszSrc );
+ msg = mir_a2t(pszSrc);
int nSentMsgId = 0;
- if ( msg != NULL ) {
- TCHAR* msgType;
- if ( ListExist( LIST_CHATROOM, dbv.ptszVal ) && _tcschr( dbv.ptszVal, '/' )==NULL )
+ if (msg != NULL) {
+ TCHAR *msgType;
+ if (ListExist(LIST_CHATROOM, dbv.ptszVal) && _tcschr(dbv.ptszVal, '/') == NULL)
msgType = _T("groupchat");
else
msgType = _T("chat");
- XmlNode m( _T("message" )); xmlAddAttr( m, _T("type"), msgType );
- if ( !isEncrypted )
- m << XCHILD( _T("body"), msg );
+ XmlNode m(_T("message")); xmlAddAttr(m, _T("type"), msgType);
+ if ( !isEncrypted)
+ m << XCHILD(_T("body"), msg);
else {
- m << XCHILD( _T("body"), _T("[This message is encrypted.]" ));
- m << XCHILD( _T("x"), msg) << XATTR(_T("xmlns"), _T("jabber:x:encrypted"));
+ m << XCHILD(_T("body"), _T("[This message is encrypted.]"));
+ m << XCHILD(_T("x"), msg) << XATTR(_T("xmlns"), _T("jabber:x:encrypted"));
}
- mir_free( msg );
+ mir_free(msg);
TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID( dbv.ptszVal, szClientJid, SIZEOF( szClientJid ));
+ GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( szClientJid );
- if ( r )
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(szClientJid);
+ if (r)
r->bMessageSessionActive = TRUE;
- JabberCapsBits jcb = GetResourceCapabilites( szClientJid, TRUE );
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
- if ( jcb & JABBER_RESOURCE_CAPS_ERROR )
+ if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
- if ( jcb & JABBER_CAPS_CHATSTATES )
- m << XCHILDNS( _T("active"), _T(JABBER_FEAT_CHATSTATES));
+ if (jcb & JABBER_CAPS_CHATSTATES)
+ m << XCHILDNS(_T("active"), _T(JABBER_FEAT_CHATSTATES));
if (
// if message delivery check disabled by entity caps manager
- ( jcb & JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY ) ||
+ (jcb & JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY) ||
// if client knows nothing about delivery
- !( jcb & ( JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_RECEIPTS )) ||
+ !(jcb & (JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_RECEIPTS)) ||
// if message sent to groupchat
- !lstrcmp( msgType, _T("groupchat")) ||
+ !lstrcmp(msgType, _T("groupchat")) ||
// if message delivery check disabled in settings
- !m_options.MsgAck || !JGetByte( hContact, "MsgAck", TRUE )) {
- if ( !lstrcmp( msgType, _T("groupchat")))
- xmlAddAttr( m, _T("to"), dbv.ptszVal );
+ !m_options.MsgAck || !JGetByte(hContact, "MsgAck", TRUE)) {
+ if ( !lstrcmp(msgType, _T("groupchat")))
+ xmlAddAttr(m, _T("to"), dbv.ptszVal);
else {
id = SerialNext();
- xmlAddAttr( m, _T("to"), szClientJid ); xmlAddAttrID( m, id );
+ xmlAddAttr(m, _T("to"), szClientJid); xmlAddAttrID(m, id);
}
- m_ThreadInfo->send( m );
+ m_ThreadInfo->send(m);
- JForkThread( &CJabberProto::SendMessageAckThread, new TFakeAckParams( hContact, 0 ));
+ JForkThread(&CJabberProto::SendMessageAckThread, new TFakeAckParams(hContact, 0));
nSentMsgId = 1;
}
else {
id = SerialNext();
- xmlAddAttr( m, _T("to"), szClientJid ); xmlAddAttrID( m, id );
+ xmlAddAttr(m, _T("to"), szClientJid); xmlAddAttrID(m, id);
// message receipts XEP priority
- if ( jcb & JABBER_CAPS_MESSAGE_RECEIPTS )
- m << XCHILDNS( _T("request"), _T(JABBER_FEAT_MESSAGE_RECEIPTS));
- else if ( jcb & JABBER_CAPS_MESSAGE_EVENTS ) {
- HXML x = m << XCHILDNS( _T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
- x << XCHILD( _T("delivered")); x << XCHILD( _T("offline"));
+ if (jcb & JABBER_CAPS_MESSAGE_RECEIPTS)
+ m << XCHILDNS(_T("request"), _T(JABBER_FEAT_MESSAGE_RECEIPTS));
+ else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
+ HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
+ x << XCHILD(_T("delivered")); x << XCHILD(_T("offline"));
}
- else
- id = 1;
+ else id = 1;
- m_ThreadInfo->send( m );
+ m_ThreadInfo->send(m);
nSentMsgId = id;
} }
- JFreeVariant( &dbv );
+ db_free(&dbv);
return nSentMsgId;
}
////////////////////////////////////////////////////////////////////////////////////////
// SendUrl
-int __cdecl CJabberProto::SendUrl( HANDLE /*hContact*/, int /*flags*/, const char* /*url*/ )
+int __cdecl CJabberProto::SendUrl(HANDLE /*hContact*/, int /*flags*/, const char* /*url*/)
{
return 1;
}
@@ -1302,42 +1285,42 @@ int __cdecl CJabberProto::SendUrl( HANDLE /*hContact*/, int /*flags*/, const cha ////////////////////////////////////////////////////////////////////////////////////////
// JabberSetApparentMode - sets the visibility status
-int __cdecl CJabberProto::SetApparentMode( HANDLE hContact, int mode )
+int __cdecl CJabberProto::SetApparentMode(HANDLE hContact, int mode)
{
- if ( mode != 0 && mode != ID_STATUS_ONLINE && mode != ID_STATUS_OFFLINE )
+ if (mode != 0 && mode != ID_STATUS_ONLINE && mode != ID_STATUS_OFFLINE)
return 1;
- int oldMode = JGetWord( hContact, "ApparentMode", 0 );
- if ( mode == oldMode )
+ int oldMode = JGetWord(hContact, "ApparentMode", 0);
+ if (mode == oldMode)
return 1;
- JSetWord( hContact, "ApparentMode", ( WORD )mode );
- if ( !m_bJabberOnline )
+ JSetWord(hContact, "ApparentMode", (WORD)mode);
+ if ( !m_bJabberOnline)
return 0;
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
TCHAR* jid = dbv.ptszVal;
- switch ( mode ) {
+ switch (mode) {
case ID_STATUS_ONLINE:
- if ( m_iStatus == ID_STATUS_INVISIBLE || oldMode == ID_STATUS_OFFLINE )
- m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), jid ));
+ if (m_iStatus == ID_STATUS_INVISIBLE || oldMode == ID_STATUS_OFFLINE)
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), jid));
break;
case ID_STATUS_OFFLINE:
- if ( m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE )
- SendPresenceTo( ID_STATUS_INVISIBLE, jid, NULL );
+ if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE)
+ SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL);
break;
case 0:
- if ( oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE )
- SendPresenceTo( ID_STATUS_INVISIBLE, jid, NULL );
- else if ( oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE )
- SendPresenceTo( m_iStatus, jid, NULL );
+ if (oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE)
+ SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL);
+ else if (oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE)
+ SendPresenceTo(m_iStatus, jid, NULL);
break;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- // TODO: update the zebra list ( jabber:iq:privacy )
+ // TODO: update the zebra list (jabber:iq:privacy)
return 0;
}
@@ -1345,49 +1328,49 @@ int __cdecl CJabberProto::SetApparentMode( HANDLE hContact, int mode ) ////////////////////////////////////////////////////////////////////////////////////////
// JabberSetStatus - sets the protocol status
-int __cdecl CJabberProto::SetStatus( int iNewStatus )
+int __cdecl CJabberProto::SetStatus(int iNewStatus)
{
if (m_iDesiredStatus == iNewStatus)
return 0;
int oldStatus = m_iStatus;
- Log( "PS_SETSTATUS( %d )", iNewStatus );
+ Log("PS_SETSTATUS(%d)", iNewStatus);
m_iDesiredStatus = iNewStatus;
- if ( iNewStatus == ID_STATUS_OFFLINE ) {
- if ( m_ThreadInfo ) {
- if ( m_bJabberOnline ) {
+ if (iNewStatus == ID_STATUS_OFFLINE) {
+ if (m_ThreadInfo) {
+ if (m_bJabberOnline) {
// Quit all chatrooms (will send quit message)
LISTFOREACH(i, this, LIST_CHATROOM)
if (JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i))
GcQuit(item, 0, NULL);
}
- m_ThreadInfo->send( "</stream:stream>" );
+ m_ThreadInfo->send("</stream:stream>");
m_ThreadInfo->shutdown();
- if ( m_bJabberConnected ) {
+ if (m_bJabberConnected) {
m_bJabberConnected = m_bJabberOnline = FALSE;
RebuildInfoFrame();
}
}
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
- else if ( !m_bJabberConnected && !m_ThreadInfo && !( m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES )) {
+ else if ( !m_bJabberConnected && !m_ThreadInfo && !(m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) {
m_iStatus = ID_STATUS_CONNECTING;
- ThreadData* thread = new ThreadData( this, JABBER_SESSION_NORMAL );
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
- thread->hThread = JForkThreadEx(( JThreadFunc )&CJabberProto::ServerThread, thread );
+ ThreadData* thread = new ThreadData(this, JABBER_SESSION_NORMAL);
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ thread->hThread = JForkThreadEx((JThreadFunc)&CJabberProto::ServerThread, thread);
RebuildInfoFrame();
}
- else if ( m_bJabberOnline )
- SetServerStatus( iNewStatus );
+ else if (m_bJabberOnline)
+ SetServerStatus(iNewStatus);
else
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
return 0;
}
@@ -1395,7 +1378,7 @@ int __cdecl CJabberProto::SetStatus( int iNewStatus ) ////////////////////////////////////////////////////////////////////////////////////////
// JabberGetAwayMsg - returns a contact's away message
-void __cdecl CJabberProto::GetAwayMsgThread( void* hContact )
+void __cdecl CJabberProto::GetAwayMsgThread(void* hContact)
{
DBVARIANT dbv;
JABBER_LIST_ITEM *item;
@@ -1403,59 +1386,59 @@ void __cdecl CJabberProto::GetAwayMsgThread( void* hContact ) int i, msgCount;
size_t len;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- if (( item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal )) != NULL ) {
- JFreeVariant( &dbv );
- if ( item->resourceCount > 0 ) {
- Log( "resourceCount > 0" );
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ if ((item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) != NULL) {
+ db_free(&dbv);
+ if (item->resourceCount > 0) {
+ Log("resourceCount > 0");
r = item->resource;
len = msgCount = 0;
- for ( i=0; i<item->resourceCount; i++ )
- if ( r[i].statusMessage ) {
+ for (i=0; i<item->resourceCount; i++)
+ if (r[i].statusMessage) {
msgCount++;
- len += ( _tcslen( r[i].resourceName ) + _tcslen( r[i].statusMessage ) + 8 );
+ len += (_tcslen(r[i].resourceName) + _tcslen(r[i].statusMessage) + 8);
}
- TCHAR* str = ( TCHAR* )alloca( sizeof( TCHAR )*( len+1 ));
+ TCHAR* str = (TCHAR*)alloca(sizeof(TCHAR)*(len+1));
str[0] = str[len] = '\0';
- for ( i=0; i < item->resourceCount; i++ )
- if ( r[i].statusMessage ) {
- if ( str[0] != '\0' ) _tcscat( str, _T("\r\n" ));
- if ( msgCount > 1 ) {
- _tcscat( str, _T("( "));
- _tcscat( str, r[i].resourceName );
- _tcscat( str, _T(" ): "));
+ for (i=0; i < item->resourceCount; i++)
+ if (r[i].statusMessage) {
+ if (str[0] != '\0') _tcscat(str, _T("\r\n"));
+ if (msgCount > 1) {
+ _tcscat(str, _T("("));
+ _tcscat(str, r[i].resourceName);
+ _tcscat(str, _T("): "));
}
- _tcscat( str, r[i].statusMessage );
+ _tcscat(str, r[i].statusMessage);
}
- JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str);
+ JSendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str);
return;
}
- if ( item->itemResource.statusMessage != NULL ) {
- JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)item->itemResource.statusMessage);
+ if (item->itemResource.statusMessage != NULL) {
+ JSendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)item->itemResource.statusMessage);
return;
}
}
- else JFreeVariant( &dbv );
+ else db_free(&dbv);
}
- JSendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE ) 1, ( LPARAM )0 );
+ JSendBroadcast(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)0);
}
-HANDLE __cdecl CJabberProto::GetAwayMsg( HANDLE hContact )
+HANDLE __cdecl CJabberProto::GetAwayMsg(HANDLE hContact)
{
- Log( "GetAwayMsg called, hContact=%08X", hContact );
+ Log("GetAwayMsg called, hContact=%08X", hContact);
- JForkThread( &CJabberProto::GetAwayMsgThread, hContact );
+ JForkThread(&CJabberProto::GetAwayMsgThread, hContact);
return (HANDLE)1;
}
////////////////////////////////////////////////////////////////////////////////////////
// PSR_AWAYMSG
-int __cdecl CJabberProto::RecvAwayMsg( HANDLE /*hContact*/, int /*statusMode*/, PROTORECVEVENT* )
+int __cdecl CJabberProto::RecvAwayMsg(HANDLE /*hContact*/, int /*statusMode*/, PROTORECVEVENT*)
{
return 1;
}
@@ -1463,7 +1446,7 @@ int __cdecl CJabberProto::RecvAwayMsg( HANDLE /*hContact*/, int /*statusMode*/, ////////////////////////////////////////////////////////////////////////////////////////
// PSS_AWAYMSG
-int __cdecl CJabberProto::SendAwayMsg( HANDLE /*hContact*/, HANDLE /*hProcess*/, const char* )
+int __cdecl CJabberProto::SendAwayMsg(HANDLE /*hContact*/, HANDLE /*hProcess*/, const char*)
{
return 1;
}
@@ -1471,58 +1454,63 @@ int __cdecl CJabberProto::SendAwayMsg( HANDLE /*hContact*/, HANDLE /*hProcess*/, ////////////////////////////////////////////////////////////////////////////////////////
// JabberSetAwayMsg - sets the away status message
-int __cdecl CJabberProto::SetAwayMsg( int status, const TCHAR* msg )
+int __cdecl CJabberProto::SetAwayMsg(int status, const TCHAR *msg)
{
- Log( "SetAwayMsg called, wParam=%d lParam=" TCHAR_STR_PARAM, status, msg );
+ Log("SetAwayMsg called, wParam=%d lParam=" TCHAR_STR_PARAM, status, msg);
- EnterCriticalSection( &m_csModeMsgMutex );
+ EnterCriticalSection(&m_csModeMsgMutex);
TCHAR **szMsg;
- switch ( status ) {
+ switch (status) {
case ID_STATUS_ONLINE:
szMsg = &m_modeMsgs.szOnline;
break;
+
case ID_STATUS_AWAY:
case ID_STATUS_ONTHEPHONE:
case ID_STATUS_OUTTOLUNCH:
szMsg = &m_modeMsgs.szAway;
status = ID_STATUS_AWAY;
break;
+
case ID_STATUS_NA:
szMsg = &m_modeMsgs.szNa;
break;
+
case ID_STATUS_DND:
case ID_STATUS_OCCUPIED:
szMsg = &m_modeMsgs.szDnd;
status = ID_STATUS_DND;
break;
+
case ID_STATUS_FREECHAT:
szMsg = &m_modeMsgs.szFreechat;
break;
+
default:
- LeaveCriticalSection( &m_csModeMsgMutex );
+ LeaveCriticalSection(&m_csModeMsgMutex);
return 1;
}
- TCHAR* newModeMsg = mir_tstrdup( msg );
+ TCHAR* newModeMsg = mir_tstrdup(msg);
- if (( *szMsg == NULL && newModeMsg == NULL ) ||
- ( *szMsg != NULL && newModeMsg != NULL && !lstrcmp( *szMsg, newModeMsg ))) {
+ if ((*szMsg == NULL && newModeMsg == NULL) ||
+ (*szMsg != NULL && newModeMsg != NULL && !lstrcmp(*szMsg, newModeMsg))) {
// Message is the same, no update needed
- mir_free( newModeMsg );
- LeaveCriticalSection( &m_csModeMsgMutex );
+ mir_free(newModeMsg);
+ LeaveCriticalSection(&m_csModeMsgMutex);
}
else {
// Update with the new mode message
- if ( *szMsg != NULL )
- mir_free( *szMsg );
+ if (*szMsg != NULL)
+ mir_free(*szMsg);
*szMsg = newModeMsg;
// Send a presence update if needed
- LeaveCriticalSection( &m_csModeMsgMutex );
- if ( status == m_iStatus ) {
- SendPresence( m_iStatus, true );
- } }
+ LeaveCriticalSection(&m_csModeMsgMutex);
+ if (status == m_iStatus)
+ SendPresence(m_iStatus, true);
+ }
return 0;
}
@@ -1530,54 +1518,54 @@ int __cdecl CJabberProto::SetAwayMsg( int status, const TCHAR* msg ) /////////////////////////////////////////////////////////////////////////////////////////
// JabberUserIsTyping - sends a UTN notification
-int __cdecl CJabberProto::UserIsTyping( HANDLE hContact, int type )
+int __cdecl CJabberProto::UserIsTyping(HANDLE hContact, int type)
{
- if ( !m_bJabberOnline ) return 0;
+ if ( !m_bJabberOnline) return 0;
DBVARIANT dbv;
- if ( JGetStringT( hContact, "jid", &dbv )) return 0;
+ if (JGetStringT(hContact, "jid", &dbv))
+ return 0;
JABBER_LIST_ITEM *item;
- if (( item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal )) != NULL ) {
+ if ((item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) != NULL) {
TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID( dbv.ptszVal, szClientJid, SIZEOF( szClientJid ));
+ GetClientJID(dbv.ptszVal, szClientJid, SIZEOF(szClientJid));
- JabberCapsBits jcb = GetResourceCapabilites( szClientJid, TRUE );
-
- if ( jcb & JABBER_RESOURCE_CAPS_ERROR )
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
- XmlNode m( _T("message")); xmlAddAttr( m, _T("to"), szClientJid );
+ XmlNode m(_T("message")); xmlAddAttr(m, _T("to"), szClientJid);
- if ( jcb & JABBER_CAPS_CHATSTATES ) {
- m << XATTR( _T("type"), _T("chat")) << XATTRID( SerialNext());
- switch ( type ) {
+ if (jcb & JABBER_CAPS_CHATSTATES) {
+ m << XATTR(_T("type"), _T("chat")) << XATTRID(SerialNext());
+ switch (type) {
case PROTOTYPE_SELFTYPING_OFF:
- m << XCHILDNS( _T("paused"), _T(JABBER_FEAT_CHATSTATES));
- m_ThreadInfo->send( m );
+ m << XCHILDNS(_T("paused"), _T(JABBER_FEAT_CHATSTATES));
+ m_ThreadInfo->send(m);
break;
case PROTOTYPE_SELFTYPING_ON:
- m << XCHILDNS( _T("composing"), _T(JABBER_FEAT_CHATSTATES));
- m_ThreadInfo->send( m );
+ m << XCHILDNS(_T("composing"), _T(JABBER_FEAT_CHATSTATES));
+ m_ThreadInfo->send(m);
break;
}
}
- else if ( jcb & JABBER_CAPS_MESSAGE_EVENTS ) {
- HXML x = m << XCHILDNS( _T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
- if ( item->messageEventIdStr != NULL )
- x << XCHILD( _T("id"), item->messageEventIdStr );
+ else if (jcb & JABBER_CAPS_MESSAGE_EVENTS) {
+ HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
+ if (item->messageEventIdStr != NULL)
+ x << XCHILD(_T("id"), item->messageEventIdStr);
- switch ( type ) {
+ switch (type) {
case PROTOTYPE_SELFTYPING_OFF:
- m_ThreadInfo->send( m );
+ m_ThreadInfo->send(m);
break;
case PROTOTYPE_SELFTYPING_ON:
- x << XCHILD( _T("composing"));
- m_ThreadInfo->send( m );
+ x << XCHILD(_T("composing"));
+ m_ThreadInfo->send(m);
break;
} } }
- JFreeVariant( &dbv );
+ db_free(&dbv);
return 0;
}
@@ -1607,17 +1595,15 @@ void CJabberProto::WindowNotify(UINT msg, bool async) void CJabberProto::InfoFrame_OnSetup(CJabberInfoFrame_Event*)
{
- OnMenuOptions(0,0);
+ OnMenuOptions(0, 0);
}
void CJabberProto::InfoFrame_OnTransport(CJabberInfoFrame_Event *evt)
{
- if (evt->m_event == CJabberInfoFrame_Event::CLICK)
- {
+ if (evt->m_event == CJabberInfoFrame_Event::CLICK) {
HANDLE hContact = (HANDLE)evt->m_pUserData;
- POINT pt;
-
HMENU hContactMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0);
+ POINT pt;
GetCursorPos(&pt);
int res = TrackPopupMenu(hContactMenu, TPM_RETURNCMD, pt.x, pt.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL);
CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(res, MPCF_CONTACTMENU), (LPARAM)hContact);
@@ -1627,25 +1613,23 @@ void CJabberProto::InfoFrame_OnTransport(CJabberInfoFrame_Event *evt) /////////////////////////////////////////////////////////////////////////////////////////
// OnEvent - maintain protocol events
-int __cdecl CJabberProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam )
+int __cdecl CJabberProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
{
- switch( eventType ) {
- case EV_PROTO_ONLOAD: return OnModulesLoadedEx( 0, 0 );
- case EV_PROTO_ONEXIT: return OnPreShutdown( 0, 0 );
- case EV_PROTO_ONOPTIONS: return OnOptionsInit( wParam, lParam );
+ switch(eventType) {
+ case EV_PROTO_ONLOAD: return OnModulesLoadedEx(0, 0);
+ case EV_PROTO_ONEXIT: return OnPreShutdown(0, 0);
+ case EV_PROTO_ONOPTIONS: return OnOptionsInit(wParam, lParam);
case EV_PROTO_ONMENU:
MenuInit();
break;
case EV_PROTO_ONRENAME:
- if ( m_hMenuRoot )
- {
- CLISTMENUITEM clmi = { 0 };
- clmi.cbSize = sizeof(CLISTMENUITEM);
+ if (m_hMenuRoot) {
+ CLISTMENUITEM clmi = { sizeof(clmi) };
clmi.flags = CMIM_NAME | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
clmi.ptszName = m_tszUserName;
- CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )m_hMenuRoot, ( LPARAM )&clmi );
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)m_hMenuRoot, (LPARAM)&clmi);
}
break;
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 002408dcae..872f773864 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -37,10 +37,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_send_manager.h"
struct CJabberProto;
-typedef void ( __cdecl CJabberProto::*JThreadFunc )( void* );
-typedef int ( __cdecl CJabberProto::*JEventFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CJabberProto::*JServiceFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CJabberProto::*JServiceFuncParam )( WPARAM, LPARAM, LPARAM );
+typedef void (__cdecl CJabberProto::*JThreadFunc)(void*);
+typedef int (__cdecl CJabberProto::*JEventFunc)(WPARAM, LPARAM);
+typedef INT_PTR (__cdecl CJabberProto::*JServiceFunc)(WPARAM, LPARAM);
+typedef INT_PTR (__cdecl CJabberProto::*JServiceFuncParam)(WPARAM, LPARAM, LPARAM);
enum TJabberGcLogInfoType { INFO_BAN, INFO_STATUS, INFO_CONFIG, INFO_AFFILIATION, INFO_ROLE };
@@ -148,85 +148,85 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject {
typedef PROTO_INTERFACE CSuper;
- CJabberProto( const char*, const TCHAR* );
+ CJabberProto(const char*, const TCHAR*);
~CJabberProto();
//====================================================================================
// PROTO_INTERFACE
//====================================================================================
- virtual HANDLE __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr );
- virtual HANDLE __cdecl AddToListByEvent( int flags, int iContact, HANDLE hDbEvent );
+ virtual HANDLE __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
+ virtual HANDLE __cdecl AddToListByEvent(int flags, int iContact, HANDLE hDbEvent);
- virtual int __cdecl Authorize( HANDLE hDbEvent );
- virtual int __cdecl AuthDeny( HANDLE hDbEvent, const TCHAR* szReason );
- virtual int __cdecl AuthRecv( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl AuthRequest( HANDLE hContact, const TCHAR* szMessage );
+ virtual int __cdecl Authorize(HANDLE hDbEvent);
+ virtual int __cdecl AuthDeny(HANDLE hDbEvent, const TCHAR *szReason);
+ virtual int __cdecl AuthRecv(HANDLE hContact, PROTORECVEVENT*);
+ virtual int __cdecl AuthRequest(HANDLE hContact, const TCHAR *szMessage);
- virtual HANDLE __cdecl ChangeInfo( int iInfoType, void* pInfoData );
+ virtual HANDLE __cdecl ChangeInfo(int iInfoType, void* pInfoData);
- virtual HANDLE __cdecl FileAllow( HANDLE hContact, HANDLE hTransfer, const TCHAR* szPath );
- virtual int __cdecl FileCancel( HANDLE hContact, HANDLE hTransfer );
- virtual int __cdecl FileDeny( HANDLE hContact, HANDLE hTransfer, const TCHAR* szReason );
- virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename );
+ virtual HANDLE __cdecl FileAllow(HANDLE hContact, HANDLE hTransfer, const TCHAR *szPath);
+ virtual int __cdecl FileCancel(HANDLE hContact, HANDLE hTransfer);
+ virtual int __cdecl FileDeny(HANDLE hContact, HANDLE hTransfer, const TCHAR *szReason);
+ virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const TCHAR** szFilename);
- virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL );
- virtual HICON __cdecl GetIcon( int iconIndex );
- virtual int __cdecl GetInfo( HANDLE hContact, int infoType );
+ virtual DWORD_PTR __cdecl GetCaps(int type, HANDLE hContact = NULL);
+ virtual HICON __cdecl GetIcon(int iconIndex);
+ virtual int __cdecl GetInfo(HANDLE hContact, int infoType);
- virtual HANDLE __cdecl SearchBasic( const TCHAR* id );
- virtual HANDLE __cdecl SearchByEmail( const TCHAR* email );
- virtual HANDLE __cdecl SearchByName( const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName );
- virtual HWND __cdecl SearchAdvanced( HWND owner );
- virtual HWND __cdecl CreateExtendedSearchUI( HWND owner );
+ virtual HANDLE __cdecl SearchBasic(const TCHAR *id);
+ virtual HANDLE __cdecl SearchByEmail(const TCHAR *email);
+ virtual HANDLE __cdecl SearchByName(const TCHAR *nick, const TCHAR *firstName, const TCHAR *lastName);
+ virtual HWND __cdecl SearchAdvanced(HWND owner);
+ virtual HWND __cdecl CreateExtendedSearchUI(HWND owner);
- virtual int __cdecl RecvContacts( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl RecvFile( HANDLE hContact, PROTORECVFILET* );
- virtual int __cdecl RecvMsg( HANDLE hContact, PROTORECVEVENT* );
- virtual int __cdecl RecvUrl( HANDLE hContact, PROTORECVEVENT* );
+ virtual int __cdecl RecvContacts(HANDLE hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvFile(HANDLE hContact, PROTORECVFILET*);
+ virtual int __cdecl RecvMsg(HANDLE hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvUrl(HANDLE hContact, PROTORECVEVENT*);
- virtual int __cdecl SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList );
- virtual HANDLE __cdecl SendFile( HANDLE hContact, const TCHAR* szDescription, TCHAR** ppszFiles );
- virtual int __cdecl SendMsg( HANDLE hContact, int flags, const char* msg );
- virtual int __cdecl SendUrl( HANDLE hContact, int flags, const char* url );
+ virtual int __cdecl SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList);
+ virtual HANDLE __cdecl SendFile(HANDLE hContact, const TCHAR *szDescription, TCHAR** ppszFiles);
+ virtual int __cdecl SendMsg(HANDLE hContact, int flags, const char* msg);
+ virtual int __cdecl SendUrl(HANDLE hContact, int flags, const char* url);
- virtual int __cdecl SetApparentMode( HANDLE hContact, int mode );
- virtual int __cdecl SetStatus( int iNewStatus );
+ virtual int __cdecl SetApparentMode(HANDLE hContact, int mode);
+ virtual int __cdecl SetStatus(int iNewStatus);
- virtual HANDLE __cdecl GetAwayMsg( HANDLE hContact );
- virtual int __cdecl RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt );
- virtual int __cdecl SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg );
- virtual int __cdecl SetAwayMsg( int m_iStatus, const TCHAR* msg );
+ virtual HANDLE __cdecl GetAwayMsg(HANDLE hContact);
+ virtual int __cdecl RecvAwayMsg(HANDLE hContact, int mode, PROTORECVEVENT* evt);
+ virtual int __cdecl SendAwayMsg(HANDLE hContact, HANDLE hProcess, const char* msg);
+ virtual int __cdecl SetAwayMsg(int m_iStatus, const TCHAR *msg);
- virtual int __cdecl UserIsTyping( HANDLE hContact, int type );
+ virtual int __cdecl UserIsTyping(HANDLE hContact, int type);
- virtual int __cdecl OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam );
+ virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam);
//====| Services |====================================================================
INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl GetMyAwayMsg(WPARAM wParam, LPARAM lParam);
//====| Events |======================================================================
- void __cdecl OnAddContactForever( DBCONTACTWRITESETTING* cws, HANDLE hContact );
- int __cdecl OnContactDeleted( WPARAM, LPARAM );
- int __cdecl OnDbSettingChanged( WPARAM, LPARAM );
- int __cdecl OnIdleChanged( WPARAM, LPARAM );
- int __cdecl OnModernOptInit( WPARAM, LPARAM );
- int __cdecl OnModulesLoadedEx( WPARAM, LPARAM );
- int __cdecl OnOptionsInit( WPARAM, LPARAM );
- int __cdecl OnPreShutdown( WPARAM, LPARAM );
- int __cdecl OnPrebuildContactMenu( WPARAM, LPARAM );
- int __cdecl OnMsgUserTyping( WPARAM, LPARAM );
- int __cdecl OnProcessSrmmIconClick( WPARAM, LPARAM );
- int __cdecl OnProcessSrmmEvent( WPARAM, LPARAM );
- int __cdecl OnReloadIcons( WPARAM, LPARAM );
- void __cdecl OnRenameContact( DBCONTACTWRITESETTING* cws, HANDLE hContact );
- void __cdecl OnRenameGroup( DBCONTACTWRITESETTING* cws, HANDLE hContact );
- int __cdecl OnUserInfoInit( WPARAM, LPARAM );
-
- int __cdecl JabberGcEventHook( WPARAM, LPARAM );
- int __cdecl JabberGcMenuHook( WPARAM, LPARAM );
- int __cdecl JabberGcInit( WPARAM, LPARAM );
+ void __cdecl OnAddContactForever(DBCONTACTWRITESETTING* cws, HANDLE hContact);
+ int __cdecl OnContactDeleted(WPARAM, LPARAM);
+ int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
+ int __cdecl OnIdleChanged(WPARAM, LPARAM);
+ int __cdecl OnModernOptInit(WPARAM, LPARAM);
+ int __cdecl OnModulesLoadedEx(WPARAM, LPARAM);
+ int __cdecl OnOptionsInit(WPARAM, LPARAM);
+ int __cdecl OnPreShutdown(WPARAM, LPARAM);
+ int __cdecl OnPrebuildContactMenu(WPARAM, LPARAM);
+ int __cdecl OnMsgUserTyping(WPARAM, LPARAM);
+ int __cdecl OnProcessSrmmIconClick(WPARAM, LPARAM);
+ int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
+ int __cdecl OnReloadIcons(WPARAM, LPARAM);
+ void __cdecl OnRenameContact(DBCONTACTWRITESETTING* cws, HANDLE hContact);
+ void __cdecl OnRenameGroup(DBCONTACTWRITESETTING* cws, HANDLE hContact);
+ int __cdecl OnUserInfoInit(WPARAM, LPARAM);
+
+ int __cdecl JabberGcEventHook(WPARAM, LPARAM);
+ int __cdecl JabberGcMenuHook(WPARAM, LPARAM);
+ int __cdecl JabberGcInit(WPARAM, LPARAM);
// Google Shared Status
BOOL m_bGoogleSharedStatus;
@@ -368,44 +368,44 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject * Function declarations
*******************************************************************/
- void JabberUpdateDialogs( BOOL bEnable );
+ void JabberUpdateDialogs(BOOL bEnable);
void CleanLastResourceMap();
BOOL IsLastResourceExists(void *pResource);
- void* AddToLastResourceMap( LPCTSTR szFullJid );
- TCHAR* FindLastResourceByDbEvent( HANDLE hDbEvent );
+ void* AddToLastResourceMap(LPCTSTR szFullJid);
+ TCHAR* FindLastResourceByDbEvent(HANDLE hDbEvent);
//---- jabber_adhoc.cpp --------------------------------------------------------------
int __cdecl ContactMenuRunCommands(WPARAM wParam, LPARAM lParam);
- HWND GetWindowFromIq( HXML iqNode );
- BOOL HandleAdhocCommandRequest( HXML iqNode, CJabberIqInfo* pInfo );
- BOOL IsRcRequestAllowedByACL( CJabberIqInfo* pInfo );
-
- int AdhocSetStatusHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
- int AdhocOptionsHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
- int AdhocForwardHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
- int AdhocLockWSHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
- int AdhocQuitMirandaHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
- int AdhocLeaveGroupchatsHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
-
- void OnIqResult_ListOfCommands( HXML iqNode );
- void OnIqResult_CommandExecution( HXML iqNode );
- int AdHoc_RequestListOfCommands( TCHAR * szResponder, HWND hwndDlg );
- int AdHoc_ExecuteCommand( HWND hwndDlg, TCHAR * jid, struct JabberAdHocData* dat );
+ HWND GetWindowFromIq(HXML iqNode);
+ BOOL HandleAdhocCommandRequest(HXML iqNode, CJabberIqInfo* pInfo);
+ BOOL IsRcRequestAllowedByACL(CJabberIqInfo* pInfo);
+
+ int AdhocSetStatusHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
+ int AdhocOptionsHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
+ int AdhocForwardHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
+ int AdhocLockWSHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
+ int AdhocQuitMirandaHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
+ int AdhocLeaveGroupchatsHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
+
+ void OnIqResult_ListOfCommands(HXML iqNode);
+ void OnIqResult_CommandExecution(HXML iqNode);
+ int AdHoc_RequestListOfCommands(TCHAR * szResponder, HWND hwndDlg);
+ int AdHoc_ExecuteCommand(HWND hwndDlg, TCHAR * jid, struct JabberAdHocData* dat);
int AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData * dat, TCHAR* action);
int AdHoc_AddCommandRadio(HWND hFrame, TCHAR * labelStr, int id, int ypos, int value);
- int AdHoc_OnJAHMCommandListResult( HWND hwndDlg, HXML iqNode, JabberAdHocData* dat );
- int AdHoc_OnJAHMProcessResult( HWND hwndDlg, HXML workNode, JabberAdHocData* dat );
+ int AdHoc_OnJAHMCommandListResult(HWND hwndDlg, HXML iqNode, JabberAdHocData* dat);
+ int AdHoc_OnJAHMProcessResult(HWND hwndDlg, HXML workNode, JabberAdHocData* dat);
- void ContactMenuAdhocCommands( struct CJabberAdhocStartupParams* param );
+ void ContactMenuAdhocCommands(struct CJabberAdhocStartupParams* param);
//---- jabber_bookmarks.c ------------------------------------------------------------
- INT_PTR __cdecl OnMenuHandleBookmarks( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl OnMenuHandleBookmarks(WPARAM wParam, LPARAM lParam);
- int AddEditBookmark( JABBER_LIST_ITEM* item );
+ int AddEditBookmark(JABBER_LIST_ITEM* item);
//---- jabber_notes.c -----------------------------------------------------------------
@@ -420,53 +420,53 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject //---- jabber_byte.c -----------------------------------------------------------------
- void __cdecl ByteSendThread( JABBER_BYTE_TRANSFER *jbt );
- void __cdecl ByteReceiveThread( JABBER_BYTE_TRANSFER *jbt );
+ void __cdecl ByteSendThread(JABBER_BYTE_TRANSFER *jbt);
+ void __cdecl ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt);
- void IqResultProxyDiscovery( HXML iqNode, CJabberIqInfo* pInfo );
- void ByteInitiateResult( HXML iqNode, CJabberIqInfo* pInfo );
- void ByteSendViaProxy( JABBER_BYTE_TRANSFER *jbt );
- int ByteSendParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen );
- void IqResultStreamActivate( HXML iqNode );
- int ByteReceiveParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen );
- int ByteSendProxyParse( HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen );
+ void IqResultProxyDiscovery(HXML iqNode, CJabberIqInfo* pInfo);
+ void ByteInitiateResult(HXML iqNode, CJabberIqInfo* pInfo);
+ void ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt);
+ int ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
+ void IqResultStreamActivate(HXML iqNode);
+ int ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
+ int ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
//---- jabber_caps.cpp ---------------------------------------------------------------
- JabberCapsBits GetTotalJidCapabilites( const TCHAR *jid );
- JabberCapsBits GetResourceCapabilites( const TCHAR *jid, BOOL appendBestResource );
+ JabberCapsBits GetTotalJidCapabilites(const TCHAR *jid);
+ JabberCapsBits GetResourceCapabilites(const TCHAR *jid, BOOL appendBestResource);
//---- jabber_captcha.cpp ------------------------------------------------------------
- void GetCaptchaImage ( HXML node, char *ImageBuf, const TCHAR *PicType, TCHAR*& CaptchaPath);
+ void GetCaptchaImage (HXML node, char *ImageBuf, const TCHAR *PicType, TCHAR*& CaptchaPath);
void sendCaptchaResult(TCHAR* buf, ThreadData* info, LPCTSTR from, LPCTSTR challenge, LPCTSTR fromjid, LPCTSTR sid);
void sendCaptchaError(ThreadData* info, LPCTSTR from, LPCTSTR to, LPCTSTR challenge);
//---- jabber_chat.cpp ---------------------------------------------------------------
- void GcLogCreate( JABBER_LIST_ITEM* item );
- void GcLogUpdateMemberStatus( JABBER_LIST_ITEM* item, const TCHAR* resource, const TCHAR* nick, const TCHAR* jid, int action, HXML reason, int nStatusCode = -1 );
- void GcLogShowInformation( JABBER_LIST_ITEM *item, JABBER_RESOURCE_STATUS *user, TJabberGcLogInfoType type );
- void GcQuit( JABBER_LIST_ITEM* jid, int code, HXML reason );
+ void GcLogCreate(JABBER_LIST_ITEM* item);
+ void GcLogUpdateMemberStatus(JABBER_LIST_ITEM* item, const TCHAR *resource, const TCHAR *nick, const TCHAR *jid, int action, HXML reason, int nStatusCode = -1);
+ void GcLogShowInformation(JABBER_LIST_ITEM *item, JABBER_RESOURCE_STATUS *user, TJabberGcLogInfoType type);
+ void GcQuit(JABBER_LIST_ITEM* jid, int code, HXML reason);
void FilterList(HWND hwndList);
void ResetListOptions(HWND hwndList);
void InviteUser(TCHAR *room, TCHAR *pUser, TCHAR *text);
- void AdminSet( const TCHAR* to, const TCHAR* ns, const TCHAR* szItem, const TCHAR* itemVal, const TCHAR* var, const TCHAR* varVal );
- void AdminGet( const TCHAR* to, const TCHAR* ns, const TCHAR* var, const TCHAR* varVal, JABBER_IQ_PFUNC foo );
- void AdminSetReason( const TCHAR* to, const TCHAR* ns, const TCHAR* szItem, const TCHAR* itemVal, const TCHAR* var, const TCHAR* varVal, const TCHAR* rsn );
- void AddMucListItem( JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str );
- void AddMucListItem( JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str , TCHAR* rsn);
- void DeleteMucListItem( JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* jid );
+ void AdminSet(const TCHAR *to, const TCHAR *ns, const TCHAR *szItem, const TCHAR *itemVal, const TCHAR *var, const TCHAR *varVal);
+ void AdminGet(const TCHAR *to, const TCHAR *ns, const TCHAR *var, const TCHAR *varVal, JABBER_IQ_PFUNC foo);
+ void AdminSetReason(const TCHAR *to, const TCHAR *ns, const TCHAR *szItem, const TCHAR *itemVal, const TCHAR *var, const TCHAR *varVal, const TCHAR *rsn);
+ void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str);
+ void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* str , TCHAR* rsn);
+ void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, TCHAR* jid);
//---- jabber_console.cpp ------------------------------------------------------------
- INT_PTR __cdecl OnMenuHandleConsole( WPARAM wParam, LPARAM lParam );
- void __cdecl ConsoleThread( void* );
+ INT_PTR __cdecl OnMenuHandleConsole(WPARAM wParam, LPARAM lParam);
+ void __cdecl ConsoleThread(void*);
- void ConsoleInit( void );
- void ConsoleUninit( void );
+ void ConsoleInit(void);
+ void ConsoleUninit(void);
bool FilterXml(HXML node, DWORD flags);
bool RecursiveCheckFilter(HXML node, DWORD flags);
@@ -474,16 +474,16 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject //---- jabber_disco.cpp --------------------------------------------------------------
void LaunchServiceDiscovery(TCHAR *jid);
- INT_PTR __cdecl OnMenuHandleServiceDiscovery( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuHandleServiceDiscoveryMyTransports( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuHandleServiceDiscoveryTransports( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuHandleServiceDiscoveryConferences( WPARAM wParam, LPARAM lParam );
-
- void OnIqResultServiceDiscoveryInfo( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultServiceDiscoveryItems( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultServiceDiscoveryRootInfo( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultServiceDiscoveryRoot( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultServiceDiscoveryRootItems( HXML iqNode, CJabberIqInfo* pInfo );
+ INT_PTR __cdecl OnMenuHandleServiceDiscovery(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuHandleServiceDiscoveryMyTransports(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuHandleServiceDiscoveryTransports(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuHandleServiceDiscoveryConferences(WPARAM wParam, LPARAM lParam);
+
+ void OnIqResultServiceDiscoveryInfo(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultServiceDiscoveryItems(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultServiceDiscoveryRootInfo(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultServiceDiscoveryRoot(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultServiceDiscoveryRootItems(HXML iqNode, CJabberIqInfo* pInfo);
BOOL SendInfoRequest(CJabberSDNode* pNode, HXML parent);
BOOL SendBothRequests(CJabberSDNode* pNode, HXML parent);
void PerformBrowse(HWND hwndDlg);
@@ -492,207 +492,207 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject BOOL SyncTree(HTREELISTITEM hIndex, CJabberSDNode* pNode);
void ServiceDiscoveryShowMenu(CJabberSDNode *node, HTREELISTITEM hItem, POINT pt);
- int SetupServiceDiscoveryDlg( TCHAR* jid );
+ int SetupServiceDiscoveryDlg(TCHAR* jid);
- void OnIqResultCapsDiscoInfo( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultCapsDiscoInfoSI( HXML iqNode, CJabberIqInfo* pInfo );
+ void OnIqResultCapsDiscoInfo(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultCapsDiscoInfoSI(HXML iqNode, CJabberIqInfo* pInfo);
- void RegisterAgent( HWND hwndDlg, TCHAR* jid );
+ void RegisterAgent(HWND hwndDlg, TCHAR* jid);
//---- jabber_file.cpp ---------------------------------------------------------------
- int FileReceiveParse( filetransfer* ft, char* buffer, int datalen );
- int FileSendParse( JABBER_SOCKET s, filetransfer* ft, char* buffer, int datalen );
+ int FileReceiveParse(filetransfer *ft, char* buffer, int datalen);
+ int FileSendParse(JABBER_SOCKET s, filetransfer *ft, char* buffer, int datalen);
- void UpdateChatUserStatus( wchar_t* chat_jid, wchar_t* jid, wchar_t* nick, int role, int affil, int status, BOOL update_nick );
+ void UpdateChatUserStatus(wchar_t* chat_jid, wchar_t* jid, wchar_t* nick, int role, int affil, int status, BOOL update_nick);
void GroupchatJoinRoomByJid(HWND hwndParent, TCHAR *jid);
- void RenameParticipantNick( JABBER_LIST_ITEM* item, const TCHAR* oldNick, HXML itemNode );
- void AcceptGroupchatInvite( const TCHAR* roomJid, const TCHAR* reason, const TCHAR* password );
+ void RenameParticipantNick(JABBER_LIST_ITEM* item, const TCHAR *oldNick, HXML itemNode);
+ void AcceptGroupchatInvite(const TCHAR *roomJid, const TCHAR *reason, const TCHAR *password);
//---- jabber_form.c -----------------------------------------------------------------
- void FormCreateDialog( HXML xNode, TCHAR* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata );
+ void FormCreateDialog(HXML xNode, TCHAR* defTitle, JABBER_FORM_SUBMIT_FUNC pfnSubmit, void *userdata);
//---- jabber_ft.c -------------------------------------------------------------------
- void __cdecl FileReceiveThread( filetransfer* ft );
- void __cdecl FileServerThread( filetransfer* ft );
+ void __cdecl FileReceiveThread(filetransfer *ft);
+ void __cdecl FileServerThread(filetransfer *ft);
- void FtCancel( filetransfer* ft );
- void FtInitiate( TCHAR* jid, filetransfer* ft );
- void FtHandleSiRequest( HXML iqNode );
- void FtAcceptSiRequest( filetransfer* ft );
- void FtAcceptIbbRequest( filetransfer* ft );
- BOOL FtHandleBytestreamRequest( HXML iqNode, CJabberIqInfo* pInfo );
- BOOL FtHandleIbbRequest( HXML iqNode, BOOL bOpen );
+ void FtCancel(filetransfer *ft);
+ void FtInitiate(TCHAR* jid, filetransfer *ft);
+ void FtHandleSiRequest(HXML iqNode);
+ void FtAcceptSiRequest(filetransfer *ft);
+ void FtAcceptIbbRequest(filetransfer *ft);
+ BOOL FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo* pInfo);
+ BOOL FtHandleIbbRequest(HXML iqNode, BOOL bOpen);
//---- jabber_groupchat.c ------------------------------------------------------------
- INT_PTR __cdecl OnMenuHandleJoinGroupchat( WPARAM wParam, LPARAM lParam );
- void __cdecl GroupchatInviteAcceptThread( JABBER_GROUPCHAT_INVITE_INFO *inviteInfo );
+ INT_PTR __cdecl OnMenuHandleJoinGroupchat(WPARAM wParam, LPARAM lParam);
+ void __cdecl GroupchatInviteAcceptThread(JABBER_GROUPCHAT_INVITE_INFO *inviteInfo);
- INT_PTR __cdecl OnJoinChat( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnLeaveChat( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl OnJoinChat(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnLeaveChat(WPARAM wParam, LPARAM lParam);
JABBER_RESOURCE_STATUS* GcFindResource(JABBER_LIST_ITEM *item, const TCHAR *resource);
- void GroupchatJoinRoom( LPCTSTR server, LPCTSTR room, LPCTSTR nick, LPCTSTR password, bool autojoin = false );
- void GroupchatProcessPresence( HXML node );
- void GroupchatProcessMessage( HXML node );
- void GroupchatProcessInvite( LPCTSTR roomJid, LPCTSTR from, LPCTSTR reason, LPCTSTR password );
- void GroupchatJoinDlg( TCHAR* roomJid );
+ void GroupchatJoinRoom(LPCTSTR server, LPCTSTR room, LPCTSTR nick, LPCTSTR password, bool autojoin = false);
+ void GroupchatProcessPresence(HXML node);
+ void GroupchatProcessMessage(HXML node);
+ void GroupchatProcessInvite(LPCTSTR roomJid, LPCTSTR from, LPCTSTR reason, LPCTSTR password);
+ void GroupchatJoinDlg(TCHAR* roomJid);
void OnIqResultDiscovery(HXML iqNode, CJabberIqInfo *pInfo);
//---- jabber_icolib.cpp -------------------------------------------------------------
int* m_transportProtoTableStartIndex;
- void IconsInit( void );
- HANDLE GetIconHandle( int iconId );
- HICON LoadIconEx( const char* name, bool big = false );
+ void IconsInit(void);
+ HANDLE GetIconHandle(int iconId);
+ HICON LoadIconEx(const char* name, bool big = false);
int LoadAdvancedIcons(int iID);
- int GetTransportProtoID( TCHAR* TransportDomain );
+ int GetTransportProtoID(TCHAR* TransportDomain);
int GetTransportStatusIconIndex(int iID, int Status);
- BOOL DBCheckIsTransportedContact(const TCHAR* jid, HANDLE hContact);
- void CheckAllContactsAreTransported( void );
- INT_PTR __cdecl JGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam );
+ BOOL DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact);
+ void CheckAllContactsAreTransported(void);
+ INT_PTR __cdecl JGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam);
//---- jabber_iq.c -------------------------------------------------------------------
- JABBER_IQ_PFUNC JabberIqFetchFunc( int iqId );
+ JABBER_IQ_PFUNC JabberIqFetchFunc(int iqId);
- void __cdecl ExpirerThread( void* );
+ void __cdecl ExpirerThread(void*);
void IqInit();
void IqUninit();
- void IqAdd( unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func );
- void IqRemove( int index );
+ void IqAdd(unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func);
+ void IqRemove(int index);
void IqExpire();
- void OnIqResultBind( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultDiscoBookmarks( HXML iqNode );
- void OnIqResultEntityTime( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultExtSearch( HXML iqNode );
- void OnIqResultGetAuth( HXML iqNode );
- void OnIqResultGetVCardAvatar( HXML iqNode );
- void OnIqResultGetClientAvatar( HXML iqNode );
- void OnIqResultGetServerAvatar( HXML iqNode );
- void OnIqResultGotAvatar( HANDLE hContact, HXML n, const TCHAR* mimeType );
- void OnIqResultGetMuc( HXML iqNode );
- void OnIqResultGetRegister( HXML iqNode );
- void OnIqResultGetRoster( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultGetVcard( HXML iqNode );
- void OnIqResultLastActivity( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultMucGetAdminList( HXML iqNode );
- void OnIqResultMucGetBanList( HXML iqNode );
- void OnIqResultMucGetMemberList( HXML iqNode );
- void OnIqResultMucGetModeratorList( HXML iqNode );
- void OnIqResultMucGetOwnerList( HXML iqNode );
- void OnIqResultMucGetVoiceList( HXML iqNode );
- void OnIqResultNestedRosterGroups( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultNotes( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultSession( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultSetAuth( HXML iqNode );
- void OnIqResultSetBookmarks( HXML iqNode );
- void OnIqResultSetPassword( HXML iqNode );
- void OnIqResultSetRegister( HXML iqNode );
- void OnIqResultSetSearch( HXML iqNode );
- void OnIqResultSetVcard( HXML iqNode );
- void OnIqResultVersion( HXML node, CJabberIqInfo *pInfo );
- void OnProcessLoginRq( ThreadData* info, DWORD rq );
- void OnLoggedIn( void );
+ void OnIqResultBind(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultDiscoBookmarks(HXML iqNode);
+ void OnIqResultEntityTime(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultExtSearch(HXML iqNode);
+ void OnIqResultGetAuth(HXML iqNode);
+ void OnIqResultGetVCardAvatar(HXML iqNode);
+ void OnIqResultGetClientAvatar(HXML iqNode);
+ void OnIqResultGetServerAvatar(HXML iqNode);
+ void OnIqResultGotAvatar(HANDLE hContact, HXML n, const TCHAR *mimeType);
+ void OnIqResultGetMuc(HXML iqNode);
+ void OnIqResultGetRegister(HXML iqNode);
+ void OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultGetVcard(HXML iqNode);
+ void OnIqResultLastActivity(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultMucGetAdminList(HXML iqNode);
+ void OnIqResultMucGetBanList(HXML iqNode);
+ void OnIqResultMucGetMemberList(HXML iqNode);
+ void OnIqResultMucGetModeratorList(HXML iqNode);
+ void OnIqResultMucGetOwnerList(HXML iqNode);
+ void OnIqResultMucGetVoiceList(HXML iqNode);
+ void OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultNotes(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultSession(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultSetAuth(HXML iqNode);
+ void OnIqResultSetBookmarks(HXML iqNode);
+ void OnIqResultSetPassword(HXML iqNode);
+ void OnIqResultSetRegister(HXML iqNode);
+ void OnIqResultSetSearch(HXML iqNode);
+ void OnIqResultSetVcard(HXML iqNode);
+ void OnIqResultVersion(HXML node, CJabberIqInfo *pInfo);
+ void OnProcessLoginRq(ThreadData* info, DWORD rq);
+ void OnLoggedIn(void);
//---- jabber_iq_handlers.cpp --------------------------------------------------------
- BOOL OnIqRequestVersion( HXML node, CJabberIqInfo* pInfo );
- BOOL OnIqRequestLastActivity( HXML node, CJabberIqInfo *pInfo );
- BOOL OnIqRequestPing( HXML node, CJabberIqInfo *pInfo );
- BOOL OnIqRequestTime( HXML node, CJabberIqInfo *pInfo );
- BOOL OnIqProcessIqOldTime( HXML node, CJabberIqInfo *pInfo );
- BOOL OnIqRequestAvatar( HXML node, CJabberIqInfo *pInfo );
- BOOL OnSiRequest( HXML node, CJabberIqInfo *pInfo );
- BOOL OnRosterPushRequest( HXML node, CJabberIqInfo *pInfo );
- BOOL OnIqRequestOOB( HXML node, CJabberIqInfo *pInfo );
- BOOL OnIqHttpAuth( HXML node, CJabberIqInfo* pInfo );
- BOOL AddClistHttpAuthEvent( CJabberHttpAuthParams *pParams );
-
- void __cdecl IbbSendThread( JABBER_IBB_TRANSFER *jibb );
- void __cdecl IbbReceiveThread( JABBER_IBB_TRANSFER *jibb );
-
- void OnIbbInitiateResult( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIbbCloseResult( HXML iqNode, CJabberIqInfo* pInfo );
- BOOL OnFtHandleIbbIq( HXML iqNode, CJabberIqInfo* pInfo );
- BOOL OnIbbRecvdData( const TCHAR *data, const TCHAR *sid, const TCHAR *seq );
-
- void OnFtSiResult( HXML iqNode, CJabberIqInfo* pInfo );
- BOOL FtIbbSend( int blocksize, filetransfer* ft );
- BOOL FtSend( HANDLE hConn, filetransfer* ft );
- void FtSendFinal( BOOL success, filetransfer* ft );
- int FtReceive( HANDLE hConn, filetransfer* ft, char* buffer, int datalen );
- void FtReceiveFinal( BOOL success, filetransfer* ft );
+ BOOL OnIqRequestVersion(HXML node, CJabberIqInfo* pInfo);
+ BOOL OnIqRequestLastActivity(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestPing(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestTime(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqProcessIqOldTime(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestAvatar(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnSiRequest(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnRosterPushRequest(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqRequestOOB(HXML node, CJabberIqInfo *pInfo);
+ BOOL OnIqHttpAuth(HXML node, CJabberIqInfo* pInfo);
+ BOOL AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams);
+
+ void __cdecl IbbSendThread(JABBER_IBB_TRANSFER *jibb);
+ void __cdecl IbbReceiveThread(JABBER_IBB_TRANSFER *jibb);
+
+ void OnIbbInitiateResult(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIbbCloseResult(HXML iqNode, CJabberIqInfo* pInfo);
+ BOOL OnFtHandleIbbIq(HXML iqNode, CJabberIqInfo* pInfo);
+ BOOL OnIbbRecvdData(const TCHAR *data, const TCHAR *sid, const TCHAR *seq);
+
+ void OnFtSiResult(HXML iqNode, CJabberIqInfo* pInfo);
+ BOOL FtIbbSend(int blocksize, filetransfer *ft);
+ BOOL FtSend(HANDLE hConn, filetransfer *ft);
+ void FtSendFinal(BOOL success, filetransfer *ft);
+ int FtReceive(HANDLE hConn, filetransfer *ft, char* buffer, int datalen);
+ void FtReceiveFinal(BOOL success, filetransfer *ft);
//---- jabber_message_handlers.cpp --------------------------------------------------------
- BOOL OnMessageError( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo );
- BOOL OnMessageIbb( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo );
- BOOL OnMessagePubsubEvent( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo );
- BOOL OnMessageGroupchat( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo );
+ BOOL OnMessageError(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessageIbb(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessagePubsubEvent(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL OnMessageGroupchat(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
//---- jabber_list.cpp ---------------------------------------------------------------
- JABBER_LIST_ITEM *ListAdd( JABBER_LIST list, const TCHAR* jid );
- JABBER_LIST_ITEM *ListGetItemPtr( JABBER_LIST list, const TCHAR* jid );
- JABBER_LIST_ITEM *ListGetItemPtrFromIndex( int index );
+ JABBER_LIST_ITEM *ListAdd(JABBER_LIST list, const TCHAR *jid);
+ JABBER_LIST_ITEM *ListGetItemPtr(JABBER_LIST list, const TCHAR *jid);
+ JABBER_LIST_ITEM *ListGetItemPtrFromIndex(int index);
- void ListWipe( void );
- int ListExist( JABBER_LIST list, const TCHAR* jid );
+ void ListWipe(void);
+ int ListExist(JABBER_LIST list, const TCHAR *jid);
BOOL ListLock();
BOOL ListUnlock();
- void ListRemove( JABBER_LIST list, const TCHAR* jid );
- void ListRemoveList( JABBER_LIST list );
- void ListRemoveByIndex( int index );
- int ListFindNext( JABBER_LIST list, int fromOffset );
+ void ListRemove(JABBER_LIST list, const TCHAR *jid);
+ void ListRemoveList(JABBER_LIST list);
+ void ListRemoveByIndex(int index);
+ int ListFindNext(JABBER_LIST list, int fromOffset);
- JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource( JABBER_LIST list, const TCHAR* jid );
- int ListAddResource( JABBER_LIST list, const TCHAR* jid, int status, const TCHAR* statusMessage, char priority = 0, const TCHAR* nick = NULL );
- void ListRemoveResource( JABBER_LIST list, const TCHAR* jid );
- TCHAR* ListGetBestResourceNamePtr( const TCHAR* jid );
- TCHAR* ListGetBestClientResourceNamePtr( const TCHAR* jid );
+ JABBER_RESOURCE_STATUS *CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid);
+ int ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority = 0, const TCHAR *nick = NULL);
+ void ListRemoveResource(JABBER_LIST list, const TCHAR *jid);
+ TCHAR* ListGetBestResourceNamePtr(const TCHAR *jid);
+ TCHAR* ListGetBestClientResourceNamePtr(const TCHAR *jid);
- void SetMucConfig( HXML node, void *from );
- void OnIqResultMucGetJidList( HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType );
+ void SetMucConfig(HXML node, void *from);
+ void OnIqResultMucGetJidList(HXML iqNode, JABBER_MUC_JIDLIST_TYPE listType);
- void OnIqResultServerDiscoInfo( HXML iqNode );
- void OnIqResultGetVcardPhoto( const TCHAR* jid, HXML n, HANDLE hContact, BOOL& hasPhoto );
+ void OnIqResultServerDiscoInfo(HXML iqNode);
+ void OnIqResultGetVcardPhoto(const TCHAR *jid, HXML n, HANDLE hContact, BOOL& hasPhoto);
void SetBookmarkRequest (XmlNodeIq& iqId);
//---- jabber_menu.cpp ---------------------------------------------------------------
- INT_PTR __cdecl OnMenuConvertChatContact( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuRosterAdd( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuHandleRequestAuth( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuHandleGrantAuth( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuOptions( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuTransportLogin( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuTransportResolve( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuBookmarkAdd( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnMenuRevokeAuth( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl OnMenuConvertChatContact(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuRosterAdd(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuHandleGrantAuth(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuOptions(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuTransportLogin(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuTransportResolve(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuBookmarkAdd(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuRevokeAuth(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuHandleResource(WPARAM wParam, LPARAM lParam, LPARAM res);
INT_PTR __cdecl OnMenuHandleDirectPresence(WPARAM wParam, LPARAM lParam, LPARAM res);
INT_PTR __cdecl OnMenuSetPriority(WPARAM wParam, LPARAM lParam, LPARAM dwDelta);
- void GlobalMenuInit( void );
- void GlobalMenuUninit( void );
+ void GlobalMenuInit(void);
+ void GlobalMenuUninit(void);
- void MenuInit( void );
+ void MenuInit(void);
void MenuHideSrmmIcon(HANDLE hContact);
void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item);
- void AuthWorker( HANDLE hContact, char* authReqType );
+ void AuthWorker(HANDLE hContact, char* authReqType);
void UpdatePriorityMenu(short priority);
@@ -702,24 +702,24 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject //---- jabber_misc.c -----------------------------------------------------------------
- INT_PTR __cdecl OnGetEventTextChatStates( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnGetEventTextPresence( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl OnGetEventTextChatStates(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnGetEventTextPresence(WPARAM wParam, LPARAM lParam);
- void AddContactToRoster( const TCHAR* jid, const TCHAR* nick, const TCHAR* grpName );
- void DBAddAuthRequest( const TCHAR* jid, const TCHAR* nick );
+ void AddContactToRoster(const TCHAR *jid, const TCHAR *nick, const TCHAR *grpName);
+ void DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick);
BOOL AddDbPresenceEvent(HANDLE hContact, BYTE btEventType);
- HANDLE DBCreateContact( const TCHAR* jid, const TCHAR* nick, BOOL temporary, BOOL stripResource );
- void GetAvatarFileName( HANDLE hContact, TCHAR* pszDest, size_t cbLen );
- void ResolveTransportNicks( const TCHAR* jid );
- void SetServerStatus( int iNewStatus );
+ HANDLE DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource);
+ void GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen);
+ void ResolveTransportNicks(const TCHAR *jid);
+ void SetServerStatus(int iNewStatus);
void FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize);
void UpdateMirVer(JABBER_LIST_ITEM *item);
void UpdateMirVer(HANDLE hContact, JABBER_RESOURCE_STATUS *resource);
void UpdateSubscriptionInfo(HANDLE hContact, JABBER_LIST_ITEM *item);
- void SetContactOfflineStatus( HANDLE hContact );
- void InitCustomFolders( void );
- void InitPopups( void );
- void MsgPopup( HANDLE hContact, const TCHAR *szMsg, const TCHAR *szTitle );
+ void SetContactOfflineStatus(HANDLE hContact);
+ void InitCustomFolders(void);
+ void InitPopups(void);
+ void MsgPopup(HANDLE hContact, const TCHAR *szMsg, const TCHAR *szTitle);
//---- jabber_opt.cpp ----------------------------------------------------------------
@@ -727,42 +727,42 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject CJabberDlgBase::CreateParam OptCreateGc;
CJabberDlgBase::CreateParam OptCreateAdvanced;
- INT_PTR __cdecl OnMenuHandleRosterControl( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam);
void _RosterExportToFile(HWND hwndDlg);
void _RosterImportFromFile(HWND hwndDlg);
void _RosterSendRequest(HWND hwndDlg, BYTE rrAction);
- void _RosterHandleGetRequest( HXML node );
+ void _RosterHandleGetRequest(HXML node);
//---- jabber_password.cpp --------------------------------------------------------------
- INT_PTR __cdecl OnMenuHandleChangePassword( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl OnMenuHandleChangePassword(WPARAM wParam, LPARAM lParam);
//---- jabber_privacy.cpp ------------------------------------------------------------
ROSTERREQUSERDATA rrud;
- INT_PTR __cdecl menuSetPrivacyList( WPARAM wParam, LPARAM lParam, LPARAM iList );
- INT_PTR __cdecl OnMenuHandlePrivacyLists( WPARAM wParam, LPARAM lParam );
+ INT_PTR __cdecl menuSetPrivacyList(WPARAM wParam, LPARAM lParam, LPARAM iList);
+ INT_PTR __cdecl OnMenuHandlePrivacyLists(WPARAM wParam, LPARAM lParam);
- void BuildPrivacyMenu( void );
- void BuildPrivacyListsMenu( bool bDeleteOld );
+ void BuildPrivacyMenu(void);
+ void BuildPrivacyListsMenu(bool bDeleteOld);
- void QueryPrivacyLists( ThreadData *pThreadInfo = NULL );
+ void QueryPrivacyLists(ThreadData *pThreadInfo = NULL);
- BOOL OnIqRequestPrivacyLists( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultPrivacyList( HXML iqNode );
- void OnIqResultPrivacyLists( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultPrivacyListActive( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultPrivacyListDefault( HXML iqNode, CJabberIqInfo* pInfo );
- void OnIqResultPrivacyListModify( HXML iqNode, CJabberIqInfo* pInfo );
+ BOOL OnIqRequestPrivacyLists(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultPrivacyList(HXML iqNode);
+ void OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo* pInfo);
+ void OnIqResultPrivacyListModify(HXML iqNode, CJabberIqInfo* pInfo);
//---- jabber_proto.cpp --------------------------------------------------------------
- void __cdecl BasicSearchThread( struct JABBER_SEARCH_BASIC *jsb );
- void __cdecl GetAwayMsgThread( void* hContact );
- void __cdecl SendMessageAckThread( void* hContact );
+ void __cdecl BasicSearchThread(struct JABBER_SEARCH_BASIC *jsb);
+ void __cdecl GetAwayMsgThread(void* hContact);
+ void __cdecl SendMessageAckThread(void* hContact);
- HANDLE AddToListByJID( const TCHAR* newJid, DWORD flags );
+ HANDLE AddToListByJID(const TCHAR *newJid, DWORD flags);
void WindowSubscribe(HWND hwnd);
void WindowUnsubscribe(HWND hwnd);
void WindowNotify(UINT msg, bool async = false);
@@ -772,74 +772,74 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject //---- jabber_rc.cpp -----------------------------------------------------------------
- int RcGetUnreadEventsCount( void );
+ int RcGetUnreadEventsCount(void);
//---- jabber_search.cpp -------------------------------------------------------------
- void SearchReturnResults( HANDLE id, void* pvUsersInfo, U_TCHAR_MAP* pmAllFields );
- void OnIqResultAdvancedSearch( HXML iqNode );
- void OnIqResultGetSearchFields( HXML iqNode );
- int SearchRenewFields( HWND hwndDlg, JabberSearchData * dat);
- void SearchDeleteFromRecent( const TCHAR* szAddr, BOOL deleteLastFromDB = TRUE );
- void SearchAddToRecent( const TCHAR* szAddr, HWND hwndDialog = NULL );
+ void SearchReturnResults(HANDLE id, void* pvUsersInfo, U_TCHAR_MAP* pmAllFields);
+ void OnIqResultAdvancedSearch(HXML iqNode);
+ void OnIqResultGetSearchFields(HXML iqNode);
+ int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat);
+ void SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFromDB = TRUE);
+ void SearchAddToRecent(const TCHAR *szAddr, HWND hwndDialog = NULL);
//---- jabber_std.cpp ----------------------------------------------
- void JCreateService( const char* szService, JServiceFunc serviceProc );
- void JCreateServiceParam( const char* szService, JServiceFuncParam serviceProc, LPARAM lParam );
- HANDLE JCreateHookableEvent( const char* szService );
- void JForkThread( JThreadFunc, void* );
- HANDLE JForkThreadEx( JThreadFunc, void*, UINT* threadID = NULL );
-
- void JDeleteSetting( HANDLE hContact, const char* valueName );
-// DWORD JGetByte( const char* valueName, int parDefltValue );
- DWORD JGetByte( HANDLE hContact, const char* valueName, int parDefltValue );
- char* JGetContactName( HANDLE hContact );
- DWORD JGetDword( HANDLE hContact, const char* valueName, DWORD parDefltValue );
- int JGetStaticString( const char* valueName, HANDLE hContact, char* dest, int dest_len );
- int JGetStringUtf( HANDLE hContact, char* valueName, DBVARIANT* dbv );
- int JGetStringT( HANDLE hContact, char* valueName, DBVARIANT* dbv );
- TCHAR *JGetStringT( HANDLE hContact, char* valueName );
- TCHAR *JGetStringT( HANDLE hContact, char* valueName, TCHAR *&out );
- TCHAR *JGetStringT( HANDLE hContact, char* valueName, TCHAR *buf, int size );
- WORD JGetWord( HANDLE hContact, const char* valueName, int parDefltValue );
- void JHookEvent( const char*, JEventFunc );
- int JSendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam );
-// DWORD JSetByte( const char* valueName, int parValue );
- DWORD JSetByte( HANDLE hContact, const char* valueName, int parValue );
- DWORD JSetDword( HANDLE hContact, const char* valueName, DWORD parValue );
- DWORD JSetString( HANDLE hContact, const char* valueName, const char* parValue );
- DWORD JSetStringT( HANDLE hContact, const char* valueName, const TCHAR* parValue );
- DWORD JSetStringUtf( HANDLE hContact, const char* valueName, const char* parValue );
- DWORD JSetWord( HANDLE hContact, const char* valueName, int parValue );
-
- TCHAR* JGetStringCrypt( HANDLE hContact, char* valueName );
- DWORD JSetStringCrypt( HANDLE hContact, char* valueName, const TCHAR* parValue );
+ void JCreateService(const char* szService, JServiceFunc serviceProc);
+ void JCreateServiceParam(const char* szService, JServiceFuncParam serviceProc, LPARAM lParam);
+ HANDLE JCreateHookableEvent(const char* szService);
+ void JForkThread(JThreadFunc, void*);
+ HANDLE JForkThreadEx(JThreadFunc, void*, UINT* threadID = NULL);
+
+ void JDeleteSetting(HANDLE hContact, const char* valueName);
+// DWORD JGetByte(const char* valueName, int parDefltValue);
+ DWORD JGetByte(HANDLE hContact, const char* valueName, int parDefltValue);
+ char* JGetContactName(HANDLE hContact);
+ DWORD JGetDword(HANDLE hContact, const char* valueName, DWORD parDefltValue);
+ int JGetStaticString(const char* valueName, HANDLE hContact, char* dest, int dest_len);
+ int JGetStringUtf(HANDLE hContact, char* valueName, DBVARIANT* dbv);
+ int JGetStringT(HANDLE hContact, char* valueName, DBVARIANT* dbv);
+ TCHAR *JGetStringT(HANDLE hContact, char* valueName);
+ TCHAR *JGetStringT(HANDLE hContact, char* valueName, TCHAR *&out);
+ TCHAR *JGetStringT(HANDLE hContact, char* valueName, TCHAR *buf, int size);
+ WORD JGetWord(HANDLE hContact, const char* valueName, int parDefltValue);
+ void JHookEvent(const char*, JEventFunc);
+ int JSendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
+// DWORD JSetByte(const char* valueName, int parValue);
+ DWORD JSetByte(HANDLE hContact, const char* valueName, int parValue);
+ DWORD JSetDword(HANDLE hContact, const char* valueName, DWORD parValue);
+ DWORD JSetString(HANDLE hContact, const char* valueName, const char* parValue);
+ DWORD JSetStringT(HANDLE hContact, const char* valueName, const TCHAR *parValue);
+ DWORD JSetStringUtf(HANDLE hContact, const char* valueName, const char* parValue);
+ DWORD JSetWord(HANDLE hContact, const char* valueName, int parValue);
+
+ TCHAR* JGetStringCrypt(HANDLE hContact, char* valueName);
+ DWORD JSetStringCrypt(HANDLE hContact, char* valueName, const TCHAR *parValue);
//---- jabber_svc.c ------------------------------------------------------------------
void CheckMenuItems();
- void EnableMenuItems( BOOL bEnable );
-
- INT_PTR __cdecl JabberGetAvatar( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberGetAvatarCaps( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberGetAvatarInfo( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl ServiceSendXML( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberSetAvatar( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberSetNickname( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberSendNudge( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberGCGetToolTipText( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberServiceParseXmppURI( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl OnHttpAuthRequest( WPARAM wParam, LPARAM lParam );
- INT_PTR __cdecl JabberGetApi( WPARAM wParam, LPARAM lParam );
-
- void ExternalTempIqHandler( HXML node, CJabberIqInfo *pInfo );
- BOOL ExternalIqHandler( HXML node, CJabberIqInfo *pInfo );
- BOOL ExternalMessageHandler( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo );
- BOOL ExternalPresenceHandler( HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo );
- BOOL ExternalSendHandler( HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo );
-
- BOOL SendHttpAuthReply( CJabberHttpAuthParams *pParams, BOOL bAuthorized );
+ void EnableMenuItems(BOOL bEnable);
+
+ INT_PTR __cdecl JabberGetAvatar(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberGetAvatarCaps(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl ServiceSendXML(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberSetAvatar(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberSetNickname(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberSendNudge(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberGCGetToolTipText(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberServiceParseXmppURI(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnHttpAuthRequest(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl JabberGetApi(WPARAM wParam, LPARAM lParam);
+
+ void ExternalTempIqHandler(HXML node, CJabberIqInfo *pInfo);
+ BOOL ExternalIqHandler(HXML node, CJabberIqInfo *pInfo);
+ BOOL ExternalMessageHandler(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo);
+ BOOL ExternalPresenceHandler(HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo);
+ BOOL ExternalSendHandler(HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo);
+
+ BOOL SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAuthorized);
//---- jabber_thread.c ----------------------------------------------
@@ -860,62 +860,62 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject AUTHMECHS m_AuthMechs;
- void __cdecl ServerThread( ThreadData* info );
+ void __cdecl ServerThread(ThreadData* info);
- void OnProcessFailure( HXML node, ThreadData *info );
- void OnProcessError( HXML node, ThreadData *info );
- void OnProcessSuccess( HXML node, ThreadData *info );
- void OnProcessChallenge( HXML node, ThreadData *info );
- void OnProcessProceed( HXML node, ThreadData *info );
- void OnProcessCompressed( HXML node, ThreadData *info );
- void OnProcessMessage( HXML node, ThreadData *info );
- void OnProcessPresence( HXML node, ThreadData *info );
- void OnProcessPresenceCapabilites( HXML node );
- void OnProcessPubsubEvent( HXML node );
+ void OnProcessFailure(HXML node, ThreadData *info);
+ void OnProcessError(HXML node, ThreadData *info);
+ void OnProcessSuccess(HXML node, ThreadData *info);
+ void OnProcessChallenge(HXML node, ThreadData *info);
+ void OnProcessProceed(HXML node, ThreadData *info);
+ void OnProcessCompressed(HXML node, ThreadData *info);
+ void OnProcessMessage(HXML node, ThreadData *info);
+ void OnProcessPresence(HXML node, ThreadData *info);
+ void OnProcessPresenceCapabilites(HXML node);
+ void OnProcessPubsubEvent(HXML node);
- void OnProcessStreamOpening( HXML node, ThreadData *info );
- void OnProcessProtocol( HXML node, ThreadData *info );
+ void OnProcessStreamOpening(HXML node, ThreadData *info);
+ void OnProcessProtocol(HXML node, ThreadData *info);
- void UpdateJidDbSettings( const TCHAR *jid );
- HANDLE CreateTemporaryContact( const TCHAR *szJid, JABBER_LIST_ITEM* chatItem );
+ void UpdateJidDbSettings(const TCHAR *jid);
+ HANDLE CreateTemporaryContact(const TCHAR *szJid, JABBER_LIST_ITEM* chatItem);
- void PerformRegistration( ThreadData* info );
- void PerformIqAuth( ThreadData* info );
- void PerformAuthentication( ThreadData* info );
- void OnProcessFeatures( HXML node, ThreadData* info );
+ void PerformRegistration(ThreadData* info);
+ void PerformIqAuth(ThreadData* info);
+ void PerformAuthentication(ThreadData* info);
+ void OnProcessFeatures(HXML node, ThreadData* info);
- void xmlStreamInitialize( char *which );
+ void xmlStreamInitialize(char *which);
void xmlStreamInitializeNow(ThreadData* info);
- BOOL OnProcessJingle( HXML node );
- void OnProcessIq( HXML node );
- void OnProcessRegIq( HXML node, ThreadData* info );
- void OnPingReply( HXML node, CJabberIqInfo* pInfo );
+ BOOL OnProcessJingle(HXML node);
+ void OnProcessIq(HXML node);
+ void OnProcessRegIq(HXML node, ThreadData* info);
+ void OnPingReply(HXML node, CJabberIqInfo* pInfo);
- bool ProcessCaptcha( HXML node, HXML parentNode, ThreadData *info );
+ bool ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info);
//---- jabber_util.c -----------------------------------------------------------------
- JABBER_RESOURCE_STATUS* ResourceInfoFromJID( const TCHAR* jid );
+ JABBER_RESOURCE_STATUS* ResourceInfoFromJID(const TCHAR *jid);
- void SerialInit( void );
- void SerialUninit( void );
- int SerialNext( void );
+ void SerialInit(void);
+ void SerialUninit(void);
+ int SerialNext(void);
- HANDLE HContactFromJID( const TCHAR* jid , BOOL bStripResource = 3);
- HANDLE ChatRoomHContactFromJID( const TCHAR* jid );
- void Log( const char* fmt, ... );
- void SendVisibleInvisiblePresence( BOOL invisible );
- void SendPresenceTo( int status, TCHAR* to, HXML extra, const TCHAR *msg = NULL );
- void SendPresence( int m_iStatus, bool bSendToAll );
- void StringAppend( char* *str, int *sizeAlloced, const char* fmt, ... );
- TCHAR* GetClientJID( const TCHAR* jid, TCHAR*, size_t );
- void RebuildInfoFrame( void );
+ HANDLE HContactFromJID(const TCHAR *jid , BOOL bStripResource = 3);
+ HANDLE ChatRoomHContactFromJID(const TCHAR *jid);
+ void Log(const char* fmt, ...);
+ void SendVisibleInvisiblePresence(BOOL invisible);
+ void SendPresenceTo(int status, TCHAR* to, HXML extra, const TCHAR *msg = NULL);
+ void SendPresence(int m_iStatus, bool bSendToAll);
+ void StringAppend(char* *str, int *sizeAlloced, const char* fmt, ...);
+ TCHAR* GetClientJID(const TCHAR *jid, TCHAR*, size_t);
+ void RebuildInfoFrame(void);
void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount=JABBER_DEFAULT_RECENT_COUNT);
void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, TCHAR *string, int recentCount=JABBER_DEFAULT_RECENT_COUNT);
BOOL EnterString(TCHAR *result, size_t resultLen, TCHAR *caption=NULL, int type=0, char *windowName=NULL, int recentCount=JABBER_DEFAULT_RECENT_COUNT, int timeout=0);
- BOOL IsMyOwnJID( LPCTSTR szJID );
+ BOOL IsMyOwnJID(LPCTSTR szJID);
void __cdecl LoadHttpAvatars(void* param);
@@ -925,40 +925,40 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject HWND m_hwndPhoto;
bool m_bPhotoChanged;
TCHAR m_szPhotoFileName[MAX_PATH];
- void OnUserInfoInit_VCard( WPARAM, LPARAM );
+ void OnUserInfoInit_VCard(WPARAM, LPARAM);
- void GroupchatJoinByHContact( HANDLE hContact, bool autojoin=false );
- int SendGetVcard( const TCHAR* jid );
- void AppendVcardFromDB( HXML n, char* tag, char* key );
- void SetServerVcard( BOOL bPhotoChanged, TCHAR* szPhotoFileName );
- void SaveVcardToDB( HWND hwndPage, int iPage );
+ void GroupchatJoinByHContact(HANDLE hContact, bool autojoin=false);
+ int SendGetVcard(const TCHAR *jid);
+ void AppendVcardFromDB(HXML n, char* tag, char* key);
+ void SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName);
+ void SaveVcardToDB(HWND hwndPage, int iPage);
//---- jabber_ws.c -------------------------------------------------
- JABBER_SOCKET WsConnect( char* host, WORD port );
+ JABBER_SOCKET WsConnect(char* host, WORD port);
BOOL WsInit(void);
void WsUninit(void);
- int WsSend( JABBER_SOCKET s, char* data, int datalen, int flags );
- int WsRecv( JABBER_SOCKET s, char* data, long datalen, int flags );
+ int WsSend(JABBER_SOCKET s, char* data, int datalen, int flags);
+ int WsRecv(JABBER_SOCKET s, char* data, long datalen, int flags);
//---- jabber_xml.c ------------------------------------------------------------------
- int OnXmlParse( char* buffer );
+ int OnXmlParse(char* buffer);
void OnConsoleProcessXml(HXML node, DWORD flags);
//---- jabber_xmlns.c ----------------------------------------------------------------
- BOOL OnHandleDiscoInfoRequest( HXML iqNode, CJabberIqInfo* pInfo );
- BOOL OnHandleDiscoItemsRequest( HXML iqNode, CJabberIqInfo* pInfo );
+ BOOL OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo* pInfo);
+ BOOL OnHandleDiscoItemsRequest(HXML iqNode, CJabberIqInfo* pInfo);
//---- jabber_xstatus.c --------------------------------------------------------------
- INT_PTR __cdecl OnSetListeningTo( WPARAM wParam, LPARAM lParams );
- INT_PTR __cdecl OnGetXStatusIcon( WPARAM wParam, LPARAM lParams );
- INT_PTR __cdecl OnGetXStatus( WPARAM wParam, LPARAM lParams );
- INT_PTR __cdecl OnSetXStatus( WPARAM wParam, LPARAM lParams );
- INT_PTR __cdecl OnSetXStatusEx( WPARAM wParam, LPARAM lParams );
+ INT_PTR __cdecl OnSetListeningTo(WPARAM wParam, LPARAM lParams);
+ INT_PTR __cdecl OnGetXStatusIcon(WPARAM wParam, LPARAM lParams);
+ INT_PTR __cdecl OnGetXStatus(WPARAM wParam, LPARAM lParams);
+ INT_PTR __cdecl OnSetXStatus(WPARAM wParam, LPARAM lParams);
+ INT_PTR __cdecl OnSetXStatusEx(WPARAM wParam, LPARAM lParams);
HICON GetXStatusIcon(int bStatus, UINT flags);
@@ -968,12 +968,12 @@ struct CJabberProto : public PROTO_INTERFACE, public MZeroedObject char* ReadAdvStatusA(HANDLE hContact, const char *pszSlot, const char *pszValue);
TCHAR* ReadAdvStatusT(HANDLE hContact, const char *pszSlot, const char *pszValue);
- BOOL SendPepTune( TCHAR* szArtist, TCHAR* szLength, TCHAR* szSource, TCHAR* szTitle, TCHAR* szTrack, TCHAR* szUri );
+ BOOL SendPepTune(TCHAR* szArtist, TCHAR* szLength, TCHAR* szSource, TCHAR* szTitle, TCHAR* szTrack, TCHAR* szUri);
- void XStatusInit( void );
- void XStatusUninit( void );
+ void XStatusInit(void);
+ void XStatusUninit(void);
- void SetContactTune( HANDLE hContact, LPCTSTR szArtist, LPCTSTR szLength, LPCTSTR szSource, LPCTSTR szTitle, LPCTSTR szTrack );
+ void SetContactTune(HANDLE hContact, LPCTSTR szArtist, LPCTSTR szLength, LPCTSTR szSource, LPCTSTR szTitle, LPCTSTR szTrack);
void InfoFrame_OnUserMood(CJabberInfoFrame_Event *evt);
void InfoFrame_OnUserActivity(CJabberInfoFrame_Event *evt);
diff --git a/protocols/JabberG/src/jabber_proxy.cpp b/protocols/JabberG/src/jabber_proxy.cpp index 1702eb52de..e36558e94f 100644 --- a/protocols/JabberG/src/jabber_proxy.cpp +++ b/protocols/JabberG/src/jabber_proxy.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
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber.h"
-int JabberHttpGatewayInit( HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/, NETLIBHTTPREQUEST* /*nlhr*/ )
+int JabberHttpGatewayInit(HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/, NETLIBHTTPREQUEST* /*nlhr*/)
{
#ifdef NNNN
WORD wLen, wVersion, wType;
@@ -33,120 +33,120 @@ int JabberHttpGatewayInit( HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/, NET char szSid[33], szHttpServer[256], szHttpGetUrl[300], szHttpPostUrl[300];
NETLIBHTTPPROXYINFO nlhpi = {0};
- for ( responseBytes = 0; ; ) {
- recvResult = Netlib_Recv( hConn, response + responseBytes, sizeof( response ) - responseBytes, MSG_DUMPPROXY );
- if ( recvResult<=0 ) break;
+ for (responseBytes = 0; ;) {
+ recvResult = Netlib_Recv(hConn, response + responseBytes, sizeof(response) - responseBytes, MSG_DUMPPROXY);
+ if (recvResult<=0) break;
responseBytes += recvResult;
- if ( responseBytes == sizeof( response ))
+ if (responseBytes == sizeof(response))
break;
}
- if ( responseBytes < 31 )
+ if (responseBytes < 31)
{
- SetLastError( ERROR_INVALID_DATA );
+ SetLastError(ERROR_INVALID_DATA);
return 0;
}
buf = response;
- unpackWord( &buf, &wLen );
- unpackWord( &buf, &wVersion ); /* always 0x0443 */
- unpackWord( &buf, &wType );
+ unpackWord(&buf, &wLen);
+ unpackWord(&buf, &wVersion); /* always 0x0443 */
+ unpackWord(&buf, &wType);
buf += 6; /* dunno */
- unpackDWord( &buf, &dwSid1 );
- unpackDWord( &buf, &dwSid2 );
- unpackDWord( &buf, &dwSid3 );
- unpackDWord( &buf, &dwSid4 );
- sprintf( szSid, "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4 );
- unpackWord( &buf, &wIpLen );
- if ( responseBytes < 30 + wIpLen || wIpLen == 0 || wIpLen > sizeof( szHttpServer ) - 1 )
+ unpackDWord(&buf, &dwSid1);
+ unpackDWord(&buf, &dwSid2);
+ unpackDWord(&buf, &dwSid3);
+ unpackDWord(&buf, &dwSid4);
+ sprintf(szSid, "%08x%08x%08x%08x", dwSid1, dwSid2, dwSid3, dwSid4);
+ unpackWord(&buf, &wIpLen);
+ if (responseBytes < 30 + wIpLen || wIpLen == 0 || wIpLen > sizeof(szHttpServer) - 1)
{
- SetLastError( ERROR_INVALID_DATA );
+ SetLastError(ERROR_INVALID_DATA);
return 0;
}
- memcpy( szHttpServer, buf, wIpLen );
+ memcpy(szHttpServer, buf, wIpLen);
szHttpServer[wIpLen] = '\0';
- nlhpi.cbSize = sizeof( nlhpi );
+ nlhpi.cbSize = sizeof(nlhpi);
nlhpi.flags = NLHPIF_USEPOSTSEQUENCE;
nlhpi.szHttpGetUrl = szHttpGetUrl;
nlhpi.szHttpPostUrl = szHttpPostUrl;
nlhpi.firstPostSequence = 1;
- sprintf( szHttpGetUrl, "http://%s/monitor?sid=%s", szHttpServer, szSid );
- sprintf( szHttpPostUrl, "http://%s/data?sid=%s&seq=", szHttpServer, szSid );
- return CallService( MS_NETLIB_SETHTTPPROXYINFO, ( WPARAM )hConn, ( LPARAM )&nlhpi );
+ sprintf(szHttpGetUrl, "http://%s/monitor?sid=%s", szHttpServer, szSid);
+ sprintf(szHttpPostUrl, "http://%s/data?sid=%s&seq=", szHttpServer, szSid);
+ return CallService(MS_NETLIB_SETHTTPPROXYINFO, (WPARAM)hConn, (LPARAM)&nlhpi);
#endif
return 1;
}
-int JabberHttpGatewayBegin( HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/ )
+int JabberHttpGatewayBegin(HANDLE /*hConn*/, NETLIBOPENCONNECTION* /*nloc*/)
{
/*
icq_packet packet;
int serverNameLen;
- serverNameLen = strlen( nloc->szHost );
+ serverNameLen = strlen(nloc->szHost);
- packet.wLen = ( WORD )( serverNameLen + 4 );
- write_httphdr( &packet, HTTP_PACKETTYPE_LOGIN );
- packWord( &packet, ( WORD )serverNameLen );
- packString( &packet, nloc->szHost, ( WORD )serverNameLen );
- packWord( &packet, nloc->wPort );
- Netlib_Send( hConn, packet.pData, packet.wLen, MSG_DUMPPROXY|MSG_NOHTTPGATEWAYWRAP );
- mir_free( packet.pData );
+ packet.wLen = (WORD)(serverNameLen + 4);
+ write_httphdr(&packet, HTTP_PACKETTYPE_LOGIN);
+ packWord(&packet, (WORD)serverNameLen);
+ packString(&packet, nloc->szHost, (WORD)serverNameLen);
+ packWord(&packet, nloc->wPort);
+ Netlib_Send(hConn, packet.pData, packet.wLen, MSG_DUMPPROXY|MSG_NOHTTPGATEWAYWRAP);
+ mir_free(packet.pData);
return 1;
*/
return 1;
}
-int JabberHttpGatewayWrapSend( HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend )
+int JabberHttpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRANDASERVICE pfnNetlibSend)
{
- TCHAR* strb = mir_utf8decodeW(( char* )buf );
+ TCHAR* strb = mir_utf8decodeW((char*)buf);
TCHAR sid[25] = _T("");
unsigned __int64 rid = 0;
- XmlNode hPayLoad( strb );
- XmlNode body( _T("body"));
- HXML hBody = body << XATTRI64( _T("rid"), rid++ ) << XATTR( _T("sid"), sid ) <<
- XATTR( _T("xmlns"), _T( "http://jabber.org/protocol/httpbind" ));
- xmlAddChild( hBody, hPayLoad );
+ XmlNode hPayLoad(strb);
+ XmlNode body(_T("body"));
+ HXML hBody = body << XATTRI64(_T("rid"), rid++) << XATTR(_T("sid"), sid) <<
+ XATTR(_T("xmlns"), _T("http://jabber.org/protocol/httpbind"));
+ xmlAddChild(hBody, hPayLoad);
- TCHAR* str = xi.toString( hBody, NULL );
+ TCHAR* str = xi.toString(hBody, NULL);
- mir_free( strb );
- char* utfStr = mir_utf8encodeT( str );
- NETLIBBUFFER nlb = { utfStr, (int)strlen( utfStr ), flags };
- int result = pfnNetlibSend(( WPARAM )hConn, ( LPARAM )&nlb);
- mir_free( utfStr );
- xi.freeMem( str );
+ mir_free(strb);
+ char* utfStr = mir_utf8encodeT(str);
+ NETLIBBUFFER nlb = { utfStr, (int)strlen(utfStr), flags };
+ int result = pfnNetlibSend((WPARAM)hConn, (LPARAM)&nlb);
+ mir_free(utfStr);
+ xi.freeMem(str);
return result;
}
#if 0
-PBYTE JabberHttpGatewayUnwrapRecv( NETLIBHTTPREQUEST *nlhr, PBYTE buf, int len, int *outBufLen, void *( *NetlibRealloc )( void *, size_t ))
+PBYTE JabberHttpGatewayUnwrapRecv(NETLIBHTTPREQUEST *nlhr, PBYTE buf, int len, int *outBufLen, void *(*NetlibRealloc)(void *, size_t))
{
WORD wLen, wType;
PBYTE tbuf;
int i, copyBytes;
tbuf = buf;
- for ( i = 0;; )
+ for (i = 0;;)
{
- if ( tbuf - buf + 2 > len ) break;
- unpackWord( &tbuf, &wLen );
- if ( wLen < 12 ) break;
- if ( tbuf - buf + wLen > len ) break;
+ if (tbuf - buf + 2 > len) break;
+ unpackWord(&tbuf, &wLen);
+ if (wLen < 12) break;
+ if (tbuf - buf + wLen > len) break;
tbuf += 2; /* version */
- unpackWord( &tbuf, &wType );
+ unpackWord(&tbuf, &wType);
tbuf += 8; /* flags & subtype */
- if ( wType == HTTP_PACKETTYPE_FLAP )
+ if (wType == HTTP_PACKETTYPE_FLAP)
{
copyBytes = wLen - 12;
- if ( copyBytes > len - i )
+ if (copyBytes > len - i)
{
/* invalid data - do our best to get something out of it */
copyBytes = len - i;
}
- memcpy( buf + i, tbuf, copyBytes );
+ memcpy(buf + i, tbuf, copyBytes);
i += copyBytes;
}
tbuf += wLen - 12;
diff --git a/protocols/JabberG/src/jabber_proxy.h b/protocols/JabberG/src/jabber_proxy.h index a42591f81e..b9bc03c73e 100644 --- a/protocols/JabberG/src/jabber_proxy.h +++ b/protocols/JabberG/src/jabber_proxy.h @@ -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
@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _JABBER_PROXY_H_
#define _JABBER_PROXY_H_
-int JabberHttpGatewayInit( HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr );
-int JabberHttpGatewayBegin( HANDLE hConn, NETLIBOPENCONNECTION *nloc );
+int JabberHttpGatewayInit(HANDLE hConn, NETLIBOPENCONNECTION *nloc, NETLIBHTTPREQUEST *nlhr);
+int JabberHttpGatewayBegin(HANDLE hConn, NETLIBOPENCONNECTION *nloc);
#endif
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index 0021733356..53f5310b28 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -1,16 +1,16 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
XEP-0146 support for Miranda IM
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
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_rc.h"
#include "m_awaymsg.h"
-CJabberAdhocSession::CJabberAdhocSession( CJabberProto* global )
+CJabberAdhocSession::CJabberAdhocSession(CJabberProto* global)
{
m_pNext = NULL;
m_pUserData = NULL;
@@ -39,178 +39,178 @@ CJabberAdhocSession::CJabberAdhocSession( CJabberProto* global ) m_dwStartTime = GetTickCount();
}
-BOOL CJabberProto::IsRcRequestAllowedByACL( CJabberIqInfo* pInfo )
+BOOL CJabberProto::IsRcRequestAllowedByACL(CJabberIqInfo* pInfo)
{
if ( !pInfo || !pInfo->GetFrom())
return FALSE;
- return IsMyOwnJID( pInfo->GetFrom());
+ return IsMyOwnJID(pInfo->GetFrom());
}
-BOOL CJabberProto::HandleAdhocCommandRequest( HXML iqNode, CJabberIqInfo* pInfo )
+BOOL CJabberProto::HandleAdhocCommandRequest(HXML iqNode, CJabberIqInfo* pInfo)
{
if ( !pInfo->GetChildNode())
return TRUE;
- if ( !m_options.EnableRemoteControl || !IsRcRequestAllowedByACL( pInfo )) {
+ if ( !m_options.EnableRemoteControl || !IsRcRequestAllowedByACL(pInfo)) {
// FIXME: send error and return
return TRUE;
}
- const TCHAR* szNode = xmlGetAttrValue( pInfo->GetChildNode(), _T("node"));
- if ( !szNode )
+ const TCHAR *szNode = xmlGetAttrValue(pInfo->GetChildNode(), _T("node"));
+ if ( !szNode)
return TRUE;
- m_adhocManager.HandleCommandRequest( iqNode, pInfo, ( TCHAR* )szNode );
+ m_adhocManager.HandleCommandRequest(iqNode, pInfo, (TCHAR*)szNode);
return TRUE;
}
-BOOL CJabberAdhocManager::HandleItemsRequest( HXML, CJabberIqInfo* pInfo, const TCHAR* szNode )
+BOOL CJabberAdhocManager::HandleItemsRequest(HXML, CJabberIqInfo* pInfo, const TCHAR *szNode)
{
- if ( !szNode || !m_pProto->m_options.EnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL( pInfo ))
+ if ( !szNode || !m_pProto->m_options.EnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL(pInfo))
return FALSE;
- if ( !_tcscmp( szNode, _T(JABBER_FEAT_COMMANDS)))
+ if ( !_tcscmp(szNode, _T(JABBER_FEAT_COMMANDS)))
{
- XmlNodeIq iq( _T("result"), pInfo );
- HXML resultQuery = iq << XQUERY( _T(JABBER_FEAT_DISCO_ITEMS)) << XATTR( _T("node"), _T(JABBER_FEAT_COMMANDS));
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML resultQuery = iq << XQUERY(_T(JABBER_FEAT_DISCO_ITEMS)) << XATTR(_T("node"), _T(JABBER_FEAT_COMMANDS));
Lock();
CJabberAdhocNode* pNode = GetFirstNode();
- while ( pNode ) {
+ while (pNode) {
TCHAR* szJid = pNode->GetJid();
- if ( !szJid )
+ if ( !szJid)
szJid = m_pProto->m_ThreadInfo->fullJID;
- resultQuery << XCHILD( _T("item")) << XATTR( _T("jid"), szJid )
- << XATTR( _T("node"), pNode->GetNode()) << XATTR( _T("name"), pNode->GetName());
+ resultQuery << XCHILD(_T("item")) << XATTR(_T("jid"), szJid)
+ << XATTR(_T("node"), pNode->GetNode()) << XATTR(_T("name"), pNode->GetName());
pNode = pNode->GetNext();
}
Unlock();
- m_pProto->m_ThreadInfo->send( iq );
+ m_pProto->m_ThreadInfo->send(iq);
return TRUE;
}
return FALSE;
}
-BOOL CJabberAdhocManager::HandleInfoRequest( HXML, CJabberIqInfo* pInfo, const TCHAR* szNode )
+BOOL CJabberAdhocManager::HandleInfoRequest(HXML, CJabberIqInfo* pInfo, const TCHAR *szNode)
{
- if ( !szNode || !m_pProto->m_options.EnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL( pInfo ))
+ if ( !szNode || !m_pProto->m_options.EnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL(pInfo))
return FALSE;
// FIXME: same code twice
- if ( !_tcscmp( szNode, _T(JABBER_FEAT_COMMANDS))) {
- XmlNodeIq iq( _T("result"), pInfo );
- HXML resultQuery = iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO)) << XATTR( _T("node"), _T(JABBER_FEAT_COMMANDS));
- resultQuery << XCHILD( _T("identity")) << XATTR( _T("name"), _T("Ad-hoc commands"))
- << XATTR( _T("category"), _T("automation")) << XATTR( _T("type"), _T("command-node"));
-
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_COMMANDS));
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_DATA_FORMS));
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_DISCO_INFO));
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_DISCO_ITEMS));
-
- m_pProto->m_ThreadInfo->send( iq );
+ if ( !_tcscmp(szNode, _T(JABBER_FEAT_COMMANDS))) {
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML resultQuery = iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO)) << XATTR(_T("node"), _T(JABBER_FEAT_COMMANDS));
+ resultQuery << XCHILD(_T("identity")) << XATTR(_T("name"), _T("Ad-hoc commands"))
+ << XATTR(_T("category"), _T("automation")) << XATTR(_T("type"), _T("command-node"));
+
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_COMMANDS));
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_DATA_FORMS));
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_DISCO_INFO));
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_DISCO_ITEMS));
+
+ m_pProto->m_ThreadInfo->send(iq);
return TRUE;
}
Lock();
- CJabberAdhocNode *pNode = FindNode( szNode );
- if ( pNode ) {
- XmlNodeIq iq( _T("result"), pInfo );
- HXML resultQuery = iq << XQUERY( _T(JABBER_FEAT_DISCO_INFO)) << XATTR( _T("node"), _T(JABBER_FEAT_DISCO_INFO));
- resultQuery << XCHILD( _T("identity")) << XATTR( _T("name"), pNode->GetName())
- << XATTR( _T("category"), _T("automation")) << XATTR( _T("type"), _T("command-node"));
+ CJabberAdhocNode *pNode = FindNode(szNode);
+ if (pNode) {
+ XmlNodeIq iq(_T("result"), pInfo);
+ HXML resultQuery = iq << XQUERY(_T(JABBER_FEAT_DISCO_INFO)) << XATTR(_T("node"), _T(JABBER_FEAT_DISCO_INFO));
+ resultQuery << XCHILD(_T("identity")) << XATTR(_T("name"), pNode->GetName())
+ << XATTR(_T("category"), _T("automation")) << XATTR(_T("type"), _T("command-node"));
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_COMMANDS));
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_DATA_FORMS));
- resultQuery << XCHILD( _T("feature")) << XATTR( _T("var"), _T(JABBER_FEAT_DISCO_INFO));
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_COMMANDS));
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_DATA_FORMS));
+ resultQuery << XCHILD(_T("feature")) << XATTR(_T("var"), _T(JABBER_FEAT_DISCO_INFO));
Unlock();
- m_pProto->m_ThreadInfo->send( iq );
+ m_pProto->m_ThreadInfo->send(iq);
return TRUE;
}
Unlock();
return FALSE;
}
-BOOL CJabberAdhocManager::HandleCommandRequest( HXML iqNode, CJabberIqInfo* pInfo, const TCHAR* szNode )
+BOOL CJabberAdhocManager::HandleCommandRequest(HXML iqNode, CJabberIqInfo* pInfo, const TCHAR *szNode)
{
// ATTN: ACL and db settings checked in calling function
HXML commandNode = pInfo->GetChildNode();
Lock();
- CJabberAdhocNode* pNode = FindNode( szNode );
- if ( !pNode ) {
+ CJabberAdhocNode* pNode = FindNode(szNode);
+ if ( !pNode) {
Unlock();
- m_pProto->m_ThreadInfo->send(
- XmlNodeIq( _T("error"), pInfo )
- << XCHILD( _T("error")) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ m_pProto->m_ThreadInfo->send(
+ XmlNodeIq(_T("error"), pInfo)
+ << XCHILD(_T("error")) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
return FALSE;
}
- const TCHAR* szSessionId = xmlGetAttrValue( commandNode, _T("sessionid"));
+ const TCHAR *szSessionId = xmlGetAttrValue(commandNode, _T("sessionid"));
CJabberAdhocSession* pSession = NULL;
- if ( szSessionId ) {
- pSession = FindSession( szSessionId );
- if ( !pSession ) {
+ if (szSessionId) {
+ pSession = FindSession(szSessionId);
+ if ( !pSession) {
Unlock();
- XmlNodeIq iq( _T("error"), pInfo );
- HXML errorNode = iq << XCHILD( _T("error")) << XATTR( _T("type"), _T("modify"));
- errorNode << XCHILDNS( _T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
- errorNode << XCHILDNS( _T("bad-sessionid"), _T(JABBER_FEAT_COMMANDS));
- m_pProto->m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), pInfo);
+ HXML errorNode = iq << XCHILD(_T("error")) << XATTR(_T("type"), _T("modify"));
+ errorNode << XCHILDNS(_T("bad-request"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
+ errorNode << XCHILDNS(_T("bad-sessionid"), _T(JABBER_FEAT_COMMANDS));
+ m_pProto->m_ThreadInfo->send(iq);
return FALSE;
}
}
else
pSession = AddNewSession();
- if ( !pSession ) {
+ if ( !pSession) {
Unlock();
m_pProto->m_ThreadInfo->send(
- XmlNodeIq( _T("error"), pInfo )
- << XCHILD( _T("error")) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("forbidden"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ XmlNodeIq(_T("error"), pInfo)
+ << XCHILD(_T("error")) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("forbidden"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
return FALSE;
}
// session id and node exits here, call handler
- int nResultCode = pNode->CallHandler( iqNode, pInfo, pSession );
+ int nResultCode = pNode->CallHandler(iqNode, pInfo, pSession);
- if ( nResultCode == JABBER_ADHOC_HANDLER_STATUS_COMPLETED ) {
+ if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_COMPLETED) {
m_pProto->m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), szNode )
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("completed"))
- << XCHILD( _T("note"), TranslateT("Command completed successfully")) << XATTR( _T("type"), _T("info")));
+ XmlNodeIq(_T("result"), pInfo)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), szNode)
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("completed"))
+ << XCHILD(_T("note"), TranslateT("Command completed successfully")) << XATTR(_T("type"), _T("info")));
- RemoveSession( pSession );
+ RemoveSession(pSession);
pSession = NULL;
}
- else if ( nResultCode == JABBER_ADHOC_HANDLER_STATUS_CANCEL ) {
+ else if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_CANCEL) {
m_pProto->m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), szNode )
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("canceled"))
- << XCHILD( _T("note"), TranslateT("Error occured during processing command")) << XATTR( _T("type"), _T("error")));
+ XmlNodeIq(_T("result"), pInfo)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), szNode)
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("canceled"))
+ << XCHILD(_T("note"), TranslateT("Error occured during processing command")) << XATTR(_T("type"), _T("error")));
- RemoveSession( pSession );
+ RemoveSession(pSession);
pSession = NULL;
}
- else if ( nResultCode == JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION ) {
- RemoveSession( pSession );
+ else if (nResultCode == JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION) {
+ RemoveSession(pSession);
pSession = NULL;
}
Unlock();
@@ -219,12 +219,12 @@ BOOL CJabberAdhocManager::HandleCommandRequest( HXML iqNode, CJabberIqInfo* pInf BOOL CJabberAdhocManager::FillDefaultNodes()
{
- AddNode( NULL, _T(JABBER_FEAT_RC_SET_STATUS), TranslateT("Set status"), &CJabberProto::AdhocSetStatusHandler );
- AddNode( NULL, _T(JABBER_FEAT_RC_SET_OPTIONS), TranslateT("Set options"), &CJabberProto::AdhocOptionsHandler );
- AddNode( NULL, _T(JABBER_FEAT_RC_FORWARD), TranslateT("Forward unread messages"), &CJabberProto::AdhocForwardHandler );
- AddNode( NULL, _T(JABBER_FEAT_RC_LEAVE_GROUPCHATS), TranslateT("Leave groupchats"), &CJabberProto::AdhocLeaveGroupchatsHandler );
- AddNode( NULL, _T(JABBER_FEAT_RC_WS_LOCK), TranslateT("Lock workstation"), &CJabberProto::AdhocLockWSHandler );
- AddNode( NULL, _T(JABBER_FEAT_RC_QUIT_MIRANDA), TranslateT("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler );
+ AddNode(NULL, _T(JABBER_FEAT_RC_SET_STATUS), TranslateT("Set status"), &CJabberProto::AdhocSetStatusHandler);
+ AddNode(NULL, _T(JABBER_FEAT_RC_SET_OPTIONS), TranslateT("Set options"), &CJabberProto::AdhocOptionsHandler);
+ AddNode(NULL, _T(JABBER_FEAT_RC_FORWARD), TranslateT("Forward unread messages"), &CJabberProto::AdhocForwardHandler);
+ AddNode(NULL, _T(JABBER_FEAT_RC_LEAVE_GROUPCHATS), TranslateT("Leave groupchats"), &CJabberProto::AdhocLeaveGroupchatsHandler);
+ AddNode(NULL, _T(JABBER_FEAT_RC_WS_LOCK), TranslateT("Lock workstation"), &CJabberProto::AdhocLockWSHandler);
+ AddNode(NULL, _T(JABBER_FEAT_RC_QUIT_MIRANDA), TranslateT("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler);
return TRUE;
}
@@ -252,219 +252,219 @@ static char *StatusModeToDbSetting(int status,const char *suffix) return str;
}
-int CJabberProto::AdhocSetStatusHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+int CJabberProto::AdhocSetStatusHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
- if ( pSession->GetStage() == 0 ) {
+ if (pSession->GetStage() == 0) {
// first form
- pSession->SetStage( 1 );
+ pSession->SetStage(1);
- XmlNodeIq iq( _T("result"), pInfo );
+ XmlNodeIq iq(_T("result"), pInfo);
HXML xNode = iq
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_SET_STATUS))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("executing"))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("form"));
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_SET_STATUS))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("executing"))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("form"));
- xNode << XCHILD( _T("title"), TranslateT("Change Status"));
- xNode << XCHILD( _T("instructions"), TranslateT("Choose the status and status message"));
+ xNode << XCHILD(_T("title"), TranslateT("Change Status"));
+ xNode << XCHILD(_T("instructions"), TranslateT("Choose the status and status message"));
- xNode << XCHILD( _T("field")) << XATTR( _T("type"), _T("hidden")) << XATTR( _T("var"), _T("FORM_TYPE"))
- << XATTR( _T("value"), _T(JABBER_FEAT_RC));
+ xNode << XCHILD(_T("field")) << XATTR(_T("type"), _T("hidden")) << XATTR(_T("var"), _T("FORM_TYPE"))
+ << XATTR(_T("value"), _T(JABBER_FEAT_RC));
- HXML fieldNode = xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Status"))
- << XATTR( _T("type"), _T("list-single")) << XATTR( _T("var"), _T("status"));
+ HXML fieldNode = xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Status"))
+ << XATTR(_T("type"), _T("list-single")) << XATTR(_T("var"), _T("status"));
- fieldNode << XCHILD( _T("required"));
+ fieldNode << XCHILD(_T("required"));
- int status = CallService( MS_CLIST_GETSTATUSMODE, 0, 0 );
- switch ( status ) {
+ int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+ switch (status) {
case ID_STATUS_INVISIBLE:
- fieldNode << XCHILD( _T("value"), _T("invisible"));
+ fieldNode << XCHILD(_T("value"), _T("invisible"));
break;
case ID_STATUS_AWAY:
case ID_STATUS_ONTHEPHONE:
case ID_STATUS_OUTTOLUNCH:
- fieldNode << XCHILD( _T("value"), _T("away"));
+ fieldNode << XCHILD(_T("value"), _T("away"));
break;
case ID_STATUS_NA:
- fieldNode << XCHILD( _T("value"), _T("xa"));
+ fieldNode << XCHILD(_T("value"), _T("xa"));
break;
case ID_STATUS_DND:
case ID_STATUS_OCCUPIED:
- fieldNode << XCHILD( _T("value"), _T("dnd"));
+ fieldNode << XCHILD(_T("value"), _T("dnd"));
break;
case ID_STATUS_FREECHAT:
- fieldNode << XCHILD( _T("value"), _T("chat"));
+ fieldNode << XCHILD(_T("value"), _T("chat"));
break;
case ID_STATUS_ONLINE:
default:
- fieldNode << XCHILD( _T("value"), _T("online"));
+ fieldNode << XCHILD(_T("value"), _T("online"));
break;
}
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Free for chat")) << XCHILD( _T("value"), _T("chat"));
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Online")) << XCHILD( _T("value"), _T("online"));
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Away")) << XCHILD( _T("value"), _T("away"));
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Extended Away (N/A)")) << XCHILD( _T("value"), _T("xa"));
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Do Not Disturb")) << XCHILD( _T("value"), _T("dnd"));
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Invisible")) << XCHILD( _T("value"), _T("invisible"));
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), TranslateT("Offline")) << XCHILD( _T("value"), _T("offline"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Free for chat")) << XCHILD(_T("value"), _T("chat"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Online")) << XCHILD(_T("value"), _T("online"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Away")) << XCHILD(_T("value"), _T("away"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Extended Away (N/A)")) << XCHILD(_T("value"), _T("xa"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Do Not Disturb")) << XCHILD(_T("value"), _T("dnd"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Invisible")) << XCHILD(_T("value"), _T("invisible"));
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), TranslateT("Offline")) << XCHILD(_T("value"), _T("offline"));
// priority
TCHAR szPriority[ 256 ];
- mir_sntprintf( szPriority, SIZEOF(szPriority), _T("%d"), (short)JGetWord( NULL, "Priority", 5 ));
- xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Priority")) << XATTR( _T("type"), _T("text-single"))
- << XATTR( _T("var"), _T("status-priority")) << XCHILD( _T("value"), szPriority );
+ mir_sntprintf(szPriority, SIZEOF(szPriority), _T("%d"), (short)JGetWord(NULL, "Priority", 5));
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Priority")) << XATTR(_T("type"), _T("text-single"))
+ << XATTR(_T("var"), _T("status-priority")) << XCHILD(_T("value"), szPriority);
// status message text
- xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Status message"))
- << XATTR( _T("type"), _T("text-multi")) << XATTR( _T("var"), _T("status-message"));
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Status message"))
+ << XATTR(_T("type"), _T("text-multi")) << XATTR(_T("var"), _T("status-message"));
// global status
- fieldNode = xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Change global status"))
- << XATTR( _T("type"), _T("boolean")) << XATTR( _T("var"), _T("status-global"));
+ fieldNode = xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Change global status"))
+ << XATTR(_T("type"), _T("boolean")) << XATTR(_T("var"), _T("status-global"));
- char* szStatusMsg = (char *)CallService( MS_AWAYMSG_GETSTATUSMSG, status, 0 );
- if ( szStatusMsg ) {
- fieldNode << XCHILD( _T("value"), _A2T(szStatusMsg));
- mir_free( szStatusMsg );
+ char* szStatusMsg = (char *)CallService(MS_AWAYMSG_GETSTATUSMSG, status, 0);
+ if (szStatusMsg) {
+ fieldNode << XCHILD(_T("value"), _A2T(szStatusMsg));
+ mir_free(szStatusMsg);
}
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
- else if ( pSession->GetStage() == 1 ) {
+ else if (pSession->GetStage() == 1) {
// result form here
HXML commandNode = pInfo->GetChildNode();
- HXML xNode = xmlGetChildByTag( commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
- if ( !xNode )
+ HXML xNode = xmlGetChildByTag(commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
- HXML fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("status"));
- if ( !xNode )
+ HXML fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("status"));
+ if ( !xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
- HXML valueNode = xmlGetChild( fieldNode , "value" );
- if ( !valueNode || !xmlGetText( valueNode ))
+ HXML valueNode = xmlGetChild(fieldNode , "value");
+ if ( !valueNode || !xmlGetText(valueNode))
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
int status = 0;
- if ( !_tcscmp( xmlGetText( valueNode ), _T("away"))) status = ID_STATUS_AWAY;
- else if ( !_tcscmp( xmlGetText( valueNode ), _T("xa"))) status = ID_STATUS_NA;
- else if ( !_tcscmp( xmlGetText( valueNode ), _T("dnd"))) status = ID_STATUS_DND;
- else if ( !_tcscmp( xmlGetText( valueNode ), _T("chat"))) status = ID_STATUS_FREECHAT;
- else if ( !_tcscmp( xmlGetText( valueNode ), _T("online"))) status = ID_STATUS_ONLINE;
- else if ( !_tcscmp( xmlGetText( valueNode ), _T("invisible"))) status = ID_STATUS_INVISIBLE;
- else if ( !_tcscmp( xmlGetText( valueNode ), _T("offline"))) status = ID_STATUS_OFFLINE;
+ if ( !_tcscmp(xmlGetText(valueNode), _T("away"))) status = ID_STATUS_AWAY;
+ else if ( !_tcscmp(xmlGetText(valueNode), _T("xa"))) status = ID_STATUS_NA;
+ else if ( !_tcscmp(xmlGetText(valueNode), _T("dnd"))) status = ID_STATUS_DND;
+ else if ( !_tcscmp(xmlGetText(valueNode), _T("chat"))) status = ID_STATUS_FREECHAT;
+ else if ( !_tcscmp(xmlGetText(valueNode), _T("online"))) status = ID_STATUS_ONLINE;
+ else if ( !_tcscmp(xmlGetText(valueNode), _T("invisible"))) status = ID_STATUS_INVISIBLE;
+ else if ( !_tcscmp(xmlGetText(valueNode), _T("offline"))) status = ID_STATUS_OFFLINE;
- if ( !status )
+ if ( !status)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
int priority = -9999;
- fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("status-priority"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ))
- priority = _ttoi( xmlGetText( valueNode ));
+ fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("status-priority"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode))
+ priority = _ttoi(xmlGetText(valueNode));
}
- if ( priority >= -128 && priority <= 127 )
- JSetWord( NULL, "Priority", (WORD)priority );
+ if (priority >= -128 && priority <= 127)
+ JSetWord(NULL, "Priority", (WORD)priority);
- const TCHAR* szStatusMessage = NULL;
- fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("status-message"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ))
- szStatusMessage = xmlGetText( valueNode );
+ const TCHAR *szStatusMessage = NULL;
+ fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("status-message"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode))
+ szStatusMessage = xmlGetText(valueNode);
}
// skip f...ng away dialog
- int nNoDlg = DBGetContactSettingByte( NULL, "SRAway", StatusModeToDbSetting( status, "NoDlg" ), 0 );
- DBWriteContactSettingByte( NULL, "SRAway", StatusModeToDbSetting( status, "NoDlg" ), 1 );
+ int nNoDlg = db_get_b(NULL, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 0);
+ db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, "NoDlg"), 1);
- DBWriteContactSettingTString( NULL, "SRAway", StatusModeToDbSetting( status, "Msg" ), szStatusMessage ? szStatusMessage : _T( "" ));
+ db_set_ts(NULL, "SRAway", StatusModeToDbSetting(status, "Msg"), szStatusMessage ? szStatusMessage : _T(""));
- fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("status-global"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ) && _ttoi( xmlGetText( valueNode )))
- CallService( MS_CLIST_SETSTATUSMODE, status, NULL );
+ fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("status-global"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode) && _ttoi(xmlGetText(valueNode)))
+ CallService(MS_CLIST_SETSTATUSMODE, status, NULL);
else
- CallProtoService( m_szModuleName, PS_SETSTATUS, status, NULL );
+ CallProtoService(m_szModuleName, PS_SETSTATUS, status, NULL);
}
- SetAwayMsg( status, szStatusMessage );
+ SetAwayMsg(status, szStatusMessage);
// return NoDlg setting
- DBWriteContactSettingByte( NULL, "SRAway", StatusModeToDbSetting( status, "NoDlg" ), (BYTE)nNoDlg );
+ db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, "NoDlg"), (BYTE)nNoDlg);
return JABBER_ADHOC_HANDLER_STATUS_COMPLETED;
}
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
}
-int CJabberProto::AdhocOptionsHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
- if ( pSession->GetStage() == 0 ) {
+ if (pSession->GetStage() == 0) {
// first form
- pSession->SetStage( 1 );
+ pSession->SetStage(1);
- XmlNodeIq iq( _T("result"), pInfo );
+ XmlNodeIq iq(_T("result"), pInfo);
HXML xNode = iq
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_SET_OPTIONS))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("executing"))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("form"));
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_SET_OPTIONS))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("executing"))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("form"));
- xNode << XCHILD( _T("title"), TranslateT("Set Options"));
- xNode << XCHILD( _T("instructions"), TranslateT("Set the desired options"));
+ xNode << XCHILD(_T("title"), TranslateT("Set Options"));
+ xNode << XCHILD(_T("instructions"), TranslateT("Set the desired options"));
- xNode << XCHILD( _T("field" )) << XATTR( _T("type"), _T("hidden")) << XATTR( _T("var"), _T("FORM_TYPE"))
- << XATTR( _T("value"), _T(JABBER_FEAT_RC));
+ xNode << XCHILD(_T("field")) << XATTR(_T("type"), _T("hidden")) << XATTR(_T("var"), _T("FORM_TYPE"))
+ << XATTR(_T("value"), _T(JABBER_FEAT_RC));
// Automatically Accept File Transfers
TCHAR szTmpBuff[ 1024 ];
- mir_sntprintf( szTmpBuff, SIZEOF(szTmpBuff), _T("%d"), DBGetContactSettingByte( NULL, "SRFile", "AutoAccept", 0 ));
- xNode << XCHILD( _T("field" )) << XATTR( _T("label"), TranslateT("Automatically Accept File Transfers" ))
- << XATTR( _T("type"), _T("boolean")) << XATTR( _T("var"), _T("auto-files")) << XCHILD( _T("value"), szTmpBuff );
+ mir_sntprintf(szTmpBuff, SIZEOF(szTmpBuff), _T("%d"), db_get_b(NULL, "SRFile", "AutoAccept", 0));
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Automatically Accept File Transfers"))
+ << XATTR(_T("type"), _T("boolean")) << XATTR(_T("var"), _T("auto-files")) << XCHILD(_T("value"), szTmpBuff);
// Use sounds
- mir_sntprintf( szTmpBuff, SIZEOF(szTmpBuff), _T("%d"), DBGetContactSettingByte( NULL, "Skin", "UseSound", 0 ));
- xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Play sounds"))
- << XATTR( _T("type"), _T("boolean")) << XATTR( _T("var"), _T("sounds")) << XCHILD( _T("value"), szTmpBuff );
+ mir_sntprintf(szTmpBuff, SIZEOF(szTmpBuff), _T("%d"), db_get_b(NULL, "Skin", "UseSound", 0));
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Play sounds"))
+ << XATTR(_T("type"), _T("boolean")) << XATTR(_T("var"), _T("sounds")) << XCHILD(_T("value"), szTmpBuff);
// Disable remote controlling
- xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Disable remote controlling (check twice what you are doing)"))
- << XATTR( _T("type"), _T("boolean")) << XATTR( _T("var"), _T("enable-rc")) << XCHILD( _T("value"), _T("0"));
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Disable remote controlling (check twice what you are doing)"))
+ << XATTR(_T("type"), _T("boolean")) << XATTR(_T("var"), _T("enable-rc")) << XCHILD(_T("value"), _T("0"));
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
- if ( pSession->GetStage() == 1 ) {
+ if (pSession->GetStage() == 1) {
// result form here
HXML commandNode = pInfo->GetChildNode();
- HXML xNode = xmlGetChildByTag( commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
- if ( !xNode )
+ HXML xNode = xmlGetChildByTag(commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
HXML fieldNode, valueNode;
// Automatically Accept File Transfers
- fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("auto-files"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ))
- DBWriteContactSettingByte( NULL, "SRFile", "AutoAccept", (BYTE)_ttoi( xmlGetText( valueNode )) );
+ fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("auto-files"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode))
+ db_set_b(NULL, "SRFile", "AutoAccept", (BYTE)_ttoi(xmlGetText(valueNode)));
}
// Use sounds
- fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("sounds"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ))
- DBWriteContactSettingByte( NULL, "Skin", "UseSound", (BYTE)_ttoi( xmlGetText( valueNode )) );
+ fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("sounds"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode))
+ db_set_b(NULL, "Skin", "UseSound", (BYTE)_ttoi(xmlGetText(valueNode)));
}
// Disable remote controlling
- fieldNode = xmlGetChildByTag( xNode, "field", "var", _T("enable-rc"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ) && _ttoi( xmlGetText( valueNode )))
+ fieldNode = xmlGetChildByTag(xNode, "field", "var", _T("enable-rc"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode) && _ttoi(xmlGetText(valueNode)))
m_options.EnableRemoteControl = 0;
}
@@ -476,32 +476,32 @@ int CJabberProto::AdhocOptionsHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocS int CJabberProto::RcGetUnreadEventsCount()
{
int nEventsSent = 0;
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_szModuleName )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
- HANDLE hDbEvent = (HANDLE)CallService( MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0 );
- while ( hDbEvent ) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0);
+ while (hDbEvent) {
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0 );
- if ( dbei.cbBlob != -1 ) {
- dbei.pBlob = (PBYTE)mir_alloc( dbei.cbBlob + 1 );
- int nGetTextResult = CallService( MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei );
+ dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ if (dbei.cbBlob != -1) {
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
+ int nGetTextResult = CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
- TCHAR* szEventText = DbGetEventTextT( &dbei, CP_ACP );
- if ( szEventText ) {
+ TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
+ if (szEventText) {
nEventsSent++;
- mir_free( szEventText );
+ mir_free(szEventText);
}
}
- mir_free( dbei.pBlob );
+ mir_free(dbei.pBlob);
}
- hDbEvent = (HANDLE)CallService( MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0 );
+ hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
}
hContact = db_find_next(hContact);
@@ -509,54 +509,54 @@ int CJabberProto::RcGetUnreadEventsCount() return nEventsSent;
}
-int CJabberProto::AdhocForwardHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
TCHAR szMsg[ 1024 ];
- if ( pSession->GetStage() == 0 ) {
+ if (pSession->GetStage() == 0) {
int nUnreadEvents = RcGetUnreadEventsCount();
- if ( !nUnreadEvents ) {
- mir_sntprintf( szMsg, SIZEOF(szMsg), TranslateT("There is no messages to forward"));
+ if ( !nUnreadEvents) {
+ mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("There is no messages to forward"));
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_FORWARD))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("completed"))
- << XCHILD( _T("note"), szMsg ) << XATTR( _T("type"), _T("info")));
+ XmlNodeIq(_T("result"), pInfo)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_FORWARD))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("completed"))
+ << XCHILD(_T("note"), szMsg) << XATTR(_T("type"), _T("info")));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
// first form
- pSession->SetStage( 1 );
+ pSession->SetStage(1);
- XmlNodeIq iq( _T("result"), pInfo );
+ XmlNodeIq iq(_T("result"), pInfo);
HXML xNode = iq
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_FORWARD))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("executing"))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("form"));
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_FORWARD))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("executing"))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("form"));
- xNode << XCHILD( _T("title"), TranslateT("Forward options"));
+ xNode << XCHILD(_T("title"), TranslateT("Forward options"));
- mir_sntprintf( szMsg, SIZEOF(szMsg), TranslateT("%d message(s) to be forwarded"), nUnreadEvents );
- xNode << XCHILD( _T("instructions"), szMsg );
+ mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%d message(s) to be forwarded"), nUnreadEvents);
+ xNode << XCHILD(_T("instructions"), szMsg);
- xNode << XCHILD( _T("field")) << XATTR( _T("type"), _T("hidden")) << XATTR( _T("var"), _T("FORM_TYPE"))
- << XCHILD( _T("value"), _T(JABBER_FEAT_RC));
+ xNode << XCHILD(_T("field")) << XATTR(_T("type"), _T("hidden")) << XATTR(_T("var"), _T("FORM_TYPE"))
+ << XCHILD(_T("value"), _T(JABBER_FEAT_RC));
// remove clist events
- xNode << XCHILD( _T("field")) << XATTR( _T("label"), TranslateT("Mark messages as read")) << XATTR( _T("type"), _T("boolean"))
- << XATTR( _T("var"), _T("remove-clist-events")) << XCHILD( _T("value"),
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Mark messages as read")) << XATTR(_T("type"), _T("boolean"))
+ << XATTR(_T("var"), _T("remove-clist-events")) << XCHILD(_T("value"),
m_options.RcMarkMessagesAsRead == 1 ? _T("1") : _T("0"));
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
- if ( pSession->GetStage() == 1 ) {
+ if (pSession->GetStage() == 1) {
// result form here
HXML commandNode = pInfo->GetChildNode();
- HXML xNode = xmlGetChildByTag( commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
- if ( !xNode )
+ HXML xNode = xmlGetChildByTag(commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
HXML fieldNode, valueNode;
@@ -564,84 +564,84 @@ int CJabberProto::AdhocForwardHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocS BOOL bRemoveCListEvents = TRUE;
// remove clist events
- fieldNode = xmlGetChildByTag( xNode,"field", "var", _T("remove-clist-events"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" ))) {
- if ( xmlGetText( valueNode ) && !_ttoi( xmlGetText( valueNode )) ) {
+ fieldNode = xmlGetChildByTag(xNode,"field", "var", _T("remove-clist-events"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value"))) {
+ if (xmlGetText(valueNode) && !_ttoi(xmlGetText(valueNode))) {
bRemoveCListEvents = FALSE;
}
}
m_options.RcMarkMessagesAsRead = bRemoveCListEvents ? 1 : 0;
int nEventsSent = 0;
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_szModuleName )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
- HANDLE hDbEvent = (HANDLE)CallService( MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0 );
- while ( hDbEvent ) {
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0);
+ while (hDbEvent) {
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0 );
- if ( dbei.cbBlob != -1 ) {
- dbei.pBlob = (PBYTE)mir_alloc( dbei.cbBlob + 1 );
- int nGetTextResult = CallService( MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei );
+ dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ if (dbei.cbBlob != -1) {
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
+ int nGetTextResult = CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
- TCHAR* szEventText = DbGetEventTextT( &dbei, CP_ACP );
- if ( szEventText ) {
- XmlNode msg( _T("message"));
- msg << XATTR( _T("to"), pInfo->GetFrom()) << XATTRID( SerialNext())
- << XCHILD( _T("body"), szEventText );
+ TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
+ if (szEventText) {
+ XmlNode msg(_T("message"));
+ msg << XATTR(_T("to"), pInfo->GetFrom()) << XATTRID(SerialNext())
+ << XCHILD(_T("body"), szEventText);
- HXML addressesNode = msg << XCHILDNS( _T("addresses"), _T(JABBER_FEAT_EXT_ADDRESSING));
+ HXML addressesNode = msg << XCHILDNS(_T("addresses"), _T(JABBER_FEAT_EXT_ADDRESSING));
TCHAR szOFrom[ JABBER_MAX_JID_LEN ];
- EnterCriticalSection( &m_csLastResourceMap );
- TCHAR *szOResource = FindLastResourceByDbEvent( hDbEvent );
- if ( szOResource )
- mir_sntprintf( szOFrom, SIZEOF( szOFrom ), _T("%s/%s"), dbv.ptszVal, szOResource );
+ EnterCriticalSection(&m_csLastResourceMap);
+ TCHAR *szOResource = FindLastResourceByDbEvent(hDbEvent);
+ if (szOResource)
+ mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s/%s"), dbv.ptszVal, szOResource);
else
- mir_sntprintf( szOFrom, SIZEOF( szOFrom ), _T("%s"), dbv.ptszVal );
- LeaveCriticalSection( &m_csLastResourceMap );
- addressesNode << XCHILD( _T("address")) << XATTR( _T("type"), _T("ofrom")) << XATTR( _T("jid"), szOFrom );
- addressesNode << XCHILD( _T("address")) << XATTR( _T("type"), _T("oto")) << XATTR( _T("jid"), m_ThreadInfo->fullJID );
+ mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s"), dbv.ptszVal);
+ LeaveCriticalSection(&m_csLastResourceMap);
+ addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("ofrom")) << XATTR(_T("jid"), szOFrom);
+ addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("oto")) << XATTR(_T("jid"), m_ThreadInfo->fullJID);
- time_t ltime = ( time_t )dbei.timestamp;
- struct tm *gmt = gmtime( <ime );
+ time_t ltime = (time_t)dbei.timestamp;
+ struct tm *gmt = gmtime(<ime);
TCHAR stime[ 512 ];
wsprintf(stime, _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
- msg << XCHILDNS( _T("delay"), _T("urn:xmpp:delay")) << XATTR( _T("stamp"), stime );
+ msg << XCHILDNS(_T("delay"), _T("urn:xmpp:delay")) << XATTR(_T("stamp"), stime);
- m_ThreadInfo->send( msg );
+ m_ThreadInfo->send(msg);
nEventsSent++;
- CallService( MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent );
- if ( bRemoveCListEvents )
- CallService( MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent );
+ CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent);
+ if (bRemoveCListEvents)
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
- mir_free( szEventText );
+ mir_free(szEventText);
}
}
- mir_free( dbei.pBlob );
+ mir_free(dbei.pBlob);
}
- hDbEvent = (HANDLE)CallService( MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0 );
+ hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
}
hContact = db_find_next(hContact);
}
- mir_sntprintf( szMsg, SIZEOF(szMsg), TranslateT("%d message(s) forwarded"), nEventsSent );
+ mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%d message(s) forwarded"), nEventsSent);
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_FORWARD))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("completed"))
- << XCHILD( _T("note"), szMsg ) << XATTR( _T("type"), _T("info")));
+ XmlNodeIq(_T("result"), pInfo)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_FORWARD))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("completed"))
+ << XCHILD(_T("note"), szMsg) << XATTR(_T("type"), _T("info")));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
@@ -649,78 +649,78 @@ int CJabberProto::AdhocForwardHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocS return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
}
-typedef BOOL (WINAPI *LWS )( VOID );
+typedef BOOL (WINAPI *LWS)(VOID);
-int CJabberProto::AdhocLockWSHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+int CJabberProto::AdhocLockWSHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
BOOL bOk = FALSE;
- HMODULE hLibrary = LoadLibrary( _T("user32.dll"));
- if ( hLibrary ) {
- LWS pLws = (LWS)GetProcAddress( hLibrary, "LockWorkStation" );
- if ( pLws )
+ HMODULE hLibrary = LoadLibrary(_T("user32.dll"));
+ if (hLibrary) {
+ LWS pLws = (LWS)GetProcAddress(hLibrary, "LockWorkStation");
+ if (pLws)
bOk = pLws();
- FreeLibrary( hLibrary );
+ FreeLibrary(hLibrary);
}
TCHAR szMsg[ 1024 ];
- if ( bOk )
- mir_sntprintf( szMsg, SIZEOF(szMsg), TranslateT("Workstation successfully locked"));
+ if (bOk)
+ mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("Workstation successfully locked"));
else
- mir_sntprintf( szMsg, SIZEOF(szMsg), TranslateT("Error %d occured during workstation lock"), GetLastError());
+ mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("Error %d occured during workstation lock"), GetLastError());
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_WS_LOCK))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("completed"))
- << XCHILD( _T("note"), szMsg ) << XATTR( _T("type"), bOk ? _T("info") : _T("error")));
+ XmlNodeIq(_T("result"), pInfo)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_WS_LOCK))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("completed"))
+ << XCHILD(_T("note"), szMsg) << XATTR(_T("type"), bOk ? _T("info") : _T("error")));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
-static void __stdcall JabberQuitMirandaIMThread( void* )
+static void __stdcall JabberQuitMirandaIMThread(void*)
{
- CallService( "CloseAction", 0, 0 );
+ CallService("CloseAction", 0, 0);
}
-int CJabberProto::AdhocQuitMirandaHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+int CJabberProto::AdhocQuitMirandaHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
- if ( pSession->GetStage() == 0 ) {
+ if (pSession->GetStage() == 0) {
// first form
- pSession->SetStage( 1 );
+ pSession->SetStage(1);
- XmlNodeIq iq( _T("result"), pInfo );
+ XmlNodeIq iq(_T("result"), pInfo);
HXML xNode = iq
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_QUIT_MIRANDA))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("executing"))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("form"));
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_QUIT_MIRANDA))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("executing"))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("form"));
- xNode << XCHILD( _T("title"), TranslateT("Confirmation needed"));
- xNode << XCHILD( _T("instructions"), TranslateT("Please confirm Miranda NG shutdown"));
+ xNode << XCHILD(_T("title"), TranslateT("Confirmation needed"));
+ xNode << XCHILD(_T("instructions"), TranslateT("Please confirm Miranda NG shutdown"));
- xNode << XCHILD( _T("field")) << XATTR( _T("type"), _T("hidden")) << XATTR( _T("var"), _T("FORM_TYPE"))
- << XCHILD( _T("value"), _T(JABBER_FEAT_RC));
+ xNode << XCHILD(_T("field")) << XATTR(_T("type"), _T("hidden")) << XATTR(_T("var"), _T("FORM_TYPE"))
+ << XCHILD(_T("value"), _T(JABBER_FEAT_RC));
// I Agree checkbox
- xNode << XCHILD( _T("field")) << XATTR( _T("label"), _T("I agree")) << XATTR( _T("type"), _T("boolean"))
- << XATTR( _T("var"), _T("allow-shutdown")) << XCHILD( _T("value"), _T("0"));
+ xNode << XCHILD(_T("field")) << XATTR(_T("label"), _T("I agree")) << XATTR(_T("type"), _T("boolean"))
+ << XATTR(_T("var"), _T("allow-shutdown")) << XCHILD(_T("value"), _T("0"));
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
- if ( pSession->GetStage() == 1 ) {
+ if (pSession->GetStage() == 1) {
// result form here
HXML commandNode = pInfo->GetChildNode();
- HXML xNode = xmlGetChildByTag( commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
- if ( !xNode )
+ HXML xNode = xmlGetChildByTag(commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
HXML fieldNode, valueNode;
// I Agree checkbox
- fieldNode = xmlGetChildByTag( xNode,"field", "var", _T("allow-shutdown"));
- if ( fieldNode && (valueNode = xmlGetChild( fieldNode , "value" )))
- if ( xmlGetText( valueNode ) && _ttoi( xmlGetText( valueNode )))
+ fieldNode = xmlGetChildByTag(xNode,"field", "var", _T("allow-shutdown"));
+ if (fieldNode && (valueNode = xmlGetChild(fieldNode , "value")))
+ if (xmlGetText(valueNode) && _ttoi(xmlGetText(valueNode)))
CallFunctionAsync(JabberQuitMirandaIMThread, 0);
return JABBER_ADHOC_HANDLER_STATUS_COMPLETED;
@@ -728,10 +728,10 @@ int CJabberProto::AdhocQuitMirandaHandler( HXML, CJabberIqInfo* pInfo, CJabberAd return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
}
-int CJabberProto::AdhocLeaveGroupchatsHandler( HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+int CJabberProto::AdhocLeaveGroupchatsHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
int i = 0;
- if ( pSession->GetStage() == 0 ) {
+ if (pSession->GetStage() == 0) {
// first form
TCHAR szMsg[ 1024 ];
@@ -739,71 +739,71 @@ int CJabberProto::AdhocLeaveGroupchatsHandler( HXML, CJabberIqInfo* pInfo, CJabb int nChatsCount = 0;
LISTFOREACH_NODEF(i, this, LIST_CHATROOM)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex( i );
- if ( item != NULL )
+ JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ if (item != NULL)
nChatsCount++;
}
ListUnlock();
- if ( !nChatsCount ) {
- mir_sntprintf( szMsg, SIZEOF(szMsg), TranslateT("There is no groupchats to leave"));
+ if ( !nChatsCount) {
+ mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("There is no groupchats to leave"));
m_ThreadInfo->send(
- XmlNodeIq( _T("result"), pInfo )
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_LEAVE_GROUPCHATS))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("completed"))
- << XCHILD( _T("note"), szMsg ) << XATTR( _T("type"), _T("info")));
+ XmlNodeIq(_T("result"), pInfo)
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_LEAVE_GROUPCHATS))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("completed"))
+ << XCHILD(_T("note"), szMsg) << XATTR(_T("type"), _T("info")));
return JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION;
}
- pSession->SetStage( 1 );
+ pSession->SetStage(1);
- XmlNodeIq iq( _T("result"), pInfo );
+ XmlNodeIq iq(_T("result"), pInfo);
HXML xNode = iq
- << XCHILDNS( _T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR( _T("node"), _T(JABBER_FEAT_RC_LEAVE_GROUPCHATS))
- << XATTR( _T("sessionid"), pSession->GetSessionId()) << XATTR( _T("status"), _T("executing"))
- << XCHILDNS( _T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR( _T("type"), _T("form"));
+ << XCHILDNS(_T("command"), _T(JABBER_FEAT_COMMANDS)) << XATTR(_T("node"), _T(JABBER_FEAT_RC_LEAVE_GROUPCHATS))
+ << XATTR(_T("sessionid"), pSession->GetSessionId()) << XATTR(_T("status"), _T("executing"))
+ << XCHILDNS(_T("x"), _T(JABBER_FEAT_DATA_FORMS)) << XATTR(_T("type"), _T("form"));
- xNode << XCHILD( _T("title"), TranslateT("Leave groupchats"));
- xNode << XCHILD( _T("instructions"), TranslateT("Choose the groupchats you want to leave"));
+ xNode << XCHILD(_T("title"), TranslateT("Leave groupchats"));
+ xNode << XCHILD(_T("instructions"), TranslateT("Choose the groupchats you want to leave"));
- xNode << XCHILD( _T("field")) << XATTR( _T("type"), _T("hidden")) << XATTR( _T("var"), _T("FORM_TYPE"))
- << XATTR( _T("value"), _T(JABBER_FEAT_RC));
+ xNode << XCHILD(_T("field")) << XATTR(_T("type"), _T("hidden")) << XATTR(_T("var"), _T("FORM_TYPE"))
+ << XATTR(_T("value"), _T(JABBER_FEAT_RC));
// Groupchats
- HXML fieldNode = xNode << XCHILD( _T("field")) << XATTR( _T("label"), NULL ) << XATTR( _T("type"), _T("list-multi")) << XATTR( _T("var"), _T("groupchats"));
- fieldNode << XCHILD( _T("required"));
+ HXML fieldNode = xNode << XCHILD(_T("field")) << XATTR(_T("label"), NULL) << XATTR(_T("type"), _T("list-multi")) << XATTR(_T("var"), _T("groupchats"));
+ fieldNode << XCHILD(_T("required"));
ListLock();
LISTFOREACH_NODEF(i, this, LIST_CHATROOM)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex( i );
- if ( item != NULL )
- fieldNode << XCHILD( _T("option")) << XATTR( _T("label"), item->jid ) << XCHILD( _T("value"), item->jid );
+ JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ if (item != NULL)
+ fieldNode << XCHILD(_T("option")) << XATTR(_T("label"), item->jid) << XCHILD(_T("value"), item->jid);
}
ListUnlock();
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
- if ( pSession->GetStage() == 1 ) {
+ if (pSession->GetStage() == 1) {
// result form here
HXML commandNode = pInfo->GetChildNode();
- HXML xNode = xmlGetChildByTag( commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
- if ( !xNode )
+ HXML xNode = xmlGetChildByTag(commandNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !xNode)
return JABBER_ADHOC_HANDLER_STATUS_CANCEL;
// Groupchat list here:
- HXML fieldNode = xmlGetChildByTag( xNode,"field", "var", _T("groupchats"));
- if ( fieldNode ) {
- for ( i = 0; i < xmlGetChildCount( fieldNode ); i++ ) {
- HXML valueNode = xmlGetChild( fieldNode, i );
- if ( valueNode && xmlGetName( valueNode ) && xmlGetText( valueNode ) && !_tcscmp( xmlGetName( valueNode ), _T("value"))) {
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, xmlGetText( valueNode ));
- if ( item )
- GcQuit( item, 0, NULL );
+ HXML fieldNode = xmlGetChildByTag(xNode,"field", "var", _T("groupchats"));
+ if (fieldNode) {
+ for (i = 0; i < xmlGetChildCount(fieldNode); i++) {
+ HXML valueNode = xmlGetChild(fieldNode, i);
+ if (valueNode && xmlGetName(valueNode) && xmlGetText(valueNode) && !_tcscmp(xmlGetName(valueNode), _T("value"))) {
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, xmlGetText(valueNode));
+ if (item)
+ GcQuit(item, 0, NULL);
}
}
}
diff --git a/protocols/JabberG/src/jabber_rc.h b/protocols/JabberG/src/jabber_rc.h index cb3bf1b9cc..dd9078e67b 100644 --- a/protocols/JabberG/src/jabber_rc.h +++ b/protocols/JabberG/src/jabber_rc.h @@ -1,16 +1,16 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
XEP-0146 support for Miranda IM
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
@@ -32,7 +32,7 @@ class CJabberAdhocSession; #define JABBER_ADHOC_HANDLER_STATUS_COMPLETED 2
#define JABBER_ADHOC_HANDLER_STATUS_CANCEL 3
#define JABBER_ADHOC_HANDLER_STATUS_REMOVE_SESSION 4
-typedef int ( CJabberProto::*JABBER_ADHOC_HANDLER )( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession );
+typedef int (CJabberProto::*JABBER_ADHOC_HANDLER)(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession);
// 5 minutes to fill out form :)
#define JABBER_ADHOC_SESSION_EXPIRE_TIME 300000
@@ -50,19 +50,19 @@ protected: DWORD m_dwStage;
public:
CJabberProto* ppro;
- CJabberAdhocSession( CJabberProto* global );
+ CJabberAdhocSession(CJabberProto* global);
~CJabberAdhocSession()
{
- if ( m_bAutofreeUserData && m_pUserData )
- mir_free( m_pUserData );
- if ( m_pNext )
+ if (m_bAutofreeUserData && m_pUserData)
+ mir_free(m_pUserData);
+ if (m_pNext)
delete m_pNext;
}
CJabberAdhocSession* GetNext()
{
return m_pNext;
}
- CJabberAdhocSession* SetNext( CJabberAdhocSession *pNext )
+ CJabberAdhocSession* SetNext(CJabberAdhocSession *pNext)
{
CJabberAdhocSession *pRetVal = m_pNext;
m_pNext = pNext;
@@ -76,15 +76,15 @@ public: {
return m_szSessionId;
}
- BOOL SetUserData( void* pUserData, BOOL bAutofree = FALSE )
+ BOOL SetUserData(void* pUserData, BOOL bAutofree = FALSE)
{
- if ( m_bAutofreeUserData && m_pUserData )
- mir_free( m_pUserData );
+ if (m_bAutofreeUserData && m_pUserData)
+ mir_free(m_pUserData);
m_pUserData = pUserData;
m_bAutofreeUserData = bAutofree;
return TRUE;
}
- DWORD SetStage( DWORD dwStage )
+ DWORD SetStage(DWORD dwStage)
{
DWORD dwRetVal = m_dwStage;
m_dwStage = dwStage;
@@ -107,31 +107,31 @@ protected: JABBER_ADHOC_HANDLER m_pHandler;
CJabberProto* m_pProto;
public:
- CJabberAdhocNode( CJabberProto* pProto, TCHAR* szJid, TCHAR* szNode, TCHAR* szName, JABBER_ADHOC_HANDLER pHandler )
+ CJabberAdhocNode(CJabberProto* pProto, TCHAR* szJid, TCHAR* szNode, TCHAR* szName, JABBER_ADHOC_HANDLER pHandler)
{
- ZeroMemory( this, sizeof( CJabberAdhocNode ));
- replaceStrT( m_szJid, szJid );
- replaceStrT( m_szNode, szNode );
- replaceStrT( m_szName, szName );
+ ZeroMemory(this, sizeof(CJabberAdhocNode));
+ replaceStrT(m_szJid, szJid);
+ replaceStrT(m_szNode, szNode);
+ replaceStrT(m_szName, szName);
m_pHandler = pHandler;
m_pProto = pProto;
}
~CJabberAdhocNode()
{
- if ( m_szJid)
- mir_free( m_szJid );
- if ( m_szNode )
- mir_free( m_szNode );
- if ( m_szName )
- mir_free( m_szName );
- if ( m_pNext )
+ if (m_szJid)
+ mir_free(m_szJid);
+ if (m_szNode)
+ mir_free(m_szNode);
+ if (m_szName)
+ mir_free(m_szName);
+ if (m_pNext)
delete m_pNext;
}
CJabberAdhocNode* GetNext()
{
return m_pNext;
}
- CJabberAdhocNode* SetNext( CJabberAdhocNode *pNext )
+ CJabberAdhocNode* SetNext(CJabberAdhocNode *pNext)
{
CJabberAdhocNode *pRetVal = m_pNext;
m_pNext = pNext;
@@ -149,11 +149,11 @@ public: {
return m_szName;
}
- BOOL CallHandler( HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession )
+ BOOL CallHandler(HXML iqNode, CJabberIqInfo* pInfo, CJabberAdhocSession* pSession)
{
- if ( m_pHandler == NULL )
+ if (m_pHandler == NULL)
return FALSE;
- return (m_pProto->*m_pHandler)( iqNode, pInfo, pSession );
+ return (m_pProto->*m_pHandler)(iqNode, pInfo, pSession);
}
};
@@ -165,11 +165,11 @@ protected: CJabberAdhocSession* m_pSessions;
CRITICAL_SECTION m_cs;
- CJabberAdhocSession* FindSession( const TCHAR* szSession )
+ CJabberAdhocSession* FindSession(const TCHAR *szSession)
{
CJabberAdhocSession* pSession = m_pSessions;
- while ( pSession ) {
- if ( !_tcscmp( pSession->GetSessionId(), szSession ))
+ while (pSession) {
+ if ( !_tcscmp(pSession->GetSessionId(), szSession))
return pSession;
pSession = pSession->GetNext();
}
@@ -178,44 +178,44 @@ protected: CJabberAdhocSession* AddNewSession()
{
- CJabberAdhocSession* pSession = new CJabberAdhocSession( m_pProto );
- if ( !pSession )
+ CJabberAdhocSession* pSession = new CJabberAdhocSession(m_pProto);
+ if ( !pSession)
return NULL;
- pSession->SetNext( m_pSessions );
+ pSession->SetNext(m_pSessions);
m_pSessions = pSession;
return pSession;
}
- CJabberAdhocNode* FindNode( const TCHAR* szNode )
+ CJabberAdhocNode* FindNode(const TCHAR *szNode)
{
CJabberAdhocNode* pNode = m_pNodes;
- while ( pNode ) {
- if ( !_tcscmp( pNode->GetNode(), szNode ))
+ while (pNode) {
+ if ( !_tcscmp(pNode->GetNode(), szNode))
return pNode;
pNode = pNode->GetNext();
}
return NULL;
}
- BOOL RemoveSession( CJabberAdhocSession* pSession )
+ BOOL RemoveSession(CJabberAdhocSession* pSession)
{
- if ( !m_pSessions )
+ if ( !m_pSessions)
return FALSE;
- if ( pSession == m_pSessions ) {
+ if (pSession == m_pSessions) {
m_pSessions = m_pSessions->GetNext();
- pSession->SetNext( NULL );
+ pSession->SetNext(NULL);
delete pSession;
return TRUE;
}
CJabberAdhocSession* pTmp = m_pSessions;
- while ( pTmp->GetNext()) {
- if ( pTmp->GetNext() == pSession ) {
- pTmp->SetNext( pSession->GetNext());
- pSession->SetNext( NULL );
+ while (pTmp->GetNext()) {
+ if (pTmp->GetNext() == pSession) {
+ pTmp->SetNext(pSession->GetNext());
+ pSession->SetNext(NULL);
delete pSession;
return TRUE;
}
@@ -224,24 +224,24 @@ protected: return FALSE;
}
- BOOL _ExpireSession( DWORD dwExpireTime )
+ BOOL _ExpireSession(DWORD dwExpireTime)
{
- if ( !m_pSessions )
+ if ( !m_pSessions)
return FALSE;
CJabberAdhocSession* pSession = m_pSessions;
- if ( pSession->GetSessionStartTime() < dwExpireTime ) {
+ if (pSession->GetSessionStartTime() < dwExpireTime) {
m_pSessions = pSession->GetNext();
- pSession->SetNext( NULL );
+ pSession->SetNext(NULL);
delete pSession;
return TRUE;
}
- while ( pSession->GetNext()) {
- if ( pSession->GetNext()->GetSessionStartTime() < dwExpireTime ) {
+ while (pSession->GetNext()) {
+ if (pSession->GetNext()->GetSessionStartTime() < dwExpireTime) {
CJabberAdhocSession* pRetVal = pSession->GetNext();
- pSession->SetNext( pSession->GetNext()->GetNext());
- pRetVal->SetNext( NULL );
+ pSession->SetNext(pSession->GetNext()->GetNext());
+ pRetVal->SetNext(NULL);
delete pRetVal;
return TRUE;
}
@@ -251,43 +251,43 @@ protected: }
public:
- CJabberAdhocManager( CJabberProto* pProto )
+ CJabberAdhocManager(CJabberProto* pProto)
{
- ZeroMemory( this, sizeof( CJabberAdhocManager ));
+ ZeroMemory(this, sizeof(CJabberAdhocManager));
m_pProto = pProto;
- InitializeCriticalSection( &m_cs );
+ InitializeCriticalSection(&m_cs);
}
~CJabberAdhocManager()
{
- if ( m_pNodes )
+ if (m_pNodes)
delete m_pNodes;
- if ( m_pSessions )
+ if (m_pSessions)
delete m_pSessions;
- DeleteCriticalSection( &m_cs );
+ DeleteCriticalSection(&m_cs);
}
void Lock()
{
- EnterCriticalSection( &m_cs );
+ EnterCriticalSection(&m_cs);
}
void Unlock()
{
- LeaveCriticalSection( &m_cs );
+ LeaveCriticalSection(&m_cs);
}
BOOL FillDefaultNodes();
- BOOL AddNode( TCHAR* szJid, TCHAR* szNode, TCHAR* szName, JABBER_ADHOC_HANDLER pHandler )
+ BOOL AddNode(TCHAR* szJid, TCHAR* szNode, TCHAR* szName, JABBER_ADHOC_HANDLER pHandler)
{
- CJabberAdhocNode* pNode = new CJabberAdhocNode( m_pProto, szJid, szNode, szName, pHandler );
- if ( !pNode )
+ CJabberAdhocNode* pNode = new CJabberAdhocNode(m_pProto, szJid, szNode, szName, pHandler);
+ if ( !pNode)
return FALSE;
Lock();
- if ( !m_pNodes )
+ if ( !m_pNodes)
m_pNodes = pNode;
else {
CJabberAdhocNode* pTmp = m_pNodes;
- while ( pTmp->GetNext())
+ while (pTmp->GetNext())
pTmp = pTmp->GetNext();
- pTmp->SetNext( pNode );
+ pTmp->SetNext(pNode);
}
Unlock();
@@ -297,15 +297,15 @@ public: {
return m_pNodes;
}
- BOOL HandleItemsRequest( HXML iqNode, CJabberIqInfo* pInfo, const TCHAR* szNode );
- BOOL HandleInfoRequest( HXML iqNode, CJabberIqInfo* pInfo, const TCHAR* szNode );
- BOOL HandleCommandRequest( HXML iqNode, CJabberIqInfo* pInfo, const TCHAR* szNode );
+ BOOL HandleItemsRequest(HXML iqNode, CJabberIqInfo* pInfo, const TCHAR *szNode);
+ BOOL HandleInfoRequest(HXML iqNode, CJabberIqInfo* pInfo, const TCHAR *szNode);
+ BOOL HandleCommandRequest(HXML iqNode, CJabberIqInfo* pInfo, const TCHAR *szNode);
BOOL ExpireSessions()
{
Lock();
DWORD dwExpireTime = GetTickCount() - JABBER_ADHOC_SESSION_EXPIRE_TIME;
- while ( _ExpireSession( dwExpireTime ));
+ while (_ExpireSession(dwExpireTime));
Unlock();
return TRUE;
}
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index ad8d204951..87557a4fef 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -1,9 +1,9 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Artem Shpynov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Artem Shpynov
Module implements a search according to XEP-0055: Jabber Search
http://www.xmpp.org/extensions/xep-0055.html
@@ -11,7 +11,7 @@ http://www.xmpp.org/extensions/xep-0055.html 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,42 +34,43 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //
static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam)
{
- if ( msg == WM_COMMAND && lParam != 0 ) {
+ if (msg == WM_COMMAND && lParam != 0) {
HWND hwndDlg=GetParent(hwnd);
JabberSearchData * dat=(JabberSearchData *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if ( dat && lParam ) {
+ if (dat && lParam) {
int pos=dat->curPos;
RECT MineRect;
RECT FrameRect;
- GetWindowRect(GetDlgItem( hwndDlg, IDC_FRAME ),&FrameRect);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_FRAME),&FrameRect);
GetWindowRect((HWND)lParam, &MineRect);
- if ( MineRect.top-10 < FrameRect.top ) {
+ if (MineRect.top-10 < FrameRect.top) {
pos=dat->curPos+(MineRect.top-14-FrameRect.top);
if (pos<0) pos=0;
}
- else if ( MineRect.bottom > FrameRect.bottom ) {
+ else if (MineRect.bottom > FrameRect.bottom) {
pos=dat->curPos+(MineRect.bottom-FrameRect.bottom);
if (dat->frameHeight+pos>dat->CurrentHeight)
pos=dat->CurrentHeight-dat->frameHeight;
}
- if ( pos != dat->curPos ) {
- ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - pos, NULL, &( dat->frameRect ));
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, pos, TRUE );
+ if (pos != dat->curPos) {
+ ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL, &(dat->frameRect));
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE);
RECT Invalid=dat->frameRect;
if (dat->curPos - pos >0)
Invalid.bottom=Invalid.top+(dat->curPos - pos);
else
Invalid.top=Invalid.bottom+(dat->curPos - pos);
- RedrawWindow(GetDlgItem( hwndDlg, IDC_FRAME ), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW |RDW_ALLCHILDREN);
+ RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW |RDW_ALLCHILDREN);
dat->curPos = pos;
- } }
+ }
+ }
if (HIWORD(wParam)==EN_SETFOCUS) { //Transmit focus set notification to parent window
PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg);
}
}
- if ( msg == WM_PAINT ) {
+ if (msg == WM_PAINT) {
PAINTSTRUCT ps;
HDC hdc=BeginPaint(hwnd, &ps);
FillRect(hdc,&(ps.rcPaint),GetSysColorBrush(COLOR_BTNFACE));
@@ -82,14 +83,16 @@ static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lPara ///////////////////////////////////////////////////////////////////////////////
// Add Search field to form
//
-static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat )
+static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat)
{
- if (!FieldDat || !FieldDat->Label || !FieldDat->Var) return FALSE;
- HFONT hFont = ( HFONT ) SendMessage( hwndDlg, WM_GETFONT, 0, 0 );
+ if ( !FieldDat || !FieldDat->Label || !FieldDat->Var)
+ return FALSE;
+
+ HFONT hFont = (HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0);
HWND hwndParent=GetDlgItem(hwndDlg,IDC_FRAME);
- LONG frameExStyle = GetWindowLongPtr( hwndParent, GWL_EXSTYLE );
+ LONG frameExStyle = GetWindowLongPtr(hwndParent, GWL_EXSTYLE);
frameExStyle |= WS_EX_CONTROLPARENT;
- SetWindowLongPtr( hwndParent, GWL_EXSTYLE, frameExStyle );
+ SetWindowLongPtr(hwndParent, GWL_EXSTYLE, frameExStyle);
SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_FRAME),GWLP_WNDPROC,(LONG_PTR)JabberSearchFrameProc);
int CornerX=1;
@@ -104,8 +107,7 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat ) HWND hwndVar=CreateWindowEx(0|WS_EX_CLIENTEDGE,_T("EDIT"),(LPCTSTR)FieldDat->defValue,WS_CHILD|WS_TABSTOP, CornerX+5, CornerY + Order*40+14, width ,20,hwndParent,NULL,hInst,0);
SendMessage(hwndLabel, WM_SETFONT, (WPARAM)hFont,0);
SendMessage(hwndVar, WM_SETFONT, (WPARAM)hFont,0);
- if (!FieldDat->bHidden)
- {
+ if ( !FieldDat->bHidden) {
ShowWindow(hwndLabel,SW_SHOW);
ShowWindow(hwndVar,SW_SHOW);
EnableWindow(hwndLabel,!FieldDat->bReadOnly);
@@ -113,9 +115,9 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat ) }
//remade list
//reallocation
- JabberSearchData * dat=(JabberSearchData *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if ( dat ) {
- dat->pJSInf=(JabberSearchFieldsInfo*) realloc(dat->pJSInf, sizeof(JabberSearchFieldsInfo)*(dat->nJSInfCount+1));
+ JabberSearchData *dat=(JabberSearchData *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
+ if (dat) {
+ dat->pJSInf=(JabberSearchFieldsInfo*)realloc(dat->pJSInf, sizeof(JabberSearchFieldsInfo)*(dat->nJSInfCount+1));
dat->pJSInf[dat->nJSInfCount].hwndCaptionItem=hwndLabel;
dat->pJSInf[dat->nJSInfCount].hwndValueItem=hwndVar;
dat->pJSInf[dat->nJSInfCount].szFieldCaption=_tcsdup(FieldDat->Label);
@@ -128,67 +130,70 @@ static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat ) ////////////////////////////////////////////////////////////////////////////////
// Available search field request result handler (XEP-0055. Examples 2, 7)
-void CJabberProto::OnIqResultGetSearchFields( HXML iqNode )
+void CJabberProto::OnIqResultGetSearchFields(HXML iqNode)
{
- if ( !searchHandleDlg )
+ if ( !searchHandleDlg)
return;
- LPCTSTR type = xmlGetAttrValue( iqNode, _T("type"));
- if ( !type )
+ LPCTSTR type = xmlGetAttrValue(iqNode, _T("type"));
+ if ( !type)
return;
- if ( !lstrcmp( type, _T("result"))) {
- HXML queryNode = xmlGetNthChild( iqNode, _T("query"), 1 );
- HXML xNode = xmlGetChildByTag( queryNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !lstrcmp(type, _T("result"))) {
+ HXML queryNode = xmlGetNthChild(iqNode, _T("query"), 1);
+ HXML xNode = xmlGetChildByTag(queryNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
ShowWindow(searchHandleDlg,SW_HIDE);
- if ( xNode ) {
+ if (xNode) {
//1. Form
- PostMessage( searchHandleDlg, WM_USER+11, ( WPARAM )xi.copyNode( xNode ), ( LPARAM )0 );
- HXML xcNode = xmlGetNthChild( xNode, _T("instructions"), 1 );
- if ( xcNode )
- SetDlgItemText( searchHandleDlg, IDC_INSTRUCTIONS, xmlGetText( xcNode ));
+ PostMessage(searchHandleDlg, WM_USER+11, (WPARAM)xi.copyNode(xNode), (LPARAM)0);
+ HXML xcNode = xmlGetNthChild(xNode, _T("instructions"), 1);
+ if (xcNode)
+ SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, xmlGetText(xcNode));
}
else {
int Order=0;
- for ( int i = 0; ; i++ ) {
- HXML chNode = xmlGetChild( queryNode, i );
- if ( !chNode )
+ for (int i = 0; ; i++) {
+ HXML chNode = xmlGetChild(queryNode, i);
+ if ( !chNode)
break;
- if ( !_tcsicmp( xmlGetName( chNode ), _T("instructions")) && xmlGetText( chNode ))
- SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,TranslateTS(xmlGetText( chNode )));
- else if ( xmlGetName( chNode )) {
+ if ( !_tcsicmp(xmlGetName(chNode), _T("instructions")) && xmlGetText(chNode))
+ SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,TranslateTS(xmlGetText(chNode)));
+ else if (xmlGetName(chNode)) {
Data *MyData=(Data*)malloc(sizeof(Data));
memset(MyData,0,sizeof(Data));
- MyData->Label = mir_tstrdup( xmlGetName( chNode ));
- MyData->Var = mir_tstrdup( xmlGetName( chNode ));
- MyData->defValue = mir_tstrdup(xmlGetText( chNode ));
+ MyData->Label = mir_tstrdup(xmlGetName(chNode));
+ MyData->Var = mir_tstrdup(xmlGetName(chNode));
+ MyData->defValue = mir_tstrdup(xmlGetText(chNode));
MyData->Order = Order;
if (MyData->defValue) MyData->bReadOnly = TRUE;
PostMessage(searchHandleDlg,WM_USER+10,(WPARAM)FALSE,(LPARAM)MyData);
Order++;
- } } }
- const TCHAR* szFrom = xmlGetAttrValue( iqNode, _T("from"));
+ }
+ }
+ }
+
+ const TCHAR *szFrom = xmlGetAttrValue(iqNode, _T("from"));
if (szFrom)
SearchAddToRecent(szFrom,searchHandleDlg);
PostMessage(searchHandleDlg,WM_USER+10,0,0);
ShowWindow(searchHandleDlg,SW_SHOW);
}
- else if ( !lstrcmp( type, _T("error"))) {
- const TCHAR* code=NULL;
- const TCHAR* description=NULL;
+ else if ( !lstrcmp(type, _T("error"))) {
+ const TCHAR *code=NULL;
+ const TCHAR *description=NULL;
TCHAR buff[255];
- HXML errorNode = xmlGetChild( iqNode, "error");
- if ( errorNode ) {
- code = xmlGetAttrValue( errorNode, _T("code"));
- description=xmlGetText( errorNode );
+ HXML errorNode = xmlGetChild(iqNode, "error");
+ if (errorNode) {
+ code = xmlGetAttrValue(errorNode, _T("code"));
+ description=xmlGetText(errorNode);
}
_sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nPlease select other server"),code ? code : _T(""),description?description:_T(""));
SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff);
}
- else SetDlgItemText( searchHandleDlg, IDC_INSTRUCTIONS, TranslateT( "Error Unknown reply recieved\r\nPlease select other server" ));
+ else SetDlgItemText(searchHandleDlg, IDC_INSTRUCTIONS, TranslateT("Error Unknown reply recieved\r\nPlease select other server"));
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -196,16 +201,16 @@ void CJabberProto::OnIqResultGetSearchFields( HXML iqNode ) // The pmFields is the pointer to map of <field Name, field Label> Not unical but ordered
// This can help to made result parser routines more simple
-void CJabberProto::SearchReturnResults( HANDLE id, void * pvUsersInfo, U_TCHAR_MAP * pmAllFields )
+void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_MAP * pmAllFields)
{
LIST<TCHAR> ListOfNonEmptyFields(20,(LIST<TCHAR>::FTSortFunc)TCharKeyCmp);
LIST<TCHAR> ListOfFields(20);
- LIST<void>* plUsersInfo = ( LIST<void>* )pvUsersInfo;
+ LIST<void>* plUsersInfo = (LIST<void>*)pvUsersInfo;
int i, nUsersFound = plUsersInfo->getCount();
// lets fill the ListOfNonEmptyFields but in users order
- for ( i=0; i < nUsersFound; i++ ) {
- U_TCHAR_MAP* pmUserData = ( U_TCHAR_MAP* )plUsersInfo->operator [](i);
+ for (i=0; i < nUsersFound; i++) {
+ U_TCHAR_MAP* pmUserData = (U_TCHAR_MAP*)plUsersInfo->operator [](i);
int nUserFields = pmUserData->getCount();
for (int j=0; j < nUserFields; j++) {
TCHAR* var = pmUserData->getKeyName(j);
@@ -215,9 +220,9 @@ void CJabberProto::SearchReturnResults( HANDLE id, void * pvUsersInfo, U_TCHAR_ // now fill the ListOfFields but order is from pmAllFields
int nAllCount = pmAllFields->getCount();
- for ( i=0; i < nAllCount; i++ ) {
+ for (i=0; i < nAllCount; i++) {
TCHAR * var=pmAllFields->getUnOrderedKeyName(i);
- if ( var && ListOfNonEmptyFields.getIndex(var) < 0 )
+ if (var && ListOfNonEmptyFields.getIndex(var) < 0)
continue;
ListOfFields.insert(var);
}
@@ -231,27 +236,27 @@ void CJabberProto::SearchReturnResults( HANDLE id, void * pvUsersInfo, U_TCHAR_ Results.nFieldCount=nFieldCount;
/* Sending Columns Titles */
- for ( i=0; i < nFieldCount; i++ ) {
+ for (i=0; i < nFieldCount; i++) {
TCHAR* var = ListOfFields[i];
- if ( var )
+ if (var)
Results.pszFields[i] = pmAllFields->operator [](var);
}
Results.jsr.hdr.cbSize = 0; // sending column names
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results);
/* Sending Users Data */
Results.jsr.hdr.cbSize = sizeof(Results.jsr); // sending user data
- for ( i=0; i < nUsersFound; i++ ) {
+ for (i=0; i < nUsersFound; i++) {
TCHAR buff[200]=_T("");
Results.jsr.jid[0]=_T('\0');
U_TCHAR_MAP * pmUserData = (U_TCHAR_MAP *) plUsersInfo->operator [](i);
- for ( int j=0; j < nFieldCount; j++ ) {
+ for (int j=0; j < nFieldCount; j++) {
TCHAR* var = ListOfFields[j];
TCHAR* value = pmUserData->operator [](var);
Results.pszFields[j] = value ? value : (TCHAR *)_T(" ");
- if (!_tcsicmp(var,_T("jid")) && value )
+ if ( !_tcsicmp(var,_T("jid")) && value)
_tcsncpy(Results.jsr.jid, value, SIZEOF(Results.jsr.jid));
}
{
@@ -263,69 +268,69 @@ void CJabberProto::SearchReturnResults( HANDLE id, void * pvUsersInfo, U_TCHAR_ int k=0;
while (nickfields[k] && !nick) nick=pmUserData->operator [](nickfields[k++]);
if (_tcsicmp(nick, Results.jsr.jid))
- _sntprintf(buff,SIZEOF(buff),_T("%s ( %s )"),nick, Results.jsr.jid);
+ _sntprintf(buff,SIZEOF(buff),_T("%s (%s)"),nick, Results.jsr.jid);
else
_tcsncpy(buff, nick, SIZEOF(buff));
Results.jsr.hdr.nick = nick ? buff : NULL;
Results.jsr.hdr.flags = PSR_TCHAR;
}
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results);
Results.jsr.hdr.nick=NULL;
}
- mir_free( Results.pszFields );
+ mir_free(Results.pszFields);
}
-void DestroyKey( TCHAR* key )
+void DestroyKey(TCHAR* key)
{
- mir_free( key );
+ mir_free(key);
}
-TCHAR* CopyKey( TCHAR* key )
+TCHAR* CopyKey(TCHAR* key)
{
- return mir_tstrdup( key );
+ return mir_tstrdup(key);
}
////////////////////////////////////////////////////////////////////////////////
// Search field request result handler (XEP-0055. Examples 3, 8)
-void CJabberProto::OnIqResultAdvancedSearch( HXML iqNode )
+void CJabberProto::OnIqResultAdvancedSearch(HXML iqNode)
{
- const TCHAR* type;
+ const TCHAR *type;
int id;
U_TCHAR_MAP mColumnsNames(10);
LIST<void> SearchResults(2);
- if ((( id = JabberGetPacketID( iqNode )) == -1 ) || (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL )) {
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ if (((id = JabberGetPacketID(iqNode)) == -1) || ((type = xmlGetAttrValue(iqNode, _T("type"))) == NULL)) {
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
return;
}
- if ( !lstrcmp( type, _T("result"))) {
- HXML queryNode = xmlGetNthChild( iqNode, _T("query"), 1 );
- HXML xNode = xmlGetChildByTag( queryNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
+ if ( !lstrcmp(type, _T("result"))) {
+ HXML queryNode = xmlGetNthChild(iqNode, _T("query"), 1);
+ HXML xNode = xmlGetChildByTag(queryNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS));
if (xNode) {
//1. Form search results info
- HXML reportNode = xmlGetNthChild( xNode, _T("reported"), 1 );
+ HXML reportNode = xmlGetNthChild(xNode, _T("reported"), 1);
if (reportNode) {
int i = 1;
- while ( HXML fieldNode = xmlGetNthChild( reportNode, _T("field"), i++ )) {
- TCHAR* var = ( TCHAR* )xmlGetAttrValue( fieldNode, _T( "var" ));
- if ( var ) {
- TCHAR* Label = ( TCHAR* )xmlGetAttrValue( fieldNode, _T( "label" ));
+ while (HXML fieldNode = xmlGetNthChild(reportNode, _T("field"), i++)) {
+ TCHAR *var = (TCHAR*)xmlGetAttrValue(fieldNode, _T("var"));
+ if (var) {
+ TCHAR* Label = (TCHAR*)xmlGetAttrValue(fieldNode, _T("label"));
mColumnsNames.insert(var, (Label!=NULL) ? Label : var);
} } }
int i=1;
HXML itemNode;
- while ( itemNode = xmlGetNthChild( xNode, _T("item"), i++ )) {
+ while (itemNode = xmlGetNthChild(xNode, _T("item"), i++)) {
U_TCHAR_MAP *pUserColumn = new U_TCHAR_MAP(10);
int j = 1;
- while ( HXML fieldNode = xmlGetNthChild( itemNode, _T("field"), j++ )) {
- if ( TCHAR* var = (TCHAR*)xmlGetAttrValue( fieldNode, _T("var"))) {
- if ( TCHAR* Text = (TCHAR*)xmlGetText( xmlGetChild( fieldNode, _T("value")))) {
- if ( !mColumnsNames[var] )
+ while (HXML fieldNode = xmlGetNthChild(itemNode, _T("field"), j++)) {
+ if (TCHAR* var = (TCHAR*)xmlGetAttrValue(fieldNode, _T("var"))) {
+ if (TCHAR* Text = (TCHAR*)xmlGetText(xmlGetChild(fieldNode, _T("value")))) {
+ if ( !mColumnsNames[var])
mColumnsNames.insert(var,var);
pUserColumn->insert(var,Text);
} } }
@@ -336,44 +341,44 @@ void CJabberProto::OnIqResultAdvancedSearch( HXML iqNode ) else {
//2. Field list search results info
int i=1;
- while ( HXML itemNode = xmlGetNthChild( queryNode, _T("item"), i++ )) {
+ while (HXML itemNode = xmlGetNthChild(queryNode, _T("item"), i++)) {
U_TCHAR_MAP *pUserColumn=new U_TCHAR_MAP(10);
- TCHAR* jid = (TCHAR*)xmlGetAttrValue( itemNode, _T("jid"));
+ TCHAR *jid = (TCHAR*)xmlGetAttrValue(itemNode, _T("jid"));
TCHAR* keyReturned;
- mColumnsNames.insertCopyKey( _T("jid"),_T("jid"),&keyReturned, CopyKey, DestroyKey );
- mColumnsNames.insert( _T("jid"), keyReturned );
- pUserColumn->insertCopyKey( _T("jid"), jid, NULL, CopyKey, DestroyKey );
+ mColumnsNames.insertCopyKey(_T("jid"),_T("jid"),&keyReturned, CopyKey, DestroyKey);
+ mColumnsNames.insert(_T("jid"), keyReturned);
+ pUserColumn->insertCopyKey(_T("jid"), jid, NULL, CopyKey, DestroyKey);
- for ( int j=0; ; j++ ) {
- HXML child = xmlGetChild( itemNode, j );
- if ( !child )
+ for (int j=0; ; j++) {
+ HXML child = xmlGetChild(itemNode, j);
+ if ( !child)
break;
- const TCHAR* szColumnName = xmlGetName( child );
- if ( szColumnName ) {
- if ( xmlGetText( child ) && xmlGetText( child )[0] != _T('\0')) {
- mColumnsNames.insertCopyKey(( TCHAR* )szColumnName,_T(""),&keyReturned, CopyKey, DestroyKey);
- mColumnsNames.insert(( TCHAR* )szColumnName,keyReturned);
- pUserColumn->insertCopyKey(( TCHAR* )szColumnName, ( TCHAR* )xmlGetText( child ),NULL, CopyKey, DestroyKey);
+ const TCHAR *szColumnName = xmlGetName(child);
+ if (szColumnName) {
+ if (xmlGetText(child) && xmlGetText(child)[0] != _T('\0')) {
+ mColumnsNames.insertCopyKey((TCHAR*)szColumnName,_T(""),&keyReturned, CopyKey, DestroyKey);
+ mColumnsNames.insert((TCHAR*)szColumnName,keyReturned);
+ pUserColumn->insertCopyKey((TCHAR*)szColumnName, (TCHAR*)xmlGetText(child),NULL, CopyKey, DestroyKey);
} } }
SearchResults.insert((void*)pUserColumn);
} }
}
- else if (!lstrcmp( type, _T("error"))) {
- const TCHAR* code=NULL;
- const TCHAR* description=NULL;
+ else if ( !lstrcmp(type, _T("error"))) {
+ const TCHAR *code = NULL;
+ const TCHAR *description = NULL;
TCHAR buff[255];
- HXML errorNode = xmlGetChild( iqNode , "error" );
+ HXML errorNode = xmlGetChild(iqNode , "error");
if (errorNode) {
- code = xmlGetAttrValue( errorNode, _T("code"));
- description = xmlGetText( errorNode );
+ code = xmlGetAttrValue(errorNode, _T("code"));
+ description = xmlGetText(errorNode);
}
_sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nTry to specify more detailed"),code ? code : _T(""),description?description:_T(""));
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
- if (searchHandleDlg )
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
+ if (searchHandleDlg)
SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff);
else
MessageBox(NULL, buff, TranslateT("Search error"), MB_OK|MB_ICONSTOP);
@@ -382,14 +387,14 @@ void CJabberProto::OnIqResultAdvancedSearch( HXML iqNode ) SearchReturnResults((HANDLE)id, (void*)&SearchResults, (U_TCHAR_MAP *)&mColumnsNames);
- for (int i=0; i < SearchResults.getCount(); i++ )
+ for (int i=0; i < SearchResults.getCount(); i++)
delete ((U_TCHAR_MAP *)SearchResults[i]);
//send success to finish searching
- JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ JSendBroadcast(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
-static BOOL CALLBACK DeleteChildWindowsProc( HWND hwnd, LPARAM )
+static BOOL CALLBACK DeleteChildWindowsProc(HWND hwnd, LPARAM)
{
DestroyWindow(hwnd);
return TRUE;
@@ -398,8 +403,8 @@ static BOOL CALLBACK DeleteChildWindowsProc( HWND hwnd, LPARAM ) static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat)
{
//lock
- if ( !dat->fSearchRequestIsXForm && dat->nJSInfCount && dat->pJSInf ) {
- for ( int i=0; i < dat->nJSInfCount; i++ ) {
+ if ( !dat->fSearchRequestIsXForm && dat->nJSInfCount && dat->pJSInf) {
+ for (int i=0; i < dat->nJSInfCount; i++) {
if (dat->pJSInf[i].hwndValueItem)
DestroyWindow(dat->pJSInf[i].hwndValueItem);
if (dat->pJSInf[i].hwndCaptionItem)
@@ -414,10 +419,10 @@ static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat) }
else EnumChildWindows(GetDlgItem(hwndDlg,IDC_FRAME),DeleteChildWindowsProc,0);
- if ( dat->xNode )
- xi.destroyNode( dat->xNode );
+ if (dat->xNode)
+ xi.destroyNode(dat->xNode);
- SendMessage(GetDlgItem(hwndDlg,IDC_FRAME), WM_SETFONT, (WPARAM) SendMessage( hwndDlg, WM_GETFONT, 0, 0 ),0 );
+ SendMessage(GetDlgItem(hwndDlg,IDC_FRAME), WM_SETFONT, (WPARAM)SendMessage(hwndDlg, WM_GETFONT, 0, 0),0);
dat->nJSInfCount=0;
ShowWindow(GetDlgItem(hwndDlg,IDC_VSCROLL),SW_HIDE);
SetDlgItemText(hwndDlg,IDC_INSTRUCTIONS,TranslateT("Select/type search service URL above and press <Go>"));
@@ -426,19 +431,19 @@ static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat) static void JabberSearchRefreshFrameScroll(HWND hwndDlg, JabberSearchData * dat)
{
- HWND hFrame = GetDlgItem( hwndDlg, IDC_FRAME );
- HWND hwndScroll = GetDlgItem( hwndDlg, IDC_VSCROLL );
+ HWND hFrame = GetDlgItem(hwndDlg, IDC_FRAME);
+ HWND hwndScroll = GetDlgItem(hwndDlg, IDC_VSCROLL);
RECT rc;
- GetClientRect( hFrame, &rc );
- GetClientRect( hFrame, &dat->frameRect );
+ GetClientRect(hFrame, &rc);
+ GetClientRect(hFrame, &dat->frameRect);
dat->frameHeight = rc.bottom-rc.top;
- if ( dat->frameHeight < dat->CurrentHeight) {
- ShowWindow( hwndScroll, SW_SHOW );
- EnableWindow( hwndScroll, TRUE );
+ if (dat->frameHeight < dat->CurrentHeight) {
+ ShowWindow(hwndScroll, SW_SHOW);
+ EnableWindow(hwndScroll, TRUE);
}
- else ShowWindow( hwndScroll, SW_HIDE );
+ else ShowWindow(hwndScroll, SW_HIDE);
- SetScrollRange( hwndScroll, SB_CTL, 0, dat->CurrentHeight-dat->frameHeight, FALSE );
+ SetScrollRange(hwndScroll, SB_CTL, 0, dat->CurrentHeight-dat->frameHeight, FALSE);
}
int CJabberProto::SearchRenewFields(HWND hwndDlg, JabberSearchData * dat)
@@ -448,50 +453,50 @@ int CJabberProto::SearchRenewFields(HWND hwndDlg, JabberSearchData * dat) GetDlgItemText(hwndDlg,IDC_SERVER,szServerName,SIZEOF(szServerName));
dat->CurrentHeight = 0;
dat->curPos = 0;
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE );
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE);
- JabberSearchFreeData( hwndDlg, dat );
- JabberSearchRefreshFrameScroll( hwndDlg, dat );
+ JabberSearchFreeData(hwndDlg, dat);
+ JabberSearchRefreshFrameScroll(hwndDlg, dat);
SetDlgItemText(hwndDlg,IDC_INSTRUCTIONS,m_bJabberOnline ? TranslateT("Please wait...\r\nConnecting search server...") : TranslateT("You have to be connected to server"));
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 0;
searchHandleDlg = hwndDlg;
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_GETSEARCHFIELDS, &CJabberProto::OnIqResultGetSearchFields );
- m_ThreadInfo->send( XmlNodeIq( _T("get"), iqId, szServerName ) << XQUERY( _T("jabber:iq:search")));
+ IqAdd(iqId, IQ_PROC_GETSEARCHFIELDS, &CJabberProto::OnIqResultGetSearchFields);
+ m_ThreadInfo->send(XmlNodeIq(_T("get"), iqId, szServerName) << XQUERY(_T("jabber:iq:search")));
return iqId;
}
-static void JabberSearchAddUrlToRecentCombo(HWND hwndDlg, const TCHAR* szAddr)
+static void JabberSearchAddUrlToRecentCombo(HWND hwndDlg, const TCHAR *szAddr)
{
- int lResult = SendMessage( GetDlgItem(hwndDlg,IDC_SERVER), (UINT) CB_FINDSTRING, 0, (LPARAM)szAddr );
- if ( lResult == -1 )
- SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, ( LPARAM )szAddr );
+ int lResult = SendMessage(GetDlgItem(hwndDlg,IDC_SERVER), (UINT) CB_FINDSTRING, 0, (LPARAM)szAddr);
+ if (lResult == -1)
+ SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szAddr);
}
-void CJabberProto::SearchDeleteFromRecent( const TCHAR* szAddr, BOOL deleteLastFromDB )
+void CJabberProto::SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFromDB)
{
DBVARIANT dbv;
char key[30];
//search in recent
- for ( int i=0; i<10; i++ ) {
+ for (int i=0; i<10; i++) {
sprintf(key,"RecentlySearched_%d",i);
- if ( !JGetStringT( NULL, key, &dbv )) {
- if ( !_tcsicmp( szAddr, dbv.ptszVal )) {
- JFreeVariant( &dbv );
- for ( int j=i; j<10; j++ ) {
- sprintf( key, "RecentlySearched_%d", j+1 );
- if ( !JGetStringT( NULL, key, &dbv )) {
+ if ( !JGetStringT(NULL, key, &dbv)) {
+ if ( !_tcsicmp(szAddr, dbv.ptszVal)) {
+ db_free(&dbv);
+ for (int j=i; j<10; j++) {
+ sprintf(key, "RecentlySearched_%d", j+1);
+ if ( !JGetStringT(NULL, key, &dbv)) {
sprintf(key,"RecentlySearched_%d",j);
JSetStringT(NULL,key,dbv.ptszVal);
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
else {
- if ( deleteLastFromDB ) {
+ if (deleteLastFromDB) {
sprintf(key,"RecentlySearched_%d",j);
JDeleteSetting(NULL,key);
}
@@ -499,61 +504,61 @@ void CJabberProto::SearchDeleteFromRecent( const TCHAR* szAddr, BOOL deleteLastF } }
break;
}
- else JFreeVariant( &dbv );
+ else db_free(&dbv);
} } }
-void CJabberProto::SearchAddToRecent( const TCHAR* szAddr, HWND hwndDialog )
+void CJabberProto::SearchAddToRecent(const TCHAR *szAddr, HWND hwndDialog)
{
DBVARIANT dbv;
char key[30];
- SearchDeleteFromRecent( szAddr );
- for ( int j=9; j > 0; j-- ) {
- sprintf( key, "RecentlySearched_%d", j-1 );
- if ( !JGetStringT( NULL, key, &dbv )) {
+ SearchDeleteFromRecent(szAddr);
+ for (int j=9; j > 0; j--) {
+ sprintf(key, "RecentlySearched_%d", j-1);
+ if ( !JGetStringT(NULL, key, &dbv)) {
sprintf(key,"RecentlySearched_%d",j);
JSetStringT(NULL,key,dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
} }
- sprintf( key, "RecentlySearched_%d", 0 );
- JSetStringT( NULL, key, szAddr );
- if ( hwndDialog )
- JabberSearchAddUrlToRecentCombo( hwndDialog, szAddr );
+ sprintf(key, "RecentlySearched_%d", 0);
+ JSetStringT(NULL, key, szAddr);
+ if (hwndDialog)
+ JabberSearchAddUrlToRecentCombo(hwndDialog, szAddr);
}
static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberSearchData* dat = ( JabberSearchData* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
- switch ( msg ) {
+ JabberSearchData* dat = (JabberSearchData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ switch (msg) {
case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
- dat = ( JabberSearchData * )mir_alloc( sizeof( JabberSearchData ));
- memset( dat, 0, sizeof( JabberSearchData ));
- dat->ppro = ( CJabberProto* )lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, (LONG_PTR)dat );
+ dat = (JabberSearchData *)mir_alloc(sizeof(JabberSearchData));
+ memset(dat, 0, sizeof(JabberSearchData));
+ dat->ppro = (CJabberProto*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
/* Server Combo box */
char szServerName[100];
- if ( dat->ppro->JGetStaticString( "Jud", NULL, szServerName, sizeof szServerName ))
- strcpy( szServerName, "users.jabber.org" );
+ if (dat->ppro->JGetStaticString("Jud", NULL, szServerName, sizeof(szServerName)))
+ strcpy(szServerName, "users.jabber.org");
SetDlgItemTextA(hwndDlg,IDC_SERVER,szServerName);
SendDlgItemMessageA(hwndDlg,IDC_SERVER,CB_ADDSTRING,0,(LPARAM)szServerName);
//TO DO: Add Transports here
int i, transpCount = dat->ppro->m_lstTransports.getCount();
- for ( i=0; i < transpCount; i++ ) {
+ for (i=0; i < transpCount; i++) {
TCHAR* szTransp = dat->ppro->m_lstTransports[i];
- if ( szTransp )
- JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp );
+ if (szTransp)
+ JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp);
}
DBVARIANT dbv;
char key[30];
- for ( i=0; i < 10; i++ ) {
+ for (i=0; i < 10; i++) {
sprintf(key,"RecentlySearched_%d",i);
- if ( !dat->ppro->JGetStringT( NULL, key, &dbv )) {
- JabberSearchAddUrlToRecentCombo(hwndDlg, dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !dat->ppro->JGetStringT(NULL, key, &dbv)) {
+ JabberSearchAddUrlToRecentCombo(hwndDlg, dbv.ptszVal);
+ db_free(&dbv);
} }
//TO DO: Add 4 recently used
@@ -562,8 +567,8 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR return TRUE;
case WM_COMMAND:
- if ( LOWORD(wParam) == IDC_SERVER ) {
- switch ( HIWORD( wParam )) {
+ if (LOWORD(wParam) == IDC_SERVER) {
+ switch (HIWORD(wParam)) {
case CBN_SETFOCUS:
PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg);
return TRUE;
@@ -583,8 +588,8 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR return TRUE;
}
}
- else if ( LOWORD(wParam) == IDC_GO && HIWORD(wParam) == BN_CLICKED ) {
- dat->ppro->SearchRenewFields( hwndDlg, dat );
+ else if (LOWORD(wParam) == IDC_GO && HIWORD(wParam) == BN_CLICKED) {
+ dat->ppro->SearchRenewFields(hwndDlg, dat);
return TRUE;
}
break;
@@ -595,7 +600,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR RECT rcForm;
GetWindowRect(hwndDlg, &rcForm);
RECT rcFrame;
- GetWindowRect( GetDlgItem(hwndDlg, IDC_FRAME), &rcFrame );
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_FRAME), &rcFrame);
rcFrame.bottom = rcForm.bottom;
SetWindowPos(GetDlgItem(hwndDlg,IDC_FRAME),NULL,0,0,rcFrame.right-rcFrame.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE);
GetWindowRect(GetDlgItem(hwndDlg,IDC_VSCROLL), &rcForm);
@@ -607,28 +612,28 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR case WM_USER+11:
{
dat->fSearchRequestIsXForm=TRUE;
- dat->xNode = ( HXML )wParam;
- JabberFormCreateUI( GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight,TRUE);
+ dat->xNode = (HXML)wParam;
+ JabberFormCreateUI(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight,TRUE);
ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME), SW_SHOW);
dat->nJSInfCount=1;
return TRUE;
}
case WM_USER+10:
{
- Data* MyDat = ( Data* )lParam;
- if ( MyDat ) {
- dat->fSearchRequestIsXForm = ( BOOL )wParam;
+ Data* MyDat = (Data*)lParam;
+ if (MyDat) {
+ dat->fSearchRequestIsXForm = (BOOL)wParam;
dat->CurrentHeight = JabberSearchAddField(hwndDlg,MyDat);
- mir_free( MyDat->Label );
- mir_free( MyDat->Var );
- mir_free( MyDat->defValue );
- free( MyDat );
+ mir_free(MyDat->Label);
+ mir_free(MyDat->Var);
+ mir_free(MyDat->defValue);
+ free(MyDat);
}
else
{
JabberSearchRefreshFrameScroll(hwndDlg,dat);
- ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - 0, NULL, &( dat->frameRect ));
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE );
+ ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - 0, NULL, &(dat->frameRect));
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE);
dat->curPos=0;
}
return TRUE;
@@ -636,7 +641,7 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR case WM_MOUSEWHEEL:
{
int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
- if ( zDelta ) {
+ if (zDelta) {
int nScrollLines=0;
SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,(void*)&nScrollLines,0);
for (int i=0; i<(nScrollLines+1)/2; i++)
@@ -647,9 +652,9 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR case WM_VSCROLL:
{
int pos;
- if ( dat != NULL ) {
+ if (dat != NULL) {
pos = dat->curPos;
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case SB_LINEDOWN:
pos += 10;
break;
@@ -657,48 +662,48 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR pos -= 10;
break;
case SB_PAGEDOWN:
- pos += ( dat->CurrentHeight - 10 );
+ pos += (dat->CurrentHeight - 10);
break;
case SB_PAGEUP:
- pos -= ( dat->CurrentHeight - 10 );
+ pos -= (dat->CurrentHeight - 10);
break;
case SB_THUMBTRACK:
- pos = HIWORD( wParam );
+ pos = HIWORD(wParam);
break;
}
- if ( pos > ( dat->CurrentHeight - dat->frameHeight ))
+ if (pos > (dat->CurrentHeight - dat->frameHeight))
pos = dat->CurrentHeight - dat->frameHeight;
- if ( pos < 0 )
+ if (pos < 0)
pos = 0;
- if ( dat->curPos != pos ) {
- ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - pos, NULL , &( dat->frameRect ));
- SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, pos, TRUE );
+ if (dat->curPos != pos) {
+ ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL , &(dat->frameRect));
+ SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE);
RECT Invalid=dat->frameRect;
if (dat->curPos - pos >0)
Invalid.bottom=Invalid.top+(dat->curPos - pos);
else
Invalid.top=Invalid.bottom+(dat->curPos - pos);
- RedrawWindow(GetDlgItem( hwndDlg, IDC_FRAME ), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN);
+ RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN);
dat->curPos = pos;
} } }
return TRUE;
case WM_DESTROY:
- JabberSearchFreeData( hwndDlg, dat );
- JabberFormDestroyUI( GetDlgItem( hwndDlg, IDC_FRAME ));
- mir_free( dat );
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, 0 );
+ JabberSearchFreeData(hwndDlg, dat);
+ JabberFormDestroyUI(GetDlgItem(hwndDlg, IDC_FRAME));
+ mir_free(dat);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
return TRUE;
}
return FALSE;
}
-HWND __cdecl CJabberProto::CreateExtendedSearchUI( HWND parent )
+HWND __cdecl CJabberProto::CreateExtendedSearchUI(HWND parent)
{
TCHAR szServer[128];
if (parent && hInst && (!JGetStringT(NULL, "LoginServer", szServer, SIZEOF(szServer)) || _tcsicmp(szServer, _T("S.ms"))))
- return CreateDialogParam( hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, ( LPARAM )this );
+ return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this);
return 0; // Failure
}
@@ -706,17 +711,17 @@ HWND __cdecl CJabberProto::CreateExtendedSearchUI( HWND parent ) //////////////////////////////////////////////////////////////////////////
// The function formats request to server
-HWND __cdecl CJabberProto::SearchAdvanced( HWND hwndDlg )
+HWND __cdecl CJabberProto::SearchAdvanced(HWND hwndDlg)
{
- if ( !m_bJabberOnline || !hwndDlg )
+ if ( !m_bJabberOnline || !hwndDlg)
return 0; //error
JabberSearchData * dat=(JabberSearchData *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- if ( !dat )
+ if ( !dat)
return 0; //error
// check if server connected (at least one field exists)
- if ( dat->nJSInfCount == 0 )
+ if (dat->nJSInfCount == 0)
return 0;
// formating request
@@ -724,39 +729,39 @@ HWND __cdecl CJabberProto::SearchAdvanced( HWND hwndDlg ) // get server name
TCHAR szServerName[100];
- GetDlgItemText( hwndDlg, IDC_SERVER, szServerName, SIZEOF( szServerName ));
+ GetDlgItemText(hwndDlg, IDC_SERVER, szServerName, SIZEOF(szServerName));
// formating query
int iqId = SerialNext();
- XmlNodeIq iq( _T("set"), iqId, szServerName );
- HXML query = iq << XQUERY( _T("jabber:iq:search"));
+ XmlNodeIq iq(_T("set"), iqId, szServerName);
+ HXML query = iq << XQUERY(_T("jabber:iq:search"));
- if ( m_tszSelectedLang )
- iq << XATTR( _T("xml:lang"), m_tszSelectedLang ); // i'm sure :)
+ if (m_tszSelectedLang)
+ iq << XATTR(_T("xml:lang"), m_tszSelectedLang); // i'm sure :)
// next can be 2 cases:
// Forms: XEP-0055 Example 7
- if ( dat->fSearchRequestIsXForm ) {
+ if (dat->fSearchRequestIsXForm) {
fRequestNotEmpty=TRUE;
HXML n = JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode);
- xmlAddChild( query, n );
- xi.destroyNode( n );
+ xmlAddChild(query, n);
+ xi.destroyNode(n);
}
else { //and Simple fields: XEP-0055 Example 3
- for ( int i=0; i<dat->nJSInfCount; i++ ) {
+ for (int i=0; i<dat->nJSInfCount; i++) {
TCHAR szFieldValue[100];
GetWindowText(dat->pJSInf[i].hwndValueItem, szFieldValue, SIZEOF(szFieldValue));
- if ( szFieldValue[0] != _T('\0')) {
- xmlAddChild( query, dat->pJSInf[i].szFieldName, szFieldValue );
+ if (szFieldValue[0] != _T('\0')) {
+ xmlAddChild(query, dat->pJSInf[i].szFieldName, szFieldValue);
fRequestNotEmpty=TRUE;
} } }
- if ( fRequestNotEmpty ) {
+ if (fRequestNotEmpty) {
// register search request result handler
- IqAdd( iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultAdvancedSearch );
+ IqAdd(iqId, IQ_PROC_GETSEARCH, &CJabberProto::OnIqResultAdvancedSearch);
// send request
- m_ThreadInfo->send( iq );
- return ( HWND )iqId;
+ m_ThreadInfo->send(iq);
+ return (HWND)iqId;
}
return 0;
}
diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h index 7450b652d1..52406d974e 100644 --- a/protocols/JabberG/src/jabber_search.h +++ b/protocols/JabberG/src/jabber_search.h @@ -1,9 +1,9 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Artem Shpynov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Artem Shpynov
Module implements a search according to XEP-0055: Jabber Search
http://www.xmpp.org/extensions/xep-0055.html
@@ -11,7 +11,7 @@ http://www.xmpp.org/extensions/xep-0055.html 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
@@ -71,8 +71,8 @@ static HWND searchHandleDlg=NULL; //local functions declarations
static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam);
-static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat );
-static void JabberIqResultGetSearchFields( HXML iqNode, void *userdata );
+static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat);
+static void JabberIqResultGetSearchFields(HXML iqNode, void *userdata);
static void JabberSearchFreeData(HWND hwndDlg, JabberSearchData * dat);
static void JabberSearchRefreshFrameScroll(HWND hwndDlg, JabberSearchData * dat);
static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -108,7 +108,7 @@ private: int _nextOrder;
LIST<_RECORD> _Records;
- static int _KeysEqual( const _RECORD* p1, const _RECORD* p2 )
+ static int _KeysEqual(const _RECORD* p1, const _RECORD* p2)
{
if (COMPARATOR)
return (int)(COMPARATOR((p1->_key),(p2->_key)));
@@ -161,7 +161,7 @@ public: int index=_Records.getIndex(rec);
if (index<0)
{
- if (!_Records.insert(rec)) delete rec;
+ if ( !_Records.insert(rec)) delete rec;
else
{
index=_Records.getIndex(rec);
@@ -175,14 +175,14 @@ public: }
return index;
}
- int insertCopyKey(_KEYTYPE* Key, TCHAR *Value, _KEYTYPE** _KeyReturn, COPYKEYPROC CopyProc, DESTROYKEYPROC DestroyProc )
+ int insertCopyKey(_KEYTYPE* Key, TCHAR *Value, _KEYTYPE** _KeyReturn, COPYKEYPROC CopyProc, DESTROYKEYPROC DestroyProc)
{
_RECORD * rec= new _RECORD(Key,Value);
int index=_Records.getIndex(rec);
if (index<0)
{
_KEYTYPE* newKey=CopyProc(Key);
- if (!_Records.insert(rec))
+ if ( !_Records.insert(rec))
{
delete rec;
DestroyProc(newKey);
@@ -205,7 +205,7 @@ public: }
return index;
}
- inline TCHAR* operator[]( _KEYTYPE* _KEY ) const
+ inline TCHAR* operator[](_KEYTYPE* _KEY) const
{
_RECORD rec(_KEY);
int index=_Records.getIndex(&rec);
@@ -220,7 +220,7 @@ public: else
return NULL;
}
- inline TCHAR* operator[]( int index ) const
+ inline TCHAR* operator[](int index) const
{
_RECORD * rv=_Records[index];
if (rv) return rv->_value;
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp index e91496f774..37c515943f 100644 --- a/protocols/JabberG/src/jabber_secur.cpp +++ b/protocols/JabberG/src/jabber_secur.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
@@ -23,92 +23,92 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber.h"
#include "jabber_secur.h"
-typedef BYTE (WINAPI *GetUserNameExType )( int NameFormat, LPTSTR lpNameBuffer, PULONG nSize );
+typedef BYTE (WINAPI *GetUserNameExType)(int NameFormat, LPTSTR lpNameBuffer, PULONG nSize);
/////////////////////////////////////////////////////////////////////////////////////////
// ntlm auth - LanServer based authorization
-TNtlmAuth::TNtlmAuth( ThreadData* info, const char* mechanism, const TCHAR* hostname ) :
- TJabberAuth( info )
+TNtlmAuth::TNtlmAuth(ThreadData* info, const char* mechanism, const TCHAR *hostname) :
+ TJabberAuth(info)
{
szName = mechanism;
szHostName = hostname;
const TCHAR *szProvider;
- if ( !strcmp( mechanism, "GSS-SPNEGO" ))
+ if ( !strcmp(mechanism, "GSS-SPNEGO"))
szProvider = _T("Negotiate");
- else if ( !strcmp( mechanism, "GSSAPI" ))
+ else if ( !strcmp(mechanism, "GSSAPI"))
szProvider = _T("GSSAPI");
- else if ( !strcmp( mechanism, "NTLM" ))
+ else if ( !strcmp(mechanism, "NTLM"))
szProvider = _T("NTLM");
else {
bIsValid = false;
return;
}
- TCHAR szSpn[ 1024 ] = _T( "" );
- if ( strcmp( mechanism, "NTLM" )) {
- if ( !getSpn( szSpn, SIZEOF( szSpn )) && !strcmp( mechanism, "GSSAPI" )) {
+ TCHAR szSpn[ 1024 ] = _T("");
+ if (strcmp(mechanism, "NTLM")) {
+ if ( !getSpn(szSpn, SIZEOF(szSpn)) && !strcmp(mechanism, "GSSAPI")) {
bIsValid = false;
return;
} }
- if (( hProvider = Netlib_InitSecurityProvider2( szProvider, szSpn )) == NULL )
+ if ((hProvider = Netlib_InitSecurityProvider2(szProvider, szSpn)) == NULL)
bIsValid = false;
}
TNtlmAuth::~TNtlmAuth()
{
- if ( hProvider != NULL )
- Netlib_DestroySecurityProvider( NULL, hProvider );
+ if (hProvider != NULL)
+ Netlib_DestroySecurityProvider(NULL, hProvider);
}
-bool TNtlmAuth::getSpn( TCHAR* szSpn, size_t dwSpnLen )
+bool TNtlmAuth::getSpn(TCHAR* szSpn, size_t dwSpnLen)
{
HMODULE hDll = GetModuleHandle(_T("secur32.dll"));
- if (!hDll)
+ if ( !hDll)
hDll = LoadLibrary(_T("secur32.dll"));
- if (!hDll)
+ if ( !hDll)
return false;
GetUserNameExType myGetUserNameEx =
- ( GetUserNameExType )GetProcAddress(hDll, "GetUserNameExW" );
+ (GetUserNameExType)GetProcAddress(hDll, "GetUserNameExW");
- if ( !myGetUserNameEx ) return false;
+ if ( !myGetUserNameEx) return false;
- TCHAR szFullUserName[128] = _T( "" );
- ULONG szFullUserNameLen = SIZEOF( szFullUserName );
- if (!myGetUserNameEx( 12, szFullUserName, &szFullUserNameLen )) {
+ TCHAR szFullUserName[128] = _T("");
+ ULONG szFullUserNameLen = SIZEOF(szFullUserName);
+ if ( !myGetUserNameEx(12, szFullUserName, &szFullUserNameLen)) {
szFullUserName[ 0 ] = 0;
- szFullUserNameLen = SIZEOF( szFullUserName );
- myGetUserNameEx( 2, szFullUserName, &szFullUserNameLen );
+ szFullUserNameLen = SIZEOF(szFullUserName);
+ myGetUserNameEx(2, szFullUserName, &szFullUserNameLen);
}
- TCHAR* name = _tcsrchr( szFullUserName, '\\' );
- if ( name ) *name = 0;
+ TCHAR* name = _tcsrchr(szFullUserName, '\\');
+ if (name) *name = 0;
else return false;
- if ( szHostName && szHostName[0] ) {
- TCHAR *szFullUserNameU = _tcsupr( mir_tstrdup( szFullUserName ));
- mir_sntprintf( szSpn, dwSpnLen, _T( "xmpp/%s/%s@%s" ), szHostName, szFullUserName, szFullUserNameU );
- mir_free( szFullUserNameU );
+ if (szHostName && szHostName[0]) {
+ TCHAR *szFullUserNameU = _tcsupr(mir_tstrdup(szFullUserName));
+ mir_sntprintf(szSpn, dwSpnLen, _T("xmpp/%s/%s@%s"), szHostName, szFullUserName, szFullUserNameU);
+ mir_free(szFullUserNameU);
} else {
const char* connectHost = info->manualHost[0] ? info->manualHost : info->server;
- unsigned long ip = inet_addr( connectHost );
+ unsigned long ip = inet_addr(connectHost);
// Convert host name to FQDN
-// PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname( szHost ) : gethostbyaddr(( char* )&ip, 4, AF_INET );
- PHOSTENT host = (ip == INADDR_NONE) ? NULL : gethostbyaddr(( char* )&ip, 4, AF_INET );
- if ( host && host->h_name )
+// PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname(szHost) : gethostbyaddr((char*)&ip, 4, AF_INET);
+ PHOSTENT host = (ip == INADDR_NONE) ? NULL : gethostbyaddr((char*)&ip, 4, AF_INET);
+ if (host && host->h_name)
connectHost = host->h_name;
- TCHAR *connectHostT = mir_a2t( connectHost );
- mir_sntprintf( szSpn, dwSpnLen, _T( "xmpp/%s@%s" ), connectHostT, _tcsupr( szFullUserName ));
- mir_free( connectHostT );
+ TCHAR *connectHostT = mir_a2t(connectHost);
+ mir_sntprintf(szSpn, dwSpnLen, _T("xmpp/%s@%s"), connectHostT, _tcsupr(szFullUserName));
+ mir_free(connectHostT);
}
- Netlib_Logf( NULL, "SPN: " TCHAR_STR_PARAM, szSpn );
+ Netlib_Logf(NULL, "SPN: " TCHAR_STR_PARAM, szSpn);
return true;
@@ -116,40 +116,40 @@ bool TNtlmAuth::getSpn( TCHAR* szSpn, size_t dwSpnLen ) char* TNtlmAuth::getInitialRequest()
{
- if ( !hProvider )
+ if ( !hProvider)
return NULL;
// This generates login method advertisement packet
char* result;
- if ( info->password[0] != 0 )
- result = Netlib_NtlmCreateResponse2( hProvider, "", info->username, info->password, &complete );
+ if (info->password[0] != 0)
+ result = Netlib_NtlmCreateResponse2(hProvider, "", info->username, info->password, &complete);
else
- result = Netlib_NtlmCreateResponse2( hProvider, "", NULL, NULL, &complete );
+ result = Netlib_NtlmCreateResponse2(hProvider, "", NULL, NULL, &complete);
return result;
}
-char* TNtlmAuth::getChallenge( const TCHAR* challenge )
+char* TNtlmAuth::getChallenge(const TCHAR *challenge)
{
- if ( !hProvider )
+ if ( !hProvider)
return NULL;
- char *text = ( !lstrcmp( challenge, _T("="))) ? mir_strdup( "" ) : mir_t2a( challenge ), *result;
- if ( info->password[0] != 0 )
- result = Netlib_NtlmCreateResponse2( hProvider, text, info->username, info->password, &complete );
+ char *text = (!lstrcmp(challenge, _T("="))) ? mir_strdup("") : mir_t2a(challenge), *result;
+ if (info->password[0] != 0)
+ result = Netlib_NtlmCreateResponse2(hProvider, text, info->username, info->password, &complete);
else
- result = Netlib_NtlmCreateResponse2( hProvider, text, NULL, NULL, &complete );
+ result = Netlib_NtlmCreateResponse2(hProvider, text, NULL, NULL, &complete);
- mir_free( text );
+ mir_free(text);
return result;
}
/////////////////////////////////////////////////////////////////////////////////////////
// md5 auth - digest-based authorization
-TMD5Auth::TMD5Auth( ThreadData* info ) :
- TJabberAuth( info ),
- iCallCount( 0 )
+TMD5Auth::TMD5Auth(ThreadData* info) :
+ TJabberAuth(info),
+ iCallCount(0)
{
szName = "DIGEST-MD5";
}
@@ -158,77 +158,77 @@ TMD5Auth::~TMD5Auth() {
}
-char* TMD5Auth::getChallenge( const TCHAR* challenge )
+char* TMD5Auth::getChallenge(const TCHAR *challenge)
{
- if ( iCallCount > 0 )
+ if (iCallCount > 0)
return NULL;
iCallCount++;
int resultLen;
- char* text = JabberBase64DecodeT( challenge, &resultLen );
+ char* text = JabberBase64DecodeT(challenge, &resultLen);
- TStringPairs pairs( text );
+ TStringPairs pairs(text);
const char *realm = pairs["realm"], *nonce = pairs["nonce"];
char cnonce[40], tmpBuf[40];
DWORD digest[4], hash1[4], hash2[4];
mir_md5_state_t ctx;
- CallService( MS_UTILS_GETRANDOM, sizeof( digest ), ( LPARAM )digest );
- sprintf( cnonce, "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
-
- char *uname = mir_utf8encodeT( info->username ),
- *passw = mir_utf8encodeT( info->password ),
- *serv = mir_utf8encode( info->server );
-
- mir_md5_init( &ctx );
- mir_md5_append( &ctx, ( BYTE* )uname, (int)strlen( uname ));
- mir_md5_append( &ctx, ( BYTE* )":", 1 );
- mir_md5_append( &ctx, ( BYTE* )realm, (int)strlen( realm ));
- mir_md5_append( &ctx, ( BYTE* )":", 1 );
- mir_md5_append( &ctx, ( BYTE* )passw, (int)strlen( passw ));
- mir_md5_finish( &ctx, ( BYTE* )hash1 );
-
- mir_md5_init( &ctx );
- mir_md5_append( &ctx, ( BYTE* )hash1, 16 );
- mir_md5_append( &ctx, ( BYTE* )":", 1 );
- mir_md5_append( &ctx, ( BYTE* )nonce, (int)strlen( nonce ));
- mir_md5_append( &ctx, ( BYTE* )":", 1 );
- mir_md5_append( &ctx, ( BYTE* )cnonce, (int)strlen( cnonce ));
- mir_md5_finish( &ctx, ( BYTE* )hash1 );
+ CallService(MS_UTILS_GETRANDOM, sizeof(digest), (LPARAM)digest);
+ sprintf(cnonce, "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
+
+ char *uname = mir_utf8encodeT(info->username),
+ *passw = mir_utf8encodeT(info->password),
+ *serv = mir_utf8encode(info->server);
+
+ mir_md5_init(&ctx);
+ mir_md5_append(&ctx, (BYTE*)uname, (int)strlen(uname));
+ mir_md5_append(&ctx, (BYTE*)":", 1);
+ mir_md5_append(&ctx, (BYTE*)realm, (int)strlen(realm));
+ mir_md5_append(&ctx, (BYTE*)":", 1);
+ mir_md5_append(&ctx, (BYTE*)passw, (int)strlen(passw));
+ mir_md5_finish(&ctx, (BYTE*)hash1);
+
+ mir_md5_init(&ctx);
+ mir_md5_append(&ctx, (BYTE*)hash1, 16);
+ mir_md5_append(&ctx, (BYTE*)":", 1);
+ mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
+ mir_md5_append(&ctx, (BYTE*)":", 1);
+ mir_md5_append(&ctx, (BYTE*)cnonce, (int)strlen(cnonce));
+ mir_md5_finish(&ctx, (BYTE*)hash1);
- mir_md5_init( &ctx );
- mir_md5_append( &ctx, ( BYTE* )"AUTHENTICATE:xmpp/", 18 );
- mir_md5_append( &ctx, ( BYTE* )serv, (int)strlen( serv ));
- mir_md5_finish( &ctx, ( BYTE* )hash2 );
-
- mir_md5_init( &ctx );
- sprintf( tmpBuf, "%08x%08x%08x%08x", htonl(hash1[0]), htonl(hash1[1]), htonl(hash1[2]), htonl(hash1[3]));
- mir_md5_append( &ctx, ( BYTE* )tmpBuf, (int)strlen( tmpBuf ));
- mir_md5_append( &ctx, ( BYTE* )":", 1 );
- mir_md5_append( &ctx, ( BYTE* )nonce, (int)strlen( nonce ));
- sprintf( tmpBuf, ":%08d:", iCallCount );
- mir_md5_append( &ctx, ( BYTE* )tmpBuf, (int)strlen( tmpBuf ));
- mir_md5_append( &ctx, ( BYTE* )cnonce, (int)strlen( cnonce ));
- mir_md5_append( &ctx, ( BYTE* )":auth:", 6 );
- sprintf( tmpBuf, "%08x%08x%08x%08x", htonl(hash2[0]), htonl(hash2[1]), htonl(hash2[2]), htonl(hash2[3]));
- mir_md5_append( &ctx, ( BYTE* )tmpBuf, (int)strlen( tmpBuf ));
- mir_md5_finish( &ctx, ( BYTE* )digest );
+ mir_md5_init(&ctx);
+ mir_md5_append(&ctx, (BYTE*)"AUTHENTICATE:xmpp/", 18);
+ mir_md5_append(&ctx, (BYTE*)serv, (int)strlen(serv));
+ mir_md5_finish(&ctx, (BYTE*)hash2);
+
+ mir_md5_init(&ctx);
+ sprintf(tmpBuf, "%08x%08x%08x%08x", htonl(hash1[0]), htonl(hash1[1]), htonl(hash1[2]), htonl(hash1[3]));
+ mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
+ mir_md5_append(&ctx, (BYTE*)":", 1);
+ mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
+ sprintf(tmpBuf, ":%08d:", iCallCount);
+ mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
+ mir_md5_append(&ctx, (BYTE*)cnonce, (int)strlen(cnonce));
+ mir_md5_append(&ctx, (BYTE*)":auth:", 6);
+ sprintf(tmpBuf, "%08x%08x%08x%08x", htonl(hash2[0]), htonl(hash2[1]), htonl(hash2[2]), htonl(hash2[3]));
+ mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
+ mir_md5_finish(&ctx, (BYTE*)digest);
char* buf = (char*)alloca(8000);
- int cbLen = mir_snprintf( buf, 8000,
+ int cbLen = mir_snprintf(buf, 8000,
"username=\"%s\",realm=\"%s\",nonce=\"%s\",cnonce=\"%s\",nc=%08d,"
"qop=auth,digest-uri=\"xmpp/%s\",charset=utf-8,response=%08x%08x%08x%08x",
uname, realm, nonce, cnonce, iCallCount, serv,
htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
- mir_free( uname );
- mir_free( passw );
- mir_free( serv );
- mir_free( text );
+ mir_free(uname);
+ mir_free(passw);
+ mir_free(serv);
+ mir_free(text);
- return JabberBase64Encode( buf, cbLen );
+ return JabberBase64Encode(buf, cbLen);
}
@@ -274,8 +274,8 @@ void hmac_sha1(mir_sha1_byte_t *md, mir_sha1_byte_t *key, size_t keylen, mir_sha mir_sha1_finish(&ctx, md);
}
-TScramAuth::TScramAuth( ThreadData* info ) :
- TJabberAuth( info )
+TScramAuth::TScramAuth(ThreadData* info) :
+ TJabberAuth(info)
{
szName = "SCRAM-SHA-1";
cnonce = msg1 = serverSignature = NULL;
@@ -283,131 +283,131 @@ TScramAuth::TScramAuth( ThreadData* info ) : TScramAuth::~TScramAuth()
{
- mir_free( cnonce );
- mir_free( msg1 );
- mir_free( serverSignature );
+ mir_free(cnonce);
+ mir_free(msg1);
+ mir_free(serverSignature);
}
-void TScramAuth::Hi( mir_sha1_byte_t* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind )
+void TScramAuth::Hi(mir_sha1_byte_t* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind)
{
mir_sha1_byte_t u[ MIR_SHA1_HASH_SIZE ];
- memcpy( u, salt, saltLen ); *( unsigned* )( u + saltLen ) = htonl( 1 ); saltLen += 4;
- memset( res, 0, MIR_SHA1_HASH_SIZE );
+ memcpy(u, salt, saltLen); *(unsigned*)(u + saltLen) = htonl(1); saltLen += 4;
+ memset(res, 0, MIR_SHA1_HASH_SIZE);
for (int i = 0; i < ind; i++)
{
- hmac_sha1( u, (mir_sha1_byte_t*)passw, passwLen, u, saltLen);
- saltLen = sizeof( u );
+ hmac_sha1(u, (mir_sha1_byte_t*)passw, passwLen, u, saltLen);
+ saltLen = sizeof(u);
- for (unsigned j = 0; j < sizeof( u ); j++)
+ for (unsigned j = 0; j < sizeof(u); j++)
res[j] ^= u[j];
}
}
-char* TScramAuth::getChallenge( const TCHAR* challenge )
+char* TScramAuth::getChallenge(const TCHAR *challenge)
{
int chlLen;
- char *chl = JabberBase64DecodeT( challenge, &chlLen );
+ char *chl = JabberBase64DecodeT(challenge, &chlLen);
- char *r = strstr( chl, "r=" ); if ( !r ) { mir_free( chl ); return NULL; }
- char *e = strchr( r, ',' ); if ( e ) *e = 0;
+ char *r = strstr(chl, "r="); if ( !r) { mir_free(chl); return NULL; }
+ char *e = strchr(r, ','); if (e) *e = 0;
char *snonce = mir_strdup(r + 2);
- if ( e ) *e = ',';
+ if (e) *e = ',';
- size_t cnlen = strlen( cnonce );
- if (strncmp(cnonce, snonce, cnlen )) { mir_free( chl ); mir_free( snonce ); return NULL; }
+ size_t cnlen = strlen(cnonce);
+ if (strncmp(cnonce, snonce, cnlen)) { mir_free(chl); mir_free(snonce); return NULL; }
- char *s = strstr( chl, "s=" ); if ( !s ) { mir_free( chl ); mir_free( snonce ); return NULL; }
- e = strchr( s, ',' ); if ( e ) *e = 0;
+ char *s = strstr(chl, "s="); if ( !s) { mir_free(chl); mir_free(snonce); return NULL; }
+ e = strchr(s, ','); if (e) *e = 0;
int saltLen;
- char *salt = JabberBase64Decode( s + 2, &saltLen );
- if ( e ) *e = ',';
+ char *salt = JabberBase64Decode(s + 2, &saltLen);
+ if (e) *e = ',';
- if ( saltLen > 16 ) {
- mir_free( salt );
- mir_free( snonce );
- mir_free( chl );
+ if (saltLen > 16) {
+ mir_free(salt);
+ mir_free(snonce);
+ mir_free(chl);
return NULL;
}
- char *in = strstr( chl, "i=" ); if ( !in ) return NULL;
- e = strchr( in, ',' ); if ( e ) *e = 0;
- int ind = atoi( in + 2 );
- if ( e ) *e = ',';
+ char *in = strstr(chl, "i="); if ( !in) return NULL;
+ e = strchr(in, ','); if (e) *e = 0;
+ int ind = atoi(in + 2);
+ if (e) *e = ',';
- char *passw = mir_utf8encodeT( info->password );
- size_t passwLen = strlen( passw );
+ char *passw = mir_utf8encodeT(info->password);
+ size_t passwLen = strlen(passw);
mir_sha1_byte_t saltedPassw[ MIR_SHA1_HASH_SIZE ];
- Hi( saltedPassw, passw, passwLen, salt, saltLen, ind );
+ Hi(saltedPassw, passw, passwLen, salt, saltLen, ind);
- mir_free( salt );
- mir_free( passw );
+ mir_free(salt);
+ mir_free(passw);
mir_sha1_byte_t clientKey[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1( clientKey, saltedPassw, sizeof( saltedPassw ), (mir_sha1_byte_t*)"Client Key", 10 );
+ hmac_sha1(clientKey, saltedPassw, sizeof(saltedPassw), (mir_sha1_byte_t*)"Client Key", 10);
mir_sha1_byte_t storedKey[ MIR_SHA1_HASH_SIZE ];
mir_sha1_ctx ctx;
- mir_sha1_init( &ctx );
- mir_sha1_append( &ctx, clientKey, MIR_SHA1_HASH_SIZE );
- mir_sha1_finish( &ctx, storedKey );
+ mir_sha1_init(&ctx);
+ mir_sha1_append(&ctx, clientKey, MIR_SHA1_HASH_SIZE);
+ mir_sha1_finish(&ctx, storedKey);
char authmsg[4096];
- int authmsgLen = mir_snprintf( authmsg, sizeof( authmsg ), "%s,%s,c=biws,r=%s", msg1, chl, snonce);
+ int authmsgLen = mir_snprintf(authmsg, sizeof(authmsg), "%s,%s,c=biws,r=%s", msg1, chl, snonce);
mir_sha1_byte_t clientSig[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1( clientSig, storedKey, sizeof( storedKey ), (mir_sha1_byte_t*)authmsg, authmsgLen);
+ hmac_sha1(clientSig, storedKey, sizeof(storedKey), (mir_sha1_byte_t*)authmsg, authmsgLen);
mir_sha1_byte_t clientProof[ MIR_SHA1_HASH_SIZE ];
- for (unsigned j = 0; j < sizeof( clientKey ); j++)
+ for (unsigned j = 0; j < sizeof(clientKey); j++)
clientProof[j] = clientKey[j] ^ clientSig[j];
/* Calculate the server signature */
mir_sha1_byte_t serverKey[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1( serverKey, saltedPassw, sizeof( saltedPassw ), (mir_sha1_byte_t*)"Server Key", 10 );
+ hmac_sha1(serverKey, saltedPassw, sizeof(saltedPassw), (mir_sha1_byte_t*)"Server Key", 10);
mir_sha1_byte_t srvSig[ MIR_SHA1_HASH_SIZE ];
- hmac_sha1( srvSig, serverKey, sizeof( serverKey ), (mir_sha1_byte_t*)authmsg, authmsgLen);
- serverSignature = JabberBase64Encode(( char* )srvSig, sizeof( srvSig ));
+ hmac_sha1(srvSig, serverKey, sizeof(serverKey), (mir_sha1_byte_t*)authmsg, authmsgLen);
+ serverSignature = JabberBase64Encode((char*)srvSig, sizeof(srvSig));
char buf[4096];
- char *encproof = JabberBase64Encode(( char* )clientProof, sizeof( clientProof ));
- int cbLen = mir_snprintf( buf, sizeof( buf ), "c=biws,r=%s,p=%s", snonce, encproof );
+ char *encproof = JabberBase64Encode((char*)clientProof, sizeof(clientProof));
+ int cbLen = mir_snprintf(buf, sizeof(buf), "c=biws,r=%s,p=%s", snonce, encproof);
- mir_free( encproof );
- mir_free( snonce );
- mir_free( chl );
+ mir_free(encproof);
+ mir_free(snonce);
+ mir_free(chl);
- return JabberBase64Encode( buf, cbLen );
+ return JabberBase64Encode(buf, cbLen);
}
char* TScramAuth::getInitialRequest()
{
- char *uname = mir_utf8encodeT( info->username ),
- *serv = mir_utf8encode( info->server );
+ char *uname = mir_utf8encodeT(info->username),
+ *serv = mir_utf8encode(info->server);
unsigned char nonce[24];
- CallService( MS_UTILS_GETRANDOM, sizeof(nonce), ( LPARAM )nonce );
- cnonce = JabberBase64Encode(( char* )nonce, sizeof( nonce ));
+ CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
+ cnonce = JabberBase64Encode((char*)nonce, sizeof(nonce));
char buf[4096];
- int cbLen = mir_snprintf( buf, sizeof( buf ), "n,,n=%s@%s,r=%s", uname, serv, cnonce );
- msg1 = mir_strdup( buf + 3 );
+ int cbLen = mir_snprintf(buf, sizeof(buf), "n,,n=%s@%s,r=%s", uname, serv, cnonce);
+ msg1 = mir_strdup(buf + 3);
- mir_free( serv );
- mir_free( uname );
+ mir_free(serv);
+ mir_free(uname);
- return JabberBase64Encode( buf, cbLen );
+ return JabberBase64Encode(buf, cbLen);
}
-bool TScramAuth::validateLogin( const TCHAR* challenge )
+bool TScramAuth::validateLogin(const TCHAR *challenge)
{
int chlLen;
- char* chl = JabberBase64DecodeT( challenge, &chlLen );
- bool res = chl && strncmp( chl + 2, serverSignature, chlLen - 2 ) == 0;
- mir_free( chl );
+ char* chl = JabberBase64DecodeT(challenge, &chlLen);
+ bool res = chl && strncmp(chl + 2, serverSignature, chlLen - 2) == 0;
+ mir_free(chl);
return res;
}
@@ -415,8 +415,8 @@ bool TScramAuth::validateLogin( const TCHAR* challenge ) /////////////////////////////////////////////////////////////////////////////////////////
// plain auth - the most simple one
-TPlainAuth::TPlainAuth( ThreadData* info, bool old ) :
- TJabberAuth( info )
+TPlainAuth::TPlainAuth(ThreadData* info, bool old) :
+ TJabberAuth(info)
{
szName = "PLAIN";
bOld = old;
@@ -428,29 +428,29 @@ TPlainAuth::~TPlainAuth() char* TPlainAuth::getInitialRequest()
{
- char *uname = mir_utf8encodeT( info->username ),
- *passw = mir_utf8encodeT( info->password );
+ char *uname = mir_utf8encodeT(info->username),
+ *passw = mir_utf8encodeT(info->password);
- size_t size = 2 * strlen( uname ) + strlen( passw ) + strlen( info->server ) + 4;
- char *toEncode = ( char* )alloca( size );
- if ( bOld )
- size = mir_snprintf( toEncode, size, "%s@%s%c%s%c%s", uname, info->server, 0, uname, 0, passw );
+ size_t size = 2 * strlen(uname) + strlen(passw) + strlen(info->server) + 4;
+ char *toEncode = (char*)alloca(size);
+ if (bOld)
+ size = mir_snprintf(toEncode, size, "%s@%s%c%s%c%s", uname, info->server, 0, uname, 0, passw);
else
- size = mir_snprintf( toEncode, size, "%c%s%c%s", 0, uname, 0, passw );
+ size = mir_snprintf(toEncode, size, "%c%s%c%s", 0, uname, 0, passw);
- mir_free( uname );
- mir_free( passw );
+ mir_free(uname);
+ mir_free(passw);
- return JabberBase64Encode( toEncode, (int)size );
+ return JabberBase64Encode(toEncode, (int)size);
}
/////////////////////////////////////////////////////////////////////////////////////////
// basic type
-TJabberAuth::TJabberAuth( ThreadData* pInfo ) :
- bIsValid( true ),
- szName( NULL ),
- info( pInfo )
+TJabberAuth::TJabberAuth(ThreadData* pInfo) :
+ bIsValid(true),
+ szName(NULL),
+ info(pInfo)
{
}
@@ -463,12 +463,12 @@ char* TJabberAuth::getInitialRequest() return NULL;
}
-char* TJabberAuth::getChallenge( const TCHAR* )
+char* TJabberAuth::getChallenge(const TCHAR*)
{
return NULL;
}
-bool TJabberAuth::validateLogin( const TCHAR* )
+bool TJabberAuth::validateLogin(const TCHAR*)
{
return true;
}
diff --git a/protocols/JabberG/src/jabber_secur.h b/protocols/JabberG/src/jabber_secur.h index 0c3287b88d..41dfc3eafe 100644 --- a/protocols/JabberG/src/jabber_secur.h +++ b/protocols/JabberG/src/jabber_secur.h @@ -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
@@ -33,12 +33,12 @@ protected: bool bIsValid; ThreadData* info;
public:
- TJabberAuth( ThreadData* );
+ TJabberAuth(ThreadData*);
virtual ~TJabberAuth();
virtual char* getInitialRequest();
- virtual char* getChallenge( const TCHAR* challenge );
- virtual bool validateLogin( const TCHAR* challenge );
+ virtual char* getChallenge(const TCHAR *challenge);
+ virtual bool validateLogin(const TCHAR *challenge);
inline const char* getName() const
{ return szName;
@@ -58,7 +58,7 @@ class TPlainAuth : public TJabberAuth bool bOld;
-public: TPlainAuth( ThreadData*, bool );
+public: TPlainAuth(ThreadData*, bool);
virtual ~TPlainAuth();
virtual char* getInitialRequest();
@@ -72,10 +72,10 @@ class TMD5Auth : public TJabberAuth int iCallCount;
public:
- TMD5Auth( ThreadData* );
+ TMD5Auth(ThreadData*);
virtual ~TMD5Auth();
- virtual char* getChallenge( const TCHAR* challenge );
+ virtual char* getChallenge(const TCHAR *challenge);
};
class TScramAuth : public TJabberAuth
@@ -84,14 +84,14 @@ class TScramAuth : public TJabberAuth char *cnonce, *msg1, *serverSignature;
public:
- TScramAuth( ThreadData* );
+ TScramAuth(ThreadData*);
virtual ~TScramAuth();
virtual char* getInitialRequest();
- virtual char* getChallenge( const TCHAR* challenge );
- virtual bool validateLogin( const TCHAR* challenge );
+ virtual char* getChallenge(const TCHAR *challenge);
+ virtual bool validateLogin(const TCHAR *challenge);
- void Hi( mir_sha1_byte_t* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind );
+ void Hi(mir_sha1_byte_t* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind);
};
// ntlm auth - LanServer based authorization
@@ -103,11 +103,11 @@ class TNtlmAuth : public TJabberAuth HANDLE hProvider;
const TCHAR *szHostName;
public:
- TNtlmAuth( ThreadData*, const char* mechanism, const TCHAR* hostname = NULL );
+ TNtlmAuth(ThreadData*, const char* mechanism, const TCHAR *hostname = NULL);
virtual ~TNtlmAuth();
virtual char* getInitialRequest();
- virtual char* getChallenge( const TCHAR* challenge );
+ virtual char* getChallenge(const TCHAR *challenge);
- bool getSpn( TCHAR* szSpn, size_t dwSpnLen );
+ bool getSpn(TCHAR* szSpn, size_t dwSpnLen);
};
diff --git a/protocols/JabberG/src/jabber_send_manager.cpp b/protocols/JabberG/src/jabber_send_manager.cpp index b37b1d2f09..6f9ee3760e 100644 --- a/protocols/JabberG/src/jabber_send_manager.cpp +++ b/protocols/JabberG/src/jabber_send_manager.cpp @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -35,7 +35,7 @@ BOOL CJabberSendManager::HandleSendPermanent(HXML node, ThreadData *pThreadData) BOOL bStopHandling = FALSE;
Lock();
CJabberSendPermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo && !bStopHandling ) {
+ while (pInfo && !bStopHandling) {
CJabberSendInfo sendInfo;
sendInfo.m_pUserData = pInfo->m_pUserData;
diff --git a/protocols/JabberG/src/jabber_send_manager.h b/protocols/JabberG/src/jabber_send_manager.h index fe4916686f..79cdf24522 100644 --- a/protocols/JabberG/src/jabber_send_manager.h +++ b/protocols/JabberG/src/jabber_send_manager.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-08 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
-Copyright ( C ) 2008-09 Dmitriy Chervov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-08 George Hazan
+Copyright (C) 2007 Maxim Mluhov
+Copyright (C) 2008-09 Dmitriy Chervov
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
@@ -28,12 +28,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_xml.h"
struct CJabberProto;
-typedef void ( CJabberProto::*JABBER_SEND_PFUNC )( HXML node, void *usedata );
-typedef void ( *SEND_USER_DATA_FREE_FUNC )( void *pUserData );
+typedef void (CJabberProto::*JABBER_SEND_PFUNC)(HXML node, void *usedata);
+typedef void (*SEND_USER_DATA_FREE_FUNC)(void *pUserData);
class CJabberSendInfo;
-typedef BOOL ( CJabberProto::*JABBER_SEND_HANDLER )( HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo );
+typedef BOOL (CJabberProto::*JABBER_SEND_HANDLER)(HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo);
class CJabberSendInfo
{
@@ -75,7 +75,7 @@ public: }
~CJabberSendPermanentInfo()
{
- if ( m_pUserDataFree )
+ if (m_pUserDataFree)
m_pUserDataFree(m_pUserData);
}
};
@@ -88,7 +88,7 @@ protected: CJabberSendPermanentInfo* m_pPermanentHandlers;
public:
- CJabberSendManager( CJabberProto* proto )
+ CJabberSendManager(CJabberProto* proto)
{
InitializeCriticalSection(&m_cs);
m_pPermanentHandlers = NULL;
@@ -98,7 +98,7 @@ public: {
Lock();
CJabberSendPermanentInfo *pInfo = m_pPermanentHandlers;
- while ( pInfo )
+ while (pInfo)
{
CJabberSendPermanentInfo *pTmp = pInfo->m_pNext;
delete pInfo;
@@ -127,7 +127,7 @@ public: CJabberSendPermanentInfo* AddPermanentHandler(JABBER_SEND_HANDLER pHandler, void *pUserData = NULL, SEND_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
{
CJabberSendPermanentInfo* pInfo = new CJabberSendPermanentInfo();
- if (!pInfo)
+ if ( !pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
@@ -136,7 +136,7 @@ public: pInfo->m_iPriority = iPriority;
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
m_pPermanentHandlers = pInfo;
else
{
@@ -159,7 +159,7 @@ public: BOOL DeletePermanentHandler(CJabberSendPermanentInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
Lock();
- if (!m_pPermanentHandlers)
+ if ( !m_pPermanentHandlers)
{
Unlock();
return FALSE;
diff --git a/protocols/JabberG/src/jabber_std.cpp b/protocols/JabberG/src/jabber_std.cpp index 099c28b993..376cb21bd1 100644 --- a/protocols/JabberG/src/jabber_std.cpp +++ b/protocols/JabberG/src/jabber_std.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
@@ -22,75 +22,75 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber.h"
-void CJabberProto::JCreateService( const char* szService, JServiceFunc serviceProc )
+void CJabberProto::JCreateService(const char* szService, JServiceFunc serviceProc)
{
char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObj( str, ( MIRANDASERVICEOBJ )*( void** )&serviceProc, this );
+ strcpy(str, m_szModuleName);
+ strcat(str, szService);
+ ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
}
-void CJabberProto::JCreateServiceParam( const char* szService, JServiceFuncParam serviceProc, LPARAM lParam )
+void CJabberProto::JCreateServiceParam(const char* szService, JServiceFuncParam serviceProc, LPARAM lParam)
{
char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObjParam( str, ( MIRANDASERVICEOBJPARAM )*( void** )&serviceProc, this, lParam );
+ strcpy(str, m_szModuleName);
+ strcat(str, szService);
+ ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
}
-void CJabberProto::JHookEvent( const char* szEvent, JEventFunc handler )
+void CJabberProto::JHookEvent(const char* szEvent, JEventFunc handler)
{
- ::HookEventObj( szEvent, ( MIRANDAHOOKOBJ )*( void** )&handler, this );
+ ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&handler, this);
}
-HANDLE CJabberProto::JCreateHookableEvent( const char* szService )
+HANDLE CJabberProto::JCreateHookableEvent(const char* szService)
{
char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- return CreateHookableEvent( str );
+ strcpy(str, m_szModuleName);
+ strcat(str, szService);
+ return CreateHookableEvent(str);
}
-void CJabberProto::JForkThread( JThreadFunc pFunc, void *param )
+void CJabberProto::JForkThread(JThreadFunc pFunc, void *param)
{
UINT threadID;
- CloseHandle(( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, &threadID ));
+ CloseHandle((HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, this, param, &threadID));
}
-HANDLE CJabberProto::JForkThreadEx( JThreadFunc pFunc, void *param, UINT* threadID )
+HANDLE CJabberProto::JForkThreadEx(JThreadFunc pFunc, void *param, UINT* threadID)
{
UINT lthreadID;
- return ( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, threadID ? threadID : <hreadID);
+ return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, this, param, threadID ? threadID : <hreadID);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::JDeleteSetting( HANDLE hContact, const char* valueName )
+void CJabberProto::JDeleteSetting(HANDLE hContact, const char* valueName)
{
- DBDeleteContactSetting( hContact, m_szModuleName, valueName );
+ DBDeleteContactSetting(hContact, m_szModuleName, valueName);
}
/*
-DWORD CJabberProto::JGetByte( const char* valueName, int parDefltValue )
+DWORD CJabberProto::JGetByte(const char* valueName, int parDefltValue)
{
- return DBGetContactSettingByte( NULL, m_szModuleName, valueName, parDefltValue );
+ return db_get_b(NULL, m_szModuleName, valueName, parDefltValue);
}
*/
-DWORD CJabberProto::JGetByte( HANDLE hContact, const char* valueName, int parDefltValue )
+DWORD CJabberProto::JGetByte(HANDLE hContact, const char* valueName, int parDefltValue)
{
- return DBGetContactSettingByte( hContact, m_szModuleName, valueName, parDefltValue );
+ return db_get_b(hContact, m_szModuleName, valueName, parDefltValue);
}
-char* __stdcall JGetContactName( HANDLE hContact )
+char* __stdcall JGetContactName(HANDLE hContact)
{
- return ( char* )CallService( MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM( hContact ), 0 );
+ return (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), 0);
}
-DWORD CJabberProto::JGetDword( HANDLE hContact, const char* valueName, DWORD parDefltValue )
+DWORD CJabberProto::JGetDword(HANDLE hContact, const char* valueName, DWORD parDefltValue)
{
- return DBGetContactSettingDword( hContact, m_szModuleName, valueName, parDefltValue );
+ return db_get_dw(hContact, m_szModuleName, valueName, parDefltValue);
}
-int CJabberProto::JGetStaticString( const char* valueName, HANDLE hContact, char* dest, int dest_len )
+int CJabberProto::JGetStaticString(const char* valueName, HANDLE hContact, char* dest, int dest_len)
{
DBVARIANT dbv;
dbv.pszVal = dest;
@@ -101,114 +101,109 @@ int CJabberProto::JGetStaticString( const char* valueName, HANDLE hContact, char sVal.pValue = &dbv;
sVal.szModule = m_szModuleName;
sVal.szSetting = valueName;
- if ( CallService( MS_DB_CONTACT_GETSETTINGSTATIC, ( WPARAM )hContact, ( LPARAM )&sVal ) != 0 )
+ if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&sVal) != 0)
return 1;
- return ( dbv.type != DBVT_ASCIIZ );
+ return (dbv.type != DBVT_ASCIIZ);
}
-int CJabberProto::JGetStringUtf( HANDLE hContact, char* valueName, DBVARIANT* dbv )
+int CJabberProto::JGetStringUtf(HANDLE hContact, char* valueName, DBVARIANT* dbv)
{
- return DBGetContactSettingStringUtf( hContact, m_szModuleName, valueName, dbv );
+ return DBGetContactSettingStringUtf(hContact, m_szModuleName, valueName, dbv);
}
-int CJabberProto::JGetStringT( HANDLE hContact, char* valueName, DBVARIANT* dbv )
+int CJabberProto::JGetStringT(HANDLE hContact, char* valueName, DBVARIANT* dbv)
{
- return DBGetContactSettingTString( hContact, m_szModuleName, valueName, dbv );
+ return DBGetContactSettingTString(hContact, m_szModuleName, valueName, dbv);
}
-TCHAR *CJabberProto::JGetStringT( HANDLE hContact, char* valueName )
+TCHAR *CJabberProto::JGetStringT(HANDLE hContact, char* valueName)
{
DBVARIANT dbv = {0};
if (JGetStringT(hContact, valueName, &dbv))
return NULL;
TCHAR *res = mir_tstrdup(dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
return res;
}
-TCHAR *CJabberProto::JGetStringT( HANDLE hContact, char* valueName, TCHAR *&out )
+TCHAR *CJabberProto::JGetStringT(HANDLE hContact, char* valueName, TCHAR *&out)
{
- return out = JGetStringT( hContact, valueName );
+ return out = JGetStringT(hContact, valueName);
}
-TCHAR *CJabberProto::JGetStringT( HANDLE hContact, char* valueName, TCHAR *buf, int size )
+TCHAR *CJabberProto::JGetStringT(HANDLE hContact, char* valueName, TCHAR *buf, int size)
{
DBVARIANT dbv = {0};
if (JGetStringT(hContact, valueName, &dbv))
return NULL;
lstrcpyn(buf, dbv.ptszVal, size);
- JFreeVariant(&dbv);
+ db_free(&dbv);
return buf;
}
-WORD CJabberProto::JGetWord( HANDLE hContact, const char* valueName, int parDefltValue )
+WORD CJabberProto::JGetWord(HANDLE hContact, const char* valueName, int parDefltValue)
{
- return DBGetContactSettingWord( hContact, m_szModuleName, valueName, parDefltValue );
+ return db_get_w(hContact, m_szModuleName, valueName, parDefltValue);
}
-void __fastcall JFreeVariant( DBVARIANT* dbv )
-{
- DBFreeVariant( dbv );
-}
-
-int CJabberProto::JSendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam )
+int CJabberProto::JSendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
// clear saved passowrd on login error. ugly hack, but at least this is centralized
if (type == ACKTYPE_LOGIN && (lParam == LOGINERR_WRONGPASSWORD || lParam == LOGINERR_BADUSERID))
*m_savedPassword = 0;
ACKDATA ack = {0};
- ack.cbSize = sizeof( ACKDATA );
+ ack.cbSize = sizeof(ACKDATA);
ack.szModule = m_szModuleName;
ack.hContact = hContact;
ack.type = type;
ack.result = result;
ack.hProcess = hProcess;
ack.lParam = lParam;
- return CallService( MS_PROTO_BROADCASTACK, 0, ( LPARAM )&ack );
+ return CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);
}
/*
-DWORD CJabberProto::JSetByte( const char* valueName, int parValue )
+DWORD CJabberProto::JSetByte(const char* valueName, int parValue)
{
- return DBWriteContactSettingByte( NULL, m_szModuleName, valueName, parValue );
+ return db_set_b(NULL, m_szModuleName, valueName, parValue);
}
*/
-DWORD CJabberProto::JSetByte( HANDLE hContact, const char* valueName, int parValue )
+DWORD CJabberProto::JSetByte(HANDLE hContact, const char* valueName, int parValue)
{
- return DBWriteContactSettingByte( hContact, m_szModuleName, valueName, parValue );
+ return db_set_b(hContact, m_szModuleName, valueName, parValue);
}
-DWORD CJabberProto::JSetDword( HANDLE hContact, const char* valueName, DWORD parValue )
+DWORD CJabberProto::JSetDword(HANDLE hContact, const char* valueName, DWORD parValue)
{
- return DBWriteContactSettingDword( hContact, m_szModuleName, valueName, parValue );
+ return db_set_dw(hContact, m_szModuleName, valueName, parValue);
}
-DWORD CJabberProto::JSetString( HANDLE hContact, const char* valueName, const char* parValue )
+DWORD CJabberProto::JSetString(HANDLE hContact, const char* valueName, const char* parValue)
{
- return DBWriteContactSettingString( hContact, m_szModuleName, valueName, parValue );
+ return db_set_s(hContact, m_szModuleName, valueName, parValue);
}
-DWORD CJabberProto::JSetStringT( HANDLE hContact, const char* valueName, const TCHAR* parValue )
+DWORD CJabberProto::JSetStringT(HANDLE hContact, const char* valueName, const TCHAR *parValue)
{
- return DBWriteContactSettingTString( hContact, m_szModuleName, valueName, parValue );
+ return db_set_ts(hContact, m_szModuleName, valueName, parValue);
}
-DWORD CJabberProto::JSetStringUtf( HANDLE hContact, const char* valueName, const char* parValue )
+DWORD CJabberProto::JSetStringUtf(HANDLE hContact, const char* valueName, const char* parValue)
{
- return DBWriteContactSettingStringUtf( hContact, m_szModuleName, valueName, parValue );
+ return db_set_utf(hContact, m_szModuleName, valueName, parValue);
}
-DWORD CJabberProto::JSetWord( HANDLE hContact, const char* valueName, int parValue )
+DWORD CJabberProto::JSetWord(HANDLE hContact, const char* valueName, int parValue)
{
- return DBWriteContactSettingWord( hContact, m_szModuleName, valueName, parValue );
+ return db_set_w(hContact, m_szModuleName, valueName, parValue);
}
-char* __fastcall JTranslate( const char* str )
+char* __fastcall JTranslate(const char* str)
{
- return Translate( str );
+ return Translate(str);
}
// save/load crypted strings
@@ -221,11 +216,11 @@ void __forceinline sttCryptString(char *str) }
}
-TCHAR* CJabberProto::JGetStringCrypt( HANDLE hContact, char* valueName )
+TCHAR* CJabberProto::JGetStringCrypt(HANDLE hContact, char *valueName)
{
DBVARIANT dbv;
- if (DBGetContactSettingString( hContact, m_szModuleName, valueName, &dbv ))
+ if (DBGetContactSettingString(hContact, m_szModuleName, valueName, &dbv))
return NULL;
sttCryptString(dbv.pszVal);
@@ -236,11 +231,11 @@ TCHAR* CJabberProto::JGetStringCrypt( HANDLE hContact, char* valueName ) return res;
}
-DWORD CJabberProto::JSetStringCrypt( HANDLE hContact, char* valueName, const TCHAR* parValue )
+DWORD CJabberProto::JSetStringCrypt(HANDLE hContact, char *valueName, const TCHAR *parValue)
{
char *tmp = mir_utf8encodeT(parValue);
sttCryptString(tmp);
- DWORD res = JSetString( hContact, valueName, tmp );
+ DWORD res = JSetString(hContact, valueName, tmp);
mir_free(tmp);
return res;
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index dc939ec107..ab3f20627e 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -44,8 +44,8 @@ INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) TCHAR *szStatus = NULL;
INT_PTR nRetVal = 0;
- EnterCriticalSection( &m_csModeMsgMutex );
- switch ( wParam ? (int)wParam : m_iStatus ) {
+ EnterCriticalSection(&m_csModeMsgMutex);
+ switch (wParam ? (int)wParam : m_iStatus) {
case ID_STATUS_ONLINE:
szStatus = m_modeMsgs.szOnline;
break;
@@ -68,9 +68,9 @@ INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) // Should not reach here
break;
}
- if ( szStatus )
- nRetVal = ( lParam & SGMA_UNICODE ) ? ( INT_PTR )mir_t2u( szStatus ) : ( INT_PTR )mir_t2a( szStatus );
- LeaveCriticalSection( &m_csModeMsgMutex );
+ if (szStatus)
+ nRetVal = (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(szStatus) : (INT_PTR)mir_t2a(szStatus);
+ LeaveCriticalSection(&m_csModeMsgMutex);
return nRetVal;
}
@@ -78,31 +78,31 @@ INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// JabberGetAvatar - retrieves the file name of my own avatar
-INT_PTR __cdecl CJabberProto::JabberGetAvatar( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberGetAvatar(WPARAM wParam, LPARAM lParam)
{
- TCHAR* buf = ( TCHAR* )wParam;
- int size = ( int )lParam;
+ TCHAR* buf = (TCHAR*)wParam;
+ int size = (int)lParam;
- if ( buf == NULL || size <= 0 )
+ if (buf == NULL || size <= 0)
return -1;
- if ( !m_options.EnableAvatars )
+ if ( !m_options.EnableAvatars)
return -2;
- GetAvatarFileName( NULL, buf, size );
+ GetAvatarFileName(NULL, buf, size);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// JabberGetAvatarCaps - returns directives how to process avatars
-INT_PTR __cdecl CJabberProto::JabberGetAvatarCaps( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberGetAvatarCaps(WPARAM wParam, LPARAM lParam)
{
- switch( wParam ) {
+ switch(wParam) {
case AF_MAXSIZE:
{
POINT* size = (POINT*)lParam;
- if ( size )
+ if (size)
size->x = size->y = 96;
}
return 0;
@@ -122,151 +122,151 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarCaps( WPARAM wParam, LPARAM lParam /////////////////////////////////////////////////////////////////////////////////////////
// JabberGetAvatarInfo - retrieves the avatar info
-INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
- if ( !m_options.EnableAvatars )
+ if ( !m_options.EnableAvatars)
return GAIR_NOAVATAR;
- PROTO_AVATAR_INFORMATIONT* AI = ( PROTO_AVATAR_INFORMATIONT* )lParam;
+ PROTO_AVATAR_INFORMATIONT* AI = (PROTO_AVATAR_INFORMATIONT*)lParam;
char szHashValue[ MAX_PATH ];
- if ( JGetStaticString( "AvatarHash", AI->hContact, szHashValue, sizeof szHashValue )) {
- Log( "No avatar" );
+ if (JGetStaticString("AvatarHash", AI->hContact, szHashValue, sizeof szHashValue)) {
+ Log("No avatar");
return GAIR_NOAVATAR;
}
TCHAR tszFileName[ MAX_PATH ];
- GetAvatarFileName( AI->hContact, tszFileName, SIZEOF(tszFileName));
- _tcsncpy( AI->filename, tszFileName, SIZEOF(AI->filename));
+ GetAvatarFileName(AI->hContact, tszFileName, SIZEOF(tszFileName));
+ _tcsncpy(AI->filename, tszFileName, SIZEOF(AI->filename));
- AI->format = ( AI->hContact == NULL ) ? PA_FORMAT_PNG : JGetByte( AI->hContact, "AvatarType", 0 );
+ AI->format = (AI->hContact == NULL) ? PA_FORMAT_PNG : JGetByte(AI->hContact, "AvatarType", 0);
- if ( ::_taccess( AI->filename, 0 ) == 0 ) {
+ if (::_taccess(AI->filename, 0) == 0) {
char szSavedHash[ 256 ];
- if ( !JGetStaticString( "AvatarSaved", AI->hContact, szSavedHash, sizeof szSavedHash )) {
- if ( !strcmp( szSavedHash, szHashValue )) {
- Log( "Avatar is Ok: %s == %s", szSavedHash, szHashValue );
+ if ( !JGetStaticString("AvatarSaved", AI->hContact, szSavedHash, sizeof szSavedHash)) {
+ if ( !strcmp(szSavedHash, szHashValue)) {
+ Log("Avatar is Ok: %s == %s", szSavedHash, szHashValue);
return GAIR_SUCCESS;
} } }
- if (( wParam & GAIF_FORCE ) != 0 && AI->hContact != NULL && m_bJabberOnline ) {
+ if ((wParam & GAIF_FORCE) != 0 && AI->hContact != NULL && m_bJabberOnline) {
DBVARIANT dbv;
- if ( !JGetStringT( AI->hContact, "jid", &dbv )) {
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, dbv.ptszVal );
- if ( item != NULL ) {
- BOOL isXVcard = JGetByte( AI->hContact, "AvatarXVcard", 0 );
+ if ( !JGetStringT(AI->hContact, "jid", &dbv)) {
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
+ if (item != NULL) {
+ BOOL isXVcard = JGetByte(AI->hContact, "AvatarXVcard", 0);
TCHAR szJid[ JABBER_MAX_JID_LEN ];
- if ( item->resourceCount != NULL && !isXVcard ) {
+ if (item->resourceCount != NULL && !isXVcard) {
TCHAR *bestResName = ListGetBestClientResourceNamePtr(dbv.ptszVal);
- mir_sntprintf( szJid, SIZEOF( szJid ), bestResName?_T("%s/%s"):_T("%s"), dbv.ptszVal, bestResName );
+ mir_sntprintf(szJid, SIZEOF(szJid), bestResName?_T("%s/%s"):_T("%s"), dbv.ptszVal, bestResName);
}
- else lstrcpyn( szJid, dbv.ptszVal, SIZEOF( szJid ));
+ else lstrcpyn(szJid, dbv.ptszVal, SIZEOF(szJid));
- Log( "Rereading %s for " TCHAR_STR_PARAM, isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid );
+ Log("Rereading %s for " TCHAR_STR_PARAM, isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid);
int iqId = SerialNext();
- if ( isXVcard )
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetVCardAvatar );
+ if (isXVcard)
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetVCardAvatar);
else
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetClientAvatar );
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetClientAvatar);
- XmlNodeIq iq( _T("get"), iqId, szJid );
- if ( isXVcard )
- iq << XCHILDNS( _T("vCard"), _T(JABBER_FEAT_VCARD_TEMP));
+ XmlNodeIq iq(_T("get"), iqId, szJid);
+ if (isXVcard)
+ iq << XCHILDNS(_T("vCard"), _T(JABBER_FEAT_VCARD_TEMP));
else
- iq << XQUERY( isXVcard ? _T("") : _T(JABBER_FEAT_AVATAR));
- m_ThreadInfo->send( iq );
+ iq << XQUERY(isXVcard ? _T("") : _T(JABBER_FEAT_AVATAR));
+ m_ThreadInfo->send(iq);
- JFreeVariant( &dbv );
+ db_free(&dbv);
return GAIR_WAITFOR;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
}
- Log( "No avatar" );
+ Log("No avatar");
return GAIR_NOAVATAR;
}
////////////////////////////////////////////////////////////////////////////////////////
// JabberGetEventTextChatStates - retrieves a chat state description from an event
-INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates( WPARAM, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::OnGetEventTextChatStates(WPARAM, LPARAM lParam)
{
- DBEVENTGETTEXT *pdbEvent = ( DBEVENTGETTEXT * )lParam;
+ DBEVENTGETTEXT *pdbEvent = (DBEVENTGETTEXT *)lParam;
INT_PTR nRetVal = 0;
- if ( pdbEvent->dbei->cbBlob > 0 ) {
- if ( pdbEvent->dbei->pBlob[0] == JABBER_DB_EVENT_CHATSTATES_GONE ) {
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->dbei->cbBlob > 0) {
+ if (pdbEvent->dbei->pBlob[0] == JABBER_DB_EVENT_CHATSTATES_GONE) {
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("closed chat session")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("closed chat session"));
}
}
-
+
return nRetVal;
}
////////////////////////////////////////////////////////////////////////////////////////
// OnGetEventTextPresence - retrieves presence state description from an event
-INT_PTR __cdecl CJabberProto::OnGetEventTextPresence( WPARAM, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::OnGetEventTextPresence(WPARAM, LPARAM lParam)
{
- DBEVENTGETTEXT *pdbEvent = ( DBEVENTGETTEXT * )lParam;
+ DBEVENTGETTEXT *pdbEvent = (DBEVENTGETTEXT *)lParam;
INT_PTR nRetVal = 0;
- if ( pdbEvent->dbei->cbBlob > 0 ) {
- switch ( pdbEvent->dbei->pBlob[0] )
+ if (pdbEvent->dbei->cbBlob > 0) {
+ switch (pdbEvent->dbei->pBlob[0])
{
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBE:
{
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent subscription request")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("sent subscription request"));
break;
}
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBED:
{
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("approved subscription request")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("approved subscription request"));
break;
}
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE:
{
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("declined subscription")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("declined subscription"));
break;
}
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED:
{
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("declined subscription")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("declined subscription"));
break;
}
case JABBER_DB_EVENT_PRESENCE_ERROR:
{
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent error presence")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("sent error presence"));
break;
}
default:
{
- if ( pdbEvent->datatype == DBVT_WCHAR )
+ if (pdbEvent->datatype == DBVT_WCHAR)
nRetVal = (INT_PTR)mir_tstrdup(TranslateTS(_T("sent unknown presence type")));
- else if ( pdbEvent->datatype == DBVT_ASCIIZ )
+ else if (pdbEvent->datatype == DBVT_ASCIIZ)
nRetVal = (INT_PTR)mir_strdup(Translate("sent unknown presence type"));
break;
}
@@ -279,66 +279,66 @@ INT_PTR __cdecl CJabberProto::OnGetEventTextPresence( WPARAM, LPARAM lParam ) ////////////////////////////////////////////////////////////////////////////////////////
// JabberSetAvatar - sets an avatar without UI
-INT_PTR __cdecl CJabberProto::JabberSetAvatar( WPARAM, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam)
{
- TCHAR* tszFileName = ( TCHAR* )lParam;
+ TCHAR* tszFileName = (TCHAR*)lParam;
- if ( m_bJabberOnline ) {
- SetServerVcard( TRUE, tszFileName );
- SendPresence( m_iDesiredStatus, false );
+ if (m_bJabberOnline) {
+ SetServerVcard(TRUE, tszFileName);
+ SendPresence(m_iDesiredStatus, false);
}
- else if ( tszFileName == NULL || tszFileName[0] == 0 ) {
+ else if (tszFileName == NULL || tszFileName[0] == 0) {
// Remove avatar
TCHAR tFileName[ MAX_PATH ];
- GetAvatarFileName( NULL, tFileName, MAX_PATH );
- DeleteFile( tFileName );
+ GetAvatarFileName(NULL, tFileName, MAX_PATH);
+ DeleteFile(tFileName);
- JDeleteSetting( NULL, "AvatarSaved" );
- JDeleteSetting( NULL, "AvatarHash" );
+ JDeleteSetting(NULL, "AvatarSaved");
+ JDeleteSetting(NULL, "AvatarHash");
}
else {
- int fileIn = _topen( tszFileName, O_RDWR | O_BINARY, S_IREAD | S_IWRITE );
- if ( fileIn == -1 ) {
+ int fileIn = _topen(tszFileName, O_RDWR | O_BINARY, S_IREAD | S_IWRITE);
+ if (fileIn == -1) {
mir_free(tszFileName);
return 1;
}
- long dwPngSize = _filelength( fileIn );
+ long dwPngSize = _filelength(fileIn);
char* pResult = new char[ dwPngSize ];
- if ( pResult == NULL ) {
- _close( fileIn );
+ if (pResult == NULL) {
+ _close(fileIn);
mir_free(tszFileName);
return 2;
}
- _read( fileIn, pResult, dwPngSize );
- _close( fileIn );
+ _read(fileIn, pResult, dwPngSize);
+ _close(fileIn);
mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
mir_sha1_ctx sha1ctx;
- mir_sha1_init( &sha1ctx );
- mir_sha1_append( &sha1ctx, (mir_sha1_byte_t*)pResult, dwPngSize );
- mir_sha1_finish( &sha1ctx, digest );
+ mir_sha1_init(&sha1ctx);
+ mir_sha1_append(&sha1ctx, (mir_sha1_byte_t*)pResult, dwPngSize);
+ mir_sha1_finish(&sha1ctx, digest);
TCHAR tFileName[ MAX_PATH ];
- GetAvatarFileName( NULL, tFileName, MAX_PATH );
- DeleteFile( tFileName );
+ GetAvatarFileName(NULL, tFileName, MAX_PATH);
+ DeleteFile(tFileName);
char buf[MIR_SHA1_HASH_SIZE*2+1];
- for ( int i=0; i<MIR_SHA1_HASH_SIZE; i++ )
- sprintf( buf+( i<<1 ), "%02x", digest[i] );
+ for (int i=0; i<MIR_SHA1_HASH_SIZE; i++)
+ sprintf(buf+(i<<1), "%02x", digest[i]);
- m_options.AvatarType = JabberGetPictureType( pResult );
+ m_options.AvatarType = JabberGetPictureType(pResult);
- GetAvatarFileName( NULL, tFileName, MAX_PATH );
- FILE* out = _tfopen( tFileName, _T("wb"));
- if ( out != NULL ) {
- fwrite( pResult, dwPngSize, 1, out );
- fclose( out );
+ GetAvatarFileName(NULL, tFileName, MAX_PATH);
+ FILE* out = _tfopen(tFileName, _T("wb"));
+ if (out != NULL) {
+ fwrite(pResult, dwPngSize, 1, out);
+ fclose(out);
}
delete[] pResult;
- JSetString( NULL, "AvatarSaved", buf );
+ JSetString(NULL, "AvatarSaved", buf);
}
return 0;
@@ -347,21 +347,21 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar( WPARAM, LPARAM lParam ) ////////////////////////////////////////////////////////////////////////////////////////
// JabberSetNickname - sets the user nickname without UI
-INT_PTR __cdecl CJabberProto::JabberSetNickname( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberSetNickname(WPARAM wParam, LPARAM lParam)
{
- TCHAR *nickname = ( wParam & SMNN_UNICODE ) ? mir_u2t( (WCHAR *) lParam ) : mir_a2t( (char *) lParam );
+ TCHAR *nickname = (wParam & SMNN_UNICODE) ? mir_u2t((WCHAR *) lParam) : mir_a2t((char *) lParam);
- JSetStringT( NULL, "Nick", nickname );
- SetServerVcard( FALSE, _T(""));
+ JSetStringT(NULL, "Nick", nickname);
+ SetServerVcard(FALSE, _T(""));
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// "/SendXML" - Allows external plugins to send XML to the server
-INT_PTR __cdecl CJabberProto::ServiceSendXML( WPARAM, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::ServiceSendXML(WPARAM, LPARAM lParam)
{
- return m_ThreadInfo->send( (char*)lParam);
+ return m_ThreadInfo->send((char*)lParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -376,18 +376,18 @@ static const TCHAR * JabberEnum2StatusStr[]= { _T("Offline"), _T("Online"), _T(" _T("Invisible"), _T("On the phone"), _T("Out to lunch"),
_T("Idle") };
-static void appendString( bool bIsTipper, const TCHAR* tszTitle, const TCHAR* tszValue, TCHAR* buf, size_t bufSize )
+static void appendString(bool bIsTipper, const TCHAR *tszTitle, const TCHAR *tszValue, TCHAR* buf, size_t bufSize)
{
- if ( *buf ) {
- const TCHAR* szSeparator = (bIsTipper) ? _T("\n") : ((IsWinVerMEPlus()) ? _T("\r\n") : _T(" | "));
- _tcsncat( buf, szSeparator, bufSize );
+ if (*buf) {
+ const TCHAR *szSeparator = (bIsTipper) ? _T("\n") : ((IsWinVerMEPlus()) ? _T("\r\n") : _T(" | "));
+ _tcsncat(buf, szSeparator, bufSize);
}
size_t len = _tcslen(buf);
buf += len;
bufSize -= len;
- if ( bIsTipper )
+ if (bIsTipper)
mir_sntprintf(buf, bufSize, _T("%s%s%s%s"), _T("<b>"), TranslateTS(tszTitle), _T("</b>\t"), tszValue);
else {
TCHAR* p = TranslateTS(tszTitle);
@@ -395,24 +395,24 @@ static void appendString( bool bIsTipper, const TCHAR* tszTitle, const TCHAR* ts }
}
-INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lParam)
{
- if ( !wParam || !lParam )
+ if ( !wParam || !lParam)
return 0; //room global tooltip not supported yet
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, (TCHAR*)wParam);
- if ( item == NULL )
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, (TCHAR*)wParam);
+ if (item == NULL)
return 0; //no room found
JABBER_RESOURCE_STATUS * info = NULL;
- for ( int i=0; i < item->resourceCount; i++ ) {
+ for (int i=0; i < item->resourceCount; i++) {
JABBER_RESOURCE_STATUS& p = item->resource[i];
- if ( !lstrcmp( p.resourceName, (TCHAR*)lParam )) {
+ if ( !lstrcmp(p.resourceName, (TCHAR*)lParam)) {
info = &p;
break;
} }
- if ( info == NULL )
+ if (info == NULL)
return 0; //no info found
// ok process info output will be:
@@ -425,21 +425,21 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText( WPARAM wParam, LPARAM lPar TCHAR outBuf[2048];
outBuf[0]=_T('\0');
- bool bIsTipper = DBGetContactSettingByte(NULL, "Tab_SRMsg", "adv_TipperTooltip", 0) && ServiceExists("mToolTip/HideTip");
+ bool bIsTipper = db_get_b(NULL, "Tab_SRMsg", "adv_TipperTooltip", 0) && ServiceExists("mToolTip/HideTip");
//JID:
- if ( _tcschr(info->resourceName, _T('@')) != NULL )
+ if (_tcschr(info->resourceName, _T('@')) != NULL)
appendString(bIsTipper, _T("JID:"), info->resourceName, outBuf, SIZEOF(outBuf));
else if (lParam) { //or simple nick
appendString(bIsTipper, _T("Nick:"), (TCHAR*) lParam, outBuf, SIZEOF(outBuf));
}
// status
- if ( info->status >= ID_STATUS_OFFLINE && info->status <= ID_STATUS_IDLE )
+ if (info->status >= ID_STATUS_OFFLINE && info->status <= ID_STATUS_IDLE )
appendString(bIsTipper, _T("Status:"), TranslateTS(JabberEnum2StatusStr[info->status-ID_STATUS_OFFLINE]), outBuf, SIZEOF(outBuf));
// status text
- if ( info->statusMessage )
+ if (info->statusMessage)
appendString(bIsTipper, _T("Status text:"), info->statusMessage, outBuf, SIZEOF(outBuf));
// Role
@@ -449,137 +449,137 @@ INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText( WPARAM wParam, LPARAM lPar appendString(bIsTipper, _T("Affiliation:"), TranslateTS(JabberEnum2AffilationStr[info->affiliation]), outBuf, SIZEOF(outBuf));
// real jid
- if ( info->szRealJid )
+ if (info->szRealJid)
appendString(bIsTipper, _T("Real JID:"), info->szRealJid, outBuf, SIZEOF(outBuf));
- return (INT_PTR)( outBuf[0] == 0 ? NULL : mir_tstrdup( outBuf ));
+ return (INT_PTR)(outBuf[0] == 0 ? NULL : mir_tstrdup(outBuf));
}
// File Association Manager plugin support
-INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM wParam, LPARAM lParam)
{
- UNREFERENCED_PARAMETER( wParam );
+ UNREFERENCED_PARAMETER(wParam);
- TCHAR *arg = ( TCHAR * )lParam;
- if ( arg == NULL )
+ TCHAR *arg = (TCHAR *)lParam;
+ if (arg == NULL)
return 1;
TCHAR szUri[ 1024 ];
- mir_sntprintf( szUri, SIZEOF(szUri), _T("%s"), arg );
+ mir_sntprintf(szUri, SIZEOF(szUri), _T("%s"), arg);
TCHAR *szJid = szUri;
// skip leading prefix
- szJid = _tcschr( szJid, _T( ':' ));
- if ( szJid == NULL )
+ szJid = _tcschr(szJid, _T(':'));
+ if (szJid == NULL)
return 1;
// skip //
- for ( ++szJid; *szJid == _T( '/' ); ++szJid );
+ for (++szJid; *szJid == _T('/'); ++szJid);
// empty jid?
- if ( !*szJid )
+ if ( !*szJid)
return 1;
// command code
TCHAR *szCommand = szJid;
- szCommand = _tcschr( szCommand, _T( '?' ));
- if ( szCommand )
- *( szCommand++ ) = 0;
+ szCommand = _tcschr(szCommand, _T('?'));
+ if (szCommand)
+ *(szCommand++) = 0;
// parameters
- TCHAR *szSecondParam = szCommand ? _tcschr( szCommand, _T( ';' )) : NULL;
- if ( szSecondParam )
- *( szSecondParam++ ) = 0;
+ TCHAR *szSecondParam = szCommand ? _tcschr(szCommand, _T(';')) : NULL;
+ if (szSecondParam)
+ *(szSecondParam++) = 0;
-// TCHAR *szThirdParam = szSecondParam ? _tcschr( szSecondParam, _T( ';' )) : NULL;
-// if ( szThirdParam )
-// *( szThirdParam++ ) = 0;
+// TCHAR *szThirdParam = szSecondParam ? _tcschr(szSecondParam, _T(';')) : NULL;
+// if (szThirdParam)
+// *(szThirdParam++) = 0;
// no command or message command
- if ( !szCommand || ( szCommand && !_tcsicmp( szCommand, _T( "message" )))) {
+ if ( !szCommand || (szCommand && !_tcsicmp(szCommand, _T("message")))) {
// message
- if ( ServiceExists( MS_MSG_SENDMESSAGE )) {
- HANDLE hContact = HContactFromJID( szJid, TRUE );
+ if (ServiceExists(MS_MSG_SENDMESSAGE)) {
+ HANDLE hContact = HContactFromJID(szJid, TRUE);
TCHAR *szMsgBody = NULL;
- if ( !hContact )
- hContact = DBCreateContact( szJid, szJid, TRUE, TRUE );
- if ( !hContact )
+ if ( !hContact)
+ hContact = DBCreateContact(szJid, szJid, TRUE, TRUE);
+ if ( !hContact)
return 1;
- if ( szSecondParam ) { //there are parameters to message
- szMsgBody = _tcsstr(szSecondParam, _T( "body=" ));
- if ( szMsgBody ) {
+ if (szSecondParam) { //there are parameters to message
+ szMsgBody = _tcsstr(szSecondParam, _T("body="));
+ if (szMsgBody) {
szMsgBody += 5;
- TCHAR* szDelim = _tcschr( szMsgBody, _T( ';' ));
- if ( szDelim )
+ TCHAR* szDelim = _tcschr(szMsgBody, _T(';'));
+ if (szDelim)
szDelim = 0;
- JabberHttpUrlDecode( szMsgBody );
+ JabberHttpUrlDecode(szMsgBody);
} }
-
+
CallService(MS_MSG_SENDMESSAGE "W",(WPARAM)hContact, (LPARAM)szMsgBody);
-
+
return 0;
}
return 1;
}
- else if ( !_tcsicmp( szCommand, _T( "roster" )))
+ else if ( !_tcsicmp(szCommand, _T("roster")))
{
- if ( !HContactFromJID( szJid )) {
+ if ( !HContactFromJID(szJid)) {
JABBER_SEARCH_RESULT jsr = { 0 };
- jsr.hdr.cbSize = sizeof( JABBER_SEARCH_RESULT );
+ jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
jsr.hdr.nick = szJid;
jsr.hdr.id = szJid;
- _tcsncpy( jsr.jid, szJid, SIZEOF(jsr.jid) - 1 );
+ _tcsncpy(jsr.jid, szJid, SIZEOF(jsr.jid) - 1);
ADDCONTACTSTRUCT acs;
acs.handleType = HANDLE_SEARCHRESULT;
acs.szProto = m_szModuleName;
acs.psr = &jsr.hdr;
- CallService( MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs );
+ CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
}
return 0;
}
- else if ( !_tcsicmp( szCommand, _T( "join" )))
+ else if ( !_tcsicmp(szCommand, _T("join")))
{
// chat join invitation
- GroupchatJoinRoomByJid( NULL, szJid );
+ GroupchatJoinRoomByJid(NULL, szJid);
return 0;
}
- else if ( !_tcsicmp( szCommand, _T( "disco" )))
+ else if ( !_tcsicmp(szCommand, _T("disco")))
{
// service discovery request
- OnMenuHandleServiceDiscovery( 0, ( LPARAM )szJid );
+ OnMenuHandleServiceDiscovery(0, (LPARAM)szJid);
return 0;
}
- else if ( !_tcsicmp( szCommand, _T( "command" )))
+ else if ( !_tcsicmp(szCommand, _T("command")))
{
// ad-hoc commands
- if ( szSecondParam ) {
- if ( !_tcsnicmp( szSecondParam, _T( "node=" ), 5 )) {
+ if (szSecondParam) {
+ if ( !_tcsnicmp(szSecondParam, _T("node="), 5)) {
szSecondParam += 5;
- if (!*szSecondParam)
+ if ( !*szSecondParam)
szSecondParam = NULL;
}
else
szSecondParam = NULL;
}
- CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams( this, szJid, szSecondParam );
- ContactMenuRunCommands( 0, ( LPARAM )pStartupParams );
+ CJabberAdhocStartupParams* pStartupParams = new CJabberAdhocStartupParams(this, szJid, szSecondParam);
+ ContactMenuRunCommands(0, (LPARAM)pStartupParams);
return 0;
}
- else if ( !_tcsicmp( szCommand, _T( "sendfile" )))
+ else if ( !_tcsicmp(szCommand, _T("sendfile")))
{
// send file
- if ( ServiceExists( MS_FILE_SENDFILE )) {
- HANDLE hContact = HContactFromJID( szJid, TRUE );
- if ( !hContact )
- hContact = DBCreateContact( szJid, szJid, TRUE, TRUE );
- if ( !hContact )
+ if (ServiceExists(MS_FILE_SENDFILE)) {
+ HANDLE hContact = HContactFromJID(szJid, TRUE);
+ if ( !hContact)
+ hContact = DBCreateContact(szJid, szJid, TRUE, TRUE);
+ if ( !hContact)
return 1;
- CallService( MS_FILE_SENDFILE, ( WPARAM )hContact, ( LPARAM )NULL );
+ CallService(MS_FILE_SENDFILE, (WPARAM)hContact, (LPARAM)NULL);
return 0;
}
return 1;
@@ -589,63 +589,63 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI( WPARAM wParam, LPARAM l }
// XEP-0224 support (Attention/Nudge)
-INT_PTR __cdecl CJabberProto::JabberSendNudge( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM wParam, LPARAM)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 0;
- HANDLE hContact = ( HANDLE )wParam;
+ HANDLE hContact = (HANDLE)wParam;
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
TCHAR tszJid[ JABBER_MAX_JID_LEN ];
- TCHAR *szResource = ListGetBestClientResourceNamePtr( dbv.ptszVal );
- if ( szResource )
- mir_sntprintf( tszJid, SIZEOF(tszJid), _T("%s/%s"), dbv.ptszVal, szResource );
+ TCHAR *szResource = ListGetBestClientResourceNamePtr(dbv.ptszVal);
+ if (szResource)
+ mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), dbv.ptszVal, szResource);
else
- mir_sntprintf( tszJid, SIZEOF(tszJid), _T("%s"), dbv.ptszVal );
- JFreeVariant( &dbv );
+ mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s"), dbv.ptszVal);
+ db_free(&dbv);
- JabberCapsBits jcb = GetResourceCapabilites( tszJid, FALSE );
+ JabberCapsBits jcb = GetResourceCapabilites(tszJid, FALSE);
m_ThreadInfo->send(
- XmlNode( _T("message")) << XATTR( _T("type"), _T("headline")) << XATTR( _T("to"), tszJid )
- << XCHILDNS( _T("attention"),
- jcb & JABBER_CAPS_ATTENTION ? _T(JABBER_FEAT_ATTENTION) : _T(JABBER_FEAT_ATTENTION_0 )));
+ XmlNode(_T("message")) << XATTR(_T("type"), _T("headline")) << XATTR(_T("to"), tszJid)
+ << XCHILDNS(_T("attention"),
+ jcb & JABBER_CAPS_ATTENTION ? _T(JABBER_FEAT_ATTENTION) : _T(JABBER_FEAT_ATTENTION_0)));
}
return 0;
}
-BOOL CJabberProto::SendHttpAuthReply( CJabberHttpAuthParams *pParams, BOOL bAuthorized )
+BOOL CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAuthorized)
{
- if ( !m_bJabberOnline || !pParams || !m_ThreadInfo )
+ if ( !m_bJabberOnline || !pParams || !m_ThreadInfo)
return FALSE;
- if ( pParams->m_nType == CJabberHttpAuthParams::IQ ) {
- XmlNodeIq iq( bAuthorized ? _T("result") : _T("error"), pParams->m_szIqId, pParams->m_szFrom );
- if ( !bAuthorized ) {
- iq << XCHILDNS( _T("confirm"), _T(JABBER_FEAT_HTTP_AUTH)) << XATTR( _T("id"), pParams->m_szId )
- << XATTR( _T("method"), pParams->m_szMethod ) << XATTR( _T("url"), pParams->m_szUrl );
- iq << XCHILD( _T("error")) << XATTRI( _T("code"), 401 ) << XATTR( _T("type"), _T("auth"))
- << XCHILDNS( _T("not-authorized"), _T("urn:ietf:params:xml:xmpp-stanzas"));
+ if (pParams->m_nType == CJabberHttpAuthParams::IQ) {
+ XmlNodeIq iq(bAuthorized ? _T("result") : _T("error"), pParams->m_szIqId, pParams->m_szFrom);
+ if ( !bAuthorized) {
+ iq << XCHILDNS(_T("confirm"), _T(JABBER_FEAT_HTTP_AUTH)) << XATTR(_T("id"), pParams->m_szId)
+ << XATTR(_T("method"), pParams->m_szMethod) << XATTR(_T("url"), pParams->m_szUrl);
+ iq << XCHILD(_T("error")) << XATTRI(_T("code"), 401) << XATTR(_T("type"), _T("auth"))
+ << XCHILDNS(_T("not-authorized"), _T("urn:ietf:params:xml:xmpp-stanzas"));
}
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
- else if ( pParams->m_nType == CJabberHttpAuthParams::MSG ) {
- XmlNode msg( _T("message"));
- msg << XATTR( _T("to"), pParams->m_szFrom );
- if ( !bAuthorized )
- msg << XATTR( _T("type"), _T("error"));
- if ( pParams->m_szThreadId )
- msg << XCHILD( _T("thread"), pParams->m_szThreadId );
-
- msg << XCHILDNS( _T("confirm"), _T(JABBER_FEAT_HTTP_AUTH)) << XATTR( _T("id"), pParams->m_szId )
- << XATTR( _T("method"), pParams->m_szMethod ) << XATTR( _T("url"), pParams->m_szUrl );
-
- if ( !bAuthorized )
- msg << XCHILD( _T("error")) << XATTRI( _T("code"), 401 ) << XATTR( _T("type"), _T("auth"))
- << XCHILDNS( _T("not-authorized"), _T("urn:ietf:params:xml:xmpp-stanzas"));
-
- m_ThreadInfo->send( msg );
+ else if (pParams->m_nType == CJabberHttpAuthParams::MSG) {
+ XmlNode msg(_T("message"));
+ msg << XATTR(_T("to"), pParams->m_szFrom);
+ if ( !bAuthorized)
+ msg << XATTR(_T("type"), _T("error"));
+ if (pParams->m_szThreadId)
+ msg << XCHILD(_T("thread"), pParams->m_szThreadId);
+
+ msg << XCHILDNS(_T("confirm"), _T(JABBER_FEAT_HTTP_AUTH)) << XATTR(_T("id"), pParams->m_szId)
+ << XATTR(_T("method"), pParams->m_szMethod) << XATTR(_T("url"), pParams->m_szUrl);
+
+ if ( !bAuthorized)
+ msg << XCHILD(_T("error")) << XATTRI(_T("code"), 401) << XATTR(_T("type"), _T("auth"))
+ << XCHILDNS(_T("not-authorized"), _T("urn:ietf:params:xml:xmpp-stanzas"));
+
+ m_ThreadInfo->send(msg);
}
else
return FALSE;
@@ -666,15 +666,15 @@ public: m_btnDeny(this, IDCANCEL),
m_pParams(pParams)
{
- m_btnAuth.OnClick = Callback( this, &CJabberDlgHttpAuth::btnAuth_OnClick );
- m_btnDeny.OnClick = Callback( this, &CJabberDlgHttpAuth::btnDeny_OnClick );
+ m_btnAuth.OnClick = Callback(this, &CJabberDlgHttpAuth::btnAuth_OnClick);
+ m_btnDeny.OnClick = Callback(this, &CJabberDlgHttpAuth::btnDeny_OnClick);
}
void OnInitDialog()
{
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "openid" );
+ WindowSetIcon(m_hwnd, m_proto, "openid");
SetDlgItemText(m_hwnd, IDC_TXT_URL, m_pParams->m_szUrl);
SetDlgItemText(m_hwnd, IDC_TXT_FROM, m_pParams->m_szFrom);
@@ -682,23 +682,23 @@ public: SetDlgItemText(m_hwnd, IDC_TXT_METHOD, m_pParams->m_szMethod);
}
- BOOL SendReply( BOOL bAuthorized )
+ BOOL SendReply(BOOL bAuthorized)
{
- BOOL bRetVal = m_proto->SendHttpAuthReply( m_pParams, bAuthorized );
+ BOOL bRetVal = m_proto->SendHttpAuthReply(m_pParams, bAuthorized);
m_pParams->Free();
- mir_free( m_pParams );
+ mir_free(m_pParams);
m_pParams = NULL;
return bRetVal;
}
void btnAuth_OnClick(CCtrlButton*)
{
- SendReply( TRUE );
+ SendReply(TRUE);
Close();
}
void btnDeny_OnClick(CCtrlButton*)
{
- SendReply( FALSE );
+ SendReply(FALSE);
Close();
}
@@ -720,17 +720,17 @@ private: };
// XEP-0070 support (http auth)
-INT_PTR __cdecl CJabberProto::OnHttpAuthRequest( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::OnHttpAuthRequest(WPARAM wParam, LPARAM lParam)
{
CLISTEVENT *pCle = (CLISTEVENT *)lParam;
CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams *)pCle->lParam;
- if ( !pParams )
+ if ( !pParams)
return 0;
- CJabberDlgHttpAuth *pDlg = new CJabberDlgHttpAuth( this, (HWND)wParam, pParams );
- if ( !pDlg ) {
+ CJabberDlgHttpAuth *pDlg = new CJabberDlgHttpAuth(this, (HWND)wParam, pParams);
+ if ( !pDlg) {
pParams->Free();
- mir_free( pParams );
+ mir_free(pParams);
return 0;
}
@@ -741,10 +741,10 @@ INT_PTR __cdecl CJabberProto::OnHttpAuthRequest( WPARAM wParam, LPARAM lParam ) // Jabber API functions
-INT_PTR __cdecl CJabberProto::JabberGetApi( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::JabberGetApi(WPARAM wParam, LPARAM lParam)
{
IJabberInterface **ji = (IJabberInterface**)lParam;
- if ( !ji )
+ if ( !ji)
return -1;
*ji = &m_JabberApi;
return 0;
@@ -780,52 +780,52 @@ int CJabberSysInterface::GetVersion() const return 1;
}
-int CJabberSysInterface::CompareJIDs( LPCTSTR jid1, LPCTSTR jid2 )
+int CJabberSysInterface::CompareJIDs(LPCTSTR jid1, LPCTSTR jid2)
{
- if ( !jid1 || !jid2 ) return 0;
- return JabberCompareJids( jid1, jid2 );
+ if ( !jid1 || !jid2) return 0;
+ return JabberCompareJids(jid1, jid2);
}
-HANDLE CJabberSysInterface::ContactFromJID( LPCTSTR jid )
+HANDLE CJabberSysInterface::ContactFromJID(LPCTSTR jid)
{
- if ( !jid ) return NULL;
- return m_psProto->HContactFromJID( jid );
+ if ( !jid) return NULL;
+ return m_psProto->HContactFromJID(jid);
}
-LPTSTR CJabberSysInterface::ContactToJID( HANDLE hContact )
+LPTSTR CJabberSysInterface::ContactToJID(HANDLE hContact)
{
- return m_psProto->JGetStringT( hContact, m_psProto->JGetByte( hContact, "ChatRoom", 0 ) ? "ChatRoomID" : "jid" );
+ return m_psProto->JGetStringT(hContact, m_psProto->JGetByte(hContact, "ChatRoom", 0) ? "ChatRoomID" : "jid");
}
-LPTSTR CJabberSysInterface::GetBestResourceName( LPCTSTR jid )
+LPTSTR CJabberSysInterface::GetBestResourceName(LPCTSTR jid)
{
- if ( jid == NULL )
+ if (jid == NULL)
return NULL;
- LPCTSTR p = _tcschr( jid, '/' );
- if ( p == NULL ) {
+ LPCTSTR p = _tcschr(jid, '/');
+ if (p == NULL) {
m_psProto->ListLock(); // make sure we allow access to the list only after making mir_tstrdup() of resource name
- LPTSTR res = mir_tstrdup( m_psProto->ListGetBestClientResourceNamePtr( jid ));
+ LPTSTR res = mir_tstrdup(m_psProto->ListGetBestClientResourceNamePtr(jid));
m_psProto->ListUnlock();
return res;
}
- return mir_tstrdup( jid );
+ return mir_tstrdup(jid);
}
-LPTSTR CJabberSysInterface::GetResourceList( LPCTSTR jid )
+LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid)
{
- if ( !jid )
+ if ( !jid)
return NULL;
m_psProto->ListLock();
JABBER_LIST_ITEM *item = NULL;
- if (( item = m_psProto->ListGetItemPtr( LIST_VCARD_TEMP, jid )) == NULL)
- item = m_psProto->ListGetItemPtr( LIST_ROSTER, jid );
- if ( item == NULL ) {
+ if ((item = m_psProto->ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
+ item = m_psProto->ListGetItemPtr(LIST_ROSTER, jid);
+ if (item == NULL) {
m_psProto->ListUnlock();
return NULL;
}
- if ( item->resource == NULL ) {
+ if (item->resource == NULL) {
m_psProto->ListUnlock();
return NULL;
}
@@ -833,14 +833,14 @@ LPTSTR CJabberSysInterface::GetResourceList( LPCTSTR jid ) int i;
int iLen = 1; // 1 for extra zero terminator at the end of the string
// calculate total necessary string length
- for ( i=0; i<item->resourceCount; i++ ) {
+ for (i=0; i<item->resourceCount; i++) {
iLen += lstrlen(item->resource[i].resourceName) + 1;
}
// allocate memory and fill it
LPTSTR str = (LPTSTR)mir_alloc(iLen * sizeof(TCHAR));
LPTSTR p = str;
- for ( i=0; i<item->resourceCount; i++ ) {
+ for (i=0; i<item->resourceCount; i++) {
lstrcpy(p, item->resource[i].resourceName);
p += lstrlen(item->resource[i].resourceName) + 1;
}
@@ -865,7 +865,7 @@ unsigned int CJabberNetInterface::SerialNext() return m_psProto->SerialNext();
}
-int CJabberNetInterface::SendXmlNode( HXML node )
+int CJabberNetInterface::SendXmlNode(HXML node)
{
return m_psProto->m_ThreadInfo->send(node);
}
@@ -877,257 +877,257 @@ typedef struct void *pUserData;
} sHandlerData;
-void CJabberProto::ExternalTempIqHandler( HXML node, CJabberIqInfo *pInfo )
+void CJabberProto::ExternalTempIqHandler(HXML node, CJabberIqInfo *pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
d->Func(&m_JabberApi, node, d->pUserData);
free(d); // free IqHandlerData allocated in CJabberNetInterface::AddIqHandler below
}
-BOOL CJabberProto::ExternalIqHandler( HXML node, CJabberIqInfo *pInfo )
+BOOL CJabberProto::ExternalIqHandler(HXML node, CJabberIqInfo *pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(&m_JabberApi, node, d->pUserData);
}
-BOOL CJabberProto::ExternalMessageHandler( HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo )
+BOOL CJabberProto::ExternalMessageHandler(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(&m_JabberApi, node, d->pUserData);
}
-BOOL CJabberProto::ExternalPresenceHandler( HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo )
+BOOL CJabberProto::ExternalPresenceHandler(HXML node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(&m_JabberApi, node, d->pUserData);
}
-BOOL CJabberProto::ExternalSendHandler( HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo )
+BOOL CJabberProto::ExternalSendHandler(HXML node, ThreadData *pThreadData, CJabberSendInfo* pInfo)
{
sHandlerData *d = (sHandlerData*)pInfo->GetUserData();
return d->Func(&m_JabberApi, node, d->pUserData);
}
-HJHANDLER CJabberNetInterface::AddPresenceHandler( JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority )
+HJHANDLER CJabberNetInterface::AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
d->pUserData = pUserData;
- return (HJHANDLER)m_psProto->m_presenceManager.AddPermanentHandler( &CJabberProto::ExternalPresenceHandler, d, free, iPriority );
+ return (HJHANDLER)m_psProto->m_presenceManager.AddPermanentHandler(&CJabberProto::ExternalPresenceHandler, d, free, iPriority);
}
-HJHANDLER CJabberNetInterface::AddMessageHandler( JABBER_HANDLER_FUNC Func, int iMsgTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData, int iPriority )
+HJHANDLER CJabberNetInterface::AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
d->pUserData = pUserData;
- return (HJHANDLER)m_psProto->m_messageManager.AddPermanentHandler( &CJabberProto::ExternalMessageHandler, iMsgTypes, 0, szXmlns, FALSE, szTag, d, free, iPriority );
+ return (HJHANDLER)m_psProto->m_messageManager.AddPermanentHandler(&CJabberProto::ExternalMessageHandler, iMsgTypes, 0, szXmlns, FALSE, szTag, d, free, iPriority);
}
-HJHANDLER CJabberNetInterface::AddIqHandler( JABBER_HANDLER_FUNC Func, int iIqTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData, int iPriority )
+HJHANDLER CJabberNetInterface::AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, LPCTSTR szXmlns, LPCTSTR szTag, void *pUserData, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
d->pUserData = pUserData;
- return (HJHANDLER)m_psProto->m_iqManager.AddPermanentHandler( &CJabberProto::ExternalIqHandler, iIqTypes, 0, szXmlns, FALSE, szTag, d, free, iPriority );
+ return (HJHANDLER)m_psProto->m_iqManager.AddPermanentHandler(&CJabberProto::ExternalIqHandler, iIqTypes, 0, szXmlns, FALSE, szTag, d, free, iPriority);
}
-HJHANDLER CJabberNetInterface::AddTemporaryIqHandler( JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData, DWORD dwTimeout, int iPriority )
+HJHANDLER CJabberNetInterface::AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData, DWORD dwTimeout, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
d->pUserData = pUserData;
- CJabberIqInfo* pInfo = m_psProto->m_iqManager.AddHandler( &CJabberProto::ExternalTempIqHandler, iIqTypes, NULL, 0, iIqId, d, iPriority );
- if ( pInfo && dwTimeout > 0 )
- pInfo->SetTimeout( dwTimeout );
+ CJabberIqInfo* pInfo = m_psProto->m_iqManager.AddHandler(&CJabberProto::ExternalTempIqHandler, iIqTypes, NULL, 0, iIqId, d, iPriority);
+ if (pInfo && dwTimeout > 0)
+ pInfo->SetTimeout(dwTimeout);
return (HJHANDLER)pInfo;
}
-HJHANDLER CJabberNetInterface::AddSendHandler( JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority )
+HJHANDLER CJabberNetInterface::AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority)
{
sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData));
d->Func = Func;
d->pUserData = pUserData;
- return (HJHANDLER)m_psProto->m_sendManager.AddPermanentHandler( &CJabberProto::ExternalSendHandler, d, free, iPriority );
+ return (HJHANDLER)m_psProto->m_sendManager.AddPermanentHandler(&CJabberProto::ExternalSendHandler, d, free, iPriority);
}
-int CJabberNetInterface::RemoveHandler( HJHANDLER hHandler )
+int CJabberNetInterface::RemoveHandler(HJHANDLER hHandler)
{
- return m_psProto->m_sendManager.DeletePermanentHandler( (CJabberSendPermanentInfo*)hHandler ) ||
- m_psProto->m_presenceManager.DeletePermanentHandler( (CJabberPresencePermanentInfo*)hHandler ) ||
- m_psProto->m_messageManager.DeletePermanentHandler( (CJabberMessagePermanentInfo*)hHandler ) ||
- m_psProto->m_iqManager.DeletePermanentHandler( (CJabberIqPermanentInfo*)hHandler ) ||
- m_psProto->m_iqManager.DeleteHandler( (CJabberIqInfo*)hHandler );
+ return m_psProto->m_sendManager.DeletePermanentHandler((CJabberSendPermanentInfo*)hHandler) ||
+ m_psProto->m_presenceManager.DeletePermanentHandler((CJabberPresencePermanentInfo*)hHandler) ||
+ m_psProto->m_messageManager.DeletePermanentHandler((CJabberMessagePermanentInfo*)hHandler) ||
+ m_psProto->m_iqManager.DeletePermanentHandler((CJabberIqPermanentInfo*)hHandler) ||
+ m_psProto->m_iqManager.DeleteHandler((CJabberIqInfo*)hHandler);
}
JabberFeatCapPairDynamic *CJabberNetInterface::FindFeature(LPCTSTR szFeature)
{
int i;
- for ( i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++ )
- if ( !lstrcmp( m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature, szFeature ))
+ for (i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
+ if ( !lstrcmp(m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature, szFeature))
return m_psProto->m_lstJabberFeatCapPairsDynamic[i];
return NULL;
}
-int CJabberNetInterface::RegisterFeature( LPCTSTR szFeature, LPCTSTR szDescription )
+int CJabberNetInterface::RegisterFeature(LPCTSTR szFeature, LPCTSTR szDescription)
{
- if ( !szFeature ) {
+ if ( !szFeature) {
return false;
}
// check for this feature in core features, and return false if it's present, to prevent re-registering a core feature
int i;
- for ( i = 0; g_JabberFeatCapPairs[i].szFeature; i++ )
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++)
{
- if ( !lstrcmp( g_JabberFeatCapPairs[i].szFeature, szFeature ))
+ if ( !lstrcmp(g_JabberFeatCapPairs[i].szFeature, szFeature))
{
return false;
}
}
m_psProto->ListLock();
- JabberFeatCapPairDynamic *fcp = FindFeature( szFeature );
- if ( !fcp ) {
+ JabberFeatCapPairDynamic *fcp = FindFeature(szFeature);
+ if ( !fcp) {
// if the feature is not registered yet, allocate new bit for it
JabberCapsBits jcb = JABBER_CAPS_OTHER_SPECIAL; // set all bits not included in g_JabberFeatCapPairs
// set all bits occupied by g_JabberFeatCapPairs
- for ( i = 0; g_JabberFeatCapPairs[i].szFeature; i++ )
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++)
jcb |= g_JabberFeatCapPairs[i].jcbCap;
// set all bits already occupied by external plugins
- for ( i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++ )
+ for (i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
jcb |= m_psProto->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
// Now get first zero bit. The line below is a fast way to do it. If there are no zero bits, it returns 0.
jcb = (~jcb) & (JabberCapsBits)(-(__int64)(~jcb));
- if ( !jcb ) {
+ if ( !jcb) {
// no more free bits
m_psProto->ListUnlock();
return false;
}
- LPTSTR szExt = mir_tstrdup( szFeature );
+ LPTSTR szExt = mir_tstrdup(szFeature);
LPTSTR pSrc, pDst;
- for ( pSrc = szExt, pDst = szExt; *pSrc; pSrc++ ) {
+ for (pSrc = szExt, pDst = szExt; *pSrc; pSrc++) {
// remove unnecessary symbols from szFeature to make the string shorter, and use it as szExt
- if ( _tcschr( _T("bcdfghjklmnpqrstvwxz0123456789"), *pSrc )) {
+ if (_tcschr(_T("bcdfghjklmnpqrstvwxz0123456789"), *pSrc)) {
*pDst++ = *pSrc;
}
}
*pDst = 0;
- m_psProto->m_clientCapsManager.SetClientCaps( _T(JABBER_CAPS_MIRANDA_NODE), szExt, jcb );
+ m_psProto->m_clientCapsManager.SetClientCaps(_T(JABBER_CAPS_MIRANDA_NODE), szExt, jcb);
fcp = new JabberFeatCapPairDynamic();
fcp->szExt = szExt; // will be deallocated along with other values of JabberFeatCapPairDynamic in CJabberProto destructor
- fcp->szFeature = mir_tstrdup( szFeature );
- fcp->szDescription = szDescription ? mir_tstrdup( szDescription ) : NULL;
+ fcp->szFeature = mir_tstrdup(szFeature);
+ fcp->szDescription = szDescription ? mir_tstrdup(szDescription) : NULL;
fcp->jcbCap = jcb;
- m_psProto->m_lstJabberFeatCapPairsDynamic.insert( fcp );
- } else if ( szDescription ) {
+ m_psProto->m_lstJabberFeatCapPairsDynamic.insert(fcp);
+ } else if (szDescription) {
// update description
- if ( fcp->szDescription )
- mir_free( fcp->szDescription );
- fcp->szDescription = mir_tstrdup( szDescription );
+ if (fcp->szDescription)
+ mir_free(fcp->szDescription);
+ fcp->szDescription = mir_tstrdup(szDescription);
}
m_psProto->ListUnlock();
return true;
}
-int CJabberNetInterface::AddFeatures( LPCTSTR szFeatures )
+int CJabberNetInterface::AddFeatures(LPCTSTR szFeatures)
{
- if ( !szFeatures ) {
+ if ( !szFeatures) {
return false;
}
m_psProto->ListLock();
BOOL ret = true;
LPCTSTR szFeat = szFeatures;
- while ( szFeat[0] ) {
- JabberFeatCapPairDynamic *fcp = FindFeature( szFeat );
+ while (szFeat[0]) {
+ JabberFeatCapPairDynamic *fcp = FindFeature(szFeat);
// if someone is trying to add one of core features, RegisterFeature() will return false, so we don't have to perform this check here
- if ( !fcp ) {
+ if ( !fcp) {
// if the feature is not registered yet
- if ( !RegisterFeature( szFeat, NULL )) {
+ if ( !RegisterFeature(szFeat, NULL)) {
ret = false;
} else {
- fcp = FindFeature( szFeat ); // update fcp after RegisterFeature()
+ fcp = FindFeature(szFeat); // update fcp after RegisterFeature()
}
}
- if ( fcp ) {
+ if (fcp) {
m_psProto->m_uEnabledFeatCapsDynamic |= fcp->jcbCap;
} else {
ret = false;
}
- szFeat += lstrlen( szFeat ) + 1;
+ szFeat += lstrlen(szFeat) + 1;
}
m_psProto->ListUnlock();
- if ( m_psProto->m_bJabberOnline ) {
- m_psProto->SendPresence( m_psProto->m_iStatus, true );
+ if (m_psProto->m_bJabberOnline) {
+ m_psProto->SendPresence(m_psProto->m_iStatus, true);
}
return ret;
}
-int CJabberNetInterface::RemoveFeatures( LPCTSTR szFeatures )
+int CJabberNetInterface::RemoveFeatures(LPCTSTR szFeatures)
{
- if ( !szFeatures ) {
+ if ( !szFeatures) {
return false;
}
m_psProto->ListLock();
BOOL ret = true;
LPCTSTR szFeat = szFeatures;
- while ( szFeat[0] ) {
- JabberFeatCapPairDynamic *fcp = FindFeature( szFeat );
- if ( fcp ) {
+ while (szFeat[0]) {
+ JabberFeatCapPairDynamic *fcp = FindFeature(szFeat);
+ if (fcp) {
m_psProto->m_uEnabledFeatCapsDynamic &= ~fcp->jcbCap;
} else {
ret = false; // indicate that there was an error removing at least one of the specified features
}
- szFeat += lstrlen( szFeat ) + 1;
+ szFeat += lstrlen(szFeat) + 1;
}
m_psProto->ListUnlock();
- if ( m_psProto->m_bJabberOnline ) {
- m_psProto->SendPresence( m_psProto->m_iStatus, true );
+ if (m_psProto->m_bJabberOnline) {
+ m_psProto->SendPresence(m_psProto->m_iStatus, true);
}
return ret;
}
-LPTSTR CJabberNetInterface::GetResourceFeatures( LPCTSTR jid )
+LPTSTR CJabberNetInterface::GetResourceFeatures(LPCTSTR jid)
{
- JabberCapsBits jcb = m_psProto->GetResourceCapabilites( jid, true );
- if ( !( jcb & JABBER_RESOURCE_CAPS_ERROR )) {
+ JabberCapsBits jcb = m_psProto->GetResourceCapabilites(jid, true);
+ if ( !(jcb & JABBER_RESOURCE_CAPS_ERROR)) {
m_psProto->ListLock(); // contents of m_lstJabberFeatCapPairsDynamic must not change from the moment we calculate total length and to the moment when we fill the string
int i;
int iLen = 1; // 1 for extra zero terminator at the end of the string
// calculate total necessary string length
- for ( i = 0; g_JabberFeatCapPairs[i].szFeature; i++ ) {
- if ( jcb & g_JabberFeatCapPairs[i].jcbCap ) {
- iLen += lstrlen( g_JabberFeatCapPairs[i].szFeature ) + 1;
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++) {
+ if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
+ iLen += lstrlen(g_JabberFeatCapPairs[i].szFeature) + 1;
}
}
- for ( i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++ ) {
- if ( jcb & m_psProto->m_lstJabberFeatCapPairsDynamic[i]->jcbCap ) {
- iLen += lstrlen( m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature ) + 1;
+ for (i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ if (jcb & m_psProto->m_lstJabberFeatCapPairsDynamic[i]->jcbCap) {
+ iLen += lstrlen(m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature) + 1;
}
}
// allocate memory and fill it
- LPTSTR str = (LPTSTR)mir_alloc( iLen * sizeof(TCHAR));
+ LPTSTR str = (LPTSTR)mir_alloc(iLen * sizeof(TCHAR));
LPTSTR p = str;
- for ( i = 0; g_JabberFeatCapPairs[i].szFeature; i++ ) {
- if ( jcb & g_JabberFeatCapPairs[i].jcbCap ) {
- lstrcpy( p, g_JabberFeatCapPairs[i].szFeature );
- p += lstrlen( g_JabberFeatCapPairs[i].szFeature ) + 1;
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++) {
+ if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
+ lstrcpy(p, g_JabberFeatCapPairs[i].szFeature);
+ p += lstrlen(g_JabberFeatCapPairs[i].szFeature) + 1;
}
}
- for ( i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++ ) {
- if ( jcb & m_psProto->m_lstJabberFeatCapPairsDynamic[i]->jcbCap ) {
- lstrcpy( p, m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature );
- p += lstrlen( m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature ) + 1;
+ for (i = 0; i < m_psProto->m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ if (jcb & m_psProto->m_lstJabberFeatCapPairsDynamic[i]->jcbCap) {
+ lstrcpy(p, m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature);
+ p += lstrlen(m_psProto->m_lstJabberFeatCapPairsDynamic[i]->szFeature) + 1;
}
}
*p = 0; // extra zero terminator
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 8e8d1b6636..12bb41479a 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -48,7 +48,7 @@ int iqIdRegSetReg; #define JCPF_ERROR 0x04UL
//extern int bSecureIM;
-static VOID CALLBACK JabberDummyApcFunc( DWORD_PTR )
+static VOID CALLBACK JabberDummyApcFunc(DWORD_PTR)
{
return;
}
@@ -64,38 +64,38 @@ struct JabberPasswordDlgParam TCHAR* ptszJid;
};
-static INT_PTR CALLBACK JabberPasswordDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberPasswordDlgParam* param = (JabberPasswordDlgParam*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JabberPasswordDlgParam* param = (JabberPasswordDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
{
param = (JabberPasswordDlgParam*)lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
TCHAR text[512];
- mir_sntprintf( text, SIZEOF(text), _T("%s %s"), TranslateT( "Enter password for" ), ( TCHAR* )param->ptszJid );
- SetDlgItemText( hwndDlg, IDC_JID, text );
+ mir_sntprintf(text, SIZEOF(text), _T("%s %s"), TranslateT("Enter password for"), (TCHAR*)param->ptszJid);
+ SetDlgItemText(hwndDlg, IDC_JID, text);
- int bSavePassword = param->pro->JGetByte( NULL, "SaveSessionPassword", 0 );
- CheckDlgButton( hwndDlg, IDC_SAVEPASSWORD, ( bSavePassword ) ? BST_CHECKED : BST_UNCHECKED );
+ int bSavePassword = param->pro->JGetByte(NULL, "SaveSessionPassword", 0);
+ CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, (bSavePassword) ? BST_CHECKED : BST_UNCHECKED);
}
return TRUE;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDOK:
- param->saveOnlinePassword = IsDlgButtonChecked( hwndDlg, IDC_SAVEPASSWORD );
- param->pro->JSetByte( NULL, "SaveSessionPassword", param->saveOnlinePassword );
+ param->saveOnlinePassword = IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD);
+ param->pro->JSetByte(NULL, "SaveSessionPassword", param->saveOnlinePassword);
- GetDlgItemText( hwndDlg, IDC_PASSWORD, param->onlinePassword, SIZEOF( param->onlinePassword ));
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, param->onlinePassword, SIZEOF(param->onlinePassword));
// Fall through
case IDCANCEL:
- param->dlgResult = LOWORD( wParam );
- SetEvent( param->hEventPasswdDlg );
- DestroyWindow( hwndDlg );
+ param->dlgResult = LOWORD(wParam);
+ SetEvent(param->hEventPasswdDlg);
+ DestroyWindow(hwndDlg);
return TRUE;
}
break;
@@ -104,31 +104,31 @@ static INT_PTR CALLBACK JabberPasswordDlgProc( HWND hwndDlg, UINT msg, WPARAM wP return FALSE;
}
-static VOID CALLBACK JabberPasswordCreateDialogApcProc( void* param )
+static VOID CALLBACK JabberPasswordCreateDialogApcProc(void* param)
{
- CreateDialogParam( hInst, MAKEINTRESOURCE( IDD_PASSWORD ), NULL, JabberPasswordDlgProc, ( LPARAM )param );
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, JabberPasswordDlgProc, (LPARAM)param);
}
-static VOID CALLBACK JabberOfflineChatWindows( void* param )
+static VOID CALLBACK JabberOfflineChatWindows(void* param)
{
- CJabberProto* ppro = ( CJabberProto* )param;
+ CJabberProto* ppro = (CJabberProto*)param;
GCDEST gcd = { ppro->m_szModuleName, NULL, GC_EVENT_CONTROL };
GCEVENT gce = { 0 };
gce.cbSize = sizeof(GCEVENT);
gce.pDest = &gcd;
- CallService( MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce );
+ CallService(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Jabber keep-alive thread
-void CJabberProto::OnPingReply( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnPingReply(HXML, CJabberIqInfo* pInfo)
{
- if ( !pInfo )
+ if ( !pInfo)
return;
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_FAIL ) {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_FAIL) {
// disconnect because of timeout
- m_ThreadInfo->send( "</stream:stream>" );
+ m_ThreadInfo->send("</stream:stream>");
m_ThreadInfo->shutdown();
}
}
@@ -143,25 +143,25 @@ static int CompareDNS(const DNS_SRV_DATAA* dns1, const DNS_SRV_DATAA* dns2) return (int)dns1->wPriority - (int)dns2->wPriority;
}
-void ThreadData::xmpp_client_query( void )
+void ThreadData::xmpp_client_query(void)
{
if (inet_addr(server) != INADDR_NONE)
return;
- HMODULE hDnsapi = LoadLibraryA( "dnsapi.dll" );
- if ( hDnsapi == NULL )
+ HMODULE hDnsapi = LoadLibraryA("dnsapi.dll");
+ if (hDnsapi == NULL)
return;
DNSQUERYA pDnsQuery = (DNSQUERYA)GetProcAddress(hDnsapi, "DnsQuery_A");
DNSFREELIST pDnsRecordListFree = (DNSFREELIST)GetProcAddress(hDnsapi, "DnsRecordListFree");
- if ( pDnsQuery == NULL ) {
+ if (pDnsQuery == NULL) {
//dnsapi.dll is not the needed dnsapi ;)
- FreeLibrary( hDnsapi );
+ FreeLibrary(hDnsapi);
return;
}
char temp[256];
- mir_snprintf( temp, SIZEOF(temp), "_xmpp-client._tcp.%s", server );
+ mir_snprintf(temp, SIZEOF(temp), "_xmpp-client._tcp.%s", server);
DNS_RECORDA *results = NULL;
DNS_STATUS status = pDnsQuery(temp, DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &results, NULL);
@@ -180,7 +180,7 @@ void ThreadData::xmpp_client_query( void ) proto->Log("%s%s resolved to %s:%d", "_xmpp-client._tcp.", server, dnsHost, dnsPort);
s = proto->WsConnect(dnsHost, dnsPort);
if (s) {
- mir_snprintf( manualHost, SIZEOF( manualHost ), "%s", dnsHost );
+ mir_snprintf(manualHost, SIZEOF(manualHost), "%s", dnsHost);
port = dnsPort;
break;
} }
@@ -196,297 +196,297 @@ void ThreadData::xmpp_client_query( void ) void CJabberProto::xmlStreamInitialize(char *szWhich)
{
Log("Stream will be initialized %s", szWhich);
- if ( m_szXmlStreamToBeInitialized )
- free( m_szXmlStreamToBeInitialized );
- m_szXmlStreamToBeInitialized = _strdup( szWhich );
+ if (m_szXmlStreamToBeInitialized)
+ free(m_szXmlStreamToBeInitialized);
+ m_szXmlStreamToBeInitialized = _strdup(szWhich);
}
void CJabberProto::xmlStreamInitializeNow(ThreadData* info)
{
- Log( "Stream is initializing %s",
- m_szXmlStreamToBeInitialized ? m_szXmlStreamToBeInitialized : "after connect" );
+ Log("Stream is initializing %s",
+ m_szXmlStreamToBeInitialized ? m_szXmlStreamToBeInitialized : "after connect");
if (m_szXmlStreamToBeInitialized) {
- free( m_szXmlStreamToBeInitialized );
+ free(m_szXmlStreamToBeInitialized);
m_szXmlStreamToBeInitialized = NULL;
}
- HXML n = xi.createNode( _T("xml"), NULL, 1 ) << XATTR( _T("version"), _T("1.0")) << XATTR( _T("encoding"), _T("UTF-8"));
+ HXML n = xi.createNode(_T("xml"), NULL, 1) << XATTR(_T("version"), _T("1.0")) << XATTR(_T("encoding"), _T("UTF-8"));
- HXML stream = n << XCHILDNS( _T("stream:stream" ), _T("jabber:client")) << XATTR( _T("to"), _A2T(info->server))
- << XATTR( _T("xmlns:stream"), _T("http://etherx.jabber.org/streams"));
+ HXML stream = n << XCHILDNS(_T("stream:stream"), _T("jabber:client")) << XATTR(_T("to"), _A2T(info->server))
+ << XATTR(_T("xmlns:stream"), _T("http://etherx.jabber.org/streams"));
- if ( m_tszSelectedLang )
- xmlAddAttr( stream, _T("xml:lang"), m_tszSelectedLang );
+ if (m_tszSelectedLang)
+ xmlAddAttr(stream, _T("xml:lang"), m_tszSelectedLang);
- if ( !m_options.Disable3920auth )
- xmlAddAttr( stream, _T("version"), _T("1.0"));
+ if ( !m_options.Disable3920auth)
+ xmlAddAttr(stream, _T("version"), _T("1.0"));
- LPTSTR xmlQuery = xi.toString( n, NULL );
- char* buf = mir_utf8encodeT( xmlQuery );
- int bufLen = (int)strlen( buf );
- if ( bufLen > 2 ) {
- strdel( buf + bufLen - 2, 1 );
+ LPTSTR xmlQuery = xi.toString(n, NULL);
+ char* buf = mir_utf8encodeT(xmlQuery);
+ int bufLen = (int)strlen(buf);
+ if (bufLen > 2) {
+ strdel(buf + bufLen - 2, 1);
bufLen--;
}
- info->send( buf, bufLen );
- mir_free( buf );
- xi.freeMem( xmlQuery );
- xi.destroyNode( n );
+ info->send(buf, bufLen);
+ mir_free(buf);
+ xi.freeMem(xmlQuery);
+ xi.destroyNode(n);
}
-void CJabberProto::ServerThread( ThreadData* info )
+void CJabberProto::ServerThread(ThreadData* info)
{
DBVARIANT dbv;
char* buffer;
int datalen;
int oldStatus;
- Log( "Thread started: type=%d", info->type );
+ Log("Thread started: type=%d", info->type);
info->resolveID = -1;
info->auth = NULL;
- if ( m_options.ManualConnect == TRUE ) {
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "ManualHost", &dbv )) {
- strncpy( info->manualHost, dbv.pszVal, SIZEOF( info->manualHost ));
- info->manualHost[SIZEOF( info->manualHost )-1] = '\0';
- JFreeVariant( &dbv );
+ if (m_options.ManualConnect == TRUE) {
+ if ( !DBGetContactSettingString(NULL, m_szModuleName, "ManualHost", &dbv)) {
+ strncpy(info->manualHost, dbv.pszVal, SIZEOF(info->manualHost));
+ info->manualHost[SIZEOF(info->manualHost)-1] = '\0';
+ db_free(&dbv);
}
- info->port = JGetWord( NULL, "ManualPort", JABBER_DEFAULT_PORT );
+ info->port = JGetWord(NULL, "ManualPort", JABBER_DEFAULT_PORT);
}
- else info->port = JGetWord( NULL, "Port", JABBER_DEFAULT_PORT );
+ else info->port = JGetWord(NULL, "Port", JABBER_DEFAULT_PORT);
info->useSSL = m_options.UseSSL;
- if ( info->type == JABBER_SESSION_NORMAL ) {
+ if (info->type == JABBER_SESSION_NORMAL) {
// Normal server connection, we will fetch all connection parameters
// e.g. username, password, etc. from the database.
- if ( m_ThreadInfo != NULL ) {
+ if (m_ThreadInfo != NULL) {
// Will not start another connection thread if a thread is already running.
// Make APC call to the main thread. This will immediately wake the thread up
// in case it is asleep in the reconnect loop so that it will immediately
// reconnect.
- QueueUserAPC( JabberDummyApcFunc, m_ThreadInfo->hThread, 0 );
- Log( "Thread ended, another normal thread is running" );
+ QueueUserAPC(JabberDummyApcFunc, m_ThreadInfo->hThread, 0);
+ Log("Thread ended, another normal thread is running");
LBL_Exit:
delete info;
return;
}
m_ThreadInfo = info;
- if ( m_szStreamId ) mir_free( m_szStreamId );
+ if (m_szStreamId) mir_free(m_szStreamId);
m_szStreamId = NULL;
- if ( !JGetStringT( NULL, "LoginName", &dbv )) {
- _tcsncpy( info->username, dbv.ptszVal, SIZEOF( info->username )-1 );
- JFreeVariant( &dbv );
+ if ( !JGetStringT(NULL, "LoginName", &dbv)) {
+ _tcsncpy(info->username, dbv.ptszVal, SIZEOF(info->username)-1);
+ db_free(&dbv);
}
- if ( *trtrim(info->username) == '\0' ) {
- DWORD dwSize = SIZEOF( info->username );
- if ( GetUserName( info->username, &dwSize ))
- JSetStringT( NULL, "LoginName", info->username );
+ if (*trtrim(info->username) == '\0') {
+ DWORD dwSize = SIZEOF(info->username);
+ if (GetUserName(info->username, &dwSize))
+ JSetStringT(NULL, "LoginName", info->username);
else
info->username[0] = 0;
}
- if ( *trtrim(info->username) == '\0' ) {
- Log( "Thread ended, login name is not configured" );
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID );
+ if (*trtrim(info->username) == '\0') {
+ Log("Thread ended, login name is not configured");
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
LBL_FatalError:
m_ThreadInfo = NULL;
oldStatus = m_iStatus;
m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
goto LBL_Exit;
}
- if ( !DBGetContactSettingString( NULL, m_szModuleName, "LoginServer", &dbv )) {
- strncpy( info->server, dbv.pszVal, SIZEOF( info->server )-1 );
- JFreeVariant( &dbv );
+ if ( !DBGetContactSettingString(NULL, m_szModuleName, "LoginServer", &dbv)) {
+ strncpy(info->server, dbv.pszVal, SIZEOF(info->server)-1);
+ db_free(&dbv);
}
else {
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK );
- Log( "Thread ended, login server is not configured" );
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
+ Log("Thread ended, login server is not configured");
goto LBL_FatalError;
}
- if ( m_options.HostNameAsResource == FALSE ) {
- if ( !JGetStringT( NULL, "Resource", &dbv )) {
- _tcsncpy( info->resource, dbv.ptszVal, SIZEOF( info->resource ) - 1 );
- JFreeVariant( &dbv );
+ if (m_options.HostNameAsResource == FALSE) {
+ if ( !JGetStringT(NULL, "Resource", &dbv)) {
+ _tcsncpy(info->resource, dbv.ptszVal, SIZEOF(info->resource) - 1);
+ db_free(&dbv);
}
- else _tcscpy( info->resource, _T("Miranda"));
+ else _tcscpy(info->resource, _T("Miranda"));
}
else {
- DWORD dwCompNameLen = SIZEOF( info->resource ) - 1;
- if ( !GetComputerName( info->resource, &dwCompNameLen ))
- _tcscpy( info->resource, _T( "Miranda" ));
+ DWORD dwCompNameLen = SIZEOF(info->resource) - 1;
+ if ( !GetComputerName(info->resource, &dwCompNameLen))
+ _tcscpy(info->resource, _T("Miranda"));
}
TCHAR jidStr[512];
- mir_sntprintf( jidStr, SIZEOF( jidStr ), _T("%s@") _T(TCHAR_STR_PARAM) _T("/%s"), info->username, info->server, info->resource );
- _tcsncpy( info->fullJID, jidStr, SIZEOF( info->fullJID )-1 );
+ mir_sntprintf(jidStr, SIZEOF(jidStr), _T("%s@") _T(TCHAR_STR_PARAM) _T("/%s"), info->username, info->server, info->resource);
+ _tcsncpy(info->fullJID, jidStr, SIZEOF(info->fullJID)-1);
- if ( m_options.SavePassword == FALSE ) {
+ if (m_options.SavePassword == FALSE) {
if (*m_savedPassword) {
- _tcsncpy( info->password, m_savedPassword, SIZEOF( info->password ));
- info->password[ SIZEOF( info->password )-1] = '\0';
+ _tcsncpy(info->password, m_savedPassword, SIZEOF(info->password));
+ info->password[ SIZEOF(info->password)-1] = '\0';
}
else {
- mir_sntprintf( jidStr, SIZEOF( jidStr ), _T("%s@") _T(TCHAR_STR_PARAM), info->username, info->server );
+ mir_sntprintf(jidStr, SIZEOF(jidStr), _T("%s@") _T(TCHAR_STR_PARAM), info->username, info->server);
JabberPasswordDlgParam param;
param.pro = this;
param.ptszJid = jidStr;
- param.hEventPasswdDlg = CreateEvent( NULL, FALSE, FALSE, NULL );
- CallFunctionAsync( JabberPasswordCreateDialogApcProc, ¶m );
- WaitForSingleObject( param.hEventPasswdDlg, INFINITE );
- CloseHandle( param.hEventPasswdDlg );
-
- if ( param.dlgResult == IDCANCEL ) {
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID );
- Log( "Thread ended, password request dialog was canceled" );
+ param.hEventPasswdDlg = CreateEvent(NULL, FALSE, FALSE, NULL);
+ CallFunctionAsync(JabberPasswordCreateDialogApcProc, ¶m);
+ WaitForSingleObject(param.hEventPasswdDlg, INFINITE);
+ CloseHandle(param.hEventPasswdDlg);
+
+ if (param.dlgResult == IDCANCEL) {
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
+ Log("Thread ended, password request dialog was canceled");
goto LBL_FatalError;
}
- if ( param.saveOnlinePassword ) lstrcpy(m_savedPassword, param.onlinePassword);
+ if (param.saveOnlinePassword) lstrcpy(m_savedPassword, param.onlinePassword);
else *m_savedPassword = 0;
- _tcsncpy( info->password, param.onlinePassword, SIZEOF( info->password ));
- info->password[ SIZEOF( info->password )-1] = '\0';
+ _tcsncpy(info->password, param.onlinePassword, SIZEOF(info->password));
+ info->password[ SIZEOF(info->password)-1] = '\0';
}
}
else {
TCHAR *passw = JGetStringCrypt(NULL, "LoginPassword");
- if ( passw == NULL ) {
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID );
- Log( "Thread ended, password is not configured" );
+ if (passw == NULL) {
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
+ Log("Thread ended, password is not configured");
goto LBL_FatalError;
}
- _tcsncpy( info->password, passw, SIZEOF( info->password ));
- info->password[SIZEOF( info->password )-1] = '\0';
- mir_free( passw );
+ _tcsncpy(info->password, passw, SIZEOF(info->password));
+ info->password[SIZEOF(info->password)-1] = '\0';
+ mir_free(passw);
} }
- else if ( info->type == JABBER_SESSION_REGISTER ) {
+ else if (info->type == JABBER_SESSION_REGISTER) {
// Register new user connection, all connection parameters are already filled-in.
- // Multiple thread allowed, although not possible : )
+ // Multiple thread allowed, although not possible :)
// thinking again.. multiple thread should not be allowed
info->reg_done = FALSE;
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 25, ( LPARAM )TranslateT( "Connecting..." ));
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 25, (LPARAM)TranslateT("Connecting..."));
iqIdRegGetReg = -1;
iqIdRegSetReg = -1;
}
else {
- Log( "Thread ended, invalid session type" );
+ Log("Thread ended, invalid session type");
goto LBL_FatalError;
}
int jabberNetworkBufferSize = 2048;
- if (( buffer=( char* )mir_alloc( jabberNetworkBufferSize + 1 )) == NULL ) { // +1 is for '\0' when debug logging this buffer
- Log( "Cannot allocate network buffer, thread ended" );
- if ( info->type == JABBER_SESSION_NORMAL ) {
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK );
+ if ((buffer=(char*)mir_alloc(jabberNetworkBufferSize + 1)) == NULL) { // +1 is for '\0' when debug logging this buffer
+ Log("Cannot allocate network buffer, thread ended");
+ if (info->type == JABBER_SESSION_NORMAL) {
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
}
- else if ( info->type == JABBER_SESSION_REGISTER ) {
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )TranslateT( "Error: Not enough memory" ));
+ else if (info->type == JABBER_SESSION_REGISTER) {
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Not enough memory"));
}
- Log( "Thread ended, network buffer cannot be allocated" );
+ Log("Thread ended, network buffer cannot be allocated");
goto LBL_FatalError;
}
- if ( info->manualHost[0] == 0 ) {
+ if (info->manualHost[0] == 0) {
info->xmpp_client_query();
- if ( info->s == NULL ) {
- strncpy( info->manualHost, info->server, SIZEOF(info->manualHost));
- info->s = WsConnect( info->manualHost, info->port );
+ if (info->s == NULL) {
+ strncpy(info->manualHost, info->server, SIZEOF(info->manualHost));
+ info->s = WsConnect(info->manualHost, info->port);
}
}
else
- info->s = WsConnect( info->manualHost, info->port );
-
- Log( "Thread type=%d server='%s' port='%d'", info->type, info->manualHost, info->port );
- if ( info->s == NULL ) {
- Log( "Connection failed ( %d )", WSAGetLastError());
- if ( info->type == JABBER_SESSION_NORMAL ) {
- if ( m_ThreadInfo == info ) {
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK );
+ info->s = WsConnect(info->manualHost, info->port);
+
+ Log("Thread type=%d server='%s' port='%d'", info->type, info->manualHost, info->port);
+ if (info->s == NULL) {
+ Log("Connection failed (%d)", WSAGetLastError());
+ if (info->type == JABBER_SESSION_NORMAL) {
+ if (m_ThreadInfo == info) {
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
} }
- else if ( info->type == JABBER_SESSION_REGISTER )
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )TranslateT( "Error: Cannot connect to the server" ));
+ else if (info->type == JABBER_SESSION_REGISTER)
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Cannot connect to the server"));
- Log( "Thread ended, connection failed" );
- mir_free( buffer );
+ Log("Thread ended, connection failed");
+ mir_free(buffer);
goto LBL_FatalError;
}
// Determine local IP
- if ( info->useSSL ) {
- Log( "Intializing SSL connection" );
- if (!CallService( MS_NETLIB_STARTSSL, ( WPARAM )info->s, 0)) {
- Log( "SSL intialization failed" );
- if ( info->type == JABBER_SESSION_NORMAL ) {
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK );
+ if (info->useSSL) {
+ Log("Intializing SSL connection");
+ if ( !CallService(MS_NETLIB_STARTSSL, (WPARAM)info->s, 0)) {
+ Log("SSL intialization failed");
+ if (info->type == JABBER_SESSION_NORMAL) {
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
}
- else if ( info->type == JABBER_SESSION_REGISTER ) {
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )TranslateT( "Error: Cannot connect to the server" ));
+ else if (info->type == JABBER_SESSION_REGISTER) {
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Cannot connect to the server"));
}
- mir_free( buffer );
+ mir_free(buffer);
info->close();
- Log( "Thread ended, SSL connection failed" );
+ Log("Thread ended, SSL connection failed");
goto LBL_FatalError;
} }
// User may change status to OFFLINE while we are connecting above
- if ( m_iDesiredStatus != ID_STATUS_OFFLINE || info->type == JABBER_SESSION_REGISTER ) {
+ if (m_iDesiredStatus != ID_STATUS_OFFLINE || info->type == JABBER_SESSION_REGISTER) {
- if ( info->type == JABBER_SESSION_NORMAL ) {
+ if (info->type == JABBER_SESSION_NORMAL) {
m_bJabberConnected = TRUE;
- size_t len = _tcslen( info->username ) + strlen( info->server )+1;
- m_szJabberJID = ( TCHAR* )mir_alloc( sizeof( TCHAR)*( len+1 ));
- mir_sntprintf( m_szJabberJID, len+1, _T("%s@") _T(TCHAR_STR_PARAM), info->username, info->server );
+ size_t len = _tcslen(info->username) + strlen(info->server)+1;
+ m_szJabberJID = (TCHAR*)mir_alloc(sizeof(TCHAR)*(len+1));
+ mir_sntprintf(m_szJabberJID, len+1, _T("%s@") _T(TCHAR_STR_PARAM), info->username, info->server);
m_bSendKeepAlive = m_options.KeepAlive != 0;
JSetStringT(NULL, "jid", m_szJabberJID); // store jid in database
}
- xmlStreamInitializeNow( info );
- const TCHAR* tag = _T("stream:stream");
+ xmlStreamInitializeNow(info);
+ const TCHAR *tag = _T("stream:stream");
- Log( "Entering main recv loop" );
+ Log("Entering main recv loop");
datalen = 0;
// cache values
DWORD dwConnectionKeepAliveInterval = m_options.ConnectionKeepAliveInterval;
- for ( ;; ) {
- if ( !info->useZlib || info->zRecvReady ) {
+ for (;;) {
+ if ( !info->useZlib || info->zRecvReady) {
DWORD dwIdle = GetTickCount() - m_lastTicks;
- if ( dwIdle >= dwConnectionKeepAliveInterval )
+ if (dwIdle >= dwConnectionKeepAliveInterval)
dwIdle = dwConnectionKeepAliveInterval - 10; // now!
NETLIBSELECT nls = {0};
- nls.cbSize = sizeof( NETLIBSELECT );
+ nls.cbSize = sizeof(NETLIBSELECT);
nls.dwTimeout = dwConnectionKeepAliveInterval - dwIdle;
nls.hReadConns[0] = info->s;
- int nSelRes = CallService( MS_NETLIB_SELECT, 0, ( LPARAM )&nls );
- if ( nSelRes == -1 ) // error
+ int nSelRes = CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls);
+ if (nSelRes == -1) // error
break;
- else if ( nSelRes == 0 && m_bSendKeepAlive ) {
- if ( m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PING ) {
- CJabberIqInfo* pInfo = m_iqManager.AddHandler( &CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, NULL, 0, -1, this );
- pInfo->SetTimeout( m_options.ConnectionKeepAliveTimeout );
- info->send( XmlNodeIq( pInfo ) << XATTR( _T("from"), m_ThreadInfo->fullJID ) << XCHILDNS( _T("ping"), _T(JABBER_FEAT_PING)));
+ else if (nSelRes == 0 && m_bSendKeepAlive) {
+ if (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PING) {
+ CJabberIqInfo* pInfo = m_iqManager.AddHandler(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, NULL, 0, -1, this);
+ pInfo->SetTimeout(m_options.ConnectionKeepAliveTimeout);
+ info->send(XmlNodeIq(pInfo) << XATTR(_T("from"), m_ThreadInfo->fullJID) << XCHILDNS(_T("ping"), _T(JABBER_FEAT_PING)));
}
- else info->send( " \t " );
+ else info->send(" \t ");
continue;
} }
- int recvResult = info->recv( buffer + datalen, jabberNetworkBufferSize - datalen);
- Log( "recvResult = %d", recvResult );
- if ( recvResult <= 0 )
+ int recvResult = info->recv(buffer + datalen, jabberNetworkBufferSize - datalen);
+ Log("recvResult = %d", recvResult);
+ if (recvResult <= 0)
break;
datalen += recvResult;
@@ -494,15 +494,15 @@ recvRest: buffer[datalen] = '\0';
TCHAR* str;
- str = mir_utf8decodeW( buffer );
+ str = mir_utf8decodeW(buffer);
int bytesParsed = 0;
- XmlNode root( str, &bytesParsed, tag );
- if ( root && tag )
+ XmlNode root(str, &bytesParsed, tag);
+ if (root && tag)
{
- char *p = strstr( buffer, "stream:stream" );
- if ( p ) p = strchr( p, '>' );
- if ( p )
+ char *p = strstr(buffer, "stream:stream");
+ if (p) p = strchr(p, '>');
+ if (p)
bytesParsed = p - buffer + 1;
else {
root = XmlNode();
@@ -513,65 +513,65 @@ recvRest: }
else {
- if ( root ) str[ bytesParsed ] = 0;
- bytesParsed = ( root ) ? mir_utf8lenW( str ) : 0;
+ if (root) str[ bytesParsed ] = 0;
+ bytesParsed = (root) ? mir_utf8lenW(str) : 0;
mir_free(str);
}
- Log( "bytesParsed = %d", bytesParsed );
- if ( root ) tag = NULL;
+ Log("bytesParsed = %d", bytesParsed);
+ if (root) tag = NULL;
- if ( xmlGetName( root ) == NULL ) {
- for ( int i=0; ; i++ ) {
- HXML n = xmlGetChild( root , i );
- if ( !n )
+ if (xmlGetName(root) == NULL) {
+ for (int i=0; ; i++) {
+ HXML n = xmlGetChild(root , i);
+ if ( !n)
break;
- OnProcessProtocol( n, info );
+ OnProcessProtocol(n, info);
}
}
- else OnProcessProtocol( root, info );
+ else OnProcessProtocol(root, info);
- if ( bytesParsed > 0 ) {
- if ( bytesParsed < datalen )
- memmove( buffer, buffer+bytesParsed, datalen-bytesParsed );
+ if (bytesParsed > 0) {
+ if (bytesParsed < datalen)
+ memmove(buffer, buffer+bytesParsed, datalen-bytesParsed);
datalen -= bytesParsed;
}
- else if ( datalen >= jabberNetworkBufferSize ) {
+ else if (datalen >= jabberNetworkBufferSize) {
//jabberNetworkBufferSize += 65536;
jabberNetworkBufferSize *= 2;
- Log( "Increasing network buffer size to %d", jabberNetworkBufferSize );
- if (( buffer=( char* )mir_realloc( buffer, jabberNetworkBufferSize + 1 )) == NULL ) {
- Log( "Cannot reallocate more network buffer, go offline now" );
+ Log("Increasing network buffer size to %d", jabberNetworkBufferSize);
+ if ((buffer=(char*)mir_realloc(buffer, jabberNetworkBufferSize + 1)) == NULL) {
+ Log("Cannot reallocate more network buffer, go offline now");
break;
} }
- else Log( "Unknown state: bytesParsed=%d, datalen=%d, jabberNetworkBufferSize=%d", bytesParsed, datalen, jabberNetworkBufferSize );
+ else Log("Unknown state: bytesParsed=%d, datalen=%d, jabberNetworkBufferSize=%d", bytesParsed, datalen, jabberNetworkBufferSize);
- if ( m_szXmlStreamToBeInitialized ) {
- xmlStreamInitializeNow( info );
+ if (m_szXmlStreamToBeInitialized) {
+ xmlStreamInitializeNow(info);
tag = _T("stream:stream");
}
- if ( root && datalen )
+ if (root && datalen)
goto recvRest;
}
- if ( info->type == JABBER_SESSION_NORMAL ) {
- m_iqManager.ExpireAll( info );
+ if (info->type == JABBER_SESSION_NORMAL) {
+ m_iqManager.ExpireAll(info);
m_bJabberOnline = FALSE;
m_bJabberConnected = FALSE;
info->zlibUninit();
- EnableMenuItems( FALSE );
+ EnableMenuItems(FALSE);
RebuildInfoFrame();
- if ( m_hwndJabberChangePassword ) {
- //DestroyWindow( hwndJabberChangePassword );
+ if (m_hwndJabberChangePassword) {
+ //DestroyWindow(hwndJabberChangePassword);
// Since this is a different thread, simulate the click on the cancel button instead
- SendMessage( m_hwndJabberChangePassword, WM_COMMAND, MAKEWORD( IDCANCEL, 0 ), 0 );
+ SendMessage(m_hwndJabberChangePassword, WM_COMMAND, MAKEWORD(IDCANCEL, 0), 0);
}
- if ( jabberChatDllPresent )
- CallFunctionAsync( JabberOfflineChatWindows, this );
+ if (jabberChatDllPresent)
+ CallFunctionAsync(JabberOfflineChatWindows, this);
- ListRemoveList( LIST_CHATROOM );
- ListRemoveList( LIST_BOOKMARK );
+ ListRemoveList(LIST_CHATROOM);
+ ListRemoveList(LIST_BOOKMARK);
//UI_SAFE_NOTIFY(m_pDlgJabberJoinGroupchat, WM_JABBER_CHECK_ONLINE);
UI_SAFE_NOTIFY_HWND(m_hwndJabberAddBookmark, WM_JABBER_CHECK_ONLINE);
//UI_SAFE_NOTIFY(m_pDlgBookmarks, WM_JABBER_CHECK_ONLINE);
@@ -580,210 +580,210 @@ recvRest: // Set status to offline
oldStatus = m_iStatus;
m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
// Set all contacts to offline
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- if ( !lstrcmpA(( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 ), m_szModuleName ))
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ if ( !lstrcmpA((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), m_szModuleName))
{
- SetContactOfflineStatus( hContact );
- MenuHideSrmmIcon( hContact );
+ SetContactOfflineStatus(hContact);
+ MenuHideSrmmIcon(hContact);
}
hContact = db_find_next(hContact);
}
- mir_free( m_szJabberJID );
+ mir_free(m_szJabberJID);
m_szJabberJID = NULL;
m_tmJabberLoggedInTime = 0;
ListWipe();
WindowNotify(WM_JABBER_REFRESH_VCARD);
}
- else if ( info->type==JABBER_SESSION_REGISTER && !info->reg_done )
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )TranslateT( "Error: Connection lost" ));
+ else if (info->type==JABBER_SESSION_REGISTER && !info->reg_done)
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Error: Connection lost"));
}
- else if ( info->type == JABBER_SESSION_NORMAL ) {
+ else if (info->type == JABBER_SESSION_NORMAL) {
oldStatus = m_iStatus;
m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
- Log( "Thread ended: type=%d server='%s'", info->type, info->server );
+ Log("Thread ended: type=%d server='%s'", info->type, info->server);
- if ( info->type==JABBER_SESSION_NORMAL && m_ThreadInfo==info ) {
- if ( m_szStreamId ) mir_free( m_szStreamId );
+ if (info->type==JABBER_SESSION_NORMAL && m_ThreadInfo==info) {
+ if (m_szStreamId) mir_free(m_szStreamId);
m_szStreamId = NULL;
m_ThreadInfo = NULL;
}
info->close();
- mir_free( buffer );
- Log( "Exiting ServerThread" );
+ mir_free(buffer);
+ Log("Exiting ServerThread");
goto LBL_Exit;
}
-void CJabberProto::PerformRegistration( ThreadData* info )
+void CJabberProto::PerformRegistration(ThreadData* info)
{
iqIdRegGetReg = SerialNext();
- info->send( XmlNodeIq( _T("get"), iqIdRegGetReg, NULL) << XQUERY( _T(JABBER_FEAT_REGISTER )));
+ info->send(XmlNodeIq(_T("get"), iqIdRegGetReg, NULL) << XQUERY(_T(JABBER_FEAT_REGISTER)));
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 50, ( LPARAM )TranslateT( "Requesting registration instruction..." ));
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 50, (LPARAM)TranslateT("Requesting registration instruction..."));
}
-void CJabberProto::PerformIqAuth( ThreadData* info )
+void CJabberProto::PerformIqAuth(ThreadData* info)
{
- if ( info->type == JABBER_SESSION_NORMAL ) {
+ if (info->type == JABBER_SESSION_NORMAL) {
int iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetAuth );
- info->send( XmlNodeIq( _T("get"), iqId ) << XQUERY( _T("jabber:iq:auth" )) << XCHILD( _T("username"), info->username ));
+ IqAdd(iqId, IQ_PROC_NONE, &CJabberProto::OnIqResultGetAuth);
+ info->send(XmlNodeIq(_T("get"), iqId) << XQUERY(_T("jabber:iq:auth")) << XCHILD(_T("username"), info->username));
}
- else if ( info->type == JABBER_SESSION_REGISTER )
- PerformRegistration( info );
+ else if (info->type == JABBER_SESSION_REGISTER)
+ PerformRegistration(info);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::OnProcessStreamOpening( HXML node, ThreadData *info )
+void CJabberProto::OnProcessStreamOpening(HXML node, ThreadData *info)
{
- if ( lstrcmp( xmlGetName( node ), _T("stream:stream")))
+ if (lstrcmp(xmlGetName(node), _T("stream:stream")))
return;
- if ( info->type == JABBER_SESSION_NORMAL ) {
- const TCHAR* sid = xmlGetAttrValue( node, _T("id"));
- if ( sid != NULL ) {
- char* pszSid = mir_t2a( sid );
- replaceStr( info->proto->m_szStreamId, pszSid );
- mir_free( pszSid );
+ if (info->type == JABBER_SESSION_NORMAL) {
+ const TCHAR *sid = xmlGetAttrValue(node, _T("id"));
+ if (sid != NULL) {
+ char* pszSid = mir_t2a(sid);
+ replaceStr(info->proto->m_szStreamId, pszSid);
+ mir_free(pszSid);
} }
// old server - disable SASL then
- if ( xmlGetAttrValue( node, _T("version")) == NULL )
+ if (xmlGetAttrValue(node, _T("version")) == NULL)
info->proto->m_options.Disable3920auth = TRUE;
- if ( info->proto->m_options.Disable3920auth )
- info->proto->PerformIqAuth( info );
+ if (info->proto->m_options.Disable3920auth)
+ info->proto->PerformIqAuth(info);
}
-void CJabberProto::PerformAuthentication( ThreadData* info )
+void CJabberProto::PerformAuthentication(ThreadData* info)
{
TJabberAuth* auth = NULL;
char* request = NULL;
- if ( info->auth ) {
+ if (info->auth) {
delete info->auth;
info->auth = NULL;
}
- if ( m_AuthMechs.isSpnegoAvailable ) {
+ if (m_AuthMechs.isSpnegoAvailable) {
m_AuthMechs.isSpnegoAvailable = false;
- auth = new TNtlmAuth( info, "GSS-SPNEGO" );
+ auth = new TNtlmAuth(info, "GSS-SPNEGO");
if ( !auth->isValid()) {
delete auth;
auth = NULL;
} }
- if ( auth == NULL && m_AuthMechs.isNtlmAvailable ) {
+ if (auth == NULL && m_AuthMechs.isNtlmAvailable) {
m_AuthMechs.isNtlmAvailable = false;
- auth = new TNtlmAuth( info, "NTLM" );
+ auth = new TNtlmAuth(info, "NTLM");
if ( !auth->isValid()) {
delete auth;
auth = NULL;
} }
- if ( auth == NULL && m_AuthMechs.isKerberosAvailable ) {
+ if (auth == NULL && m_AuthMechs.isKerberosAvailable) {
m_AuthMechs.isKerberosAvailable = false;
- auth = new TNtlmAuth( info, "GSSAPI", m_AuthMechs.m_gssapiHostName );
+ auth = new TNtlmAuth(info, "GSSAPI", m_AuthMechs.m_gssapiHostName);
if ( !auth->isValid()) {
delete auth;
auth = NULL;
} else {
request = auth->getInitialRequest();
- if ( !request ) {
+ if ( !request) {
delete auth;
auth = NULL;
} } }
- if ( auth == NULL && m_AuthMechs.isScramAvailable ) {
+ if (auth == NULL && m_AuthMechs.isScramAvailable) {
m_AuthMechs.isScramAvailable = false;
- auth = new TScramAuth( info );
+ auth = new TScramAuth(info);
}
- if ( auth == NULL && m_AuthMechs.isMd5Available ) {
+ if (auth == NULL && m_AuthMechs.isMd5Available) {
m_AuthMechs.isMd5Available = false;
- auth = new TMD5Auth( info );
+ auth = new TMD5Auth(info);
}
- if ( auth == NULL && m_AuthMechs.isPlainAvailable ) {
+ if (auth == NULL && m_AuthMechs.isPlainAvailable) {
m_AuthMechs.isPlainAvailable = false;
- auth = new TPlainAuth( info, false );
+ auth = new TPlainAuth(info, false);
}
- if ( auth == NULL && m_AuthMechs.isPlainOldAvailable ) {
+ if (auth == NULL && m_AuthMechs.isPlainOldAvailable) {
m_AuthMechs.isPlainOldAvailable = false;
- auth = new TPlainAuth( info, true );
+ auth = new TPlainAuth(info, true);
}
- if ( auth == NULL ) {
- if ( m_AuthMechs.isAuthAvailable ) { // no known mechanisms but iq_auth is available
+ if (auth == NULL) {
+ if (m_AuthMechs.isAuthAvailable) { // no known mechanisms but iq_auth is available
m_AuthMechs.isAuthAvailable = false;
- PerformIqAuth( info );
+ PerformIqAuth(info);
return;
}
TCHAR text[1024];
- mir_sntprintf( text, SIZEOF( text ), _T("%s %s@")_T(TCHAR_STR_PARAM)_T("."), TranslateT( "Authentication failed for" ), info->username, info->server );
- MsgPopup( NULL, text, TranslateT( "Jabber Authentication" ));
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD );
- info->send( "</stream:stream>" );
+ mir_sntprintf(text, SIZEOF(text), _T("%s %s@")_T(TCHAR_STR_PARAM)_T("."), TranslateT("Authentication failed for"), info->username, info->server);
+ MsgPopup(NULL, text, TranslateT("Jabber Authentication"));
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
+ info->send("</stream:stream>");
m_ThreadInfo = NULL;
return;
}
info->auth = auth;
- if ( !request ) request = auth->getInitialRequest();
- info->send( XmlNode( _T("auth"), _A2T(request)) << XATTR( _T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-sasl"))
- << XATTR( _T("mechanism"), _A2T(auth->getName())));
- mir_free( request );
+ if ( !request) request = auth->getInitialRequest();
+ info->send(XmlNode(_T("auth"), _A2T(request)) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-sasl"))
+ << XATTR(_T("mechanism"), _A2T(auth->getName())));
+ mir_free(request);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::OnProcessFeatures( HXML node, ThreadData* info )
+void CJabberProto::OnProcessFeatures(HXML node, ThreadData* info)
{
bool isRegisterAvailable = false;
bool areMechanismsDefined = false;
- for ( int i=0; ;i++ ) {
- HXML n = xmlGetChild( node ,i);
- if ( !n )
+ for (int i=0; ;i++) {
+ HXML n = xmlGetChild(node ,i);
+ if ( !n)
break;
- if ( !_tcscmp( xmlGetName( n ), _T("starttls"))) {
- if ( !info->useSSL && m_options.UseTLS ) {
- Log( "Requesting TLS" );
- info->send( XmlNode( xmlGetName( n )) << XATTR( _T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-tls" )));
+ if ( !_tcscmp(xmlGetName(n), _T("starttls"))) {
+ if ( !info->useSSL && m_options.UseTLS) {
+ Log("Requesting TLS");
+ info->send(XmlNode(xmlGetName(n)) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-tls")));
return;
} }
- if ( !_tcscmp( xmlGetName( n ), _T("compression")) && m_options.EnableZlib == TRUE ) {
+ if ( !_tcscmp(xmlGetName(n), _T("compression")) && m_options.EnableZlib == TRUE) {
Log("Server compression available");
- for ( int k=0; ; k++ ) {
- HXML c = xmlGetChild( n ,k);
- if ( !c )
+ for (int k=0; ; k++) {
+ HXML c = xmlGetChild(n ,k);
+ if ( !c)
break;
- if ( !_tcscmp( xmlGetName( c ), _T("method"))) {
- if ( !_tcscmp( xmlGetText( c ), _T("zlib")) && info->zlibInit() == TRUE ) {
+ if ( !_tcscmp(xmlGetName(c), _T("method"))) {
+ if ( !_tcscmp(xmlGetText(c), _T("zlib")) && info->zlibInit() == TRUE) {
Log("Requesting Zlib compression");
- info->send( XmlNode( _T("compress")) << XATTR( _T("xmlns"), _T("http://jabber.org/protocol/compress"))
- << XCHILD( _T("method"), _T("zlib")));
+ info->send(XmlNode(_T("compress")) << XATTR(_T("xmlns"), _T("http://jabber.org/protocol/compress"))
+ << XCHILD(_T("method"), _T("zlib")));
return;
} } } }
- if ( !_tcscmp( xmlGetName( n ), _T("mechanisms"))) {
+ if ( !_tcscmp(xmlGetName(n), _T("mechanisms"))) {
m_AuthMechs.isPlainAvailable = false;
m_AuthMechs.isPlainOldAvailable = false;
m_AuthMechs.isMd5Available = false;
@@ -791,73 +791,73 @@ void CJabberProto::OnProcessFeatures( HXML node, ThreadData* info ) m_AuthMechs.isNtlmAvailable = false;
m_AuthMechs.isSpnegoAvailable = false;
m_AuthMechs.isKerberosAvailable = false;
- mir_free( m_AuthMechs.m_gssapiHostName ); m_AuthMechs.m_gssapiHostName = NULL;
+ mir_free(m_AuthMechs.m_gssapiHostName); m_AuthMechs.m_gssapiHostName = NULL;
areMechanismsDefined = true;
//JabberLog("%d mechanisms\n",n->numChild);
- for ( int k=0; ; k++ ) {
- HXML c = xmlGetChild( n ,k);
- if ( !c )
+ for (int k=0; ; k++) {
+ HXML c = xmlGetChild(n ,k);
+ if ( !c)
break;
- if ( !_tcscmp( xmlGetName( c ), _T("mechanism"))) {
- //JabberLog("Mechanism: %s",xmlGetText( c ));
- if ( !_tcscmp( xmlGetText( c ), _T("PLAIN"))) m_AuthMechs.isPlainOldAvailable = m_AuthMechs.isPlainAvailable = true;
- else if ( !_tcscmp( xmlGetText( c ), _T("DIGEST-MD5"))) m_AuthMechs.isMd5Available = true;
- else if ( !_tcscmp( xmlGetText( c ), _T("SCRAM-SHA-1"))) m_AuthMechs.isScramAvailable = true;
- else if ( !_tcscmp( xmlGetText( c ), _T("NTLM"))) m_AuthMechs.isNtlmAvailable = true;
- else if ( !_tcscmp( xmlGetText( c ), _T("GSS-SPNEGO"))) m_AuthMechs.isSpnegoAvailable = true;
- else if ( !_tcscmp( xmlGetText( c ), _T("GSSAPI"))) m_AuthMechs.isKerberosAvailable = true;
+ if ( !_tcscmp(xmlGetName(c), _T("mechanism"))) {
+ //JabberLog("Mechanism: %s",xmlGetText(c));
+ if ( !_tcscmp(xmlGetText(c), _T("PLAIN"))) m_AuthMechs.isPlainOldAvailable = m_AuthMechs.isPlainAvailable = true;
+ else if ( !_tcscmp(xmlGetText(c), _T("DIGEST-MD5"))) m_AuthMechs.isMd5Available = true;
+ else if ( !_tcscmp(xmlGetText(c), _T("SCRAM-SHA-1"))) m_AuthMechs.isScramAvailable = true;
+ else if ( !_tcscmp(xmlGetText(c), _T("NTLM"))) m_AuthMechs.isNtlmAvailable = true;
+ else if ( !_tcscmp(xmlGetText(c), _T("GSS-SPNEGO"))) m_AuthMechs.isSpnegoAvailable = true;
+ else if ( !_tcscmp(xmlGetText(c), _T("GSSAPI"))) m_AuthMechs.isKerberosAvailable = true;
}
- else if ( !_tcscmp( xmlGetName( c ), _T("hostname"))) {
- const TCHAR *mech = xmlGetAttrValue( c, _T("mechanism"));
- if ( mech && _tcsicmp( mech, _T("GSSAPI")) == 0 ) {
- m_AuthMechs.m_gssapiHostName = mir_tstrdup( xmlGetText( c ));
+ else if ( !_tcscmp(xmlGetName(c), _T("hostname"))) {
+ const TCHAR *mech = xmlGetAttrValue(c, _T("mechanism"));
+ if (mech && _tcsicmp(mech, _T("GSSAPI")) == 0) {
+ m_AuthMechs.m_gssapiHostName = mir_tstrdup(xmlGetText(c));
}
}
} }
- else if ( !_tcscmp( xmlGetName( n ), _T("register" ))) isRegisterAvailable = true;
- else if ( !_tcscmp( xmlGetName( n ), _T("auth" ))) m_AuthMechs.isAuthAvailable = true;
- else if ( !_tcscmp( xmlGetName( n ), _T("session" ))) m_AuthMechs.isSessionAvailable = true;
+ else if ( !_tcscmp(xmlGetName(n), _T("register"))) isRegisterAvailable = true;
+ else if ( !_tcscmp(xmlGetName(n), _T("auth" ))) m_AuthMechs.isAuthAvailable = true;
+ else if ( !_tcscmp(xmlGetName(n), _T("session" ))) m_AuthMechs.isSessionAvailable = true;
}
- if ( areMechanismsDefined ) {
- if ( info->type == JABBER_SESSION_NORMAL )
- PerformAuthentication( info );
- else if ( info->type == JABBER_SESSION_REGISTER )
- PerformRegistration( info );
+ if (areMechanismsDefined) {
+ if (info->type == JABBER_SESSION_NORMAL)
+ PerformAuthentication(info);
+ else if (info->type == JABBER_SESSION_REGISTER)
+ PerformRegistration(info);
else
- info->send( "</stream:stream>" );
+ info->send("</stream:stream>");
return;
}
// mechanisms are not defined.
- if ( info->auth ) { //We are already logged-in
+ if (info->auth) { //We are already logged-in
info->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIqResultBind, JABBER_IQ_TYPE_SET ))
- << XCHILDNS( _T("bind"), _T("urn:ietf:params:xml:ns:xmpp-bind" ))
- << XCHILD( _T("resource"), info->resource ));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIqResultBind, JABBER_IQ_TYPE_SET))
+ << XCHILDNS(_T("bind"), _T("urn:ietf:params:xml:ns:xmpp-bind"))
+ << XCHILD(_T("resource"), info->resource));
- if ( m_AuthMechs.isSessionAvailable )
+ if (m_AuthMechs.isSessionAvailable)
info->bIsSessionAvailable = TRUE;
return;
}
//mechanisms not available and we are not logged in
- PerformIqAuth( info );
+ PerformIqAuth(info);
}
-void CJabberProto::OnProcessFailure( HXML node, ThreadData* info )
+void CJabberProto::OnProcessFailure(HXML node, ThreadData* info)
{
- const TCHAR* type;
+ const TCHAR *type;
//failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"
- if (( type = xmlGetAttrValue( node, _T("xmlns"))) == NULL ) return;
- if ( !_tcscmp( type, _T("urn:ietf:params:xml:ns:xmpp-sasl"))) {
- PerformAuthentication( info );
+ if ((type = xmlGetAttrValue(node, _T("xmlns"))) == NULL) return;
+ if ( !_tcscmp(type, _T("urn:ietf:params:xml:ns:xmpp-sasl"))) {
+ PerformAuthentication(info);
} }
-void CJabberProto::OnProcessError( HXML node, ThreadData* info )
+void CJabberProto::OnProcessError(HXML node, ThreadData* info)
{
TCHAR *buff;
int i;
@@ -865,120 +865,120 @@ void CJabberProto::OnProcessError( HXML node, ThreadData* info ) bool skipMsg = false;
//failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"
- if ( !xmlGetChild( node ,0))
+ if ( !xmlGetChild(node ,0))
return;
buff = (TCHAR *)mir_alloc(1024*sizeof(TCHAR));
pos=0;
- for ( i=0; ; i++ ) {
- HXML n = xmlGetChild( node , i );
- if ( !n )
+ for (i=0; ; i++) {
+ HXML n = xmlGetChild(node , i);
+ if ( !n)
break;
- const TCHAR *name = xmlGetName( n );
- const TCHAR *desc = xmlGetText( n );
- if ( desc )
- pos += mir_sntprintf( buff+pos, 1024-pos, _T("%s: %s\r\n"), name, desc );
+ const TCHAR *name = xmlGetName(n);
+ const TCHAR *desc = xmlGetText(n);
+ if (desc)
+ pos += mir_sntprintf(buff+pos, 1024-pos, _T("%s: %s\r\n"), name, desc);
else
- pos += mir_sntprintf( buff+pos, 1024-pos, _T("%s\r\n"), name );
+ pos += mir_sntprintf(buff+pos, 1024-pos, _T("%s\r\n"), name);
- if ( !_tcscmp( name, _T("conflict")))
- JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION);
- else if ( !_tcscmp( name, _T("see-other-host"))) {
+ if ( !_tcscmp(name, _T("conflict")))
+ JSendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION);
+ else if ( !_tcscmp(name, _T("see-other-host"))) {
skipMsg = true;
}
}
- if (!skipMsg) MsgPopup( NULL, buff, TranslateT( "Jabber Error" ));
+ if ( !skipMsg) MsgPopup(NULL, buff, TranslateT("Jabber Error"));
mir_free(buff);
- info->send( "</stream:stream>" );
+ info->send("</stream:stream>");
}
-void CJabberProto::OnProcessSuccess( HXML node, ThreadData* info )
+void CJabberProto::OnProcessSuccess(HXML node, ThreadData* info)
{
- const TCHAR* type;
+ const TCHAR *type;
// int iqId;
// RECVED: <success ...
// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
- if (( type = xmlGetAttrValue( node, _T("xmlns"))) == NULL )
+ if ((type = xmlGetAttrValue(node, _T("xmlns"))) == NULL)
return;
- if ( !_tcscmp( type, _T("urn:ietf:params:xml:ns:xmpp-sasl"))) {
+ if ( !_tcscmp(type, _T("urn:ietf:params:xml:ns:xmpp-sasl"))) {
DBVARIANT dbv;
- if ( !info->auth->validateLogin( xmlGetText( node ))) {
- info->send( "</stream:stream>" );
+ if ( !info->auth->validateLogin(xmlGetText(node))) {
+ info->send("</stream:stream>");
return;
}
- Log( "Success: Logged-in." );
- if ( DBGetContactSettingString( NULL, m_szModuleName, "Nick", &dbv ))
- JSetStringT( NULL, "Nick", info->username );
+ Log("Success: Logged-in.");
+ if (DBGetContactSettingString(NULL, m_szModuleName, "Nick", &dbv))
+ JSetStringT(NULL, "Nick", info->username);
else
- JFreeVariant( &dbv );
- xmlStreamInitialize( "after successful sasl" );
+ db_free(&dbv);
+ xmlStreamInitialize("after successful sasl");
}
- else Log( "Success: unknown action "TCHAR_STR_PARAM".",type);
+ else Log("Success: unknown action "TCHAR_STR_PARAM".",type);
}
-void CJabberProto::OnProcessChallenge( HXML node, ThreadData* info )
+void CJabberProto::OnProcessChallenge(HXML node, ThreadData* info)
{
- if ( info->auth == NULL ) {
- Log( "No previous auth have been made, exiting..." );
+ if (info->auth == NULL) {
+ Log("No previous auth have been made, exiting...");
return;
}
- if ( lstrcmp( xmlGetAttrValue( node, _T("xmlns")), _T("urn:ietf:params:xml:ns:xmpp-sasl")))
+ if (lstrcmp(xmlGetAttrValue(node, _T("xmlns")), _T("urn:ietf:params:xml:ns:xmpp-sasl")))
return;
- char* challenge = info->auth->getChallenge( xmlGetText( node ));
- info->send( XmlNode( _T("response"), _A2T(challenge)) << XATTR( _T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-sasl")));
- mir_free( challenge );
+ char* challenge = info->auth->getChallenge(xmlGetText(node));
+ info->send(XmlNode(_T("response"), _A2T(challenge)) << XATTR(_T("xmlns"), _T("urn:ietf:params:xml:ns:xmpp-sasl")));
+ mir_free(challenge);
}
-void CJabberProto::OnProcessProtocol( HXML node, ThreadData* info )
+void CJabberProto::OnProcessProtocol(HXML node, ThreadData* info)
{
OnConsoleProcessXml(node, JCPF_IN);
- if ( !lstrcmp( xmlGetName( node ), _T("proceed")))
- OnProcessProceed( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("compressed")))
- OnProcessCompressed( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("stream:features")))
- OnProcessFeatures( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("stream:stream")))
- OnProcessStreamOpening( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("success")))
- OnProcessSuccess( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("failure")))
- OnProcessFailure( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("stream:error")))
- OnProcessError( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("challenge")))
- OnProcessChallenge( node, info );
- else if ( info->type == JABBER_SESSION_NORMAL ) {
- if ( !lstrcmp( xmlGetName( node ), _T("message")))
- OnProcessMessage( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("presence")))
- OnProcessPresence( node, info );
- else if ( !lstrcmp( xmlGetName( node ), _T("iq")))
- OnProcessIq( node );
+ if ( !lstrcmp(xmlGetName(node), _T("proceed")))
+ OnProcessProceed(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("compressed")))
+ OnProcessCompressed(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("stream:features")))
+ OnProcessFeatures(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("stream:stream")))
+ OnProcessStreamOpening(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("success")))
+ OnProcessSuccess(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("failure")))
+ OnProcessFailure(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("stream:error")))
+ OnProcessError(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("challenge")))
+ OnProcessChallenge(node, info);
+ else if (info->type == JABBER_SESSION_NORMAL) {
+ if ( !lstrcmp(xmlGetName(node), _T("message")))
+ OnProcessMessage(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("presence")))
+ OnProcessPresence(node, info);
+ else if ( !lstrcmp(xmlGetName(node), _T("iq")))
+ OnProcessIq(node);
else
- Log( "Invalid top-level tag ( only <message/> <presence/> and <iq/> allowed )" );
+ Log("Invalid top-level tag (only <message/> <presence/> and <iq/> allowed)");
}
- else if ( info->type == JABBER_SESSION_REGISTER ) {
- if ( !lstrcmp( xmlGetName( node ), _T("iq")))
- OnProcessRegIq( node, info );
+ else if (info->type == JABBER_SESSION_REGISTER) {
+ if ( !lstrcmp(xmlGetName(node), _T("iq")))
+ OnProcessRegIq(node, info);
else
- Log( "Invalid top-level tag ( only <iq/> allowed )" );
+ Log("Invalid top-level tag (only <iq/> allowed)");
} }
-void CJabberProto::OnProcessProceed( HXML node, ThreadData* info )
+void CJabberProto::OnProcessProceed(HXML node, ThreadData* info)
{
- const TCHAR* type;
- if (( type = xmlGetAttrValue( node, _T("xmlns"))) != NULL && !lstrcmp( type, _T("error")))
+ const TCHAR *type;
+ if ((type = xmlGetAttrValue(node, _T("xmlns"))) != NULL && !lstrcmp(type, _T("error")))
return;
- if ( !lstrcmp( type, _T("urn:ietf:params:xml:ns:xmpp-tls" ))) {
+ if ( !lstrcmp(type, _T("urn:ietf:params:xml:ns:xmpp-tls"))) {
Log("Starting TLS...");
char* gtlk = strstr(info->manualHost, "google.com");
@@ -988,271 +988,271 @@ void CJabberProto::OnProcessProceed( HXML node, ThreadData* info ) NETLIBSSL ssl = {0};
ssl.cbSize = sizeof(ssl);
ssl.host = isHosted ? info->manualHost : info->server;
- if (!CallService( MS_NETLIB_STARTSSL, ( WPARAM )info->s, ( LPARAM )&ssl)) {
- Log( "SSL initialization failed" );
- info->send( "</stream:stream>" );
+ if ( !CallService(MS_NETLIB_STARTSSL, (WPARAM)info->s, (LPARAM)&ssl)) {
+ Log("SSL initialization failed");
+ info->send("</stream:stream>");
info->shutdown();
}
else
- xmlStreamInitialize( "after successful StartTLS" );
+ xmlStreamInitialize("after successful StartTLS");
} }
-void CJabberProto::OnProcessCompressed( HXML node, ThreadData* info )
+void CJabberProto::OnProcessCompressed(HXML node, ThreadData* info)
{
- const TCHAR* type;
+ const TCHAR *type;
- Log( "Compression confirmed" );
+ Log("Compression confirmed");
- if (( type = xmlGetAttrValue( node, _T("xmlns"))) != NULL && !lstrcmp( type, _T( "error" )))
+ if ((type = xmlGetAttrValue(node, _T("xmlns"))) != NULL && !lstrcmp(type, _T("error")))
return;
- if ( lstrcmp( type, _T( "http://jabber.org/protocol/compress" )))
+ if (lstrcmp(type, _T("http://jabber.org/protocol/compress")))
return;
- Log( "Starting Zlib stream compression..." );
+ Log("Starting Zlib stream compression...");
info->useZlib = TRUE;
- info->zRecvData = ( char* )mir_alloc( ZLIB_CHUNK_SIZE );
+ info->zRecvData = (char*)mir_alloc(ZLIB_CHUNK_SIZE);
- xmlStreamInitialize( "after successful Zlib init" );
+ xmlStreamInitialize("after successful Zlib init");
}
-void CJabberProto::OnProcessPubsubEvent( HXML node )
+void CJabberProto::OnProcessPubsubEvent(HXML node)
{
- const TCHAR* from = xmlGetAttrValue( node, _T("from"));
- if ( !from )
+ const TCHAR *from = xmlGetAttrValue(node, _T("from"));
+ if ( !from)
return;
- HXML eventNode = xmlGetChildByTag( node, "event", "xmlns", _T(JABBER_FEAT_PUBSUB_EVENT));
- if ( !eventNode )
+ HXML eventNode = xmlGetChildByTag(node, "event", "xmlns", _T(JABBER_FEAT_PUBSUB_EVENT));
+ if ( !eventNode)
return;
m_pepServices.ProcessEvent(from, eventNode);
- HANDLE hContact = HContactFromJID( from );
- if ( !hContact )
+ HANDLE hContact = HContactFromJID(from);
+ if ( !hContact)
return;
HXML itemsNode;
- if ( m_options.EnableUserTune && (itemsNode = xmlGetChildByTag( eventNode, "items", "node", _T(JABBER_FEAT_USER_TUNE)))) {
+ if (m_options.EnableUserTune && (itemsNode = xmlGetChildByTag(eventNode, "items", "node", _T(JABBER_FEAT_USER_TUNE)))) {
// node retract?
- if ( xmlGetChild( itemsNode , "retract" )) {
- SetContactTune( hContact, NULL, NULL, NULL, NULL, NULL );
+ if (xmlGetChild(itemsNode , "retract")) {
+ SetContactTune(hContact, NULL, NULL, NULL, NULL, NULL);
return;
}
- HXML tuneNode = XPath( itemsNode, _T("item/tune[@xmlns='") _T(JABBER_FEAT_USER_TUNE) _T("']"));
- if ( !tuneNode )
+ HXML tuneNode = XPath(itemsNode, _T("item/tune[@xmlns='") _T(JABBER_FEAT_USER_TUNE) _T("']"));
+ if ( !tuneNode)
return;
- const TCHAR *szArtist = XPathT( tuneNode, "artist" );
- const TCHAR *szLength = XPathT( tuneNode, "length" );
- const TCHAR *szSource = XPathT( tuneNode, "source" );
- const TCHAR *szTitle = XPathT( tuneNode, "title" );
- const TCHAR *szTrack = XPathT( tuneNode, "track" );
+ const TCHAR *szArtist = XPathT(tuneNode, "artist");
+ const TCHAR *szLength = XPathT(tuneNode, "length");
+ const TCHAR *szSource = XPathT(tuneNode, "source");
+ const TCHAR *szTitle = XPathT(tuneNode, "title");
+ const TCHAR *szTrack = XPathT(tuneNode, "track");
TCHAR szLengthInTime[32];
szLengthInTime[0] = _T('\0');
- if ( szLength ) {
- int nLength = _ttoi( szLength );
- mir_sntprintf( szLengthInTime, SIZEOF( szLengthInTime ), _T("%02d:%02d:%02d"),
- nLength / 3600, (nLength / 60) % 60, nLength % 60 );
+ if (szLength) {
+ int nLength = _ttoi(szLength);
+ mir_sntprintf(szLengthInTime, SIZEOF(szLengthInTime), _T("%02d:%02d:%02d"),
+ nLength / 3600, (nLength / 60) % 60, nLength % 60);
}
- SetContactTune( hContact, szArtist, szLength ? szLengthInTime : NULL, szSource, szTitle, szTrack );
+ SetContactTune(hContact, szArtist, szLength ? szLengthInTime : NULL, szSource, szTitle, szTrack);
}
}
// returns 0, if error or no events
-DWORD JabberGetLastContactMessageTime( HANDLE hContact )
+DWORD JabberGetLastContactMessageTime(HANDLE hContact)
{
// TODO: time cache can improve performance
- HANDLE hDbEvent = (HANDLE)CallService( MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0 );
- if ( !hDbEvent )
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ if ( !hDbEvent)
return 0;
DWORD dwTime = 0;
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0 );
- if ( dbei.cbBlob != -1 ) {
- dbei.pBlob = (PBYTE)mir_alloc( dbei.cbBlob + 1 );
- int nGetTextResult = CallService( MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei );
- if ( !nGetTextResult )
+ dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ if (dbei.cbBlob != -1) {
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
+ int nGetTextResult = CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
+ if ( !nGetTextResult)
dwTime = dbei.timestamp;
- mir_free( dbei.pBlob );
+ mir_free(dbei.pBlob);
}
return dwTime;
}
-HANDLE CJabberProto::CreateTemporaryContact( const TCHAR *szJid, JABBER_LIST_ITEM* chatItem )
+HANDLE CJabberProto::CreateTemporaryContact(const TCHAR *szJid, JABBER_LIST_ITEM* chatItem)
{
HANDLE hContact = NULL;
- if ( chatItem ) {
- const TCHAR* p = _tcschr( szJid, '/' );
- if ( p != NULL && p[1] != '\0' )
+ if (chatItem) {
+ const TCHAR *p = _tcschr(szJid, '/');
+ if (p != NULL && p[1] != '\0')
p++;
else
p = szJid;
- hContact = DBCreateContact( szJid, p, TRUE, FALSE );
+ hContact = DBCreateContact(szJid, p, TRUE, FALSE);
- for ( int i=0; i < chatItem->resourceCount; i++ ) {
- if ( !lstrcmp( chatItem->resource[i].resourceName, p )) {
- JSetWord( hContact, "Status", chatItem->resource[i].status );
+ for (int i=0; i < chatItem->resourceCount; i++) {
+ if ( !lstrcmp(chatItem->resource[i].resourceName, p)) {
+ JSetWord(hContact, "Status", chatItem->resource[i].status);
break;
}
}
}
else {
- TCHAR *nick = JabberNickFromJID( szJid );
- hContact = DBCreateContact( szJid, nick, TRUE, TRUE );
- mir_free( nick );
+ TCHAR *nick = JabberNickFromJID(szJid);
+ hContact = DBCreateContact(szJid, nick, TRUE, TRUE);
+ mir_free(nick);
}
return hContact;
}
-void CJabberProto::OnProcessMessage( HXML node, ThreadData* info )
+void CJabberProto::OnProcessMessage(HXML node, ThreadData* info)
{
HXML subjectNode, xNode, inviteNode, idNode, n;
LPCTSTR from, type, idStr, fromResource;
HANDLE hContact;
- if ( !xmlGetName( node ) || _tcscmp( xmlGetName( node ), _T("message")))
+ if ( !xmlGetName(node) || _tcscmp(xmlGetName(node), _T("message")))
return;
- type = xmlGetAttrValue( node, _T("type"));
- if (( from = xmlGetAttrValue( node, _T("from"))) == NULL )
+ type = xmlGetAttrValue(node, _T("type"));
+ if ((from = xmlGetAttrValue(node, _T("from"))) == NULL)
return;
- idStr = xmlGetAttrValue( node, _T("id"));
- JABBER_RESOURCE_STATUS *resourceStatus = ResourceInfoFromJID( from );
+ idStr = xmlGetAttrValue(node, _T("id"));
+ JABBER_RESOURCE_STATUS *resourceStatus = ResourceInfoFromJID(from);
// Message receipts delivery request. Reply here, before a call to HandleMessagePermanent() to make sure message receipts are handled for external plugins too.
- if ( ( !type || _tcsicmp( type, _T("error"))) && xmlGetChildByTag( node, "request", "xmlns", _T( JABBER_FEAT_MESSAGE_RECEIPTS ))) {
+ if ((!type || _tcsicmp(type, _T("error"))) && xmlGetChildByTag(node, "request", "xmlns", _T(JABBER_FEAT_MESSAGE_RECEIPTS))) {
info->send(
- XmlNode( _T("message")) << XATTR( _T("to"), from ) << XATTR( _T("id"), idStr )
- << XCHILDNS( _T("received"), _T(JABBER_FEAT_MESSAGE_RECEIPTS)) << XATTR( _T("id"), idStr ));
+ XmlNode(_T("message")) << XATTR(_T("to"), from) << XATTR(_T("id"), idStr)
+ << XCHILDNS(_T("received"), _T(JABBER_FEAT_MESSAGE_RECEIPTS)) << XATTR(_T("id"), idStr));
- if ( resourceStatus )
+ if (resourceStatus)
resourceStatus->jcbManualDiscoveredCaps |= JABBER_CAPS_MESSAGE_RECEIPTS;
}
- if ( m_messageManager.HandleMessagePermanent( node, info ))
+ if (m_messageManager.HandleMessagePermanent(node, info))
return;
- hContact = HContactFromJID( from );
- JABBER_LIST_ITEM *chatItem = ListGetItemPtr( LIST_CHATROOM, from );
- if ( chatItem ) {
- HXML xCaptcha = xmlGetChild( node, "captcha" );
- if ( xCaptcha )
- if ( ProcessCaptcha( xCaptcha, node, info ))
+ hContact = HContactFromJID(from);
+ JABBER_LIST_ITEM *chatItem = ListGetItemPtr(LIST_CHATROOM, from);
+ if (chatItem) {
+ HXML xCaptcha = xmlGetChild(node, "captcha");
+ if (xCaptcha)
+ if (ProcessCaptcha(xCaptcha, node, info))
return;
}
- const TCHAR* szMessage = NULL;
- HXML bodyNode = xmlGetChildByTag( node , "body", "xml:lang", m_tszSelectedLang );
- if ( bodyNode == NULL )
- bodyNode = xmlGetChild( node , "body" );
- if ( bodyNode != NULL && xmlGetText( bodyNode ))
- szMessage = xmlGetText( bodyNode );
- if (( subjectNode = xmlGetChild( node , "subject" )) && xmlGetText( subjectNode ) && xmlGetText( subjectNode )[0] != _T('\0')) {
- size_t cbLen = (szMessage ? _tcslen( szMessage ) : 0) + _tcslen( xmlGetText( subjectNode )) + 128;
- TCHAR* szTmp = ( TCHAR * )alloca( sizeof(TCHAR) * cbLen );
+ const TCHAR *szMessage = NULL;
+ HXML bodyNode = xmlGetChildByTag(node , "body", "xml:lang", m_tszSelectedLang);
+ if (bodyNode == NULL)
+ bodyNode = xmlGetChild(node , "body");
+ if (bodyNode != NULL && xmlGetText(bodyNode))
+ szMessage = xmlGetText(bodyNode);
+ if ((subjectNode = xmlGetChild(node , "subject")) && xmlGetText(subjectNode) && xmlGetText(subjectNode)[0] != _T('\0')) {
+ size_t cbLen = (szMessage ? _tcslen(szMessage) : 0) + _tcslen(xmlGetText(subjectNode)) + 128;
+ TCHAR* szTmp = (TCHAR *)alloca(sizeof(TCHAR) * cbLen);
szTmp[0] = _T('\0');
- if ( szMessage )
- _tcscat( szTmp, _T("Subject: "));
- _tcscat( szTmp, xmlGetText( subjectNode ));
- if ( szMessage ) {
- _tcscat( szTmp, _T("\r\n"));
- _tcscat( szTmp, szMessage );
+ if (szMessage)
+ _tcscat(szTmp, _T("Subject: "));
+ _tcscat(szTmp, xmlGetText(subjectNode));
+ if (szMessage) {
+ _tcscat(szTmp, _T("\r\n"));
+ _tcscat(szTmp, szMessage);
}
szMessage = szTmp;
}
- if ( szMessage && (n = xmlGetChildByTag( node, "addresses", "xmlns", _T(JABBER_FEAT_EXT_ADDRESSING)))) {
- HXML addressNode = xmlGetChildByTag( n, "address", "type", _T("ofrom"));
- if ( addressNode ) {
- const TCHAR* szJid = xmlGetAttrValue( addressNode, _T("jid"));
- if ( szJid ) {
- size_t cbLen = _tcslen( szMessage ) + 1000;
- TCHAR* p = ( TCHAR* )alloca( sizeof( TCHAR ) * cbLen );
- mir_sntprintf( p, cbLen, TranslateT("Message redirected from: %s\r\n%s"), from, szMessage );
+ if (szMessage && (n = xmlGetChildByTag(node, "addresses", "xmlns", _T(JABBER_FEAT_EXT_ADDRESSING)))) {
+ HXML addressNode = xmlGetChildByTag(n, "address", "type", _T("ofrom"));
+ if (addressNode) {
+ const TCHAR *szJid = xmlGetAttrValue(addressNode, _T("jid"));
+ if (szJid) {
+ size_t cbLen = _tcslen(szMessage) + 1000;
+ TCHAR* p = (TCHAR*)alloca(sizeof(TCHAR) * cbLen);
+ mir_sntprintf(p, cbLen, TranslateT("Message redirected from: %s\r\n%s"), from, szMessage);
szMessage = p;
from = szJid;
// rewrite hContact
- hContact = HContactFromJID( from );
+ hContact = HContactFromJID(from);
}
}
}
- // If message is from a stranger ( not in roster ), item is NULL
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, from );
- if ( !item )
- item = ListGetItemPtr( LIST_VCARD_TEMP, from );
+ // If message is from a stranger (not in roster), item is NULL
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_ROSTER, from);
+ if ( !item)
+ item = ListGetItemPtr(LIST_VCARD_TEMP, from);
time_t msgTime = 0;
BOOL isChatRoomInvitation = FALSE;
- const TCHAR* inviteRoomJid = NULL;
- const TCHAR* inviteFromJid = NULL;
- const TCHAR* inviteReason = NULL;
- const TCHAR* invitePassword = NULL;
+ const TCHAR *inviteRoomJid = NULL;
+ const TCHAR *inviteFromJid = NULL;
+ const TCHAR *inviteReason = NULL;
+ const TCHAR *invitePassword = NULL;
BOOL delivered = FALSE;
// check chatstates availability
- if ( resourceStatus && xmlGetChildByTag( node, "active", "xmlns", _T( JABBER_FEAT_CHATSTATES )))
+ if (resourceStatus && xmlGetChildByTag(node, "active", "xmlns", _T(JABBER_FEAT_CHATSTATES)))
resourceStatus->jcbManualDiscoveredCaps |= JABBER_CAPS_CHATSTATES;
// chatstates composing event
- if ( hContact && xmlGetChildByTag( node, "composing", "xmlns", _T( JABBER_FEAT_CHATSTATES )))
- CallService( MS_PROTO_CONTACTISTYPING, ( WPARAM )hContact, 60 );
+ if (hContact && xmlGetChildByTag(node, "composing", "xmlns", _T(JABBER_FEAT_CHATSTATES)))
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, 60);
// chatstates paused event
- if ( hContact && xmlGetChildByTag( node, "paused", "xmlns", _T( JABBER_FEAT_CHATSTATES )))
- CallService( MS_PROTO_CONTACTISTYPING, ( WPARAM )hContact, PROTOTYPE_CONTACTTYPING_OFF );
+ if (hContact && xmlGetChildByTag(node, "paused", "xmlns", _T(JABBER_FEAT_CHATSTATES)))
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, PROTOTYPE_CONTACTTYPING_OFF);
// chatstates inactive event
- if ( hContact && xmlGetChildByTag( node, "inactive", "xmlns", _T( JABBER_FEAT_CHATSTATES )))
- CallService( MS_PROTO_CONTACTISTYPING, ( WPARAM )hContact, PROTOTYPE_CONTACTTYPING_OFF );
+ if (hContact && xmlGetChildByTag(node, "inactive", "xmlns", _T(JABBER_FEAT_CHATSTATES)))
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, PROTOTYPE_CONTACTTYPING_OFF);
// message receipts delivery notification
- if ( n = xmlGetChildByTag( node, "received", "xmlns", _T( JABBER_FEAT_MESSAGE_RECEIPTS ))) {
- int nPacketId = JabberGetPacketID( n );
- if ( nPacketId == -1 )
- nPacketId = JabberGetPacketID( node );
- if ( nPacketId != -1)
- JSendBroadcast( hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, ( HANDLE ) nPacketId, 0 );
+ if (n = xmlGetChildByTag(node, "received", "xmlns", _T(JABBER_FEAT_MESSAGE_RECEIPTS))) {
+ int nPacketId = JabberGetPacketID(n);
+ if (nPacketId == -1)
+ nPacketId = JabberGetPacketID(node);
+ if (nPacketId != -1)
+ JSendBroadcast(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)nPacketId, 0);
}
// XEP-0203 delay support
- if ( n = xmlGetChildByTag( node, "delay", "xmlns", _T("urn:xmpp:delay")) ) {
- const TCHAR* ptszTimeStamp = xmlGetAttrValue( n, _T("stamp"));
- if ( ptszTimeStamp != NULL ) {
+ if (n = xmlGetChildByTag(node, "delay", "xmlns", _T("urn:xmpp:delay"))) {
+ const TCHAR *ptszTimeStamp = xmlGetAttrValue(n, _T("stamp"));
+ if (ptszTimeStamp != NULL) {
// skip '-' chars
- TCHAR* szStamp = mir_tstrdup( ptszTimeStamp );
+ TCHAR* szStamp = mir_tstrdup(ptszTimeStamp);
int si = 0, sj = 0;
while (1) {
- if ( szStamp[si] == _T('-'))
+ if (szStamp[si] == _T('-'))
si++;
else
- if ( !( szStamp[sj++] = szStamp[si++] ))
+ if ( !(szStamp[sj++] = szStamp[si++]))
break;
};
- msgTime = JabberIsoToUnixTime( szStamp );
- mir_free( szStamp );
+ msgTime = JabberIsoToUnixTime(szStamp);
+ mir_free(szStamp);
}
}
// XEP-0224 support (Attention/Nudge)
- if ( xmlGetChildByTag( node, "attention", "xmlns", _T( JABBER_FEAT_ATTENTION )) ||
- xmlGetChildByTag( node, "attention", "xmlns", _T( JABBER_FEAT_ATTENTION_0 ))) {
- if ( !hContact )
- hContact = CreateTemporaryContact( from, chatItem );
- if ( hContact )
- NotifyEventHooks( m_hEventNudge, (WPARAM)hContact, 0 );
+ if (xmlGetChildByTag(node, "attention", "xmlns", _T(JABBER_FEAT_ATTENTION)) ||
+ xmlGetChildByTag(node, "attention", "xmlns", _T(JABBER_FEAT_ATTENTION_0))) {
+ if ( !hContact)
+ hContact = CreateTemporaryContact(from, chatItem);
+ if (hContact)
+ NotifyEventHooks(m_hEventNudge, (WPARAM)hContact, 0);
}
// chatstates gone event
- if ( hContact && xmlGetChildByTag( node, "gone", "xmlns", _T( JABBER_FEAT_CHATSTATES )) && m_options.LogChatstates ) {
+ if (hContact && xmlGetChildByTag(node, "gone", "xmlns", _T(JABBER_FEAT_CHATSTATES)) && m_options.LogChatstates) {
DBEVENTINFO dbei;
BYTE bEventType = JABBER_DB_EVENT_CHATSTATES_GONE; // gone event
dbei.cbSize = sizeof(dbei);
@@ -1265,222 +1265,222 @@ void CJabberProto::OnProcessMessage( HXML node, ThreadData* info ) CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
}
- if (( n = xmlGetChildByTag( node, "confirm", "xmlns", _T( JABBER_FEAT_HTTP_AUTH ))) && m_options.AcceptHttpAuth ) {
- const TCHAR *szId = xmlGetAttrValue( n, _T("id"));
- const TCHAR *szMethod = xmlGetAttrValue( n, _T("method"));
- const TCHAR *szUrl = xmlGetAttrValue( n, _T("url"));
- if ( !szId || !szMethod || !szUrl )
+ if ((n = xmlGetChildByTag(node, "confirm", "xmlns", _T(JABBER_FEAT_HTTP_AUTH))) && m_options.AcceptHttpAuth) {
+ const TCHAR *szId = xmlGetAttrValue(n, _T("id"));
+ const TCHAR *szMethod = xmlGetAttrValue(n, _T("method"));
+ const TCHAR *szUrl = xmlGetAttrValue(n, _T("url"));
+ if ( !szId || !szMethod || !szUrl)
return;
- CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams *)mir_alloc( sizeof( CJabberHttpAuthParams ));
- if ( !pParams )
+ CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams *)mir_alloc(sizeof(CJabberHttpAuthParams));
+ if ( !pParams)
return;
- ZeroMemory( pParams, sizeof( CJabberHttpAuthParams ));
+ ZeroMemory(pParams, sizeof(CJabberHttpAuthParams));
pParams->m_nType = CJabberHttpAuthParams::MSG;
- pParams->m_szFrom = mir_tstrdup( from );
- HXML pThreadNode = xmlGetChild( node , "thread" );
- if ( pThreadNode && xmlGetText( pThreadNode ) && xmlGetText( pThreadNode )[0] )
- pParams->m_szThreadId = mir_tstrdup( xmlGetText( pThreadNode ));
- pParams->m_szId = mir_tstrdup( szId );
- pParams->m_szMethod = mir_tstrdup( szMethod );
- pParams->m_szUrl = mir_tstrdup( szUrl );
-
- AddClistHttpAuthEvent( pParams );
+ pParams->m_szFrom = mir_tstrdup(from);
+ HXML pThreadNode = xmlGetChild(node , "thread");
+ if (pThreadNode && xmlGetText(pThreadNode) && xmlGetText(pThreadNode)[0])
+ pParams->m_szThreadId = mir_tstrdup(xmlGetText(pThreadNode));
+ pParams->m_szId = mir_tstrdup(szId);
+ pParams->m_szMethod = mir_tstrdup(szMethod);
+ pParams->m_szUrl = mir_tstrdup(szUrl);
+
+ AddClistHttpAuthEvent(pParams);
return;
}
- for ( int i = 0; ( xNode = xmlGetChild( node, i )) != NULL; i++ ) {
- xNode = xmlGetNthChild( node, _T("x"), i + 1 );
- if ( xNode == NULL ) {
- xNode = xmlGetNthChild( node, _T("user:x"), i + 1 );
- if ( xNode == NULL )
+ for (int i = 0; (xNode = xmlGetChild(node, i)) != NULL; i++) {
+ xNode = xmlGetNthChild(node, _T("x"), i + 1);
+ if (xNode == NULL) {
+ xNode = xmlGetNthChild(node, _T("user:x"), i + 1);
+ if (xNode == NULL)
continue;
}
- const TCHAR* ptszXmlns = xmlGetAttrValue( xNode, _T("xmlns"));
- if ( ptszXmlns == NULL )
- ptszXmlns = xmlGetAttrValue( xNode, _T("xmlns:user"));
- if ( ptszXmlns == NULL )
+ const TCHAR *ptszXmlns = xmlGetAttrValue(xNode, _T("xmlns"));
+ if (ptszXmlns == NULL)
+ ptszXmlns = xmlGetAttrValue(xNode, _T("xmlns:user"));
+ if (ptszXmlns == NULL)
continue;
- if ( !_tcscmp( ptszXmlns, _T(JABBER_FEAT_MIRANDA_NOTES))) {
+ if ( !_tcscmp(ptszXmlns, _T(JABBER_FEAT_MIRANDA_NOTES))) {
if (OnIncomingNote(from, xmlGetChild(xNode, "note")))
return;
}
- else if ( !_tcscmp( ptszXmlns, _T("jabber:x:encrypted" ))) {
- if ( xmlGetText( xNode ) == NULL )
+ else if ( !_tcscmp(ptszXmlns, _T("jabber:x:encrypted"))) {
+ if (xmlGetText(xNode) == NULL)
return;
TCHAR* prolog = _T("-----BEGIN PGP MESSAGE-----\r\n\r\n");
TCHAR* epilog = _T("\r\n-----END PGP MESSAGE-----\r\n");
- TCHAR* tempstring = ( TCHAR* )alloca( sizeof( TCHAR ) * ( _tcslen( prolog ) + _tcslen( xmlGetText( xNode )) + _tcslen( epilog ) + 3 ));
- _tcsncpy( tempstring, prolog, _tcslen( prolog ) + 1 );
- _tcsncpy( tempstring + _tcslen( prolog ), xmlGetText( xNode ), _tcslen( xmlGetText( xNode )) + 1);
- _tcsncpy( tempstring + _tcslen( prolog ) + _tcslen(xmlGetText( xNode )), epilog, _tcslen( epilog ) + 1);
+ TCHAR* tempstring = (TCHAR*)alloca(sizeof(TCHAR) * (_tcslen(prolog) + _tcslen(xmlGetText(xNode)) + _tcslen(epilog) + 3));
+ _tcsncpy(tempstring, prolog, _tcslen(prolog) + 1);
+ _tcsncpy(tempstring + _tcslen(prolog), xmlGetText(xNode), _tcslen(xmlGetText(xNode)) + 1);
+ _tcsncpy(tempstring + _tcslen(prolog) + _tcslen(xmlGetText(xNode)), epilog, _tcslen(epilog) + 1);
szMessage = tempstring;
}
- else if ( !_tcscmp( ptszXmlns, _T(JABBER_FEAT_DELAY)) && msgTime == 0 ) {
- const TCHAR* ptszTimeStamp = xmlGetAttrValue( xNode, _T("stamp"));
- if ( ptszTimeStamp != NULL )
- msgTime = JabberIsoToUnixTime( ptszTimeStamp );
+ else if ( !_tcscmp(ptszXmlns, _T(JABBER_FEAT_DELAY)) && msgTime == 0) {
+ const TCHAR *ptszTimeStamp = xmlGetAttrValue(xNode, _T("stamp"));
+ if (ptszTimeStamp != NULL)
+ msgTime = JabberIsoToUnixTime(ptszTimeStamp);
}
- else if ( !_tcscmp( ptszXmlns, _T(JABBER_FEAT_MESSAGE_EVENTS))) {
+ else if ( !_tcscmp(ptszXmlns, _T(JABBER_FEAT_MESSAGE_EVENTS))) {
// set events support only if we discovered caps and if events not already set
- JabberCapsBits jcbCaps = GetResourceCapabilites( from, TRUE );
- if ( jcbCaps & JABBER_RESOURCE_CAPS_ERROR )
+ JabberCapsBits jcbCaps = GetResourceCapabilites(from, TRUE);
+ if (jcbCaps & JABBER_RESOURCE_CAPS_ERROR)
jcbCaps = JABBER_RESOURCE_CAPS_NONE;
// FIXME: disabled due to expired XEP-0022 and problems with bombus delivery checks
-// if ( jcbCaps && resourceStatus && (!(jcbCaps & JABBER_CAPS_MESSAGE_EVENTS)))
+// if (jcbCaps && resourceStatus && (!(jcbCaps & JABBER_CAPS_MESSAGE_EVENTS)))
// resourceStatus->jcbManualDiscoveredCaps |= (JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY);
- if ( bodyNode == NULL ) {
- idNode = xmlGetChild( xNode , "id" );
- if ( xmlGetChild( xNode , "delivered" ) != NULL || xmlGetChild( xNode , "offline" ) != NULL ) {
+ if (bodyNode == NULL) {
+ idNode = xmlGetChild(xNode , "id");
+ if (xmlGetChild(xNode , "delivered") != NULL || xmlGetChild(xNode , "offline") != NULL) {
int id = -1;
- if ( idNode != NULL && xmlGetText( idNode ) != NULL )
- if ( !_tcsncmp( xmlGetText( idNode ), _T(JABBER_IQID), strlen( JABBER_IQID )))
- id = _ttoi(( xmlGetText( idNode ))+strlen( JABBER_IQID ));
+ if (idNode != NULL && xmlGetText(idNode) != NULL)
+ if ( !_tcsncmp(xmlGetText(idNode), _T(JABBER_IQID), strlen(JABBER_IQID)))
+ id = _ttoi((xmlGetText(idNode))+strlen(JABBER_IQID));
- if ( id != -1 )
- JSendBroadcast( hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 );
+ if (id != -1)
+ JSendBroadcast(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
- if ( hContact && xmlGetChild( xNode , "composing" ) != NULL )
- CallService( MS_PROTO_CONTACTISTYPING, ( WPARAM ) hContact, 60 );
+ if (hContact && xmlGetChild(xNode , "composing") != NULL)
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, 60);
// Maybe a cancel to the previous composing
- HXML child = xmlGetChild( xNode ,0);
- if ( hContact && ( !child || ( child && idNode != NULL )))
- CallService( MS_PROTO_CONTACTISTYPING, ( WPARAM ) hContact, PROTOTYPE_CONTACTTYPING_OFF );
+ HXML child = xmlGetChild(xNode ,0);
+ if (hContact && (!child || (child && idNode != NULL)))
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, PROTOTYPE_CONTACTTYPING_OFF);
}
else {
// Check whether any event is requested
- if ( !delivered && ( n = xmlGetChild( xNode , "delivered" )) != NULL ) {
+ if ( !delivered && (n = xmlGetChild(xNode , "delivered")) != NULL) {
delivered = TRUE;
- XmlNode m( _T("message" )); m << XATTR( _T("to"), from );
- HXML x = m << XCHILDNS( _T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
- x << XCHILD( _T("delivered"));
- x << XCHILD( _T("id"), idStr );
- info->send( m );
+ XmlNode m(_T("message")); m << XATTR(_T("to"), from);
+ HXML x = m << XCHILDNS(_T("x"), _T(JABBER_FEAT_MESSAGE_EVENTS));
+ x << XCHILD(_T("delivered"));
+ x << XCHILD(_T("id"), idStr);
+ info->send(m);
}
- if ( item != NULL && xmlGetChild( xNode , "composing" ) != NULL ) {
- if ( item->messageEventIdStr )
- mir_free( item->messageEventIdStr );
- item->messageEventIdStr = ( idStr==NULL )?NULL:mir_tstrdup( idStr );
+ if (item != NULL && xmlGetChild(xNode , "composing") != NULL) {
+ if (item->messageEventIdStr)
+ mir_free(item->messageEventIdStr);
+ item->messageEventIdStr = (idStr==NULL)?NULL:mir_tstrdup(idStr);
} }
}
- else if ( !_tcscmp( ptszXmlns, _T(JABBER_FEAT_OOB2))) {
+ else if ( !_tcscmp(ptszXmlns, _T(JABBER_FEAT_OOB2))) {
HXML urlNode;
- if ( ((urlNode = xmlGetChild( xNode , "url" )) != NULL) && xmlGetText( urlNode ) && xmlGetText( urlNode )[0] != _T('\0')) {
- size_t cbLen = (szMessage ? _tcslen( szMessage ) : 0) + _tcslen( xmlGetText( urlNode )) + 32;
- TCHAR* szTmp = ( TCHAR * )alloca( sizeof(TCHAR) * cbLen );
- _tcscpy( szTmp, xmlGetText( urlNode ));
- if ( szMessage ) {
- _tcscat( szTmp, _T("\r\n"));
- _tcscat( szTmp, szMessage );
+ if (((urlNode = xmlGetChild(xNode , "url")) != NULL) && xmlGetText(urlNode) && xmlGetText(urlNode)[0] != _T('\0')) {
+ size_t cbLen = (szMessage ? _tcslen(szMessage) : 0) + _tcslen(xmlGetText(urlNode)) + 32;
+ TCHAR* szTmp = (TCHAR *)alloca(sizeof(TCHAR) * cbLen);
+ _tcscpy(szTmp, xmlGetText(urlNode));
+ if (szMessage) {
+ _tcscat(szTmp, _T("\r\n"));
+ _tcscat(szTmp, szMessage);
}
szMessage = szTmp;
}
}
- else if ( !_tcscmp( ptszXmlns, _T(JABBER_FEAT_MUC_USER))) {
- inviteNode = xmlGetChild( xNode , _T("invite"));
- if ( inviteNode == NULL )
- inviteNode = xmlGetChild( xNode , _T("user:invite"));
-
- if ( inviteNode != NULL ) {
- inviteFromJid = xmlGetAttrValue( inviteNode, _T("from"));
- n = xmlGetChild( inviteNode , _T("reason"));
- if ( n == NULL )
- n = xmlGetChild( inviteNode , _T("user:reason"));
- if ( n != NULL )
- inviteReason = xmlGetText( n );
+ else if ( !_tcscmp(ptszXmlns, _T(JABBER_FEAT_MUC_USER))) {
+ inviteNode = xmlGetChild(xNode , _T("invite"));
+ if (inviteNode == NULL)
+ inviteNode = xmlGetChild(xNode , _T("user:invite"));
+
+ if (inviteNode != NULL) {
+ inviteFromJid = xmlGetAttrValue(inviteNode, _T("from"));
+ n = xmlGetChild(inviteNode , _T("reason"));
+ if (n == NULL)
+ n = xmlGetChild(inviteNode , _T("user:reason"));
+ if (n != NULL)
+ inviteReason = xmlGetText(n);
}
inviteRoomJid = from;
- if ( !inviteReason )
+ if ( !inviteReason)
inviteReason = szMessage;
isChatRoomInvitation = TRUE;
- if (( n = xmlGetChild( xNode , "password" )) != NULL )
- invitePassword = xmlGetText( n );
+ if ((n = xmlGetChild(xNode , "password")) != NULL)
+ invitePassword = xmlGetText(n);
}
- else if ( !_tcscmp( ptszXmlns, _T(JABBER_FEAT_ROSTER_EXCHANGE)) &&
+ else if ( !_tcscmp(ptszXmlns, _T(JABBER_FEAT_ROSTER_EXCHANGE)) &&
item != NULL && (item->subscription == SUB_BOTH || item->subscription == SUB_TO)) {
TCHAR chkJID[JABBER_MAX_JID_LEN] = _T("@");
- JabberStripJid( from, chkJID + 1, SIZEOF(chkJID) - 1 );
- for ( int i = 1; ; ++i ) {
- HXML iNode = xmlGetNthChild( xNode , _T("item"), i );
- if ( iNode == NULL ) break;
- const TCHAR *action = xmlGetAttrValue( iNode, _T("action"));
- const TCHAR *jid = xmlGetAttrValue( iNode, _T("jid"));
- const TCHAR *nick = xmlGetAttrValue( iNode, _T("name"));
- const TCHAR *group = xmlGetText( xmlGetChild( iNode, _T("group")));
- if ( action && jid && _tcsstr( jid, chkJID )) {
- if ( !_tcscmp( action, _T("add"))) {
- HANDLE hContact = DBCreateContact( jid, nick, FALSE, FALSE );
- if ( group )
- DBWriteContactSettingTString( hContact, "CList", "Group", group );
+ JabberStripJid(from, chkJID + 1, SIZEOF(chkJID) - 1);
+ for (int i = 1; ; ++i) {
+ HXML iNode = xmlGetNthChild(xNode , _T("item"), i);
+ if (iNode == NULL) break;
+ const TCHAR *action = xmlGetAttrValue(iNode, _T("action"));
+ const TCHAR *jid = xmlGetAttrValue(iNode, _T("jid"));
+ const TCHAR *nick = xmlGetAttrValue(iNode, _T("name"));
+ const TCHAR *group = xmlGetText(xmlGetChild(iNode, _T("group")));
+ if (action && jid && _tcsstr(jid, chkJID)) {
+ if ( !_tcscmp(action, _T("add"))) {
+ HANDLE hContact = DBCreateContact(jid, nick, FALSE, FALSE);
+ if (group)
+ db_set_ts(hContact, "CList", "Group", group);
}
- else if ( !_tcscmp( action, _T("modify"))) {
-// HANDLE hContact = HContactFromJID( jid );
+ else if ( !_tcscmp(action, _T("modify"))) {
+// HANDLE hContact = HContactFromJID(jid);
}
- else if ( !_tcscmp( action, _T("delete"))) {
- HANDLE hContact = HContactFromJID( jid );
- if ( hContact )
- CallService( MS_DB_CONTACT_DELETE, ( WPARAM ) hContact, 0 );
+ else if ( !_tcscmp(action, _T("delete"))) {
+ HANDLE hContact = HContactFromJID(jid);
+ if (hContact)
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
}
}
}
- else if ( !isChatRoomInvitation && !_tcscmp( ptszXmlns, _T("jabber:x:conference"))) {
- inviteRoomJid = xmlGetAttrValue( xNode, _T("jid"));
+ else if ( !isChatRoomInvitation && !_tcscmp(ptszXmlns, _T("jabber:x:conference"))) {
+ inviteRoomJid = xmlGetAttrValue(xNode, _T("jid"));
inviteFromJid = from;
- if ( inviteReason == NULL )
- inviteReason = xmlGetText( xNode );
- if ( !inviteReason )
+ if (inviteReason == NULL)
+ inviteReason = xmlGetText(xNode);
+ if ( !inviteReason)
inviteReason = szMessage;
isChatRoomInvitation = TRUE;
}
}
- if ( isChatRoomInvitation ) {
- if ( inviteRoomJid != NULL ) {
- if ( m_options.IgnoreMUCInvites ) {
+ if (isChatRoomInvitation) {
+ if (inviteRoomJid != NULL) {
+ if (m_options.IgnoreMUCInvites) {
// FIXME: temporary disabled due to MUC inconsistence on server side
/*
- XmlNode m( "message" ); xmlAddAttr( m, "to", from );
- XmlNode xNode = xmlAddChild( m, "x" );
- xmlAddAttr( xNode, "xmlns", JABBER_FEAT_MUC_USER );
- XmlNode declineNode = xmlAddChild( xNode, "decline" );
- xmlAddAttr( declineNode, "from", inviteRoomJid );
- XmlNode reasonNode = xmlAddChild( declineNode, "reason", "The user has chosen to not accept chat invites" );
- info->send( m );
+ XmlNode m("message"); xmlAddAttr(m, "to", from);
+ XmlNode xNode = xmlAddChild(m, "x");
+ xmlAddAttr(xNode, "xmlns", JABBER_FEAT_MUC_USER);
+ XmlNode declineNode = xmlAddChild(xNode, "decline");
+ xmlAddAttr(declineNode, "from", inviteRoomJid);
+ XmlNode reasonNode = xmlAddChild(declineNode, "reason", "The user has chosen to not accept chat invites");
+ info->send(m);
*/
}
else
- GroupchatProcessInvite( inviteRoomJid, inviteFromJid, inviteReason, invitePassword );
+ GroupchatProcessInvite(inviteRoomJid, inviteFromJid, inviteReason, invitePassword);
}
return;
}
- if ( szMessage ) {
- if (( szMessage = JabberUnixToDosT( szMessage )) == NULL )
- szMessage = mir_tstrdup( _T(""));
+ if (szMessage) {
+ if ((szMessage = JabberUnixToDosT(szMessage)) == NULL)
+ szMessage = mir_tstrdup(_T(""));
- char* buf = mir_utf8encodeW( szMessage );
+ char* buf = mir_utf8encodeW(szMessage);
- if ( item != NULL ) {
- if ( resourceStatus ) resourceStatus->bMessageSessionActive = TRUE;
- if ( hContact != NULL )
- CallService( MS_PROTO_CONTACTISTYPING, ( WPARAM ) hContact, PROTOTYPE_CONTACTTYPING_OFF );
+ if (item != NULL) {
+ if (resourceStatus) resourceStatus->bMessageSessionActive = TRUE;
+ if (hContact != NULL)
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, PROTOTYPE_CONTACTTYPING_OFF);
// no we will monitor last resource in all modes
- if ( /*item->resourceMode==RSMODE_LASTSEEN &&*/ ( fromResource = _tcschr( from, '/' ))!=NULL ) {
+ if (/*item->resourceMode==RSMODE_LASTSEEN &&*/ (fromResource = _tcschr(from, '/'))!=NULL) {
fromResource++;
- if ( *fromResource != '\0' ) {
- for ( int i=0; i<item->resourceCount; i++ ) {
- if ( !lstrcmp( item->resource[i].resourceName, fromResource )) {
+ if (*fromResource != '\0') {
+ for (int i=0; i<item->resourceCount; i++) {
+ if ( !lstrcmp(item->resource[i].resourceName, fromResource)) {
int nLastSeenResource = item->lastSeenResource;
item->lastSeenResource = i;
if ((item->resourceMode==RSMODE_LASTSEEN) && (i != nLastSeenResource))
@@ -1489,134 +1489,132 @@ void CJabberProto::OnProcessMessage( HXML node, ThreadData* info ) } } } } }
// Create a temporary contact
- if ( hContact == NULL )
- hContact = CreateTemporaryContact( from, chatItem );
+ if (hContact == NULL)
+ hContact = CreateTemporaryContact(from, chatItem);
- time_t now = time( NULL );
- if ( !msgTime )
+ time_t now = time(NULL);
+ if ( !msgTime)
msgTime = now;
- if ( m_options.FixIncorrectTimestamps && ( msgTime > now || ( msgTime < ( time_t )JabberGetLastContactMessageTime( hContact ))))
+ if (m_options.FixIncorrectTimestamps && (msgTime > now || (msgTime < (time_t)JabberGetLastContactMessageTime(hContact))))
msgTime = now;
PROTORECVEVENT recv;
recv.flags = PREF_UTF;
- recv.timestamp = ( DWORD )msgTime;
+ recv.timestamp = (DWORD)msgTime;
recv.szMessage = buf;
- EnterCriticalSection( &m_csLastResourceMap );
- recv.lParam = (LPARAM)AddToLastResourceMap( from );
- LeaveCriticalSection( &m_csLastResourceMap );
+ EnterCriticalSection(&m_csLastResourceMap);
+ recv.lParam = (LPARAM)AddToLastResourceMap(from);
+ LeaveCriticalSection(&m_csLastResourceMap);
CCSDATA ccs;
ccs.hContact = hContact;
ccs.wParam = 0;
ccs.szProtoService = PSR_MESSAGE;
- ccs.lParam = ( LPARAM )&recv;
- CallService( MS_PROTO_CHAINRECV, 0, ( LPARAM )&ccs );
+ ccs.lParam = (LPARAM)&recv;
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
- mir_free(( void* )szMessage );
- mir_free( buf );
+ mir_free((void*)szMessage);
+ mir_free(buf);
}
}
// XEP-0115: Entity Capabilities
-void CJabberProto::OnProcessPresenceCapabilites( HXML node )
+void CJabberProto::OnProcessPresenceCapabilites(HXML node)
{
- const TCHAR* from;
- if (( from = xmlGetAttrValue( node, _T("from"))) == NULL )
+ const TCHAR *from;
+ if ((from = xmlGetAttrValue(node, _T("from"))) == NULL)
return;
Log("presence: for jid " TCHAR_STR_PARAM, from);
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( from );
- if ( r == NULL ) return;
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(from);
+ if (r == NULL) return;
HXML n;
// check XEP-0115 support, and old style:
- if (( n = xmlGetChildByTag( node, "c", "xmlns", _T(JABBER_FEAT_ENTITY_CAPS))) != NULL ||
- ( n = xmlGetChildByTag( node, "caps:c", "xmlns:caps", _T(JABBER_FEAT_ENTITY_CAPS))) != NULL ||
- ( n = xmlGetChild( node, "c" )) != NULL ) {
- const TCHAR *szNode = xmlGetAttrValue( n, _T("node"));
- const TCHAR *szVer = xmlGetAttrValue( n, _T("ver"));
- const TCHAR *szExt = xmlGetAttrValue( n, _T("ext"));
- if ( szNode && szVer ) {
- replaceStrT( r->szCapsNode, szNode );
- replaceStrT( r->szCapsVer, szVer );
- replaceStrT( r->szCapsExt, szExt );
- HANDLE hContact = HContactFromJID( from );
- if ( hContact )
- UpdateMirVer( hContact, r );
+ if ((n = xmlGetChildByTag(node, "c", "xmlns", _T(JABBER_FEAT_ENTITY_CAPS))) != NULL ||
+ (n = xmlGetChildByTag(node, "caps:c", "xmlns:caps", _T(JABBER_FEAT_ENTITY_CAPS))) != NULL ||
+ (n = xmlGetChild(node, "c")) != NULL) {
+ const TCHAR *szNode = xmlGetAttrValue(n, _T("node"));
+ const TCHAR *szVer = xmlGetAttrValue(n, _T("ver"));
+ const TCHAR *szExt = xmlGetAttrValue(n, _T("ext"));
+ if (szNode && szVer) {
+ replaceStrT(r->szCapsNode, szNode);
+ replaceStrT(r->szCapsVer, szVer);
+ replaceStrT(r->szCapsExt, szExt);
+ HANDLE hContact = HContactFromJID(from);
+ if (hContact)
+ UpdateMirVer(hContact, r);
}
}
// update user's caps
- // JabberCapsBits jcbCaps = GetResourceCapabilites( from, TRUE );
+ // JabberCapsBits jcbCaps = GetResourceCapabilites(from, TRUE);
}
-void CJabberProto::UpdateJidDbSettings( const TCHAR *jid )
+void CJabberProto::UpdateJidDbSettings(const TCHAR *jid)
{
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_ROSTER, jid );
- if ( !item ) return;
- HANDLE hContact = HContactFromJID( jid );
- if ( !hContact ) return;
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
+ if ( !item) return;
+ HANDLE hContact = HContactFromJID(jid);
+ if ( !hContact) return;
int status = ID_STATUS_OFFLINE;
- if ( !item->resourceCount ) {
+ if ( !item->resourceCount) {
// set offline only if jid has resources
- if ( _tcschr( jid, '/' )==NULL )
+ if (_tcschr(jid, '/')==NULL)
status = item->itemResource.status;
- if ( item->itemResource.statusMessage )
- DBWriteContactSettingTString( hContact, "CList", "StatusMsg", item->itemResource.statusMessage );
+ if (item->itemResource.statusMessage)
+ db_set_ts(hContact, "CList", "StatusMsg", item->itemResource.statusMessage);
else
- DBDeleteContactSetting( hContact, "CList", "StatusMsg" );
+ DBDeleteContactSetting(hContact, "CList", "StatusMsg");
}
// Determine status to show for the contact based on the remaining resources
int nSelectedResource = -1, i = 0;
int nMaxPriority = -999; // -128...+127 valid range
- for ( i = 0; i < item->resourceCount; i++ )
+ for (i = 0; i < item->resourceCount; i++)
{
- if ( item->resource[i].priority > nMaxPriority ) {
+ if (item->resource[i].priority > nMaxPriority) {
nMaxPriority = item->resource[i].priority;
status = item->resource[i].status;
nSelectedResource = i;
}
- else if ( item->resource[i].priority == nMaxPriority) {
- if (( status = JabberCombineStatus( status, item->resource[i].status )) == item->resource[i].status )
+ else if (item->resource[i].priority == nMaxPriority) {
+ if ((status = JabberCombineStatus(status, item->resource[i].status)) == item->resource[i].status)
nSelectedResource = i;
}
}
item->itemResource.status = status;
- if ( nSelectedResource != -1 ) {
- Log("JabberUpdateJidDbSettings: updating jid " TCHAR_STR_PARAM " to rc " TCHAR_STR_PARAM, item->jid, item->resource[nSelectedResource].resourceName );
- if ( item->resource[nSelectedResource].statusMessage )
- DBWriteContactSettingTString( hContact, "CList", "StatusMsg", item->resource[nSelectedResource].statusMessage );
+ if (nSelectedResource != -1) {
+ Log("JabberUpdateJidDbSettings: updating jid " TCHAR_STR_PARAM " to rc " TCHAR_STR_PARAM, item->jid, item->resource[nSelectedResource].resourceName);
+ if (item->resource[nSelectedResource].statusMessage)
+ db_set_ts(hContact, "CList", "StatusMsg", item->resource[nSelectedResource].statusMessage);
else
- DBDeleteContactSetting( hContact, "CList", "StatusMsg" );
- UpdateMirVer( hContact, &item->resource[nSelectedResource] );
- }
- else {
- JDeleteSetting( hContact, DBSETTING_DISPLAY_UID );
+ DBDeleteContactSetting(hContact, "CList", "StatusMsg");
+ UpdateMirVer(hContact, &item->resource[nSelectedResource]);
}
+ else JDeleteSetting(hContact, DBSETTING_DISPLAY_UID);
- if ( _tcschr( jid, '@' )!=NULL || m_options.ShowTransport==TRUE )
- if ( JGetWord( hContact, "Status", ID_STATUS_OFFLINE ) != status )
- JSetWord( hContact, "Status", ( WORD )status );
+ if (_tcschr(jid, '@') != NULL || m_options.ShowTransport == TRUE)
+ if (JGetWord(hContact, "Status", ID_STATUS_OFFLINE) != status)
+ JSetWord(hContact, "Status", (WORD)status);
if (status == ID_STATUS_OFFLINE)
{ // remove x-status icon
- JDeleteSetting( hContact, DBSETTING_XSTATUSID );
- JDeleteSetting( hContact, DBSETTING_XSTATUSNAME );
- JDeleteSetting( hContact, DBSETTING_XSTATUSMSG );
+ JDeleteSetting(hContact, DBSETTING_XSTATUSID);
+ JDeleteSetting(hContact, DBSETTING_XSTATUSNAME);
+ JDeleteSetting(hContact, DBSETTING_XSTATUSMSG);
//JabberUpdateContactExtraIcon(hContact);
}
- MenuUpdateSrmmIcon( item );
+ MenuUpdateSrmmIcon(item);
}
-void CJabberProto::OnProcessPresence( HXML node, ThreadData* info )
+void CJabberProto::OnProcessPresence(HXML node, ThreadData* info)
{
HANDLE hContact;
HXML showNode, statusNode, priorityNode;
@@ -1624,301 +1622,301 @@ void CJabberProto::OnProcessPresence( HXML node, ThreadData* info ) LPCTSTR from, show, p;
TCHAR *nick;
- if ( !node || !xmlGetName( node ) ||_tcscmp( xmlGetName( node ), _T("presence"))) return;
- if (( from = xmlGetAttrValue( node, _T("from"))) == NULL ) return;
+ if ( !node || !xmlGetName(node) ||_tcscmp(xmlGetName(node), _T("presence"))) return;
+ if ((from = xmlGetAttrValue(node, _T("from"))) == NULL) return;
- if ( m_presenceManager.HandlePresencePermanent( node, info ))
+ if (m_presenceManager.HandlePresencePermanent(node, info))
return;
- if ( ListExist( LIST_CHATROOM, from )) {
- GroupchatProcessPresence( node );
+ if (ListExist(LIST_CHATROOM, from)) {
+ GroupchatProcessPresence(node);
return;
}
BOOL bSelfPresence = FALSE;
TCHAR szBareFrom[ JABBER_MAX_JID_LEN ];
- JabberStripJid( from, szBareFrom, SIZEOF( szBareFrom ));
+ JabberStripJid(from, szBareFrom, SIZEOF(szBareFrom));
TCHAR szBareOurJid[ JABBER_MAX_JID_LEN ];
- JabberStripJid( info->fullJID, szBareOurJid, SIZEOF( szBareOurJid ));
+ JabberStripJid(info->fullJID, szBareOurJid, SIZEOF(szBareOurJid));
- if ( !_tcsicmp( szBareFrom, szBareOurJid ))
+ if ( !_tcsicmp(szBareFrom, szBareOurJid))
bSelfPresence = TRUE;
- LPCTSTR type = xmlGetAttrValue( node, _T("type"));
- if ( type == NULL || !_tcscmp( type, _T("available"))) {
- if (( nick = JabberNickFromJID( from )) == NULL )
+ LPCTSTR type = xmlGetAttrValue(node, _T("type"));
+ if (type == NULL || !_tcscmp(type, _T("available"))) {
+ if ((nick = JabberNickFromJID(from)) == NULL)
return;
- if (( hContact = HContactFromJID( from )) == NULL ) {
- if ( !_tcsicmp( info->fullJID, from ) || ( !bSelfPresence && !ListExist( LIST_ROSTER, from ))) {
- Log("SKIP Receive presence online from "TCHAR_STR_PARAM" ( who is not in my roster and not in list - skiping)", from );
- mir_free( nick );
+ if ((hContact = HContactFromJID(from)) == NULL) {
+ if ( !_tcsicmp(info->fullJID, from) || (!bSelfPresence && !ListExist(LIST_ROSTER, from))) {
+ Log("SKIP Receive presence online from "TCHAR_STR_PARAM" (who is not in my roster and not in list - skiping)", from);
+ mir_free(nick);
return;
}
- hContact = DBCreateContact( from, nick, TRUE, TRUE );
+ hContact = DBCreateContact(from, nick, TRUE, TRUE);
}
- if ( !ListExist( LIST_ROSTER, from )) {
- Log("Receive presence online from "TCHAR_STR_PARAM" ( who is not in my roster )", from );
- ListAdd( LIST_ROSTER, from );
+ if ( !ListExist(LIST_ROSTER, from)) {
+ Log("Receive presence online from "TCHAR_STR_PARAM" (who is not in my roster)", from);
+ ListAdd(LIST_ROSTER, from);
}
- DBCheckIsTransportedContact( from, hContact );
+ DBCheckIsTransportedContact(from, hContact);
int status = ID_STATUS_ONLINE;
- if (( showNode = xmlGetChild( node , "show" )) != NULL ) {
- if (( show = xmlGetText( showNode )) != NULL ) {
- if ( !_tcscmp( show, _T("away"))) status = ID_STATUS_AWAY;
- else if ( !_tcscmp( show, _T("xa"))) status = ID_STATUS_NA;
- else if ( !_tcscmp( show, _T("dnd"))) status = ID_STATUS_DND;
- else if ( !_tcscmp( show, _T("chat"))) status = ID_STATUS_FREECHAT;
+ if ((showNode = xmlGetChild(node , "show")) != NULL) {
+ if ((show = xmlGetText(showNode)) != NULL) {
+ if ( !_tcscmp(show, _T("away"))) status = ID_STATUS_AWAY;
+ else if ( !_tcscmp(show, _T("xa"))) status = ID_STATUS_NA;
+ else if ( !_tcscmp(show, _T("dnd"))) status = ID_STATUS_DND;
+ else if ( !_tcscmp(show, _T("chat"))) status = ID_STATUS_FREECHAT;
}
}
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 (( statusNode = xmlGetChild( node , "status" )) != NULL && xmlGetText( statusNode ) != NULL )
- p = xmlGetText( statusNode );
+ if ((statusNode = xmlGetChild(node , "status")) != NULL && xmlGetText(statusNode) != NULL)
+ p = xmlGetText(statusNode);
else
p = NULL;
- ListAddResource( LIST_ROSTER, from, status, p, priority );
+ ListAddResource(LIST_ROSTER, from, status, p, priority);
// XEP-0115: Entity Capabilities
- OnProcessPresenceCapabilites( node );
+ OnProcessPresenceCapabilites(node);
- UpdateJidDbSettings( from );
+ UpdateJidDbSettings(from);
- if ( _tcschr( from, '@' )==NULL ) {
+ if (_tcschr(from, '@')==NULL) {
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
}
- Log( TCHAR_STR_PARAM " ( " TCHAR_STR_PARAM " ) online, set contact status to %s", nick, from, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)status,0 ));
- mir_free( nick );
+ Log(TCHAR_STR_PARAM " (" TCHAR_STR_PARAM ") online, set contact status to %s", nick, from, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)status,0));
+ mir_free(nick);
HXML xNode;
- if ( m_options.EnableAvatars ) {
+ if (m_options.EnableAvatars) {
BOOL hasAvatar = false;
BOOL removedAvatar = false;
- Log( "Avatar enabled" );
- for ( int i = 1; ( xNode=xmlGetNthChild( node, _T("x"), i )) != NULL; i++ ) {
- if ( !lstrcmp( xmlGetAttrValue( xNode, _T("xmlns")), _T("jabber:x:avatar"))) {
- if (( xNode = xmlGetChild( xNode , "hash" )) != NULL && xmlGetText( xNode ) != NULL ) {
+ Log("Avatar enabled");
+ for (int i = 1; (xNode=xmlGetNthChild(node, _T("x"), i)) != NULL; i++) {
+ if ( !lstrcmp(xmlGetAttrValue(xNode, _T("xmlns")), _T("jabber:x:avatar"))) {
+ if ((xNode = xmlGetChild(xNode , "hash")) != NULL && xmlGetText(xNode) != NULL) {
JDeleteSetting(hContact,"AvatarXVcard");
- Log( "AvatarXVcard deleted" );
- JSetStringT( hContact, "AvatarHash", xmlGetText( xNode ));
+ Log("AvatarXVcard deleted");
+ JSetStringT(hContact, "AvatarHash", xmlGetText(xNode));
hasAvatar = true;
DBVARIANT dbv;
- int result = JGetStringT( hContact, "AvatarSaved", &dbv );
- if ( result || lstrcmp( dbv.ptszVal, xmlGetText( xNode ))) {
- Log( "Avatar was changed" );
- JSendBroadcast( hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, NULL );
- } else Log( "Not broadcasting avatar changed" );
- if ( !result ) JFreeVariant( &dbv );
+ int result = JGetStringT(hContact, "AvatarSaved", &dbv);
+ if (result || lstrcmp(dbv.ptszVal, xmlGetText(xNode))) {
+ Log("Avatar was changed");
+ JSendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, NULL);
+ } else Log("Not broadcasting avatar changed");
+ if ( !result) db_free(&dbv);
} else {
removedAvatar = true;
}
} }
- if ( !hasAvatar ) { //no jabber:x:avatar. try vcard-temp:x:update
- Log( "Not hasXAvatar" );
- for ( int i = 1; ( xNode=xmlGetNthChild( node, _T("x"), i )) != NULL; i++ ) {
- if ( !lstrcmp( xmlGetAttrValue( xNode, _T("xmlns")), _T("vcard-temp:x:update"))) {
- if (( xNode = xmlGetChild( xNode , "photo" )) != NULL ) {
- LPCTSTR txt = xmlGetText( xNode );
- if ( txt != NULL && txt[0] != 0) {
- JSetByte( hContact, "AvatarXVcard", 1 );
- Log( "AvatarXVcard set" );
- JSetStringT( hContact, "AvatarHash", txt );
+ if ( !hasAvatar) { //no jabber:x:avatar. try vcard-temp:x:update
+ Log("Not hasXAvatar");
+ for (int i = 1; (xNode=xmlGetNthChild(node, _T("x"), i)) != NULL; i++) {
+ if ( !lstrcmp(xmlGetAttrValue(xNode, _T("xmlns")), _T("vcard-temp:x:update"))) {
+ if ((xNode = xmlGetChild(xNode , "photo")) != NULL) {
+ LPCTSTR txt = xmlGetText(xNode);
+ if (txt != NULL && txt[0] != 0) {
+ JSetByte(hContact, "AvatarXVcard", 1);
+ Log("AvatarXVcard set");
+ JSetStringT(hContact, "AvatarHash", txt);
hasAvatar = true;
DBVARIANT dbv;
- int result = JGetStringT( hContact, "AvatarSaved", &dbv );
- if ( result || lstrcmp( dbv.ptszVal, txt )) {
- Log( "Avatar was changed. Using vcard-temp:x:update" );
- JSendBroadcast( hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, NULL );
+ int result = JGetStringT(hContact, "AvatarSaved", &dbv);
+ if (result || lstrcmp(dbv.ptszVal, txt)) {
+ Log("Avatar was changed. Using vcard-temp:x:update");
+ JSendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, NULL);
}
- else Log( "Not broadcasting avatar changed" );
- if ( !result ) JFreeVariant( &dbv );
+ else Log("Not broadcasting avatar changed");
+ if ( !result) db_free(&dbv);
} else {
removedAvatar = true;
}
} } } }
- if ( !hasAvatar && removedAvatar ) {
- Log( "Has no avatar" );
- JDeleteSetting( hContact, "AvatarHash" );
+ if ( !hasAvatar && removedAvatar) {
+ Log("Has no avatar");
+ JDeleteSetting(hContact, "AvatarHash");
DBVARIANT dbv = {0};
- if ( !JGetStringT( hContact, "AvatarSaved", &dbv )) {
- JFreeVariant( &dbv );
- JDeleteSetting( hContact, "AvatarSaved" );
- JSendBroadcast( hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL );
+ if ( !JGetStringT(hContact, "AvatarSaved", &dbv)) {
+ db_free(&dbv);
+ JDeleteSetting(hContact, "AvatarSaved");
+ JSendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL);
} } }
return;
}
- if ( !_tcscmp( type, _T("unavailable"))) {
- hContact = HContactFromJID( from );
- if (( item = ListGetItemPtr( LIST_ROSTER, from )) != NULL ) {
- ListRemoveResource( LIST_ROSTER, from );
+ if ( !_tcscmp(type, _T("unavailable"))) {
+ hContact = HContactFromJID(from);
+ if ((item = ListGetItemPtr(LIST_ROSTER, from)) != NULL) {
+ ListRemoveResource(LIST_ROSTER, from);
- hContact = HContactFromJID( from );
- if ( hContact && DBGetContactSettingByte( hContact, "CList", "NotOnList", 0) == 1 ) {
+ hContact = HContactFromJID(from);
+ if (hContact && db_get_b(hContact, "CList", "NotOnList", 0) == 1) {
// remove selfcontact, if where is no more another resources
- if ( item->resourceCount == 1 && ResourceInfoFromJID( info->fullJID ))
- ListRemoveResource( LIST_ROSTER, info->fullJID );
+ if (item->resourceCount == 1 && ResourceInfoFromJID(info->fullJID))
+ ListRemoveResource(LIST_ROSTER, info->fullJID);
}
// set status only if no more available resources
- if ( !item->resourceCount )
+ if ( !item->resourceCount)
{
item->itemResource.status = ID_STATUS_OFFLINE;
- if ((( statusNode = xmlGetChild( node , "status" )) != NULL ) && xmlGetText( statusNode ))
- replaceStrT( item->itemResource.statusMessage, xmlGetText( statusNode ));
+ if (((statusNode = xmlGetChild(node , "status")) != NULL) && xmlGetText(statusNode))
+ replaceStrT(item->itemResource.statusMessage, xmlGetText(statusNode));
else
- replaceStrT( item->itemResource.statusMessage, NULL );
+ replaceStrT(item->itemResource.statusMessage, NULL);
}
}
- else Log( "SKIP Receive presence offline from " TCHAR_STR_PARAM " ( who is not in my roster )", from );
+ else Log("SKIP Receive presence offline from " TCHAR_STR_PARAM " (who is not in my roster)", from);
- UpdateJidDbSettings( from );
+ UpdateJidDbSettings(from);
- if ( _tcschr( from, '@' )==NULL ) {
+ if (_tcschr(from, '@')==NULL) {
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
}
DBCheckIsTransportedContact(from, hContact);
return;
}
- if ( !_tcscmp( type, _T("subscribe"))) {
- if (hContact = HContactFromJID( from ))
- AddDbPresenceEvent( hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBE );
+ if ( !_tcscmp(type, _T("subscribe"))) {
+ if (hContact = HContactFromJID(from))
+ AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBE);
// automatically send authorization allowed to agent/transport
- if ( _tcschr( from, '@' ) == NULL || m_options.AutoAcceptAuthorization ) {
- ListAdd( LIST_ROSTER, from );
- info->send( XmlNode( _T("presence")) << XATTR( _T("to"), from ) << XATTR( _T("type"), _T("subscribed")));
-
- if ( m_options.AutoAdd == TRUE ) {
- if (( item = ListGetItemPtr( LIST_ROSTER, from )) == NULL || ( item->subscription != SUB_BOTH && item->subscription != SUB_TO )) {
- Log( "Try adding contact automatically jid = " TCHAR_STR_PARAM, from );
- if (( hContact=AddToListByJID( from, 0 )) != NULL ) {
+ if (_tcschr(from, '@') == NULL || m_options.AutoAcceptAuthorization) {
+ ListAdd(LIST_ROSTER, from);
+ info->send(XmlNode(_T("presence")) << XATTR(_T("to"), from) << XATTR(_T("type"), _T("subscribed")));
+
+ if (m_options.AutoAdd == TRUE) {
+ if ((item = ListGetItemPtr(LIST_ROSTER, from)) == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) {
+ Log("Try adding contact automatically jid = " TCHAR_STR_PARAM, from);
+ if ((hContact=AddToListByJID(from, 0)) != NULL) {
// Trigger actual add by removing the "NotOnList" added by AddToListByJID()
// See AddToListByJID() and JabberDbSettingChanged().
- DBDeleteContactSetting( hContact, "CList", "NotOnList" );
+ DBDeleteContactSetting(hContact, "CList", "NotOnList");
} } }
RebuildInfoFrame();
}
else {
- HXML n = xmlGetChild( node , "nick" );
- nick = ( n == NULL ) ? JabberNickFromJID( from ) : mir_tstrdup( xmlGetText( n ));
- if ( nick != NULL ) {
- Log( TCHAR_STR_PARAM " ( " TCHAR_STR_PARAM " ) requests authorization", nick, from );
- DBAddAuthRequest( from, nick );
- mir_free( nick );
+ HXML n = xmlGetChild(node , "nick");
+ nick = (n == NULL) ? JabberNickFromJID(from) : mir_tstrdup(xmlGetText(n));
+ if (nick != NULL) {
+ Log(TCHAR_STR_PARAM " (" TCHAR_STR_PARAM ") requests authorization", nick, from);
+ DBAddAuthRequest(from, nick);
+ mir_free(nick);
} }
return;
}
- if ( !_tcscmp( type, _T("unsubscribe"))) {
- if (hContact = HContactFromJID( from ))
- AddDbPresenceEvent( hContact, JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE );
+ if ( !_tcscmp(type, _T("unsubscribe"))) {
+ if (hContact = HContactFromJID(from))
+ AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE);
}
- if ( !_tcscmp( type, _T("unsubscribed"))) {
- if (hContact = HContactFromJID( from ))
- AddDbPresenceEvent( hContact, JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED );
+ if ( !_tcscmp(type, _T("unsubscribed"))) {
+ if (hContact = HContactFromJID(from))
+ AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED);
}
- if ( !_tcscmp( type, _T("error"))) {
- if (hContact = HContactFromJID( from )) {
- AddDbPresenceEvent( hContact, JABBER_DB_EVENT_PRESENCE_ERROR );
+ if ( !_tcscmp(type, _T("error"))) {
+ if (hContact = HContactFromJID(from)) {
+ AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_ERROR);
}
}
- if ( !_tcscmp( type, _T("subscribed"))) {
+ if ( !_tcscmp(type, _T("subscribed"))) {
- if (hContact = HContactFromJID( from ))
- AddDbPresenceEvent( hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBED );
+ if (hContact = HContactFromJID(from))
+ AddDbPresenceEvent(hContact, JABBER_DB_EVENT_PRESENCE_SUBSCRIBED);
- if (( item=ListGetItemPtr( LIST_ROSTER, from )) != NULL ) {
- if ( item->subscription == SUB_FROM ) item->subscription = SUB_BOTH;
- else if ( item->subscription == SUB_NONE ) {
+ if ((item=ListGetItemPtr(LIST_ROSTER, from)) != NULL) {
+ if (item->subscription == SUB_FROM) item->subscription = SUB_BOTH;
+ else if (item->subscription == SUB_NONE) {
item->subscription = SUB_TO;
- if ( _tcschr( from, '@' )==NULL ) {
+ if (_tcschr(from, '@')==NULL) {
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
}
}
- UpdateSubscriptionInfo( hContact, item );
+ UpdateSubscriptionInfo(hContact, item);
}
}
}
-void CJabberProto::OnIqResultVersion( HXML /*node*/, CJabberIqInfo *pInfo )
+void CJabberProto::OnIqResultVersion(HXML /*node*/, CJabberIqInfo *pInfo)
{
- JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID( pInfo->GetFrom());
- if ( r == NULL ) return;
+ JABBER_RESOURCE_STATUS *r = ResourceInfoFromJID(pInfo->GetFrom());
+ if (r == NULL) return;
r->dwVersionRequestTime = -1;
- replaceStrT( r->software, NULL );
- replaceStrT( r->version, NULL );
- replaceStrT( r->system, NULL );
+ replaceStrT(r->software, NULL);
+ replaceStrT(r->version, NULL);
+ replaceStrT(r->system, NULL);
HXML queryNode = pInfo->GetChildNode();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && queryNode) {
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && queryNode) {
HXML n;
- if (( n = xmlGetChild( queryNode , "name" ))!=NULL && xmlGetText( n ))
- r->software = mir_tstrdup( xmlGetText( n ));
- if (( n = xmlGetChild( queryNode , "version" ))!=NULL && xmlGetText( n ))
- r->version = mir_tstrdup( xmlGetText( n ));
- if (( n = xmlGetChild( queryNode , "os" ))!=NULL && xmlGetText( n ))
- r->system = mir_tstrdup( xmlGetText( n ));
+ if ((n = xmlGetChild(queryNode , "name"))!=NULL && xmlGetText(n))
+ r->software = mir_tstrdup(xmlGetText(n));
+ if ((n = xmlGetChild(queryNode , "version"))!=NULL && xmlGetText(n))
+ r->version = mir_tstrdup(xmlGetText(n));
+ if ((n = xmlGetChild(queryNode , "os"))!=NULL && xmlGetText(n))
+ r->system = mir_tstrdup(xmlGetText(n));
}
- GetResourceCapabilites( pInfo->GetFrom(), TRUE );
- if ( pInfo->GetHContact())
- UpdateMirVer( pInfo->GetHContact(), r );
+ GetResourceCapabilites(pInfo->GetFrom(), TRUE);
+ if (pInfo->GetHContact())
+ UpdateMirVer(pInfo->GetHContact(), r);
JabberUserInfoUpdate(pInfo->GetHContact());
}
-BOOL CJabberProto::OnProcessJingle( HXML node )
+BOOL CJabberProto::OnProcessJingle(HXML node)
{
LPCTSTR type;
- HXML child = xmlGetChildByTag( node, _T("jingle"), _T("xmlns"), _T(JABBER_FEAT_JINGLE));
-
- if ( child ) {
- if (( type=xmlGetAttrValue( node, _T("type"))) == NULL ) return FALSE;
- if (( !_tcscmp( type, _T("get")) || !_tcscmp( type, _T("set")))) {
- LPCTSTR szAction = xmlGetAttrValue( child, _T("action"));
- LPCTSTR idStr = xmlGetAttrValue( node, _T("id"));
- LPCTSTR from = xmlGetAttrValue( node, _T("from"));
- if ( szAction && !_tcscmp( szAction, _T("session-initiate"))) {
+ HXML child = xmlGetChildByTag(node, _T("jingle"), _T("xmlns"), _T(JABBER_FEAT_JINGLE));
+
+ if (child) {
+ if ((type=xmlGetAttrValue(node, _T("type"))) == NULL) return FALSE;
+ if ((!_tcscmp(type, _T("get")) || !_tcscmp(type, _T("set")))) {
+ LPCTSTR szAction = xmlGetAttrValue(child, _T("action"));
+ LPCTSTR idStr = xmlGetAttrValue(node, _T("id"));
+ LPCTSTR from = xmlGetAttrValue(node, _T("from"));
+ if (szAction && !_tcscmp(szAction, _T("session-initiate"))) {
// if this is a Jingle 'session-initiate' and noone processed it yet, reply with "unsupported-applications"
- m_ThreadInfo->send( XmlNodeIq( _T("result"), idStr, from ));
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), idStr, from));
- XmlNodeIq iq( _T("set"), SerialNext(), from );
- HXML jingleNode = iq << XCHILDNS( _T("jingle"), _T(JABBER_FEAT_JINGLE));
-
- jingleNode << XATTR( _T("action"), _T("session-terminate"));
- LPCTSTR szInitiator = xmlGetAttrValue( child, _T("initiator"));
- if ( szInitiator )
- jingleNode << XATTR( _T("initiator"), szInitiator );
- LPCTSTR szSid = xmlGetAttrValue( child, _T("sid"));
- if ( szSid )
- jingleNode << XATTR( _T("sid"), szSid );
-
- jingleNode << XCHILD( _T("reason"))
- << XCHILD( _T("unsupported-applications"));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("set"), SerialNext(), from);
+ HXML jingleNode = iq << XCHILDNS(_T("jingle"), _T(JABBER_FEAT_JINGLE));
+
+ jingleNode << XATTR(_T("action"), _T("session-terminate"));
+ LPCTSTR szInitiator = xmlGetAttrValue(child, _T("initiator"));
+ if (szInitiator)
+ jingleNode << XATTR(_T("initiator"), szInitiator);
+ LPCTSTR szSid = xmlGetAttrValue(child, _T("sid"));
+ if (szSid)
+ jingleNode << XATTR(_T("sid"), szSid);
+
+ jingleNode << XCHILD(_T("reason"))
+ << XCHILD(_T("unsupported-applications"));
+ m_ThreadInfo->send(iq);
return TRUE;
}
else {
// if it's something else than 'session-initiate' and noone processed it yet, reply with "unknown-session"
- XmlNodeIq iq( _T("error"), idStr, from );
- HXML errNode = iq << XCHILD( _T("error"));
- errNode << XATTR( _T("type"), _T("cancel"));
- errNode << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
- errNode << XCHILDNS( _T("unknown-session"), _T("urn:xmpp:jingle:errors:1"));
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("error"), idStr, from);
+ HXML errNode = iq << XCHILD(_T("error"));
+ errNode << XATTR(_T("type"), _T("cancel"));
+ errNode << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
+ errNode << XCHILDNS(_T("unknown-session"), _T("urn:xmpp:jingle:errors:1"));
+ m_ThreadInfo->send(iq);
return TRUE;
}
}
@@ -1926,116 +1924,116 @@ BOOL CJabberProto::OnProcessJingle( HXML node ) return FALSE;
}
-void CJabberProto::OnProcessIq( HXML node )
+void CJabberProto::OnProcessIq(HXML node)
{
HXML queryNode;
const TCHAR *type, *xmlns;
JABBER_IQ_PFUNC pfunc;
- if ( !xmlGetName( node ) || _tcscmp( xmlGetName( node ), _T("iq"))) return;
- if (( type=xmlGetAttrValue( node, _T("type"))) == NULL ) return;
+ if ( !xmlGetName(node) || _tcscmp(xmlGetName(node), _T("iq"))) return;
+ if ((type=xmlGetAttrValue(node, _T("type"))) == NULL) return;
- int id = JabberGetPacketID( node );
- const TCHAR* idStr = xmlGetAttrValue( node, _T("id"));
+ int id = JabberGetPacketID(node);
+ const TCHAR *idStr = xmlGetAttrValue(node, _T("id"));
- queryNode = xmlGetChild( node , "query" );
- xmlns = xmlGetAttrValue( queryNode, _T("xmlns"));
+ queryNode = xmlGetChild(node , "query");
+ xmlns = xmlGetAttrValue(queryNode, _T("xmlns"));
// new match by id
- if ( m_iqManager.HandleIq( id, node ))
+ if (m_iqManager.HandleIq(id, node))
return;
// new iq handler engine
- if ( m_iqManager.HandleIqPermanent( node ))
+ if (m_iqManager.HandleIqPermanent(node))
return;
// Jingle support
- if ( OnProcessJingle( node ))
+ if (OnProcessJingle(node))
return;
/////////////////////////////////////////////////////////////////////////
// OLD MATCH BY ID
/////////////////////////////////////////////////////////////////////////
- if ( ( !_tcscmp( type, _T("result")) || !_tcscmp( type, _T("error"))) && (( pfunc=JabberIqFetchFunc( id )) != NULL )) {
- Log( "Handling iq request for id=%d", id );
- (this->*pfunc)( node );
+ if ((!_tcscmp(type, _T("result")) || !_tcscmp(type, _T("error"))) && ((pfunc=JabberIqFetchFunc(id)) != NULL)) {
+ Log("Handling iq request for id=%d", id);
+ (this->*pfunc)(node);
return;
}
// RECVED: <iq type='error'> ...
- else if ( !_tcscmp( type, _T("error"))) {
- Log( "XXX on entry" );
+ else if ( !_tcscmp(type, _T("error"))) {
+ Log("XXX on entry");
// Check for file transfer deny by comparing idStr with ft->iqId
LISTFOREACH(i, this, LIST_FILE)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex( i );
- if ( item->ft != NULL && item->ft->state == FT_CONNECTING && !_tcscmp( idStr, item->ft->iqId )) {
- Log( "Denying file sending request" );
+ JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ if (item->ft != NULL && item->ft->state == FT_CONNECTING && !_tcscmp(idStr, item->ft->iqId)) {
+ Log("Denying file sending request");
item->ft->state = FT_DENIED;
- if ( item->ft->hFileEvent != NULL )
- SetEvent( item->ft->hFileEvent ); // Simulate the termination of file server connection
+ if (item->ft->hFileEvent != NULL)
+ SetEvent(item->ft->hFileEvent); // Simulate the termination of file server connection
}
} }
- else if (( !_tcscmp( type, _T("get")) || !_tcscmp( type, _T("set")))) {
- XmlNodeIq iq( _T("error"), idStr, xmlGetAttrValue( node, _T("from")));
+ else if ((!_tcscmp(type, _T("get")) || !_tcscmp(type, _T("set")))) {
+ XmlNodeIq iq(_T("error"), idStr, xmlGetAttrValue(node, _T("from")));
- HXML pFirstChild = xmlGetChild( node , 0 );
- if ( pFirstChild )
- xmlAddChild( iq, pFirstChild );
+ HXML pFirstChild = xmlGetChild(node , 0);
+ if (pFirstChild)
+ xmlAddChild(iq, pFirstChild);
- iq << XCHILD( _T("error")) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("service-unavailable"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
- m_ThreadInfo->send( iq );
+ iq << XCHILD(_T("error")) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("service-unavailable"), _T("urn:ietf:params:xml:ns:xmpp-stanzas"));
+ m_ThreadInfo->send(iq);
}
}
-void CJabberProto::OnProcessRegIq( HXML node, ThreadData* info )
+void CJabberProto::OnProcessRegIq(HXML node, ThreadData* info)
{
HXML errorNode;
const TCHAR *type;
- if ( !xmlGetName( node ) || _tcscmp( xmlGetName( node ), _T("iq"))) return;
- if (( type=xmlGetAttrValue( node, _T("type"))) == NULL ) return;
+ if ( !xmlGetName(node) || _tcscmp(xmlGetName(node), _T("iq"))) return;
+ if ((type=xmlGetAttrValue(node, _T("type"))) == NULL) return;
- int id = JabberGetPacketID( node );
+ int id = JabberGetPacketID(node);
- if ( !_tcscmp( type, _T("result"))) {
+ if ( !_tcscmp(type, _T("result"))) {
// RECVED: result of the request for registration mechanism
// ACTION: send account registration information
- if ( id == iqIdRegGetReg ) {
+ if (id == iqIdRegGetReg) {
iqIdRegSetReg = SerialNext();
- XmlNodeIq iq( _T("set"), iqIdRegSetReg );
- HXML query = iq << XQUERY( _T(JABBER_FEAT_REGISTER));
- query << XCHILD( _T("password"), info->password );
- query << XCHILD( _T("username"), info->username );
- info->send( iq );
+ XmlNodeIq iq(_T("set"), iqIdRegSetReg);
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_REGISTER));
+ query << XCHILD(_T("password"), info->password);
+ query << XCHILD(_T("username"), info->username);
+ info->send(iq);
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 75, ( LPARAM )TranslateT( "Sending registration information..." ));
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 75, (LPARAM)TranslateT("Sending registration information..."));
}
// RECVED: result of the registration process
// ACTION: account registration successful
- else if ( id == iqIdRegSetReg ) {
- info->send( "</stream:stream>" );
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )TranslateT( "Registration successful" ));
+ else if (id == iqIdRegSetReg) {
+ info->send("</stream:stream>");
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Registration successful"));
info->reg_done = TRUE;
} }
- else if ( !_tcscmp( type, _T("error"))) {
- errorNode = xmlGetChild( node , "error" );
- TCHAR* str = JabberErrorMsg( errorNode );
- SendMessage( info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, ( LPARAM )str );
- mir_free( str );
+ else if ( !_tcscmp(type, _T("error"))) {
+ errorNode = xmlGetChild(node , "error");
+ TCHAR* str = JabberErrorMsg(errorNode);
+ SendMessage(info->reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)str);
+ mir_free(str);
info->reg_done = TRUE;
- info->send( "</stream:stream>" );
+ info->send("</stream:stream>");
} }
/////////////////////////////////////////////////////////////////////////////////////////
// ThreadData constructor & destructor
-ThreadData::ThreadData( CJabberProto* aproto, JABBER_SESSION_TYPE parType )
+ThreadData::ThreadData(CJabberProto* aproto, JABBER_SESSION_TYPE parType)
{
- memset( this, 0, sizeof( *this ));
+ memset(this, 0, sizeof(*this));
type = parType;
proto = aproto;
iomutex = CreateMutex(NULL, FALSE, NULL);
@@ -2043,79 +2041,79 @@ ThreadData::ThreadData( CJabberProto* aproto, JABBER_SESSION_TYPE parType ) ThreadData::~ThreadData()
{
- if ( auth ) delete auth;
- mir_free( zRecvData );
- CloseHandle( iomutex );
+ if (auth) delete auth;
+ mir_free(zRecvData);
+ CloseHandle(iomutex);
CloseHandle(hThread);
}
-void ThreadData::close( void )
+void ThreadData::close(void)
{
- if ( s ) {
+ if (s) {
Netlib_CloseHandle(s);
s = NULL;
} }
-void ThreadData::shutdown( void )
+void ThreadData::shutdown(void)
{
- if ( s )
+ if (s)
Netlib_Shutdown(s);
}
-int ThreadData::recvws( char* buf, size_t len, int flags )
+int ThreadData::recvws(char* buf, size_t len, int flags)
{
- if ( this == NULL )
+ if (this == NULL)
return 0;
- return proto->WsRecv( s, buf, (int)len, flags );
+ return proto->WsRecv(s, buf, (int)len, flags);
}
-int ThreadData::recv( char* buf, size_t len )
+int ThreadData::recv(char* buf, size_t len)
{
- if ( useZlib )
- return zlibRecv( buf, (long)len );
+ if (useZlib)
+ return zlibRecv(buf, (long)len);
- return recvws( buf, len, MSG_DUMPASTEXT );
+ return recvws(buf, len, MSG_DUMPASTEXT);
}
-int ThreadData::sendws( char* buffer, size_t bufsize, int flags )
+int ThreadData::sendws(char* buffer, size_t bufsize, int flags)
{
- return proto->WsSend( s, buffer, (int)bufsize, flags );
+ return proto->WsSend(s, buffer, (int)bufsize, flags);
}
-int ThreadData::send( char* buffer, int bufsize )
+int ThreadData::send(char* buffer, int bufsize)
{
- if ( this == NULL )
+ if (this == NULL)
return 0;
int result;
- WaitForSingleObject( iomutex, 6000 );
+ WaitForSingleObject(iomutex, 6000);
- if ( useZlib )
- result = zlibSend( buffer, bufsize );
+ if (useZlib)
+ result = zlibSend(buffer, bufsize);
else
- result = sendws( buffer, bufsize, MSG_DUMPASTEXT );
+ result = sendws(buffer, bufsize, MSG_DUMPASTEXT);
- ReleaseMutex( iomutex );
+ ReleaseMutex(iomutex);
return result;
}
-// Caution: DO NOT use ->send() to send binary ( non-string ) data
-int ThreadData::send( HXML node )
+// Caution: DO NOT use ->send() to send binary (non-string) data
+int ThreadData::send(HXML node)
{
- if ( this == NULL )
+ if (this == NULL)
return 0;
- while ( HXML parent = xi.getParent( node ))
+ while (HXML parent = xi.getParent(node))
node = parent;
- if ( proto->m_sendManager.HandleSendPermanent( node, this ))
+ if (proto->m_sendManager.HandleSendPermanent(node, this))
return 0;
proto->OnConsoleProcessXml(node, JCPF_OUT);
- TCHAR* str = xi.toString( node, NULL );
+ TCHAR* str = xi.toString(node, NULL);
// strip forbidden control characters from outgoing XML stream
TCHAR *q = str;
@@ -2131,31 +2129,31 @@ int ThreadData::send( HXML node ) *q = 0;
- char* utfStr = mir_utf8encodeT( str );
- int result = send( utfStr, (int)strlen( utfStr ));
- mir_free( utfStr );
+ char* utfStr = mir_utf8encodeT(str);
+ int result = send(utfStr, (int)strlen(utfStr));
+ mir_free(utfStr);
- xi.freeMem( str );
+ xi.freeMem(str);
return result;
}
-int ThreadData::send( const char* fmt, ... )
+int ThreadData::send(const char* fmt, ...)
{
- if ( this == NULL )
+ if (this == NULL)
return 0;
va_list vararg;
- va_start( vararg, fmt );
+ va_start(vararg, fmt);
int size = 512;
- char* str = ( char* )mir_alloc( size );
- while ( _vsnprintf( str, size, fmt, vararg ) == -1 ) {
+ char* str = (char*)mir_alloc(size);
+ while (_vsnprintf(str, size, fmt, vararg) == -1) {
size += 512;
- str = ( char* )mir_realloc( str, size );
+ str = (char*)mir_realloc(str, size);
}
- va_end( vararg );
+ va_end(vararg);
- int result = send( str, (int)strlen( str ));
+ int result = send(str, (int)strlen(str));
- mir_free( str );
+ mir_free(str);
return result;
}
diff --git a/protocols/JabberG/src/jabber_treelist.cpp b/protocols/JabberG/src/jabber_treelist.cpp index 8e1e28cb45..f98422c8bc 100644 --- a/protocols/JabberG/src/jabber_treelist.cpp +++ b/protocols/JabberG/src/jabber_treelist.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Victor Pavlychko
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
@@ -49,10 +49,10 @@ struct TTreeList_ItemInfo ~TTreeList_ItemInfo()
{
int i;
- for (i = text.getCount(); i--; )
+ for (i = text.getCount(); i--;)
mir_free(text[i]);
text.destroy();
- for (i = subItems.getCount(); i--; )
+ for (i = subItems.getCount(); i--;)
delete subItems[i];
subItems.destroy();
}
@@ -128,16 +128,16 @@ void TreeList_Create(HWND hwnd) data->hItemSelected = data->root;
sttTreeList_SeWindowData(hwnd, data);
- ListView_SetExtendedListViewStyle(hwnd, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_INFOTIP );
+ ListView_SetExtendedListViewStyle(hwnd, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
HIMAGELIST hIml;
- hIml = ImageList_Create(16, 16, ILC_MASK + ( IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 ), 2, 1);
+ hIml = ImageList_Create(16, 16, ILC_MASK + (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 2, 1);
ListView_SetImageList (hwnd, hIml, LVSIL_SMALL);
- hIml = ImageList_Create(16, 16, ILC_MASK + ( IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 ), 2, 1);
- ImageList_AddIcon_Icolib(hIml, (HICON)CallService( MS_SKIN_LOADICON, SKINICON_OTHER_GROUPOPEN, 0 ));
- ImageList_AddIcon_Icolib(hIml, (HICON)CallService( MS_SKIN_LOADICON, SKINICON_OTHER_GROUPSHUT, 0 ));
- ImageList_AddIcon_Icolib(hIml, (HICON)CallService( MS_SKIN_LOADICON, SKINICON_OTHER_DOWNARROW, 0 ));
+ hIml = ImageList_Create(16, 16, ILC_MASK + (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 2, 1);
+ ImageList_AddIcon_Icolib(hIml, (HICON)CallService(MS_SKIN_LOADICON, SKINICON_OTHER_GROUPOPEN, 0));
+ ImageList_AddIcon_Icolib(hIml, (HICON)CallService(MS_SKIN_LOADICON, SKINICON_OTHER_GROUPSHUT, 0));
+ ImageList_AddIcon_Icolib(hIml, (HICON)CallService(MS_SKIN_LOADICON, SKINICON_OTHER_DOWNARROW, 0));
ListView_SetImageList (hwnd, hIml, LVSIL_STATE);
}
@@ -201,7 +201,7 @@ HTREELISTITEM TreeList_GetActiveItem(HWND hwnd) HTREELISTITEM TreeList_AddItem(HWND hwnd, HTREELISTITEM hParent, TCHAR *text, LPARAM nodeDdata)
{
TTreeList_Data *data = (TTreeList_Data *)sttTreeList_GeWindowData(hwnd);
- if (!hParent) hParent = data->root;
+ if ( !hParent) hParent = data->root;
TTreeList_ItemInfo *item = new TTreeList_ItemInfo;
item->data = nodeDdata;
@@ -222,7 +222,7 @@ void TreeList_ResetItem(HWND hwnd, HTREELISTITEM hParent) {
TTreeList_Data *data = (TTreeList_Data *)sttTreeList_GeWindowData(hwnd);
- for (int i = hParent->subItems.getCount(); i--; )
+ for (int i = hParent->subItems.getCount(); i--;)
delete hParent->subItems[i];
hParent->subItems.destroy();
@@ -263,9 +263,9 @@ void TreeList_SetIcon(HTREELISTITEM hItem, int iIcon, int iOverlay) void TreeList_RecursiveApply(HTREELISTITEM hItem, void (*func)(HTREELISTITEM, LPARAM), LPARAM data)
{
- for ( int i = 0; i < hItem->subItems.getCount(); i++ ) {
- func( hItem->subItems[i], data );
- TreeList_RecursiveApply( hItem->subItems[i], func, data );
+ for (int i = 0; i < hItem->subItems.getCount(); i++) {
+ func(hItem->subItems[i], data);
+ TreeList_RecursiveApply(hItem->subItems[i], func, data);
} }
void TreeList_Update(HWND hwnd)
@@ -280,17 +280,17 @@ void TreeList_Update(HWND hwnd) TreeList_RecursiveApply(hItem, sttTreeList_ResetIndex, (LPARAM)&sortIndex);
if (data->filter)
TreeList_RecursiveApply(hItem, sttTreeList_FilterItems, (LPARAM)data->filter);
- for ( int i = ListView_GetItemCount(hwnd); i--; ) {
+ for (int i = ListView_GetItemCount(hwnd); i--;) {
LVITEM lvi = {0};
lvi.mask = LVIF_PARAM;
lvi.iItem = i;
lvi.iSubItem = 0;
ListView_GetItem(hwnd, &lvi);
- HTREELISTITEM ptli = ( HTREELISTITEM )lvi.lParam;
- if (( ptli->flags & TLIF_VISIBLE ) && (!data->filter || ( ptli->flags & TLIF_FILTERED ))) {
+ HTREELISTITEM ptli = (HTREELISTITEM)lvi.lParam;
+ if ((ptli->flags & TLIF_VISIBLE) && (!data->filter || (ptli->flags & TLIF_FILTERED))) {
ptli->flags |= TLIF_HASITEM;
- if ( ptli->flags & TLIF_MODIFIED ) {
+ if (ptli->flags & TLIF_MODIFIED) {
lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE | LVIF_TEXT;
lvi.iItem = i;
lvi.iSubItem = 0;
@@ -302,18 +302,18 @@ void TreeList_Update(HWND hwnd) lvi.state =
INDEXTOSTATEIMAGEMASK(
((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 :
- (ptli->flags & TLIF_EXPANDED) ? 1 : 2 ) |
- INDEXTOOVERLAYMASK( ptli->iOverlay );
+ (ptli->flags & TLIF_EXPANDED) ? 1 : 2) |
+ INDEXTOOVERLAYMASK(ptli->iOverlay);
} else
{
lvi.state =
INDEXTOSTATEIMAGEMASK(
- ((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 : 3 ) |
- INDEXTOOVERLAYMASK( ptli->iOverlay );
+ ((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 : 3) |
+ INDEXTOOVERLAYMASK(ptli->iOverlay);
}
ListView_SetItem(hwnd, &lvi);
for (int j = 1; j < ptli->text.getCount(); ++j)
- ListView_SetItemText( hwnd, i, j, ptli->text[j]);
+ ListView_SetItemText(hwnd, i, j, ptli->text[j]);
}
}
else ListView_DeleteItem(hwnd, i);
@@ -322,7 +322,7 @@ void TreeList_Update(HWND hwnd) TreeList_RecursiveApply(hItem, sttTreeList_CreateItems, (LPARAM)hwnd);
else
{
- for (int i = data->hItemSelected->subItems.getCount(); i--; )
+ for (int i = data->hItemSelected->subItems.getCount(); i--;)
sttTreeList_CreateItems_List(data->hItemSelected->subItems[i], (LPARAM)hwnd);
for (HTREELISTITEM hItem = data->hItemSelected; !(hItem->flags & TLIF_ROOT); hItem = hItem->parent)
sttTreeList_CreateItems_List(hItem, (LPARAM)hwnd);
@@ -332,7 +332,7 @@ void TreeList_Update(HWND hwnd) UpdateWindow(hwnd);
}
-BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT idc, BOOL* )
+BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT idc, BOOL*)
{
LVITEM lvi = {0};
@@ -359,7 +359,7 @@ BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT id ListView_GetItem(lpnmia->hdr.hwndFrom, &lvi);
HTREELISTITEM hItem = (lvi.iItem < 0) ? data-> root : (HTREELISTITEM)lvi.lParam;
- if (!hItem->subItems.getCount() && !(hItem->flags & TLIF_FAKEPARENT)) break;
+ if ( !hItem->subItems.getCount() && !(hItem->flags & TLIF_FAKEPARENT)) break;
data->hItemSelected = hItem;
NMTREEVIEW nmtv;
@@ -392,13 +392,13 @@ BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT id case VK_SUBTRACT:
case VK_LEFT:
{
- if ( hItem->subItems.getCount() && (hItem->flags & TLIF_EXPANDED )) {
+ if (hItem->subItems.getCount() && (hItem->flags & TLIF_EXPANDED)) {
hItem->flags &= ~TLIF_EXPANDED;
hItem->flags |= TLIF_MODIFIED;
- TreeList_Update( lpnmlvk->hdr.hwndFrom );
+ TreeList_Update(lpnmlvk->hdr.hwndFrom);
}
- else if ( hItem->indent && (lpnmlvk->wVKey != VK_SUBTRACT )) {
- for ( int i = lvi.iItem; i--; ) {
+ else if (hItem->indent && (lpnmlvk->wVKey != VK_SUBTRACT)) {
+ for (int i = lvi.iItem; i--;) {
lvi.mask = LVIF_INDENT;
lvi.iItem = i;
lvi.iSubItem = 0;
@@ -416,8 +416,8 @@ BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT id case VK_ADD:
case VK_RIGHT:
- if ( (hItem->subItems.getCount() || (hItem->flags & TLIF_FAKEPARENT)) &&
- !( hItem->flags & TLIF_EXPANDED ))
+ if ((hItem->subItems.getCount() || (hItem->flags & TLIF_FAKEPARENT)) &&
+ !(hItem->flags & TLIF_EXPANDED))
{
hItem->flags |= TLIF_EXPANDED;
hItem->flags |= TLIF_MODIFIED;
@@ -428,7 +428,7 @@ BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT id nmtv.hdr.idFrom = lpnmlvk->hdr.idFrom;
nmtv.itemNew.hItem = (HTREEITEM)hItem;
SendMessage(hwnd, WM_NOTIFY, lpnmlvk->hdr.idFrom, (LPARAM)&nmtv);
- TreeList_Update( lpnmlvk->hdr.hwndFrom );
+ TreeList_Update(lpnmlvk->hdr.hwndFrom);
}
break;
} }
@@ -444,11 +444,11 @@ BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT id lvhti.pt = lpnmia->ptAction;
ListView_HitTest(lpnmia->hdr.hwndFrom, &lvhti);
- HTREELISTITEM ptli = ( HTREELISTITEM )lvi.lParam;
- if ((lvhti.iSubItem == 0) && ( (lvhti.flags&LVHT_ONITEM) == LVHT_ONITEMSTATEICON ) &&
+ HTREELISTITEM ptli = (HTREELISTITEM)lvi.lParam;
+ if ((lvhti.iSubItem == 0) && ((lvhti.flags&LVHT_ONITEM) == LVHT_ONITEMSTATEICON) &&
(ptli->subItems.getCount() || ptli->flags & TLIF_FAKEPARENT))
{
- if ( ptli->flags & TLIF_EXPANDED )
+ if (ptli->flags & TLIF_EXPANDED)
ptli->flags &= ~TLIF_EXPANDED;
else {
ptli->flags |= TLIF_EXPANDED;
@@ -461,7 +461,7 @@ BOOL TreeList_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, UINT id SendMessage(hwnd, WM_NOTIFY, lpnmia->hdr.idFrom, (LPARAM)&nmtv);
}
ptli->flags |= TLIF_MODIFIED;
- TreeList_Update( lpnmia->hdr.hwndFrom );
+ TreeList_Update(lpnmia->hdr.hwndFrom);
} }
break;
}
@@ -480,7 +480,7 @@ static int sttTreeList_SortItems_Cmp5(const void *p1, const void *p2) { return - static void sttTreeList_SortItems(HTREELISTITEM hItem, LPARAM data)
{
- if (!hItem->subItems.getCount()) return;
+ if ( !hItem->subItems.getCount()) return;
typedef int (__cdecl *TQSortCmp)(const void *, const void *);
static TQSortCmp funcs[] =
@@ -492,14 +492,14 @@ static void sttTreeList_SortItems(HTREELISTITEM hItem, LPARAM data) sttTreeList_SortItems_Cmp4,
sttTreeList_SortItems_Cmp5,
};
- qsort(((SortedList *)&hItem->subItems)->items, hItem->subItems.getCount(), sizeof(void *), funcs[data-1]);
+ qsort(((SortedList *)&hItem->subItems)->items, hItem->subItems.getCount(), sizeof(void*), funcs[data-1]);
}
static void sttTreeList_ResetIndex(HTREELISTITEM hItem, LPARAM data)
{
hItem->flags &= ~TLIF_HASITEM;
- if ( !hItem->parent || (hItem->parent->flags & TLIF_VISIBLE) && (hItem->parent->flags & TLIF_EXPANDED ))
+ if ( !hItem->parent || (hItem->parent->flags & TLIF_VISIBLE) && (hItem->parent->flags & TLIF_EXPANDED))
hItem->flags |= TLIF_VISIBLE;
else
hItem->flags &= ~TLIF_VISIBLE;
@@ -530,7 +530,7 @@ static void sttTreeList_FilterItems(HTREELISTITEM hItem, LPARAM data) static void sttTreeList_CreateItems(HTREELISTITEM hItem, LPARAM data)
{
TTreeList_Data *listData = (TTreeList_Data *)sttTreeList_GeWindowData((HWND)data);
- if (( hItem->flags & TLIF_VISIBLE ) && (!listData->filter || ( hItem->flags & TLIF_FILTERED )) && !( hItem->flags & TLIF_HASITEM ) && !( hItem->flags & TLIF_ROOT )) {
+ if ((hItem->flags & TLIF_VISIBLE) && (!listData->filter || (hItem->flags & TLIF_FILTERED)) && !(hItem->flags & TLIF_HASITEM) && !(hItem->flags & TLIF_ROOT)) {
LVITEM lvi = {0};
lvi.mask = LVIF_INDENT | LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT | LVIF_STATE;
lvi.iIndent = hItem->indent;
@@ -541,18 +541,18 @@ static void sttTreeList_CreateItems(HTREELISTITEM hItem, LPARAM data) lvi.state =
INDEXTOSTATEIMAGEMASK(
((hItem->subItems.getCount() == 0) && !(hItem->flags & TLIF_FAKEPARENT)) ? 0 :
- (hItem->flags & TLIF_EXPANDED) ? 1 : 2 ) |
+ (hItem->flags & TLIF_EXPANDED) ? 1 : 2) |
INDEXTOOVERLAYMASK(hItem->iOverlay);
int idx = ListView_InsertItem((HWND)data, &lvi);
- for ( int i = 1; i < hItem->text.getCount(); i++ )
+ for (int i = 1; i < hItem->text.getCount(); i++)
ListView_SetItemText((HWND)data, idx, i, hItem->text[i]);
} }
static void sttTreeList_CreateItems_List(HTREELISTITEM hItem, LPARAM data)
{
TTreeList_Data *listData = (TTreeList_Data *)sttTreeList_GeWindowData((HWND)data);
- if ((!listData->filter || ( hItem->flags & TLIF_FILTERED )) && !( hItem->flags & TLIF_HASITEM ) && !( hItem->flags & TLIF_ROOT )) {
+ if ((!listData->filter || (hItem->flags & TLIF_FILTERED)) && !(hItem->flags & TLIF_HASITEM) && !(hItem->flags & TLIF_ROOT)) {
LVITEM lvi = {0};
lvi.mask = LVIF_INDENT | LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT | LVIF_STATE;
lvi.iIndent = hItem->indent;
@@ -562,21 +562,21 @@ static void sttTreeList_CreateItems_List(HTREELISTITEM hItem, LPARAM data) lvi.iImage = hItem->iIcon;
lvi.state =
INDEXTOSTATEIMAGEMASK(
- ((hItem->subItems.getCount() == 0) && !(hItem->flags & TLIF_FAKEPARENT)) ? 0 : 3 ) |
- INDEXTOOVERLAYMASK( hItem->iOverlay );
+ ((hItem->subItems.getCount() == 0) && !(hItem->flags & TLIF_FAKEPARENT)) ? 0 : 3) |
+ INDEXTOOVERLAYMASK(hItem->iOverlay);
int idx = ListView_InsertItem((HWND)data, &lvi);
- for ( int i = 1; i < hItem->text.getCount(); i++ )
+ for (int i = 1; i < hItem->text.getCount(); i++)
ListView_SetItemText((HWND)data, idx, i, hItem->text[i]);
} }
-static int CALLBACK sttTreeList_SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM )
+static int CALLBACK sttTreeList_SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM)
{
- HTREELISTITEM p1 = ( HTREELISTITEM )lParam1, p2 = ( HTREELISTITEM )lParam2;
- if ( p1->sortIndex < p2->sortIndex )
+ HTREELISTITEM p1 = (HTREELISTITEM)lParam1, p2 = (HTREELISTITEM)lParam2;
+ if (p1->sortIndex < p2->sortIndex)
return -1;
- if ( p1->sortIndex > p2->sortIndex )
+ if (p1->sortIndex > p2->sortIndex)
return +1;
return 0;
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index cc7c0257e8..1894d79934 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -43,28 +43,28 @@ struct UserInfoStringBuf UserInfoStringBuf() { buf = 0; size = 0; offset = 0; }
~UserInfoStringBuf() { mir_free(buf); }
- void append( TCHAR *str ) {
- if ( !str ) return;
+ void append(TCHAR *str) {
+ if ( !str) return;
- int length = lstrlen( str );
- if ( size - offset < length + 1 ) {
- size += ( length + STRINGBUF_INCREMENT );
- buf = ( TCHAR * )mir_realloc( buf, size * sizeof( TCHAR ));
+ int length = lstrlen(str);
+ if (size - offset < length + 1) {
+ size += (length + STRINGBUF_INCREMENT);
+ buf = (TCHAR *)mir_realloc(buf, size * sizeof(TCHAR));
}
- lstrcpy( buf + offset, str );
+ lstrcpy(buf + offset, str);
offset += length;
}
- TCHAR *allocate( int length ) {
- if ( size - offset < length ) {
- size += ( length + STRINGBUF_INCREMENT );
- buf = ( TCHAR * )mir_realloc( buf, size * sizeof( TCHAR ));
+ TCHAR *allocate(int length) {
+ if (size - offset < length) {
+ size += (length + STRINGBUF_INCREMENT);
+ buf = (TCHAR *)mir_realloc(buf, size * sizeof(TCHAR));
}
return buf + offset;
}
void actualize() {
- if ( buf ) offset = lstrlen( buf );
+ if (buf) offset = lstrlen(buf);
}
};
@@ -107,14 +107,14 @@ enum __forceinline DWORD sttInfoLineId(DWORD res, DWORD type, DWORD line=0)
{
return
- ( type << 24 ) & 0x7f000000 |
- ( res << 12 ) & 0x00fff000 |
- ( line ) & 0x00000fff;
+ (type << 24) & 0x7f000000 |
+ (res << 12) & 0x00fff000 |
+ (line ) & 0x00000fff;
}
-static HTREEITEM sttFindInfoLine( HWND hwndTree, HTREEITEM htiRoot, LPARAM id=INFOLINE_BAD_ID )
+static HTREEITEM sttFindInfoLine(HWND hwndTree, HTREEITEM htiRoot, LPARAM id=INFOLINE_BAD_ID)
{
- if ( id == INFOLINE_BAD_ID ) return NULL;
+ if (id == INFOLINE_BAD_ID) return NULL;
for (HTREEITEM hti = TreeView_GetChild(hwndTree, htiRoot); hti; hti = TreeView_GetNextSibling(hwndTree, hti))
{
TVITEMEX tvi = {0};
@@ -158,7 +158,7 @@ void sttCleanupInfo(HWND hwndTree, int stage) hItem = hItemTmp;
else {
while (1) {
- if (!(hItem = TreeView_GetParent(hwndTree, hItem))) break;
+ if ( !(hItem = TreeView_GetParent(hwndTree, hItem))) break;
if (hItemTmp = TreeView_GetNextSibling(hwndTree, hItem)) {
hItem = hItemTmp;
break;
@@ -168,15 +168,15 @@ void sttCleanupInfo(HWND hwndTree, int stage) }
}
-static HTREEITEM sttFillInfoLine( HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, TCHAR *title, TCHAR *value, LPARAM id=INFOLINE_BAD_ID, bool expand=false )
+static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, TCHAR *title, TCHAR *value, LPARAM id=INFOLINE_BAD_ID, bool expand=false)
{
HTREEITEM hti = sttFindInfoLine(hwndTree, htiRoot, id);
TCHAR buf[256];
- if ( title )
- mir_sntprintf( buf, SIZEOF(buf), _T("%s: %s"), title, value );
+ if (title)
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s: %s"), title, value);
else
- lstrcpyn( buf, value, SIZEOF( buf ));
+ lstrcpyn(buf, value, SIZEOF(buf));
TVINSERTSTRUCT tvis = {0};
tvis.hParent = htiRoot;
@@ -185,42 +185,42 @@ static HTREEITEM sttFillInfoLine( HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, tvis.itemex.pszText = buf;
tvis.itemex.lParam = id;
- if ( hIcon ) {
- HIMAGELIST himl = TreeView_GetImageList( hwndTree, TVSIL_NORMAL );
+ if (hIcon) {
+ HIMAGELIST himl = TreeView_GetImageList(hwndTree, TVSIL_NORMAL);
tvis.itemex.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE;
tvis.itemex.iImage =
- tvis.itemex.iSelectedImage = ImageList_AddIcon( himl, hIcon );
- g_ReleaseIcon( hIcon );
+ tvis.itemex.iSelectedImage = ImageList_AddIcon(himl, hIcon);
+ g_ReleaseIcon(hIcon);
}
- if ( hti ) {
+ if (hti) {
tvis.itemex.mask |= TVIF_HANDLE;
tvis.itemex.hItem = hti;
- TreeView_SetItem( hwndTree, &tvis.itemex );
+ TreeView_SetItem(hwndTree, &tvis.itemex);
}
else {
tvis.itemex.mask |= TVIF_STATE;
tvis.itemex.stateMask = TVIS_EXPANDED;
tvis.itemex.state = expand ? TVIS_EXPANDED : 0;
- hti = TreeView_InsertItem( hwndTree, &tvis );
+ hti = TreeView_InsertItem(hwndTree, &tvis);
}
return hti;
}
-static void sttFillResourceInfo( CJabberProto* ppro, HWND hwndTree, HTREEITEM htiRoot, JABBER_LIST_ITEM *item, int resource )
+static void sttFillResourceInfo(CJabberProto* ppro, HWND hwndTree, HTREEITEM htiRoot, JABBER_LIST_ITEM *item, int resource)
{
TCHAR buf[256];
HTREEITEM htiResource = htiRoot;
JABBER_RESOURCE_STATUS *res = resource ? &item->resource[resource-1] : &item->itemResource;
- if ( res->resourceName && *res->resourceName )
- htiResource = sttFillInfoLine( hwndTree, htiRoot, LoadSkinnedProtoIcon( ppro->m_szModuleName, res->status ),
- TranslateT("Resource"), res->resourceName, sttInfoLineId(resource, INFOLINE_NAME), true );
+ if (res->resourceName && *res->resourceName)
+ htiResource = sttFillInfoLine(hwndTree, htiRoot, LoadSkinnedProtoIcon(ppro->m_szModuleName, res->status),
+ TranslateT("Resource"), res->resourceName, sttInfoLineId(resource, INFOLINE_NAME), true);
// StatusMsg
- sttFillInfoLine( hwndTree, htiResource, NULL /*LoadSkinnedIcon( SKINICON_EVENT_MESSAGE )*/,
- TranslateT( "Message" ), res->statusMessage ? res->statusMessage : TranslateT( "<not specified>" ),
+ sttFillInfoLine(hwndTree, htiResource, NULL /*LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)*/,
+ TranslateT("Message"), res->statusMessage ? res->statusMessage : TranslateT("<not specified>"),
sttInfoLineId(resource, INFOLINE_MESSAGE));
// Software
@@ -228,94 +228,94 @@ static void sttFillResourceInfo( CJabberProto* ppro, HWND hwndTree, HTREEITEM ht if (ServiceExists(MS_FP_GETCLIENTICONT)) {
if (res->software != NULL) {
mir_sntprintf(buf, SIZEOF(buf), _T("%s %s"), res->software, res->version);
- hIcon = (HICON)CallService( MS_FP_GETCLIENTICONT, (WPARAM)buf, 0 );
+ hIcon = (HICON)CallService(MS_FP_GETCLIENTICONT, (WPARAM)buf, 0);
} }
- sttFillInfoLine( hwndTree, htiResource, hIcon, TranslateT( "Software" ),
- res->software ? res->software : TranslateT( "<not specified>" ),
+ sttFillInfoLine(hwndTree, htiResource, hIcon, TranslateT("Software"),
+ res->software ? res->software : TranslateT("<not specified>"),
sttInfoLineId(resource, INFOLINE_SOFTWARE));
- if(hIcon)
+ if (hIcon)
DestroyIcon(hIcon);
// Version
- sttFillInfoLine( hwndTree, htiResource, NULL, TranslateT( "Version" ),
- res->version ? res->version : TranslateT( "<not specified>" ),
+ sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Version"),
+ res->version ? res->version : TranslateT("<not specified>"),
sttInfoLineId(resource, INFOLINE_VERSION));
// System
- sttFillInfoLine( hwndTree, htiResource, NULL, TranslateT( "System" ),
- res->system ? res->system : TranslateT( "<not specified>" ),
+ sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("System"),
+ res->system ? res->system : TranslateT("<not specified>"),
sttInfoLineId(resource, INFOLINE_SYSTEM));
// Resource priority
TCHAR szPriority[128];
- mir_sntprintf( szPriority, SIZEOF( szPriority ), _T("%d"), (int)res->priority );
- sttFillInfoLine( hwndTree, htiResource, NULL, TranslateT( "Resource priority" ), szPriority, sttInfoLineId(resource, INFOLINE_PRIORITY));
+ mir_sntprintf(szPriority, SIZEOF(szPriority), _T("%d"), (int)res->priority);
+ sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Resource priority"), szPriority, sttInfoLineId(resource, INFOLINE_PRIORITY));
// Idle
- if ( res->idleStartTime > 0 ) {
- lstrcpyn(buf, _tctime( &res->idleStartTime ), SIZEOF( buf ));
+ if (res->idleStartTime > 0) {
+ lstrcpyn(buf, _tctime(&res->idleStartTime), SIZEOF(buf));
int len = lstrlen(buf);
if (len > 0) buf[len-1] = 0;
}
- else if ( !res->idleStartTime )
- lstrcpyn(buf, TranslateT( "unknown" ), SIZEOF( buf ));
+ else if ( !res->idleStartTime)
+ lstrcpyn(buf, TranslateT("unknown"), SIZEOF(buf));
else
- lstrcpyn(buf, TranslateT( "<not specified>" ), SIZEOF( buf ));
+ lstrcpyn(buf, TranslateT("<not specified>"), SIZEOF(buf));
- sttFillInfoLine( hwndTree, htiResource, NULL, TranslateT("Idle since"), buf, sttInfoLineId(resource, INFOLINE_IDLE));
+ sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Idle since"), buf, sttInfoLineId(resource, INFOLINE_IDLE));
// caps
- mir_sntprintf( buf, SIZEOF(buf), _T("%s/%s"), item->jid, res->resourceName );
- JabberCapsBits jcb = ppro->GetResourceCapabilites( buf, TRUE );
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s/%s"), item->jid, res->resourceName);
+ JabberCapsBits jcb = ppro->GetResourceCapabilites(buf, TRUE);
- if ( !( jcb & JABBER_RESOURCE_CAPS_ERROR )) {
- HTREEITEM htiCaps = sttFillInfoLine( hwndTree, htiResource, ppro->LoadIconEx( "main" ), NULL, TranslateT( "Client capabilities" ), sttInfoLineId(resource, INFOLINE_CAPS));
+ if ( !(jcb & JABBER_RESOURCE_CAPS_ERROR)) {
+ HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), NULL, TranslateT("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS));
int i;
- for ( i = 0; g_JabberFeatCapPairs[i].szFeature; i++ )
- if ( jcb & g_JabberFeatCapPairs[i].jcbCap ) {
+ for (i = 0; g_JabberFeatCapPairs[i].szFeature; i++)
+ if (jcb & g_JabberFeatCapPairs[i].jcbCap) {
TCHAR szDescription[ 1024 ];
- if ( g_JabberFeatCapPairs[i].szDescription )
- mir_sntprintf( szDescription, SIZEOF( szDescription ), _T("%s (%s)"), TranslateTS(g_JabberFeatCapPairs[i].szDescription), g_JabberFeatCapPairs[i].szFeature );
+ if (g_JabberFeatCapPairs[i].szDescription)
+ mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s (%s)"), TranslateTS(g_JabberFeatCapPairs[i].szDescription), g_JabberFeatCapPairs[i].szFeature);
else
- mir_sntprintf( szDescription, SIZEOF( szDescription ), _T("%s"), g_JabberFeatCapPairs[i].szFeature );
- sttFillInfoLine( hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
+ mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s"), g_JabberFeatCapPairs[i].szFeature);
+ sttFillInfoLine(hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
}
- for ( int j = 0; j < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); j++, i++ )
- if ( jcb & ppro->m_lstJabberFeatCapPairsDynamic[j]->jcbCap ) {
+ for (int j = 0; j < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); j++, i++)
+ if (jcb & ppro->m_lstJabberFeatCapPairsDynamic[j]->jcbCap) {
TCHAR szDescription[ 1024 ];
- if ( ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription )
- mir_sntprintf( szDescription, SIZEOF( szDescription ), _T("%s (%s)"), TranslateTS(ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature );
+ if (ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription)
+ mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s (%s)"), TranslateTS(ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature);
else
- mir_sntprintf( szDescription, SIZEOF( szDescription ), _T("%s"), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature );
- sttFillInfoLine( hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
+ mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s"), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature);
+ sttFillInfoLine(hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
}
}
// Software info
- if ( res->pSoftwareInfo ) {
- HTREEITEM htiSoftwareInfo = sttFillInfoLine( hwndTree, htiResource, ppro->LoadIconEx( "main" ), NULL, TranslateT( "Software information" ), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION));
+ if (res->pSoftwareInfo) {
+ HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), NULL, TranslateT("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION));
int nLineId = 0;
- if ( res->pSoftwareInfo->szOs )
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system"), res->pSoftwareInfo->szOs, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if ( res->pSoftwareInfo->szOsVersion )
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system version"), res->pSoftwareInfo->szOsVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if ( res->pSoftwareInfo->szSoftware )
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Software"), res->pSoftwareInfo->szSoftware, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if ( res->pSoftwareInfo->szSoftwareVersion )
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Software version"), res->pSoftwareInfo->szSoftwareVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- if ( res->pSoftwareInfo->szXMirandaCoreVersion ) {
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Miranda NG core version"), res->pSoftwareInfo->szXMirandaCoreVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Unicode build"), res->pSoftwareInfo->bXMirandaIsUnicode ? TranslateT("Yes") : TranslateT("No"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Alpha build"), res->pSoftwareInfo->bXMirandaIsAlpha ? TranslateT("Yes") : TranslateT("No"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
- sttFillInfoLine( hwndTree, htiSoftwareInfo, NULL, TranslateT("Debug build"), res->pSoftwareInfo->bXMirandaIsDebug ? TranslateT("Yes") : TranslateT("No"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (res->pSoftwareInfo->szOs)
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system"), res->pSoftwareInfo->szOs, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (res->pSoftwareInfo->szOsVersion)
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system version"), res->pSoftwareInfo->szOsVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (res->pSoftwareInfo->szSoftware)
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software"), res->pSoftwareInfo->szSoftware, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (res->pSoftwareInfo->szSoftwareVersion)
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software version"), res->pSoftwareInfo->szSoftwareVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ if (res->pSoftwareInfo->szXMirandaCoreVersion) {
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Miranda NG core version"), res->pSoftwareInfo->szXMirandaCoreVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Unicode build"), res->pSoftwareInfo->bXMirandaIsUnicode ? TranslateT("Yes") : TranslateT("No"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Alpha build"), res->pSoftwareInfo->bXMirandaIsAlpha ? TranslateT("Yes") : TranslateT("No"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
+ sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Debug build"), res->pSoftwareInfo->bXMirandaIsDebug ? TranslateT("Yes") : TranslateT("No"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++));
}
}
}
-static void sttFillAdvStatusInfo( CJabberProto* ppro, HWND hwndTree, HTREEITEM htiRoot, DWORD dwInfoLine, HANDLE hContact, TCHAR *szTitle, char *pszSlot )
+static void sttFillAdvStatusInfo(CJabberProto* ppro, HWND hwndTree, HTREEITEM htiRoot, DWORD dwInfoLine, HANDLE hContact, TCHAR *szTitle, char *pszSlot)
{
char *szAdvStatusIcon = ppro->ReadAdvStatusA(hContact, pszSlot, ADVSTATUS_VAL_ICON);
TCHAR *szAdvStatusTitle = ppro->ReadAdvStatusT(hContact, pszSlot, ADVSTATUS_VAL_TITLE);
@@ -323,11 +323,11 @@ static void sttFillAdvStatusInfo( CJabberProto* ppro, HWND hwndTree, HTREEITEM h if (szAdvStatusIcon && szAdvStatusTitle && *szAdvStatusTitle) {
TCHAR szText[2048];
- if ( szAdvStatusText && *szAdvStatusText )
+ if (szAdvStatusText && *szAdvStatusText)
mir_sntprintf(szText, 2047, _T("%s (%s)"), TranslateTS(szAdvStatusTitle), szAdvStatusText);
else
mir_sntprintf(szText, 2047, _T("%s"), TranslateTS(szAdvStatusTitle));
- sttFillInfoLine( hwndTree, htiRoot, Skin_GetIcon(szAdvStatusIcon), szTitle, szText, dwInfoLine);
+ sttFillInfoLine(hwndTree, htiRoot, Skin_GetIcon(szAdvStatusIcon), szTitle, szText, dwInfoLine);
}
mir_free(szAdvStatusIcon);
@@ -335,111 +335,111 @@ static void sttFillAdvStatusInfo( CJabberProto* ppro, HWND hwndTree, HTREEITEM h mir_free(szAdvStatusText);
}
-static void sttFillUserInfo( CJabberProto* ppro, HWND hwndTree, JABBER_LIST_ITEM *item )
+static void sttFillUserInfo(CJabberProto* ppro, HWND hwndTree, JABBER_LIST_ITEM *item)
{
- SendMessage( hwndTree, WM_SETREDRAW, FALSE, 0 );
+ SendMessage(hwndTree, WM_SETREDRAW, FALSE, 0);
sttCleanupInfo(hwndTree, 0);
- HTREEITEM htiRoot = sttFillInfoLine( hwndTree, NULL, ppro->LoadIconEx( "main" ), _T( "JID" ), item->jid, sttInfoLineId(0, INFOLINE_NAME), true );
+ HTREEITEM htiRoot = sttFillInfoLine(hwndTree, NULL, ppro->LoadIconEx("main"), _T("JID"), item->jid, sttInfoLineId(0, INFOLINE_NAME), true);
TCHAR buf[256];
if (HANDLE hContact = ppro->HContactFromJID(item->jid)) {
- sttFillAdvStatusInfo( ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_MOOD), hContact, TranslateT("Mood"), ADVSTATUS_MOOD );
- sttFillAdvStatusInfo( ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_ACTIVITY), hContact, TranslateT("Activity"), ADVSTATUS_ACTIVITY );
- sttFillAdvStatusInfo( ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_TUNE), hContact, TranslateT("Tune"), ADVSTATUS_TUNE );
+ sttFillAdvStatusInfo(ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_MOOD), hContact, TranslateT("Mood"), ADVSTATUS_MOOD);
+ sttFillAdvStatusInfo(ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_ACTIVITY), hContact, TranslateT("Activity"), ADVSTATUS_ACTIVITY);
+ sttFillAdvStatusInfo(ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_TUNE), hContact, TranslateT("Tune"), ADVSTATUS_TUNE);
}
// subscription
- switch ( item->subscription ) {
+ switch (item->subscription) {
case SUB_BOTH:
- sttFillInfoLine( hwndTree, htiRoot, NULL, TranslateT( "Subscription" ), TranslateT( "both" ), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("both"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
case SUB_TO:
- sttFillInfoLine( hwndTree, htiRoot, NULL, TranslateT( "Subscription" ), TranslateT( "to" ), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("to"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
case SUB_FROM:
- sttFillInfoLine( hwndTree, htiRoot, NULL, TranslateT( "Subscription" ), TranslateT( "from" ), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("from"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
default:
- sttFillInfoLine( hwndTree, htiRoot, NULL, TranslateT( "Subscription" ), TranslateT( "none" ), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Subscription"), TranslateT("none"), sttInfoLineId(0, INFOLINE_SUBSCRIPTION));
break;
}
// logoff
- if ( item->itemResource.idleStartTime > 0 ) {
- lstrcpyn( buf, _tctime( &item->itemResource.idleStartTime ), SIZEOF( buf ));
+ if (item->itemResource.idleStartTime > 0) {
+ lstrcpyn(buf, _tctime(&item->itemResource.idleStartTime), SIZEOF(buf));
int len = lstrlen(buf);
if (len > 0) buf[len-1] = 0;
}
- else if ( !item->itemResource.idleStartTime )
- lstrcpyn( buf, TranslateT( "unknown" ), SIZEOF( buf ));
+ else if ( !item->itemResource.idleStartTime)
+ lstrcpyn(buf, TranslateT("unknown"), SIZEOF(buf));
else
- lstrcpyn( buf, TranslateT( "<not specified>" ), SIZEOF( buf ));
+ lstrcpyn(buf, TranslateT("<not specified>"), SIZEOF(buf));
- sttFillInfoLine( hwndTree, htiRoot, NULL,
- ( item->jid && _tcschr( item->jid, _T( '@' ))) ? TranslateT( "Last logoff time" ) : TranslateT( "Uptime"), buf,
+ sttFillInfoLine(hwndTree, htiRoot, NULL,
+ (item->jid && _tcschr(item->jid, _T('@'))) ? TranslateT("Last logoff time") : TranslateT("Uptime"), buf,
sttInfoLineId(0, INFOLINE_LOGOFF));
// logoff msg
- sttFillInfoLine( hwndTree, htiRoot, NULL, TranslateT( "Logoff message" ),
- item->itemResource.statusMessage ? item->itemResource.statusMessage : TranslateT( "<not specified>" ), sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Logoff message"),
+ item->itemResource.statusMessage ? item->itemResource.statusMessage : TranslateT("<not specified>"), sttInfoLineId(0, INFOLINE_LOGOFF_MSG));
// activity
- if (( item->lastSeenResource >= 0 ) && ( item->lastSeenResource < item->resourceCount ))
- lstrcpyn( buf, item->resource[item->lastSeenResource].resourceName, SIZEOF( buf ));
+ if ((item->lastSeenResource >= 0) && (item->lastSeenResource < item->resourceCount))
+ lstrcpyn(buf, item->resource[item->lastSeenResource].resourceName, SIZEOF(buf));
else
- lstrcpyn( buf, TranslateT( "<no information available>" ), SIZEOF( buf ));
+ lstrcpyn(buf, TranslateT("<no information available>"), SIZEOF(buf));
- sttFillInfoLine( hwndTree, htiRoot, NULL, TranslateT( "Last active resource" ), buf,
+ sttFillInfoLine(hwndTree, htiRoot, NULL, TranslateT("Last active resource"), buf,
sttInfoLineId(0, INFOLINE_LASTACTIVE));
// resources
- if ( item->resourceCount ) {
+ if (item->resourceCount) {
for (int i = 0; i < item->resourceCount; ++i)
- sttFillResourceInfo( ppro, hwndTree, htiRoot, item, i+1 );
+ sttFillResourceInfo(ppro, hwndTree, htiRoot, item, i+1);
}
else if ( !_tcschr(item->jid, _T('@')) || (item->itemResource.status != ID_STATUS_OFFLINE))
- sttFillResourceInfo( ppro, hwndTree, htiRoot, item, 0 );
+ sttFillResourceInfo(ppro, hwndTree, htiRoot, item, 0);
sttCleanupInfo(hwndTree, 1);
- SendMessage( hwndTree, WM_SETREDRAW, TRUE, 0 );
+ SendMessage(hwndTree, WM_SETREDRAW, TRUE, 0);
- RedrawWindow( hwndTree, NULL, NULL, RDW_INVALIDATE );
+ RedrawWindow(hwndTree, NULL, NULL, RDW_INVALIDATE);
}
-static void sttGetNodeText( HWND hwndTree, HTREEITEM hti, UserInfoStringBuf *buf, int indent = 0 )
+static void sttGetNodeText(HWND hwndTree, HTREEITEM hti, UserInfoStringBuf *buf, int indent = 0)
{
- for ( int i = 0; i < indent; ++i )
- buf->append( _T( "\t" ));
+ for (int i = 0; i < indent; ++i)
+ buf->append(_T("\t"));
TVITEMEX tvi = {0};
tvi.mask = TVIF_HANDLE|TVIF_TEXT|TVIF_STATE;
tvi.hItem = hti;
tvi.cchTextMax = 256;
- tvi.pszText = buf->allocate( tvi.cchTextMax );
- if (!TreeView_GetItem( hwndTree, &tvi )) { // failure, maybe item was removed...
+ tvi.pszText = buf->allocate(tvi.cchTextMax);
+ if ( !TreeView_GetItem(hwndTree, &tvi)) { // failure, maybe item was removed...
buf->buf[ buf->offset ] = 0;
buf->actualize();
return;
}
buf->actualize();
- buf->append( _T( "\r\n" ));
+ buf->append(_T("\r\n"));
- if ( tvi.state & TVIS_EXPANDED )
- for ( hti = TreeView_GetChild( hwndTree, hti ); hti; hti = TreeView_GetNextSibling( hwndTree, hti ))
- sttGetNodeText( hwndTree, hti, buf, indent + 1 );
+ if (tvi.state & TVIS_EXPANDED)
+ for (hti = TreeView_GetChild(hwndTree, hti); hti; hti = TreeView_GetNextSibling(hwndTree, hti))
+ sttGetNodeText(hwndTree, hti, buf, indent + 1);
}
-static INT_PTR CALLBACK JabberUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberUserInfoDlgData *dat = (JabberUserInfoDlgData *)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JabberUserInfoDlgData *dat = (JabberUserInfoDlgData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
// lParam is hContact
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIconBig(SKINICON_OTHER_USERDETAILS));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS));
@@ -448,16 +448,16 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wP ZeroMemory(dat, sizeof(JabberUserInfoDlgData));
dat->resourceCount = -1;
- if ( CallService(MS_DB_CONTACT_IS, (WPARAM)lParam, 0 ))
+ if (CallService(MS_DB_CONTACT_IS, (WPARAM)lParam, 0))
dat->hContact = (HANDLE)lParam;
- else if (!IsBadReadPtr((void *)lParam, sizeof(JABBER_LIST_ITEM))) {
+ else if ( !IsBadReadPtr((void*)lParam, sizeof(JABBER_LIST_ITEM))) {
dat->hContact = NULL;
dat->item = (JABBER_LIST_ITEM *)lParam;
}
{
- RECT rc; GetClientRect( hwndDlg, &rc );
- MoveWindow( GetDlgItem( hwndDlg, IDC_TV_INFO ), 5, 5, rc.right-10, rc.bottom-10, TRUE );
+ RECT rc; GetClientRect(hwndDlg, &rc);
+ MoveWindow(GetDlgItem(hwndDlg, IDC_TV_INFO), 5, 5, rc.right-10, rc.bottom-10, TRUE);
HIMAGELIST himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR|ILC_COLOR32|ILC_MASK, 5, 1);
ImageList_AddIcon_Icolib(himl, LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT));
@@ -469,31 +469,31 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wP break;
case WM_JABBER_REFRESH:
- if ( !dat ) break;
+ if ( !dat) break;
- if ( !dat->item ) {
+ if ( !dat->item) {
DBVARIANT dbv = {0};
- if ( dat->ppro->JGetStringT(dat->hContact, "jid", &dbv))
+ if (dat->ppro->JGetStringT(dat->hContact, "jid", &dbv))
break;
- if (!(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)))
+ if ( !(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)))
dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- if (!dat->item)
+ if ( !dat->item)
{
HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_INFO);
- TreeView_DeleteAllItems( hwndTree );
- HTREEITEM htiRoot = sttFillInfoLine( hwndTree, NULL, dat->ppro->LoadIconEx( "main" ), _T( "JID" ), dbv.ptszVal, sttInfoLineId(0, INFOLINE_NAME), true );
- sttFillInfoLine( hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), NULL,
+ TreeView_DeleteAllItems(hwndTree);
+ HTREEITEM htiRoot = sttFillInfoLine(hwndTree, NULL, dat->ppro->LoadIconEx("main"), _T("JID"), dbv.ptszVal, sttInfoLineId(0, INFOLINE_NAME), true);
+ sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), NULL,
TranslateT("Please switch online to see more details."));
- JFreeVariant(&dbv);
+ db_free(&dbv);
break;
}
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
- sttFillUserInfo( dat->ppro, GetDlgItem(hwndDlg, IDC_TV_INFO), dat->item);
+ sttFillUserInfo(dat->ppro, GetDlgItem(hwndDlg, IDC_TV_INFO), dat->item);
break;
case WM_SIZE:
@@ -501,79 +501,79 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wP break;
case WM_CONTEXTMENU:
- if ( GetWindowLongPtr(( HWND )wParam, GWL_ID ) == IDC_TV_INFO ) {
- HWND hwndTree = GetDlgItem( hwndDlg, IDC_TV_INFO );
- POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) };
+ if (GetWindowLongPtr((HWND)wParam, GWL_ID) == IDC_TV_INFO) {
+ HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_INFO);
+ POINT pt = { (signed short)LOWORD(lParam), (signed short)HIWORD(lParam) };
HTREEITEM hItem = 0;
- if (( pt.x == -1 ) && ( pt.y == -1 )) {
- if (hItem = TreeView_GetSelection( hwndTree )) {
+ if ((pt.x == -1) && (pt.y == -1)) {
+ if (hItem = TreeView_GetSelection(hwndTree)) {
RECT rc;
- TreeView_GetItemRect( hwndTree, hItem, &rc, TRUE );
+ TreeView_GetItemRect(hwndTree, hItem, &rc, TRUE);
pt.x = rc.left;
pt.y = rc.bottom;
- ClientToScreen( hwndTree, &pt );
+ ClientToScreen(hwndTree, &pt);
}
}
else {
TVHITTESTINFO tvhti = {0};
tvhti.pt = pt;
- ScreenToClient( hwndTree, &tvhti.pt );
- TreeView_HitTest( hwndTree, &tvhti );
- if ( tvhti.flags & TVHT_ONITEM ) {
+ ScreenToClient(hwndTree, &tvhti.pt);
+ TreeView_HitTest(hwndTree, &tvhti);
+ if (tvhti.flags & TVHT_ONITEM) {
hItem = tvhti.hItem;
TreeView_Select(hwndTree, hItem, TVGN_CARET);
} }
- if ( hItem ) {
+ if (hItem) {
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, TranslateT("Copy"));
AppendMenu(hMenu, MF_STRING, (UINT_PTR)2, TranslateT("Copy only this value"));
AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel"));
- int nReturnCmd = TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL );
- if ( nReturnCmd == 1 ) {
+ int nReturnCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ if (nReturnCmd == 1) {
UserInfoStringBuf buf;
- sttGetNodeText( hwndTree, hItem, &buf );
- JabberCopyText( hwndDlg, buf.buf );
+ sttGetNodeText(hwndTree, hItem, &buf);
+ JabberCopyText(hwndDlg, buf.buf);
}
- else if ( nReturnCmd == 2 ) {
+ else if (nReturnCmd == 2) {
TCHAR szBuffer[ 1024 ];
TVITEMEX tvi = {0};
tvi.mask = TVIF_HANDLE|TVIF_TEXT|TVIF_STATE;
tvi.hItem = hItem;
- tvi.cchTextMax = SIZEOF( szBuffer );
+ tvi.cchTextMax = SIZEOF(szBuffer);
tvi.pszText = szBuffer;
- if ( TreeView_GetItem( hwndTree, &tvi )) {
+ if (TreeView_GetItem(hwndTree, &tvi)) {
if (TCHAR *str = _tcsstr(szBuffer, _T(": ")))
- JabberCopyText( hwndDlg, str+2 );
+ JabberCopyText(hwndDlg, str+2);
else
- JabberCopyText( hwndDlg, szBuffer );
+ JabberCopyText(hwndDlg, szBuffer);
} }
- DestroyMenu( hMenu );
+ DestroyMenu(hMenu);
} }
break;
case WM_NOTIFY:
- if (( ( LPNMHDR )lParam )->idFrom == 0 ) {
- switch (( ( LPNMHDR )lParam )->code ) {
+ if (((LPNMHDR)lParam)->idFrom == 0) {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
{
- HANDLE hContact = ( HANDLE ) (( LPPSHNOTIFY ) lParam )->lParam;
- SendMessage( hwndDlg, WM_JABBER_REFRESH, 0, ( LPARAM )hContact );
+ HANDLE hContact = (HANDLE)((LPPSHNOTIFY) lParam)->lParam;
+ SendMessage(hwndDlg, WM_JABBER_REFRESH, 0, (LPARAM)hContact);
}
break;
case PSN_PARAMCHANGED:
- dat->ppro = ( CJabberProto* )( CJabberProto* )(( PSHNOTIFY* )lParam )->lParam;
- if ( dat->hContact != NULL ) {
+ dat->ppro = (CJabberProto*)(CJabberProto*)((PSHNOTIFY*)lParam)->lParam;
+ if (dat->hContact != NULL) {
DBVARIANT dbv = {0};
- if ( dat->ppro->JGetStringT(dat->hContact, "jid", &dbv))
+ if (dat->ppro->JGetStringT(dat->hContact, "jid", &dbv))
break;
- if ( !(dat->item = dat->ppro->ListGetItemPtr( LIST_VCARD_TEMP, dbv.ptszVal )))
- dat->item = dat->ppro->ListGetItemPtr( LIST_ROSTER, dbv.ptszVal );
- JFreeVariant(&dbv);
+ if ( !(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)))
+ dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
+ db_free(&dbv);
}
break;
} }
@@ -585,12 +585,12 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wP case WM_DESTROY:
WindowList_Remove(hUserInfoList, hwndDlg);
- if ( dat ) {
+ if (dat) {
mir_free(dat);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
}
ImageList_Destroy(TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TV_INFO), NULL, TVSIL_NORMAL));
- WindowFreeIcon( hwndDlg );
+ WindowFreeIcon(hwndDlg);
break;
}
return FALSE;
@@ -606,37 +606,37 @@ struct USER_PHOTO_INFO CJabberProto* ppro;
};
-static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
USER_PHOTO_INFO *photoInfo;
- photoInfo = ( USER_PHOTO_INFO * ) GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ photoInfo = (USER_PHOTO_INFO *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
// lParam is hContact
- TranslateDialogDefault( hwndDlg );
- photoInfo = ( USER_PHOTO_INFO * ) mir_alloc( sizeof( USER_PHOTO_INFO ));
- photoInfo->hContact = ( HANDLE ) lParam;
+ TranslateDialogDefault(hwndDlg);
+ photoInfo = (USER_PHOTO_INFO *) mir_alloc(sizeof(USER_PHOTO_INFO));
+ photoInfo->hContact = (HANDLE)lParam;
photoInfo->ppro = NULL;
photoInfo->hBitmap = NULL;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR ) photoInfo );
- SendDlgItemMessage( hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, ( LPARAM )LoadImage( hInst, MAKEINTRESOURCE( IDI_SAVE ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 ));
- SendDlgItemMessage( hwndDlg, IDC_SAVE, BUTTONSETASFLATBTN, TRUE, 0);
- ShowWindow( GetDlgItem( hwndDlg, IDC_LOAD ), SW_HIDE );
- ShowWindow( GetDlgItem( hwndDlg, IDC_DELETE ), SW_HIDE );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) photoInfo);
+ SendDlgItemMessage(hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_SAVE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_SAVE, BUTTONSETASFLATBTN, TRUE, 0);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_LOAD), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_DELETE), SW_HIDE);
break;
case WM_NOTIFY:
- switch ((( LPNMHDR )lParam )->idFrom ) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
- switch ((( LPNMHDR )lParam )->code ) {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
- SendMessage( hwndDlg, WM_JABBER_REFRESH, 0, 0 );
+ SendMessage(hwndDlg, WM_JABBER_REFRESH, 0, 0);
break;
case PSN_PARAMCHANGED:
- photoInfo->ppro = ( CJabberProto* )(( PSHNOTIFY* )lParam )->lParam;
+ photoInfo->ppro = (CJabberProto*)((PSHNOTIFY*)lParam)->lParam;
break;
}
break;
@@ -648,34 +648,34 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM w JABBER_LIST_ITEM *item;
DBVARIANT dbv;
- if ( photoInfo->hBitmap ) {
- DeleteObject( photoInfo->hBitmap );
+ if (photoInfo->hBitmap) {
+ DeleteObject(photoInfo->hBitmap);
photoInfo->hBitmap = NULL;
}
- ShowWindow( GetDlgItem( hwndDlg, IDC_SAVE ), SW_HIDE );
- if ( !photoInfo->ppro->JGetStringT( photoInfo->hContact, "jid", &dbv )) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE);
+ if ( !photoInfo->ppro->JGetStringT(photoInfo->hContact, "jid", &dbv)) {
TCHAR* jid = dbv.ptszVal;
- if (( item = photoInfo->ppro->ListGetItemPtr( LIST_VCARD_TEMP, jid )) == NULL)
- item = photoInfo->ppro->ListGetItemPtr( LIST_ROSTER, jid );
- if ( item != NULL ) {
- if ( item->photoFileName ) {
- photoInfo->ppro->Log( "Showing picture from " TCHAR_STR_PARAM, item->photoFileName );
- char* p = mir_t2a( item->photoFileName );
- photoInfo->hBitmap = ( HBITMAP ) CallService( MS_UTILS_LOADBITMAP, 0, ( LPARAM )p );
- mir_free( p );
+ if ((item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
+ item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid);
+ if (item != NULL) {
+ if (item->photoFileName) {
+ photoInfo->ppro->Log("Showing picture from " TCHAR_STR_PARAM, item->photoFileName);
+ char* p = mir_t2a(item->photoFileName);
+ photoInfo->hBitmap = (HBITMAP) CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)p);
+ mir_free(p);
JabberBitmapPremultiplyChannels(photoInfo->hBitmap);
- ShowWindow( GetDlgItem( hwndDlg, IDC_SAVE ), SW_SHOW );
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_SHOW);
}
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- InvalidateRect( hwndDlg, NULL, TRUE );
- UpdateWindow( hwndDlg );
+ InvalidateRect(hwndDlg, NULL, TRUE);
+ UpdateWindow(hwndDlg);
}
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDC_SAVE:
{
DBVARIANT dbv;
@@ -686,36 +686,36 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM w TCHAR szFileName[MAX_PATH];
DWORD n;
- if ( photoInfo->ppro->JGetStringT( photoInfo->hContact, "jid", &dbv ))
+ if (photoInfo->ppro->JGetStringT(photoInfo->hContact, "jid", &dbv))
break;
TCHAR* jid = dbv.ptszVal;
- if (( item = photoInfo->ppro->ListGetItemPtr( LIST_VCARD_TEMP, jid )) == NULL)
- item = photoInfo->ppro->ListGetItemPtr( LIST_ROSTER, jid );
- if ( item != NULL ) {
- if (( hFile=CreateFile( item->photoFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL )) != INVALID_HANDLE_VALUE ) {
- if ( ReadFile( hFile, buffer, 3, &n, NULL ) && n==3 ) {
- if ( !strncmp(( char* )buffer, "BM", 2 )) {
- mir_sntprintf( szFilter, SIZEOF( szFilter ), _T("BMP %s ( *.bmp )"), TranslateT( "format" ));
- n = (DWORD)_tcslen( szFilter );
- _tcsncpy( szFilter+n+1, _T("*.BMP"), SIZEOF( szFilter )-n-2 );
+ if ((item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
+ item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid);
+ if (item != NULL) {
+ if ((hFile=CreateFile(item->photoFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
+ if (ReadFile(hFile, buffer, 3, &n, NULL) && n==3) {
+ if ( !strncmp((char*)buffer, "BM", 2)) {
+ mir_sntprintf(szFilter, SIZEOF(szFilter), _T("BMP %s (*.bmp)"), TranslateT("format"));
+ n = (DWORD)_tcslen(szFilter);
+ _tcsncpy(szFilter+n+1, _T("*.BMP"), SIZEOF(szFilter)-n-2);
}
- else if ( !strncmp(( char* )buffer, "GIF", 3 )) {
- mir_sntprintf( szFilter, SIZEOF( szFilter ), _T("GIF %s ( *.gif )"), TranslateT( "format" ));
- n = (DWORD)_tcslen( szFilter );
- _tcsncpy( szFilter+n+1, _T("*.GIF"), SIZEOF( szFilter )-n-2 );
+ else if ( !strncmp((char*)buffer, "GIF", 3)) {
+ mir_sntprintf(szFilter, SIZEOF(szFilter), _T("GIF %s (*.gif)"), TranslateT("format"));
+ n = (DWORD)_tcslen(szFilter);
+ _tcsncpy(szFilter+n+1, _T("*.GIF"), SIZEOF(szFilter)-n-2);
}
- else if ( buffer[0]==0xff && buffer[1]==0xd8 && buffer[2]==0xff ) {
- mir_sntprintf( szFilter, SIZEOF( szFilter ), _T("JPEG %s ( *.jpg;*.jpeg )"), TranslateT( "format" ));
- n = (DWORD)_tcslen( szFilter );
- _tcsncpy( szFilter+n+1, _T("*.JPG;*.JPEG"), SIZEOF( szFilter )-n-2 );
+ else if (buffer[0]==0xff && buffer[1]==0xd8 && buffer[2]==0xff) {
+ mir_sntprintf(szFilter, SIZEOF(szFilter), _T("JPEG %s (*.jpg;*.jpeg)"), TranslateT("format"));
+ n = (DWORD)_tcslen(szFilter);
+ _tcsncpy(szFilter+n+1, _T("*.JPG;*.JPEG"), SIZEOF(szFilter)-n-2);
}
else {
- mir_sntprintf( szFilter, SIZEOF( szFilter ), _T("%s ( *.* )"), TranslateT( "Unknown format" ));
- n = (DWORD)_tcslen( szFilter );
- _tcsncpy( szFilter+n+1, _T("*.*"), SIZEOF( szFilter )-n-2 );
+ mir_sntprintf(szFilter, SIZEOF(szFilter), _T("%s (*.*)"), TranslateT("Unknown format"));
+ n = (DWORD)_tcslen(szFilter);
+ _tcsncpy(szFilter+n+1, _T("*.*"), SIZEOF(szFilter)-n-2);
}
- szFilter[SIZEOF( szFilter )-1] = 0;
+ szFilter[SIZEOF(szFilter)-1] = 0;
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
@@ -739,15 +739,15 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM w ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
szFileName[0] = '\0';
- if ( GetSaveFileName( &ofn )) {
- photoInfo->ppro->Log( "File selected is %s", szFileName );
- CopyFile( item->photoFileName, szFileName, FALSE );
+ if (GetSaveFileName(&ofn)) {
+ photoInfo->ppro->Log("File selected is %s", szFileName);
+ CopyFile(item->photoFileName, szFileName, FALSE);
}
}
- CloseHandle( hFile );
+ CloseHandle(hFile);
}
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
break;
@@ -755,47 +755,47 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM w break;
case WM_PAINT:
- if ( !photoInfo->ppro->m_bJabberOnline )
- SetDlgItemText( hwndDlg, IDC_CANVAS, TranslateT( "<Photo not available while offline>" ));
- else if ( !photoInfo->hBitmap )
- SetDlgItemText( hwndDlg, IDC_CANVAS, TranslateT( "<No photo>" ));
+ if ( !photoInfo->ppro->m_bJabberOnline)
+ SetDlgItemText(hwndDlg, IDC_CANVAS, TranslateT("<Photo not available while offline>"));
+ else if ( !photoInfo->hBitmap)
+ SetDlgItemText(hwndDlg, IDC_CANVAS, TranslateT("<No photo>"));
else {
BITMAP bm;
POINT ptSize, ptOrg, pt, ptFitSize;
RECT rect;
- SetDlgItemTextA( hwndDlg, IDC_CANVAS, "" );
+ SetDlgItemTextA(hwndDlg, IDC_CANVAS, "");
HBITMAP hBitmap = photoInfo->hBitmap;
- HWND hwndCanvas = GetDlgItem( hwndDlg, IDC_CANVAS );
- HDC hdcCanvas = GetDC( hwndCanvas );
- HDC hdcMem = CreateCompatibleDC( hdcCanvas );
- SelectObject( hdcMem, hBitmap );
- SetMapMode( hdcMem, GetMapMode( hdcCanvas ));
- GetObject( hBitmap, sizeof( BITMAP ), ( LPVOID ) &bm );
+ HWND hwndCanvas = GetDlgItem(hwndDlg, IDC_CANVAS);
+ HDC hdcCanvas = GetDC(hwndCanvas);
+ HDC hdcMem = CreateCompatibleDC(hdcCanvas);
+ SelectObject(hdcMem, hBitmap);
+ SetMapMode(hdcMem, GetMapMode(hdcCanvas));
+ GetObject(hBitmap, sizeof(BITMAP), (LPVOID) &bm);
ptSize.x = bm.bmWidth;
ptSize.y = bm.bmHeight;
- DPtoLP( hdcCanvas, &ptSize, 1 );
+ DPtoLP(hdcCanvas, &ptSize, 1);
ptOrg.x = ptOrg.y = 0;
- DPtoLP( hdcMem, &ptOrg, 1 );
- GetClientRect( hwndCanvas, &rect );
- InvalidateRect( hwndCanvas, NULL, TRUE );
- UpdateWindow( hwndCanvas );
- if ( ptSize.x<=rect.right && ptSize.y<=rect.bottom ) {
- pt.x = ( rect.right - ptSize.x )/2;
- pt.y = ( rect.bottom - ptSize.y )/2;
+ DPtoLP(hdcMem, &ptOrg, 1);
+ GetClientRect(hwndCanvas, &rect);
+ InvalidateRect(hwndCanvas, NULL, TRUE);
+ UpdateWindow(hwndCanvas);
+ if (ptSize.x<=rect.right && ptSize.y<=rect.bottom) {
+ pt.x = (rect.right - ptSize.x)/2;
+ pt.y = (rect.bottom - ptSize.y)/2;
ptFitSize = ptSize;
}
else {
- if (( ( float )( ptSize.x-rect.right ))/ptSize.x > (( float )( ptSize.y-rect.bottom ))/ptSize.y ) {
+ if (((float)(ptSize.x-rect.right))/ptSize.x > ((float)(ptSize.y-rect.bottom))/ptSize.y) {
ptFitSize.x = rect.right;
- ptFitSize.y = ( ptSize.y*rect.right )/ptSize.x;
+ ptFitSize.y = (ptSize.y*rect.right)/ptSize.x;
pt.x = 0;
- pt.y = ( rect.bottom - ptFitSize.y )/2;
+ pt.y = (rect.bottom - ptFitSize.y)/2;
}
else {
- ptFitSize.x = ( ptSize.x*rect.bottom )/ptSize.y;
+ ptFitSize.x = (ptSize.x*rect.bottom)/ptSize.y;
ptFitSize.y = rect.bottom;
- pt.x = ( rect.right - ptFitSize.x )/2;
+ pt.x = (rect.right - ptFitSize.x)/2;
pt.y = 0;
}
}
@@ -809,29 +809,29 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM w FillRect(hdcCanvas, &rc, (HBRUSH)GetSysColorBrush(COLOR_BTNFACE));
}
- if (JabberAlphaBlend && bm.bmBitsPixel == 32 ) {
+ if (JabberAlphaBlend && bm.bmBitsPixel == 32) {
BLENDFUNCTION bf = {0};
bf.AlphaFormat = AC_SRC_ALPHA;
bf.BlendOp = AC_SRC_OVER;
bf.SourceConstantAlpha = 255;
- JabberAlphaBlend( hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, bf );
+ JabberAlphaBlend(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, bf);
}
else {
- SetStretchBltMode( hdcCanvas, COLORONCOLOR );
- StretchBlt( hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, SRCCOPY );
+ SetStretchBltMode(hdcCanvas, COLORONCOLOR);
+ StretchBlt(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, SRCCOPY);
}
- DeleteDC( hdcMem );
+ DeleteDC(hdcMem);
}
break;
case WM_DESTROY:
- DestroyIcon(( HICON )SendDlgItemMessage( hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, 0 ));
- if ( photoInfo->hBitmap ) {
- photoInfo->ppro->Log( "Delete bitmap" );
- DeleteObject( photoInfo->hBitmap );
+ DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, 0));
+ if (photoInfo->hBitmap) {
+ photoInfo->ppro->Log("Delete bitmap");
+ DeleteObject(photoInfo->hBitmap);
}
- if ( photoInfo ) mir_free( photoInfo );
+ if (photoInfo) mir_free(photoInfo);
break;
}
return FALSE;
@@ -840,29 +840,29 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM w /////////////////////////////////////////////////////////////////////////////////////////
// OnInfoInit - initializes user info option dialogs
-int CJabberProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam )
+int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM lParam)
{
- if ( !CallService( MS_PROTO_ISPROTOCOLLOADED, 0, ( LPARAM )m_szModuleName ))
+ if ( !CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)m_szModuleName))
return 0;
OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof( odp );
+ odp.cbSize = sizeof(odp);
odp.hInstance = hInst;
- odp.dwInitParam = ( LPARAM )this;
+ odp.dwInitParam = (LPARAM)this;
- HANDLE hContact = ( HANDLE )lParam;
- if ( hContact ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_szModuleName )) {
+ HANDLE hContact = (HANDLE)lParam;
+ if (hContact) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
odp.pfnDlgProc = JabberUserInfoDlgProc;
odp.position = -2000000000;
- odp.pszTemplate = MAKEINTRESOURCEA( IDD_INFO_JABBER );
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_JABBER);
odp.pszTitle = LPGEN("Account");
UserInfo_AddPage(wParam, &odp);
odp.pfnDlgProc = JabberUserPhotoDlgProc;
odp.position = 2000000000;
- odp.pszTemplate = MAKEINTRESOURCEA( IDD_VCARD_PHOTO );
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_PHOTO);
odp.pszTitle = LPGEN("Photo");
UserInfo_AddPage(wParam, &odp);
}
@@ -880,16 +880,16 @@ int CJabberProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam ) void JabberUserInfoInit()
{
- hUserInfoList = ( HANDLE )CallService( MS_UTILS_ALLOCWINDOWLIST, 0, 0 );
+ hUserInfoList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
// JabberUserInfoUpdate
-void JabberUserInfoUpdate( HANDLE hContact )
+void JabberUserInfoUpdate(HANDLE hContact)
{
- if ( !hContact )
- WindowList_BroadcastAsync( hUserInfoList, WM_JABBER_REFRESH, 0, 0 );
- else if ( HWND hwnd = WindowList_Find( hUserInfoList, hContact ))
- PostMessage( hwnd, WM_JABBER_REFRESH, 0, 0 );
+ if ( !hContact)
+ WindowList_BroadcastAsync(hUserInfoList, WM_JABBER_REFRESH, 0, 0);
+ else if (HWND hwnd = WindowList_Find(hUserInfoList, hContact))
+ PostMessage(hwnd, WM_JABBER_REFRESH, 0, 0);
}
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index f0b85068db..8c59d09f6b 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.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
@@ -32,62 +32,62 @@ extern CRITICAL_SECTION mutex; extern int bSecureIM;
-void CJabberProto::SerialInit( void )
+void CJabberProto::SerialInit(void)
{
- InitializeCriticalSection( &m_csSerial );
+ InitializeCriticalSection(&m_csSerial);
m_nSerial = 0;
}
-void CJabberProto::SerialUninit( void )
+void CJabberProto::SerialUninit(void)
{
- DeleteCriticalSection( &m_csSerial );
+ DeleteCriticalSection(&m_csSerial);
}
-int CJabberProto::SerialNext( void )
+int CJabberProto::SerialNext(void)
{
unsigned int ret;
- EnterCriticalSection( &m_csSerial );
+ EnterCriticalSection(&m_csSerial);
ret = m_nSerial;
m_nSerial++;
- LeaveCriticalSection( &m_csSerial );
+ LeaveCriticalSection(&m_csSerial);
return ret;
}
-void CJabberProto::Log( const char* fmt, ... )
+void CJabberProto::Log(const char* fmt, ...)
{
va_list vararg;
- va_start( vararg, fmt );
- char* str = ( char* )alloca( 32000 );
- mir_vsnprintf( str, 32000, fmt, vararg );
- va_end( vararg );
+ va_start(vararg, fmt);
+ char* str = (char*)alloca(32000);
+ mir_vsnprintf(str, 32000, fmt, vararg);
+ va_end(vararg);
- CallService( MS_NETLIB_LOG, ( WPARAM )m_hNetlibUser, ( LPARAM )str );
+ CallService(MS_NETLIB_LOG, (WPARAM)m_hNetlibUser, (LPARAM)str);
}
///////////////////////////////////////////////////////////////////////////////
// JabberChatRoomHContactFromJID - looks for the char room HCONTACT with required JID
-HANDLE CJabberProto::ChatRoomHContactFromJID( const TCHAR* jid )
+HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
{
- if ( jid == NULL )
- return ( HANDLE )NULL;
+ if (jid == NULL)
+ return (HANDLE)NULL;
HANDLE hContactMatched = NULL;
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( m_szModuleName, szProto )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
- int result = JGetStringT( hContact, "ChatRoomID", &dbv );
- if ( result )
- result = JGetStringT( hContact, "jid", &dbv );
+ int result = JGetStringT(hContact, "ChatRoomID", &dbv);
+ if (result)
+ result = JGetStringT(hContact, "jid", &dbv);
- if ( !result ) {
+ if ( !result) {
int result;
- result = lstrcmpi( jid, dbv.ptszVal );
- JFreeVariant( &dbv );
- if ( !result && JGetByte( hContact, "ChatRoom", 0 ) != 0 ) {
+ result = lstrcmpi(jid, dbv.ptszVal);
+ db_free(&dbv);
+ if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0) {
hContactMatched = hContact;
break;
} } }
@@ -101,46 +101,46 @@ HANDLE CJabberProto::ChatRoomHContactFromJID( const TCHAR* jid ) ///////////////////////////////////////////////////////////////////////////////
// JabberHContactFromJID - looks for the HCONTACT with required JID
-HANDLE CJabberProto::HContactFromJID( const TCHAR* jid , BOOL bStripResource )
+HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource)
{
- if ( jid == NULL )
- return ( HANDLE )NULL;
+ if (jid == NULL)
+ return (HANDLE)NULL;
- JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, jid );
+ JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, jid);
HANDLE hContactMatched = NULL;
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( m_szModuleName, szProto )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
int result;
//safer way to check UID (coz some contact have both setting from convert to chat)
- if(DBGetContactSettingByte(hContact, szProto, "ChatRoom",0))
- result = JGetStringT( hContact, "ChatRoomID", &dbv );
+ if (db_get_b(hContact, szProto, "ChatRoom",0))
+ result = JGetStringT(hContact, "ChatRoomID", &dbv);
else
- result = JGetStringT( hContact, "jid", &dbv );
+ result = JGetStringT(hContact, "jid", &dbv);
- if ( !result ) {
+ if ( !result) {
int result;
- if ( item != NULL )
- result = lstrcmpi( jid, dbv.ptszVal );
+ if (item != NULL)
+ result = lstrcmpi(jid, dbv.ptszVal);
else {
- if ( bStripResource == 3 ) {
+ if (bStripResource == 3) {
if (JGetByte(hContact, "ChatRoom", 0))
- result = lstrcmpi( jid, dbv.ptszVal ); // for chat room we have to have full contact matched
- else if ( TRUE )
- result = _tcsnicmp( jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
+ result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
+ else if (TRUE)
+ result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
else
- result = JabberCompareJids( jid, dbv.ptszVal );
+ result = JabberCompareJids(jid, dbv.ptszVal);
}
// most probably it should just look full matching contact
else
- result = lstrcmpi( jid, dbv.ptszVal );
+ result = lstrcmpi(jid, dbv.ptszVal);
}
- JFreeVariant( &dbv );
- if ( !result ) {
+ db_free(&dbv);
+ if ( !result) {
hContactMatched = hContact;
break;
} } }
@@ -151,84 +151,84 @@ HANDLE CJabberProto::HContactFromJID( const TCHAR* jid , BOOL bStripResource ) return hContactMatched;
}
-TCHAR* __stdcall JabberNickFromJID( const TCHAR* jid )
+TCHAR* __stdcall JabberNickFromJID(const TCHAR *jid)
{
- if (!jid) return mir_tstrdup(_T(""));
+ if ( !jid) return mir_tstrdup(_T(""));
- const TCHAR* p;
+ const TCHAR *p;
TCHAR* nick;
- if (( p = _tcschr( jid, '@' )) == NULL )
- p = _tcschr( jid, '/' );
+ if ((p = _tcschr(jid, '@')) == NULL)
+ p = _tcschr(jid, '/');
- if ( p != NULL ) {
- if (( nick=( TCHAR* )mir_alloc( sizeof(TCHAR)*( int( p-jid )+1 ))) != NULL ) {
- _tcsncpy( nick, jid, p-jid );
+ if (p != NULL) {
+ if ((nick=(TCHAR*)mir_alloc(sizeof(TCHAR)*(int(p-jid)+1))) != NULL) {
+ _tcsncpy(nick, jid, p-jid);
nick[p-jid] = '\0';
}
}
- else nick = mir_tstrdup( jid );
+ else nick = mir_tstrdup(jid);
return nick;
}
-JABBER_RESOURCE_STATUS* CJabberProto::ResourceInfoFromJID( const TCHAR* jid )
+JABBER_RESOURCE_STATUS* CJabberProto::ResourceInfoFromJID(const TCHAR *jid)
{
- if ( !jid )
+ if ( !jid)
return NULL;
JABBER_LIST_ITEM *item = NULL;
- if (( item = ListGetItemPtr( LIST_VCARD_TEMP, jid )) == NULL)
- item = ListGetItemPtr( LIST_ROSTER, jid );
- if ( item == NULL ) return NULL;
+ if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
+ item = ListGetItemPtr(LIST_ROSTER, jid);
+ if (item == NULL) return NULL;
- const TCHAR* p = _tcschr( jid, '/' );
- if ( p == NULL )
+ const TCHAR *p = _tcschr(jid, '/');
+ if (p == NULL)
return &item->itemResource;
- if ( *++p == '\0' ) return NULL;
+ if (*++p == '\0') return NULL;
JABBER_RESOURCE_STATUS *r = item->resource;
- if ( r == NULL ) return NULL;
+ if (r == NULL) return NULL;
int i;
- for ( i=0; i<item->resourceCount && _tcscmp( r->resourceName, p ); i++, r++ );
- if ( i >= item->resourceCount )
+ for (i=0; i<item->resourceCount && _tcscmp(r->resourceName, p); i++, r++);
+ if (i >= item->resourceCount)
return NULL;
return r;
}
-TCHAR* JabberPrepareJid( LPCTSTR jid )
+TCHAR* JabberPrepareJid(LPCTSTR jid)
{
- if ( !jid ) return NULL;
- TCHAR* szNewJid = mir_tstrdup( jid );
- if ( !szNewJid ) return NULL;
- TCHAR* pDelimiter = _tcschr( szNewJid, _T('/'));
- if ( pDelimiter ) *pDelimiter = _T('\0');
- CharLower( szNewJid );
- if ( pDelimiter ) *pDelimiter = _T('/');
+ if ( !jid) return NULL;
+ TCHAR* szNewJid = mir_tstrdup(jid);
+ if ( !szNewJid) return NULL;
+ TCHAR* pDelimiter = _tcschr(szNewJid, _T('/'));
+ if (pDelimiter) *pDelimiter = _T('\0');
+ CharLower(szNewJid);
+ if (pDelimiter) *pDelimiter = _T('/');
return szNewJid;
}
-void strdel( char* parBuffer, int len )
+void strdel(char* parBuffer, int len)
{
char* p;
- for ( p = parBuffer+len; *p != 0; p++ )
+ for (p = parBuffer+len; *p != 0; p++)
p[ -len ] = *p;
p[ -len ] = '\0';
}
-char* __stdcall JabberUrlDecode( char* str )
+char* __stdcall JabberUrlDecode(char* str)
{
char* p, *q;
- if ( str == NULL )
+ if (str == NULL)
return NULL;
- for ( p=q=str; *p!='\0'; p++,q++ ) {
- if ( *p == '<' ) {
+ for (p=q=str; *p!='\0'; p++,q++) {
+ if (*p == '<') {
// skip CDATA
- if ( !strncmp( p, "<![CDATA[", 9 ))
+ if ( !strncmp(p, "<![CDATA[", 9))
{
p += 9;
char *tail = strstr(p, "]]>");
@@ -241,12 +241,12 @@ char* __stdcall JabberUrlDecode( char* str ) *q = *p;
}
} else
- if ( *p == '&' ) {
- if ( !strncmp( p, "&", 5 )) { *q = '&'; p += 4; }
- else if ( !strncmp( p, "'", 6 )) { *q = '\''; p += 5; }
- else if ( !strncmp( p, ">", 4 )) { *q = '>'; p += 3; }
- else if ( !strncmp( p, "<", 4 )) { *q = '<'; p += 3; }
- else if ( !strncmp( p, """, 6 )) { *q = '"'; p += 5; }
+ if (*p == '&') {
+ if ( !strncmp(p, "&", 5)) { *q = '&'; p += 4; }
+ else if ( !strncmp(p, "'", 6)) { *q = '\''; p += 5; }
+ else if ( !strncmp(p, ">", 4)) { *q = '>'; p += 3; }
+ else if ( !strncmp(p, "<", 4)) { *q = '<'; p += 3; }
+ else if ( !strncmp(p, """, 6)) { *q = '"'; p += 5; }
else { *q = *p; }
} else
{
@@ -257,19 +257,19 @@ char* __stdcall JabberUrlDecode( char* str ) return str;
}
-void __stdcall JabberUrlDecodeW( WCHAR* str )
+void __stdcall JabberUrlDecodeW(WCHAR* str)
{
- if ( str == NULL )
+ if (str == NULL)
return;
WCHAR* p, *q;
- for ( p=q=str; *p!='\0'; p++,q++ ) {
- if ( *p == '&' ) {
- if ( !wcsncmp( p, L"&", 5 )) { *q = '&'; p += 4; }
- else if ( !wcsncmp( p, L"'", 6 )) { *q = '\''; p += 5; }
- else if ( !wcsncmp( p, L">", 4 )) { *q = '>'; p += 3; }
- else if ( !wcsncmp( p, L"<", 4 )) { *q = '<'; p += 3; }
- else if ( !wcsncmp( p, L""", 6 )) { *q = '"'; p += 5; }
+ for (p=q=str; *p!='\0'; p++,q++) {
+ if (*p == '&') {
+ if ( !wcsncmp(p, L"&", 5)) { *q = '&'; p += 4; }
+ else if ( !wcsncmp(p, L"'", 6)) { *q = '\''; p += 5; }
+ else if ( !wcsncmp(p, L">", 4)) { *q = '>'; p += 3; }
+ else if ( !wcsncmp(p, L"<", 4)) { *q = '<'; p += 3; }
+ else if ( !wcsncmp(p, L""", 6)) { *q = '"'; p += 5; }
else { *q = *p; }
}
else {
@@ -279,16 +279,16 @@ void __stdcall JabberUrlDecodeW( WCHAR* str ) *q = '\0';
}
-char* __stdcall JabberUrlEncode( const char* str )
+char* __stdcall JabberUrlEncode(const char* str)
{
char* s, *p, *q;
int c;
- if ( str == NULL )
+ if (str == NULL)
return NULL;
- for ( c=0,p=( char* )str; *p!='\0'; p++ ) {
- switch ( *p ) {
+ for (c=0,p=(char*)str; *p!='\0'; p++) {
+ switch (*p) {
case '&': c += 5; break;
case '\'': c += 6; break;
case '>': c += 4; break;
@@ -297,17 +297,17 @@ char* __stdcall JabberUrlEncode( const char* str ) default: c++; break;
}
}
- if (( s=( char* )mir_alloc( c+1 )) != NULL ) {
- for ( p=( char* )str,q=s; *p!='\0'; p++ ) {
- switch ( *p ) {
- case '&': strcpy( q, "&" ); q += 5; break;
- case '\'': strcpy( q, "'" ); q += 6; break;
- case '>': strcpy( q, ">" ); q += 4; break;
- case '<': strcpy( q, "<" ); q += 4; break;
- case '"': strcpy( q, """ ); q += 6; break;
+ if ((s=(char*)mir_alloc(c+1)) != NULL) {
+ for (p=(char*)str,q=s; *p!='\0'; p++) {
+ switch (*p) {
+ case '&': strcpy(q, "&"); q += 5; break;
+ case '\'': strcpy(q, "'"); q += 6; break;
+ case '>': strcpy(q, ">"); q += 4; break;
+ case '<': strcpy(q, "<"); q += 4; break;
+ case '"': strcpy(q, """); q += 6; break;
default:
- if ( *p > 0 && *p < 32 ) {
- switch( *p ) {
+ if (*p > 0 && *p < 32) {
+ switch(*p) {
case '\r':
case '\n':
case '\t':
@@ -328,60 +328,60 @@ char* __stdcall JabberUrlEncode( const char* str ) return s;
}
-void __stdcall JabberUtfToTchar( const char* pszValue, size_t cbLen, LPTSTR& dest )
+void __stdcall JabberUtfToTchar(const char* pszValue, size_t cbLen, LPTSTR& dest)
{
char* pszCopy = NULL;
bool bNeedsFree = false;
__try
{
// this code can cause access violation when a stack overflow occurs
- pszCopy = ( char* )alloca( cbLen+1 );
+ pszCopy = (char*)alloca(cbLen+1);
}
- __except( EXCEPTION_EXECUTE_HANDLER )
+ __except(EXCEPTION_EXECUTE_HANDLER)
{
bNeedsFree = true;
- pszCopy = ( char* )malloc( cbLen+1 );
+ pszCopy = (char*)malloc(cbLen+1);
}
- if ( pszCopy == NULL )
+ if (pszCopy == NULL)
return;
- memcpy( pszCopy, pszValue, cbLen );
+ memcpy(pszCopy, pszValue, cbLen);
pszCopy[ cbLen ] = 0;
- JabberUrlDecode( pszCopy );
+ JabberUrlDecode(pszCopy);
- mir_utf8decode( pszCopy, &dest );
+ mir_utf8decode(pszCopy, &dest);
- if ( bNeedsFree )
- free( pszCopy );
+ if (bNeedsFree)
+ free(pszCopy);
}
-char* __stdcall JabberSha1( char* str )
+char* __stdcall JabberSha1(char* str)
{
mir_sha1_ctx sha;
mir_sha1_byte_t digest[20];
char* result;
int i;
- if ( str == NULL )
+ if (str == NULL)
return NULL;
- mir_sha1_init( &sha );
- mir_sha1_append( &sha, (mir_sha1_byte_t* )str, (int)strlen( str ));
- mir_sha1_finish( &sha, digest );
- if (( result=( char* )mir_alloc( 41 )) == NULL )
+ mir_sha1_init(&sha);
+ mir_sha1_append(&sha, (mir_sha1_byte_t*)str, (int)strlen(str));
+ mir_sha1_finish(&sha, digest);
+ if ((result=(char*)mir_alloc(41)) == NULL)
return NULL;
- for ( i=0; i<20; i++ )
- sprintf( result+( i<<1 ), "%02x", digest[i] );
+ for (i=0; i<20; i++)
+ sprintf(result+(i<<1), "%02x", digest[i]);
return result;
}
-TCHAR* __stdcall JabberStrFixLines( const TCHAR* str )
+TCHAR* __stdcall JabberStrFixLines(const TCHAR *str)
{
- if (!str) return NULL;
+ if ( !str) return NULL;
const TCHAR *p;
int add = 0;
@@ -410,22 +410,22 @@ TCHAR* __stdcall JabberStrFixLines( const TCHAR* str ) return buf;
}
-char* __stdcall JabberUnixToDos( const char* str )
+char* __stdcall JabberUnixToDos(const char* str)
{
char* p, *q, *res;
int extra;
- if ( str==NULL || str[0]=='\0' )
+ if (str==NULL || str[0]=='\0')
return NULL;
extra = 0;
- for ( p=( char* )str; *p!='\0'; p++ ) {
- if ( *p == '\n' )
+ for (p=(char*)str; *p!='\0'; p++) {
+ if (*p == '\n')
extra++;
}
- if (( res=( char* )mir_alloc( strlen( str )+extra+1 )) != NULL ) {
- for ( p=( char* )str,q=res; *p!='\0'; p++,q++ ) {
- if ( *p == '\n' ) {
+ if ((res=(char*)mir_alloc(strlen(str)+extra+1)) != NULL) {
+ for (p=(char*)str,q=res; *p!='\0'; p++,q++) {
+ if (*p == '\n') {
*q = '\r';
q++;
}
@@ -436,22 +436,22 @@ char* __stdcall JabberUnixToDos( const char* str ) return res;
}
-WCHAR* __stdcall JabberUnixToDosW( const WCHAR* str )
+WCHAR* __stdcall JabberUnixToDosW(const WCHAR* str)
{
- if ( str==NULL || str[0]=='\0' )
+ if (str==NULL || str[0]=='\0')
return NULL;
const WCHAR* p;
WCHAR* q, *res;
int extra = 0;
- for ( p = str; *p!='\0'; p++ ) {
- if ( *p == '\n' )
+ for (p = str; *p!='\0'; p++) {
+ if (*p == '\n')
extra++;
}
- if (( res = ( WCHAR* )mir_alloc( sizeof( WCHAR )*( wcslen( str ) + extra + 1 ))) != NULL ) {
- for ( p = str,q=res; *p!='\0'; p++,q++ ) {
- if ( *p == '\n' ) {
+ if ((res = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str) + extra + 1))) != NULL) {
+ for (p = str,q=res; *p!='\0'; p++,q++) {
+ if (*p == '\n') {
*q = '\r';
q++;
}
@@ -462,18 +462,18 @@ WCHAR* __stdcall JabberUnixToDosW( const WCHAR* str ) return res;
}
-TCHAR* __stdcall JabberHttpUrlEncode( const TCHAR* str )
+TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str)
{
TCHAR* p, *q, *res;
- if ( str == NULL ) return NULL;
- res = ( TCHAR* ) mir_alloc( 3*_tcslen( str ) + 1 );
- for ( p = ( TCHAR* )str, q = res; *p!='\0'; p++,q++ ) {
- if (( *p>='A' && *p<='Z' ) || ( *p>='a' && *p<='z' ) || ( *p>='0' && *p<='9' ) || strchr( "$-_.+!*'(),", *p )!=NULL ) {
+ if (str == NULL) return NULL;
+ res = (TCHAR*) mir_alloc(3*_tcslen(str) + 1);
+ for (p = (TCHAR*)str, q = res; *p!='\0'; p++,q++) {
+ if ((*p>='A' && *p<='Z') || (*p>='a' && *p<='z') || (*p>='0' && *p<='9') || strchr("$-_.+!*'(),", *p)!=NULL) {
*q = *p;
}
else {
- wsprintf( q, _T("%%%02X"), *p );
+ wsprintf(q, _T("%%%02X"), *p);
q += 2;
}
}
@@ -481,16 +481,16 @@ TCHAR* __stdcall JabberHttpUrlEncode( const TCHAR* str ) return res;
}
-void __stdcall JabberHttpUrlDecode( TCHAR* str )
+void __stdcall JabberHttpUrlDecode(TCHAR* str)
{
TCHAR* p, *q;
unsigned int code;
- if ( str == NULL ) return;
- for ( p = q = ( TCHAR* )str; *p!='\0'; p++,q++ ) {
- if ( *p=='%' && *( p+1 )!='\0' && isxdigit( *( p+1 )) && *( p+2 )!='\0' && isxdigit( *( p+2 ))) {
- _stscanf(( TCHAR* )p+1, _T("%2x"), &code );
- *q = ( unsigned char ) code;
+ if (str == NULL) return;
+ for (p = q = (TCHAR*)str; *p!='\0'; p++,q++) {
+ if (*p=='%' && *(p+1)!='\0' && isxdigit(*(p+1)) && *(p+2)!='\0' && isxdigit(*(p+2))) {
+ _stscanf((TCHAR*)p+1, _T("%2x"), &code);
+ *q = (unsigned char) code;
p += 2;
}
else {
@@ -500,30 +500,30 @@ void __stdcall JabberHttpUrlDecode( TCHAR* str ) *q = '\0';
}
-int __stdcall JabberCombineStatus( int status1, int status2 )
+int __stdcall JabberCombineStatus(int status1, int status2)
{
- // Combine according to the following priority ( high to low )
+ // Combine according to the following priority (high to low)
// ID_STATUS_FREECHAT
// ID_STATUS_ONLINE
// ID_STATUS_DND
// ID_STATUS_AWAY
// ID_STATUS_NA
- // ID_STATUS_INVISIBLE ( valid only for TLEN_PLUGIN )
+ // ID_STATUS_INVISIBLE (valid only for TLEN_PLUGIN)
// ID_STATUS_OFFLINE
- // other ID_STATUS in random order ( actually return status1 )
- if ( status1==ID_STATUS_FREECHAT || status2==ID_STATUS_FREECHAT )
+ // other ID_STATUS in random order (actually return status1)
+ if (status1==ID_STATUS_FREECHAT || status2==ID_STATUS_FREECHAT)
return ID_STATUS_FREECHAT;
- if ( status1==ID_STATUS_ONLINE || status2==ID_STATUS_ONLINE )
+ if (status1==ID_STATUS_ONLINE || status2==ID_STATUS_ONLINE)
return ID_STATUS_ONLINE;
- if ( status1==ID_STATUS_DND || status2==ID_STATUS_DND )
+ if (status1==ID_STATUS_DND || status2==ID_STATUS_DND)
return ID_STATUS_DND;
- if ( status1==ID_STATUS_AWAY || status2==ID_STATUS_AWAY )
+ if (status1==ID_STATUS_AWAY || status2==ID_STATUS_AWAY)
return ID_STATUS_AWAY;
- if ( status1==ID_STATUS_NA || status2==ID_STATUS_NA )
+ if (status1==ID_STATUS_NA || status2==ID_STATUS_NA)
return ID_STATUS_NA;
- if ( status1==ID_STATUS_INVISIBLE || status2==ID_STATUS_INVISIBLE )
+ if (status1==ID_STATUS_INVISIBLE || status2==ID_STATUS_INVISIBLE)
return ID_STATUS_INVISIBLE;
- if ( status1==ID_STATUS_OFFLINE || status2==ID_STATUS_OFFLINE )
+ if (status1==ID_STATUS_OFFLINE || status2==ID_STATUS_OFFLINE)
return ID_STATUS_OFFLINE;
return status1;
}
@@ -552,73 +552,73 @@ static JabberErrorCodeToStrMapping[] = { { -1, _T("Unknown error") }
};
-TCHAR* __stdcall JabberErrorStr( int errorCode )
+TCHAR* __stdcall JabberErrorStr(int errorCode)
{
int i;
- for ( i=0; JabberErrorCodeToStrMapping[i].code!=-1 && JabberErrorCodeToStrMapping[i].code!=errorCode; i++ );
+ for (i=0; JabberErrorCodeToStrMapping[i].code!=-1 && JabberErrorCodeToStrMapping[i].code!=errorCode; i++);
return JabberErrorCodeToStrMapping[i].str;
}
-TCHAR* __stdcall JabberErrorMsg( HXML errorNode, int* pErrorCode )
+TCHAR* __stdcall JabberErrorMsg(HXML errorNode, int* pErrorCode)
{
- TCHAR* errorStr = ( TCHAR* )mir_alloc( 256 * sizeof( TCHAR ));
- if ( errorNode == NULL ) {
- if ( pErrorCode )
+ TCHAR* errorStr = (TCHAR*)mir_alloc(256 * sizeof(TCHAR));
+ if (errorNode == NULL) {
+ if (pErrorCode)
*pErrorCode = -1;
- mir_sntprintf( errorStr, 256, _T("%s -1: %s"), TranslateT( "Error" ), TranslateT( "Unknown error message" ));
+ mir_sntprintf(errorStr, 256, _T("%s -1: %s"), TranslateT("Error"), TranslateT("Unknown error message"));
return errorStr;
}
int errorCode = -1;
- const TCHAR *str = xmlGetAttrValue( errorNode, _T("code"));
- if ( str != NULL )
- errorCode = _ttoi( str );
-
- str = xmlGetText( errorNode );
- if ( str == NULL )
- str = xmlGetText( xmlGetChild( errorNode, _T("text")));
- if ( str == NULL ) {
- for (int i = 0; ; ++i ) {
- HXML c = xmlGetChild( errorNode, i );
- if ( c == NULL ) break;
- const TCHAR *attr = xmlGetAttrValue( c, _T("xmlns"));
- if ( attr && !_tcscmp( attr, _T("urn:ietf:params:xml:ns:xmpp-stanzas"))) {
- str = xmlGetName( c );
+ const TCHAR *str = xmlGetAttrValue(errorNode, _T("code"));
+ if (str != NULL)
+ errorCode = _ttoi(str);
+
+ str = xmlGetText(errorNode);
+ if (str == NULL)
+ str = xmlGetText(xmlGetChild(errorNode, _T("text")));
+ if (str == NULL) {
+ for (int i = 0; ; ++i) {
+ HXML c = xmlGetChild(errorNode, i);
+ if (c == NULL) break;
+ const TCHAR *attr = xmlGetAttrValue(c, _T("xmlns"));
+ if (attr && !_tcscmp(attr, _T("urn:ietf:params:xml:ns:xmpp-stanzas"))) {
+ str = xmlGetName(c);
break;
}
}
}
- if ( str != NULL )
- mir_sntprintf( errorStr, 256, _T("%s %d: %s\r\n%s"), TranslateT( "Error" ), errorCode, TranslateTS( JabberErrorStr( errorCode )), str );
+ if (str != NULL)
+ mir_sntprintf(errorStr, 256, _T("%s %d: %s\r\n%s"), TranslateT("Error"), errorCode, TranslateTS(JabberErrorStr(errorCode)), str);
else
- mir_sntprintf( errorStr, 256, _T("%s %d: %s"), TranslateT( "Error" ), errorCode, TranslateTS( JabberErrorStr( errorCode )));
+ mir_sntprintf(errorStr, 256, _T("%s %d: %s"), TranslateT("Error"), errorCode, TranslateTS(JabberErrorStr(errorCode)));
- if ( pErrorCode )
+ if (pErrorCode)
*pErrorCode = errorCode;
return errorStr;
}
-void CJabberProto::SendVisibleInvisiblePresence( BOOL invisible )
+void CJabberProto::SendVisibleInvisiblePresence(BOOL invisible)
{
- if ( !m_bJabberOnline ) return;
+ if ( !m_bJabberOnline) return;
LISTFOREACH(i, this, LIST_ROSTER)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex( i );
- if ( item == NULL )
+ JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ if (item == NULL)
continue;
- HANDLE hContact = HContactFromJID( item->jid );
- if ( hContact == NULL )
+ HANDLE hContact = HContactFromJID(item->jid);
+ if (hContact == NULL)
continue;
- WORD apparentMode = JGetWord( hContact, "ApparentMode", 0 );
- if ( invisible==TRUE && apparentMode==ID_STATUS_OFFLINE )
- m_ThreadInfo->send( XmlNode( _T("presence" )) << XATTR( _T("to"), item->jid ) << XATTR( _T("type"), _T("invisible")));
- else if ( invisible==FALSE && apparentMode==ID_STATUS_ONLINE )
- SendPresenceTo( m_iStatus, item->jid, NULL );
+ WORD apparentMode = JGetWord(hContact, "ApparentMode", 0);
+ if (invisible==TRUE && apparentMode==ID_STATUS_OFFLINE)
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), item->jid) << XATTR(_T("type"), _T("invisible")));
+ else if (invisible==FALSE && apparentMode==ID_STATUS_ONLINE)
+ SendPresenceTo(m_iStatus, item->jid, NULL);
} }
/////////////////////////////////////////////////////////////////////////////////////////
@@ -626,36 +626,36 @@ void CJabberProto::SendVisibleInvisiblePresence( BOOL invisible ) static char b64table[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-char* __stdcall JabberBase64Encode( const char* buffer, int bufferLen )
+char* __stdcall JabberBase64Encode(const char* buffer, int bufferLen)
{
- if ( buffer==NULL || bufferLen<=0 )
+ if (buffer==NULL || bufferLen<=0)
return NULL;
- char* res = (char*)mir_alloc(((( bufferLen+2 )*4 )/3 ) + 1);
- if ( res == NULL )
+ char* res = (char*)mir_alloc((((bufferLen+2)*4)/3) + 1);
+ if (res == NULL)
return NULL;
unsigned char igroup[3];
char *r = res;
const char* peob = buffer + bufferLen;
- for ( const char* p = buffer; p < peob; ) {
+ for (const char* p = buffer; p < peob;) {
igroup[ 0 ] = igroup[ 1 ] = igroup[ 2 ] = 0;
int n;
- for ( n=0; n<3; n++ ) {
- if ( p >= peob ) break;
- igroup[n] = ( unsigned char ) *p;
+ for (n=0; n<3; n++) {
+ if (p >= peob) break;
+ igroup[n] = (unsigned char) *p;
p++;
}
- if ( n > 0 ) {
+ if (n > 0) {
r[0] = b64table[ igroup[0]>>2 ];
- r[1] = b64table[ (( igroup[0]&3 )<<4 ) | ( igroup[1]>>4 ) ];
- r[2] = b64table[ (( igroup[1]&0xf )<<2 ) | ( igroup[2]>>6 ) ];
+ r[1] = b64table[ ((igroup[0]&3)<<4) | (igroup[1]>>4) ];
+ r[2] = b64table[ ((igroup[1]&0xf)<<2) | (igroup[2]>>6) ];
r[3] = b64table[ igroup[2]&0x3f ];
- if ( n < 3 ) {
+ if (n < 3) {
r[3] = '=';
- if ( n < 2 )
+ if (n < 2)
r[2] = '=';
}
r += 4;
@@ -671,7 +671,7 @@ char* __stdcall JabberBase64Encode( const char* buffer, int bufferLen ) static unsigned char b64rtable[256];
-char* __stdcall JabberBase64DecodeW( const WCHAR* str, int *resultLen )
+char* __stdcall JabberBase64DecodeW(const WCHAR* str, int *resultLen)
{
char *stra = mir_u2a(str);
char *res = JabberBase64Decode(stra, resultLen);
@@ -679,43 +679,43 @@ char* __stdcall JabberBase64DecodeW( const WCHAR* str, int *resultLen ) return res;
}
-char* __stdcall JabberBase64Decode( const char* str, int *resultLen )
+char* __stdcall JabberBase64Decode(const char* str, int *resultLen)
{
char* res;
unsigned char* r, igroup[4], a[4];
int n, num, count;
- if ( str==NULL || resultLen==NULL ) return NULL;
- if (( res=( char* )mir_alloc(( ( strlen( str )+3 )/4 )*3 )) == NULL ) return NULL;
+ if (str==NULL || resultLen==NULL) return NULL;
+ if ((res=(char*)mir_alloc(((strlen(str)+3)/4)*3)) == NULL) return NULL;
- for ( n=0; n<256; n++ )
- b64rtable[n] = ( unsigned char ) 0x80;
- for ( n=0; n<26; n++ )
+ for (n=0; n<256; n++)
+ b64rtable[n] = (unsigned char) 0x80;
+ for (n=0; n<26; n++)
b64rtable['A'+n] = n;
- for ( n=0; n<26; n++ )
+ for (n=0; n<26; n++)
b64rtable['a'+n] = n + 26;
- for ( n=0; n<10; n++ )
+ for (n=0; n<10; n++)
b64rtable['0'+n] = n + 52;
b64rtable['+'] = 62;
b64rtable['/'] = 63;
b64rtable['='] = 0;
count = 0;
- for ( r=( unsigned char* )res; *str != '\0'; ) {
- for ( n=0; n<4; n++ ) {
- if ( BYTE(*str) == '\r' || BYTE(*str) == '\n' ) {
+ for (r=(unsigned char*)res; *str != '\0';) {
+ for (n=0; n<4; n++) {
+ if (BYTE(*str) == '\r' || BYTE(*str) == '\n') {
n--; str++;
continue;
}
- if ( BYTE(*str)=='\0' ) {
- if ( n == 0 )
+ if (BYTE(*str)=='\0') {
+ if (n == 0)
goto LBL_Exit;
- mir_free( res );
+ mir_free(res);
return NULL;
}
- if ( b64rtable[BYTE(*str)]==0x80 ) {
- mir_free( res );
+ if (b64rtable[BYTE(*str)]==0x80) {
+ mir_free(res);
return NULL;
}
@@ -727,211 +727,211 @@ char* __stdcall JabberBase64Decode( const char* str, int *resultLen ) r[1] = igroup[1]<<4 | igroup[2]>>2;
r[2] = igroup[2]<<6 | igroup[3];
r += 3;
- num = ( a[2]=='='?1:( a[3]=='='?2:3 ));
+ num = (a[2]=='='?1:(a[3]=='='?2:3));
count += num;
- if ( num < 3 ) break;
+ if (num < 3) break;
}
LBL_Exit:
*resultLen = count;
return res;
}
-time_t __stdcall JabberIsoToUnixTime( const TCHAR* stamp )
+time_t __stdcall JabberIsoToUnixTime(const TCHAR *stamp)
{
struct tm timestamp;
TCHAR date[9];
int i, y;
time_t t;
- if ( stamp == NULL ) return ( time_t ) 0;
+ if (stamp == NULL) return (time_t) 0;
const TCHAR *p = stamp;
// Get the date part
- for ( i=0; *p!='\0' && i<8 && isdigit( *p ); p++,i++ )
+ for (i=0; *p!='\0' && i<8 && isdigit(*p); p++,i++)
date[i] = *p;
// Parse year
- if ( i == 6 ) {
- // 2-digit year ( 1970-2069 )
- y = ( date[0]-'0' )*10 + ( date[1]-'0' );
- if ( y < 70 ) y += 100;
+ if (i == 6) {
+ // 2-digit year (1970-2069)
+ y = (date[0]-'0')*10 + (date[1]-'0');
+ if (y < 70) y += 100;
}
- else if ( i == 8 ) {
+ else if (i == 8) {
// 4-digit year
- y = ( date[0]-'0' )*1000 + ( date[1]-'0' )*100 + ( date[2]-'0' )*10 + date[3]-'0';
+ y = (date[0]-'0')*1000 + (date[1]-'0')*100 + (date[2]-'0')*10 + date[3]-'0';
y -= 1900;
}
else
- return ( time_t ) 0;
+ return (time_t) 0;
timestamp.tm_year = y;
// Parse month
- timestamp.tm_mon = ( date[i-4]-'0' )*10 + date[i-3]-'0' - 1;
+ timestamp.tm_mon = (date[i-4]-'0')*10 + date[i-3]-'0' - 1;
// Parse date
- timestamp.tm_mday = ( date[i-2]-'0' )*10 + date[i-1]-'0';
+ timestamp.tm_mday = (date[i-2]-'0')*10 + date[i-1]-'0';
// Skip any date/time delimiter
- for ( ; *p!='\0' && !isdigit( *p ); p++ );
+ for (; *p!='\0' && !isdigit(*p); p++);
// Parse time
- if ( _stscanf( p, _T("%d:%d:%d"), ×tamp.tm_hour, ×tamp.tm_min, ×tamp.tm_sec ) != 3 )
- return ( time_t ) 0;
+ if (_stscanf(p, _T("%d:%d:%d"), ×tamp.tm_hour, ×tamp.tm_min, ×tamp.tm_sec) != 3)
+ return (time_t) 0;
timestamp.tm_isdst = 0; // DST is already present in _timezone below
- t = mktime( ×tamp );
+ t = mktime(×tamp);
_tzset();
t -= _timezone;
- if ( t >= 0 )
+ if (t >= 0)
return t;
else
- return ( time_t ) 0;
+ return (time_t) 0;
}
-void CJabberProto::SendPresenceTo( int status, TCHAR* to, HXML extra, const TCHAR *msg )
+void CJabberProto::SendPresenceTo(int status, TCHAR* to, HXML extra, const TCHAR *msg)
{
- if ( !m_bJabberOnline ) return;
+ if ( !m_bJabberOnline) return;
- // Send <presence/> update for status ( we won't handle ID_STATUS_OFFLINE here )
- short iPriority = (short)JGetWord( NULL, "Priority", 0 );
+ // Send <presence/> update for status (we won't handle ID_STATUS_OFFLINE here)
+ short iPriority = (short)JGetWord(NULL, "Priority", 0);
UpdatePriorityMenu(iPriority);
TCHAR szPriority[40];
- _itot( iPriority, szPriority, 10 );
+ _itot(iPriority, szPriority, 10);
- XmlNode p( _T("presence")); p << XCHILD( _T("priority"), szPriority );
- if ( to != NULL )
- p << XATTR( _T("to"), to );
+ XmlNode p(_T("presence")); p << XCHILD(_T("priority"), szPriority);
+ if (to != NULL)
+ p << XATTR(_T("to"), to);
- if ( extra )
- xmlAddChild( p, extra );
+ if (extra)
+ xmlAddChild(p, extra);
// XEP-0115:Entity Capabilities
- HXML c = p << XCHILDNS( _T("c"), _T(JABBER_FEAT_ENTITY_CAPS)) << XATTR( _T("node"), _T(JABBER_CAPS_MIRANDA_NODE))
- << XATTR( _T("ver"), szCoreVersion);
+ HXML c = p << XCHILDNS(_T("c"), _T(JABBER_FEAT_ENTITY_CAPS)) << XATTR(_T("node"), _T(JABBER_CAPS_MIRANDA_NODE))
+ << XATTR(_T("ver"), szCoreVersion);
TCHAR szExtCaps[ 512 ] = _T("");
- if ( m_bGoogleTalk )
- _tcscat( szExtCaps, _T(JABBER_EXT_GTALK_PMUC));
+ if (m_bGoogleTalk)
+ _tcscat(szExtCaps, _T(JABBER_EXT_GTALK_PMUC));
- if ( bSecureIM ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, _T(JABBER_EXT_SECUREIM));
+ if (bSecureIM) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, _T(JABBER_EXT_SECUREIM));
}
- if ( m_options.EnableRemoteControl ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, _T(JABBER_EXT_COMMANDS));
+ if (m_options.EnableRemoteControl) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, _T(JABBER_EXT_COMMANDS));
}
- if ( m_options.EnableUserMood ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, _T(JABBER_EXT_USER_MOOD));
+ if (m_options.EnableUserMood) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, _T(JABBER_EXT_USER_MOOD));
}
- if ( m_options.EnableUserTune ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, _T(JABBER_EXT_USER_TUNE));
+ if (m_options.EnableUserTune) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, _T(JABBER_EXT_USER_TUNE));
}
- if ( m_options.EnableUserActivity ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, _T(JABBER_EXT_USER_ACTIVITY));
+ if (m_options.EnableUserActivity) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, _T(JABBER_EXT_USER_ACTIVITY));
}
- if ( m_options.AcceptNotes ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, _T(JABBER_EXT_MIR_NOTES));
+ if (m_options.AcceptNotes) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, _T(JABBER_EXT_MIR_NOTES));
}
// add features enabled through IJabberNetInterface::AddFeatures()
- for ( int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++ ) {
- if ( m_uEnabledFeatCapsDynamic & m_lstJabberFeatCapPairsDynamic[i]->jcbCap ) {
- if ( szExtCaps[0] )
- _tcscat( szExtCaps, _T(" "));
- _tcscat( szExtCaps, m_lstJabberFeatCapPairsDynamic[i]->szExt );
+ for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ if (m_uEnabledFeatCapsDynamic & m_lstJabberFeatCapPairsDynamic[i]->jcbCap) {
+ if (szExtCaps[0])
+ _tcscat(szExtCaps, _T(" "));
+ _tcscat(szExtCaps, m_lstJabberFeatCapPairsDynamic[i]->szExt);
}
}
- if ( szExtCaps[0] )
- xmlAddAttr( c, _T("ext"), szExtCaps );
+ if (szExtCaps[0])
+ xmlAddAttr(c, _T("ext"), szExtCaps);
- if ( m_options.EnableAvatars ) {
+ if (m_options.EnableAvatars) {
char hashValue[ 50 ];
- if ( !JGetStaticString( "AvatarHash", NULL, hashValue, sizeof( hashValue ))) {
+ if ( !JGetStaticString("AvatarHash", NULL, hashValue, sizeof(hashValue))) {
// XEP-0153: vCard-Based Avatars
- HXML x = p << XCHILDNS( _T("x"), _T("vcard-temp:x:update"));
- x << XCHILD( _T("photo"), _A2T(hashValue));
+ HXML x = p << XCHILDNS(_T("x"), _T("vcard-temp:x:update"));
+ x << XCHILD(_T("photo"), _A2T(hashValue));
} else {
- HXML x = p << XCHILDNS( _T("x"), _T("vcard-temp:x:update"));
- x << XCHILD( _T("photo"));
+ HXML x = p << XCHILDNS(_T("x"), _T("vcard-temp:x:update"));
+ x << XCHILD(_T("photo"));
}
}
- EnterCriticalSection( &m_csModeMsgMutex );
- switch ( status ) {
+ EnterCriticalSection(&m_csModeMsgMutex);
+ switch (status) {
case ID_STATUS_ONLINE:
- if ( !msg ) msg = m_modeMsgs.szOnline;
+ if ( !msg) msg = m_modeMsgs.szOnline;
break;
case ID_STATUS_INVISIBLE:
- if (!m_bGoogleSharedStatus) p << XATTR( _T("type"), _T("invisible"));
+ if ( !m_bGoogleSharedStatus) p << XATTR(_T("type"), _T("invisible"));
break;
case ID_STATUS_AWAY:
case ID_STATUS_ONTHEPHONE:
case ID_STATUS_OUTTOLUNCH:
- p << XCHILD( _T("show"), _T("away"));
- if ( !msg ) msg = m_modeMsgs.szAway;
+ p << XCHILD(_T("show"), _T("away"));
+ if ( !msg) msg = m_modeMsgs.szAway;
break;
case ID_STATUS_NA:
- p << XCHILD( _T("show"), _T("xa"));
- if ( !msg ) msg = m_modeMsgs.szNa;
+ p << XCHILD(_T("show"), _T("xa"));
+ if ( !msg) msg = m_modeMsgs.szNa;
break;
case ID_STATUS_DND:
case ID_STATUS_OCCUPIED:
- p << XCHILD( _T("show"), _T("dnd"));
- if ( !msg ) msg = m_modeMsgs.szDnd;
+ p << XCHILD(_T("show"), _T("dnd"));
+ if ( !msg) msg = m_modeMsgs.szDnd;
break;
case ID_STATUS_FREECHAT:
- p << XCHILD( _T("show"), _T("chat"));
- if ( !msg ) msg = m_modeMsgs.szFreechat;
+ p << XCHILD(_T("show"), _T("chat"));
+ if ( !msg) msg = m_modeMsgs.szFreechat;
break;
default:
// Should not reach here
break;
}
- if ( msg )
- p << XCHILD( _T("status"), msg );
+ if (msg)
+ p << XCHILD(_T("status"), msg);
- if ( m_bGoogleSharedStatus && !to )
- SendIqGoogleSharedStatus( status, msg );
+ if (m_bGoogleSharedStatus && !to)
+ SendIqGoogleSharedStatus(status, msg);
- LeaveCriticalSection( &m_csModeMsgMutex );
- m_ThreadInfo->send( p );
+ LeaveCriticalSection(&m_csModeMsgMutex);
+ m_ThreadInfo->send(p);
}
-void CJabberProto::SendPresence( int status, bool bSendToAll )
+void CJabberProto::SendPresence(int status, bool bSendToAll)
{
- SendPresenceTo( status, NULL, NULL );
- SendVisibleInvisiblePresence( status == ID_STATUS_INVISIBLE );
+ SendPresenceTo(status, NULL, NULL);
+ SendVisibleInvisiblePresence(status == ID_STATUS_INVISIBLE);
// Also update status in all chatrooms
- if ( bSendToAll ) {
+ if (bSendToAll) {
LISTFOREACH(i, this, LIST_CHATROOM)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex( i );
- if ( item != NULL ) {
+ JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ if (item != NULL) {
TCHAR text[ 1024 ];
- mir_sntprintf( text, SIZEOF( text ), _T("%s/%s"), item->jid, item->nick );
- SendPresenceTo( status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, NULL );
+ mir_sntprintf(text, SIZEOF(text), _T("%s/%s"), item->jid, item->nick);
+ SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, NULL);
} } } }
/////////////////////////////////////////////////////////////////////////////////////////
@@ -985,47 +985,47 @@ void CJabberProto::SendIqGoogleSharedStatus(int status, const TCHAR *msg) { m_ThreadInfo->send(iq);
}
-void __stdcall JabberStringAppend( char* *str, int *sizeAlloced, const char* fmt, ... )
+void __stdcall JabberStringAppend(char* *str, int *sizeAlloced, const char* fmt, ...)
{
va_list vararg;
char* p;
size_t size, len;
- if ( str == NULL ) return;
+ if (str == NULL) return;
- if ( *str==NULL || *sizeAlloced<=0 ) {
+ if (*str==NULL || *sizeAlloced<=0) {
*sizeAlloced = 2048;
size = 2048;
- *str = ( char* )mir_alloc( size );
+ *str = (char*)mir_alloc(size);
len = 0;
}
else {
- len = strlen( *str );
- size = *sizeAlloced - strlen( *str );
+ len = strlen(*str);
+ size = *sizeAlloced - strlen(*str);
}
p = *str + len;
- va_start( vararg, fmt );
- while ( _vsnprintf( p, size, fmt, vararg ) == -1 ) {
+ va_start(vararg, fmt);
+ while (_vsnprintf(p, size, fmt, vararg) == -1) {
size += 2048;
- ( *sizeAlloced ) += 2048;
- *str = ( char* )mir_realloc( *str, *sizeAlloced );
+ (*sizeAlloced) += 2048;
+ *str = (char*)mir_realloc(*str, *sizeAlloced);
p = *str + len;
}
- va_end( vararg );
+ va_end(vararg);
}
///////////////////////////////////////////////////////////////////////////////
// JabberGetPacketID - converts the xml id attribute into an integer
-int __stdcall JabberGetPacketID( HXML n )
+int __stdcall JabberGetPacketID(HXML n)
{
int result = -1;
- const TCHAR* str = xmlGetAttrValue( n, _T("id"));
- if ( str )
- if ( !_tcsncmp( str, _T(JABBER_IQID), SIZEOF( JABBER_IQID )-1 ))
- result = _ttoi( str + SIZEOF( JABBER_IQID )-1 );
+ const TCHAR *str = xmlGetAttrValue(n, _T("id"));
+ if (str)
+ if ( !_tcsncmp(str, _T(JABBER_IQID), SIZEOF(JABBER_IQID)-1))
+ result = _ttoi(str + SIZEOF(JABBER_IQID)-1);
return result;
}
@@ -1033,32 +1033,32 @@ int __stdcall JabberGetPacketID( HXML n ) ///////////////////////////////////////////////////////////////////////////////
// JabberGetClientJID - adds a resource postfix to a JID
-TCHAR* CJabberProto::GetClientJID( const TCHAR* jid, TCHAR* dest, size_t destLen )
+TCHAR* CJabberProto::GetClientJID(const TCHAR *jid, TCHAR* dest, size_t destLen)
{
- if ( jid == NULL )
+ if (jid == NULL)
return NULL;
- size_t len = _tcslen( jid );
- if ( len >= destLen )
+ size_t len = _tcslen(jid);
+ if (len >= destLen)
len = destLen-1;
- _tcsncpy( dest, jid, len );
+ _tcsncpy(dest, jid, len);
dest[ len ] = '\0';
- TCHAR* p = _tcschr( dest, '/' );
+ TCHAR* p = _tcschr(dest, '/');
- JABBER_LIST_ITEM* LI = ListGetItemPtr( LIST_ROSTER, jid );
- if ( LI && LI->resourceCount == 1 && LI->resource[ 0 ].szCapsNode &&
- _tcsicmp( LI->resource[ 0 ].szCapsNode, _T( "http://talk.google.com/xmpp/bot/caps")) == 0)
+ JABBER_LIST_ITEM* LI = ListGetItemPtr(LIST_ROSTER, jid);
+ if (LI && LI->resourceCount == 1 && LI->resource[ 0 ].szCapsNode &&
+ _tcsicmp(LI->resource[ 0 ].szCapsNode, _T("http://talk.google.com/xmpp/bot/caps")) == 0)
{
- if ( p ) *p = 0;
+ if (p) *p = 0;
return dest;
}
- if ( p == NULL ) {
- TCHAR* resource = ListGetBestResourceNamePtr( jid );
- if ( resource != NULL )
- mir_sntprintf( dest+len, destLen-len-1, _T("/%s"), resource );
+ if (p == NULL) {
+ TCHAR* resource = ListGetBestResourceNamePtr(jid);
+ if (resource != NULL)
+ mir_sntprintf(dest+len, destLen-len-1, _T("/%s"), resource);
}
return dest;
@@ -1067,20 +1067,20 @@ TCHAR* CJabberProto::GetClientJID( const TCHAR* jid, TCHAR* dest, size_t destLen ///////////////////////////////////////////////////////////////////////////////
// JabberStripJid - strips a resource postfix from a JID
-TCHAR* __stdcall JabberStripJid( const TCHAR* jid, TCHAR* dest, size_t destLen )
+TCHAR* __stdcall JabberStripJid(const TCHAR *jid, TCHAR* dest, size_t destLen)
{
- if ( jid == NULL )
+ if (jid == NULL)
*dest = 0;
else {
- size_t len = _tcslen( jid );
- if ( len >= destLen )
+ size_t len = _tcslen(jid);
+ if (len >= destLen)
len = destLen-1;
- memcpy( dest, jid, len * sizeof( TCHAR ));
+ memcpy(dest, jid, len * sizeof(TCHAR));
dest[ len ] = 0;
- TCHAR* p = _tcschr( dest, '/' );
- if ( p != NULL )
+ TCHAR* p = _tcschr(dest, '/');
+ if (p != NULL)
*p = 0;
}
@@ -1090,13 +1090,13 @@ TCHAR* __stdcall JabberStripJid( const TCHAR* jid, TCHAR* dest, size_t destLen ) /////////////////////////////////////////////////////////////////////////////////////////
// JabberGetPictureType - tries to autodetect the picture type from the buffer
-int __stdcall JabberGetPictureType( const char* buf )
+int __stdcall JabberGetPictureType(const char* buf)
{
- if ( buf != NULL ) {
- if ( memcmp( buf, "GIF8", 4 ) == 0 ) return PA_FORMAT_GIF;
- if ( memcmp( buf, "\x89PNG", 4 ) == 0 ) return PA_FORMAT_PNG;
- if ( memcmp( buf, "BM", 2 ) == 0 ) return PA_FORMAT_BMP;
- if ( memcmp( buf, "\xFF\xD8", 2 ) == 0 ) return PA_FORMAT_JPEG;
+ if (buf != NULL) {
+ if (memcmp(buf, "GIF8", 4) == 0) return PA_FORMAT_GIF;
+ if (memcmp(buf, "\x89PNG", 4) == 0) return PA_FORMAT_PNG;
+ if (memcmp(buf, "BM", 2) == 0) return PA_FORMAT_BMP;
+ if (memcmp(buf, "\xFF\xD8", 2) == 0) return PA_FORMAT_JPEG;
}
return PA_FORMAT_UNKNOWN;
@@ -1105,38 +1105,38 @@ int __stdcall JabberGetPictureType( const char* buf ) /////////////////////////////////////////////////////////////////////////////////////////
// TStringPairs class members
-TStringPairs::TStringPairs( char* buffer ) :
- elems( NULL )
+TStringPairs::TStringPairs(char* buffer) :
+ elems(NULL)
{
TStringPairsElem tempElem[ 100 ];
- char* token = strtok( buffer, "," );
+ char* token = strtok(buffer, ",");
- for ( numElems=0; token != NULL; numElems++ ) {
- char* p = strchr( token, '=' ), *p1;
- if ( p == NULL )
+ for (numElems=0; token != NULL; numElems++) {
+ char* p = strchr(token, '='), *p1;
+ if (p == NULL)
break;
- while( isspace( *token ))
+ while(isspace(*token))
token++;
- tempElem[ numElems ].name = rtrim( token );
+ tempElem[ numElems ].name = rtrim(token);
*p++ = 0;
- if (( p1 = strchr( p, '\"' )) != NULL ) {
+ if ((p1 = strchr(p, '\"')) != NULL) {
*p1 = 0;
p = p1+1;
}
- if (( p1 = strrchr( p, '\"' )) != NULL )
+ if ((p1 = strrchr(p, '\"')) != NULL)
*p1 = 0;
- tempElem[ numElems ].value = rtrim( p );
- token = strtok( NULL, "," );
+ tempElem[ numElems ].value = rtrim(p);
+ token = strtok(NULL, ",");
}
- if ( numElems ) {
+ if (numElems) {
elems = new TStringPairsElem[ numElems ];
- memcpy( elems, tempElem, sizeof(tempElem[0]) * numElems );
+ memcpy(elems, tempElem, sizeof(tempElem[0]) * numElems);
} }
TStringPairs::~TStringPairs()
@@ -1144,10 +1144,10 @@ TStringPairs::~TStringPairs() delete[] elems;
}
-const char* TStringPairs::operator[]( const char* key ) const
+const char* TStringPairs::operator[](const char* key) const
{
- for ( int i = 0; i < numElems; i++ )
- if ( !strcmp( elems[i].name, key ))
+ for (int i = 0; i < numElems; i++)
+ if ( !strcmp(elems[i].name, key))
return elems[i].value;
return "";
@@ -1162,17 +1162,17 @@ void CJabberProto::ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *par DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "%s%d", param, i);
- if (!JGetStringT(NULL, setting, &dbv)) {
+ if ( !JGetStringT(NULL, setting, &dbv)) {
SendDlgItemMessage(hwndDlg, idcCombo, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
} }
- if (!SendDlgItemMessage(hwndDlg, idcCombo, CB_GETCOUNT, 0, 0))
+ if ( !SendDlgItemMessage(hwndDlg, idcCombo, CB_GETCOUNT, 0, 0))
SendDlgItemMessage(hwndDlg, idcCombo, CB_ADDSTRING, 0, (LPARAM)_T(""));
}
void CJabberProto::ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, TCHAR *string, int recentCount)
{
- if (!string || !*string)
+ if ( !string || !*string)
return;
if (SendDlgItemMessage(hwndDlg, idcCombo, CB_FINDSTRING, (WPARAM)-1, (LPARAM)string) != CB_ERR)
return;
@@ -1192,14 +1192,14 @@ void CJabberProto::ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param /////////////////////////////////////////////////////////////////////////////////////////
// jabber frame maintenance code
-static VOID CALLBACK sttRebuildInfoFrameApcProc( void* param )
+static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param)
{
CJabberProto *ppro = (CJabberProto *)param;
- if (!ppro->m_pInfoFrame)
+ if ( !ppro->m_pInfoFrame)
return;
ppro->m_pInfoFrame->LockUpdates();
- if (!ppro->m_bJabberOnline) {
+ if ( !ppro->m_bJabberOnline) {
ppro->m_pInfoFrame->RemoveInfoItem("$/PEP");
ppro->m_pInfoFrame->RemoveInfoItem("$/Transports");
ppro->m_pInfoFrame->UpdateInfoItem("$/JID", LoadSkinnedIconHandle(SKINICON_OTHER_USERDETAILS), TranslateT("Offline"));
@@ -1207,7 +1207,7 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc( void* param ) else {
ppro->m_pInfoFrame->UpdateInfoItem("$/JID", LoadSkinnedIconHandle(SKINICON_OTHER_USERDETAILS), ppro->m_szJabberJID);
- if (!ppro->m_bPepSupported)
+ if ( !ppro->m_bPepSupported)
ppro->m_pInfoFrame->RemoveInfoItem("$/PEP");
else {
ppro->m_pInfoFrame->RemoveInfoItem("$/PEP/");
@@ -1230,10 +1230,10 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc( void* param ) JABBER_LIST_ITEM *item = NULL;
LISTFOREACH(i, ppro, LIST_ROSTER)
{
- if (( item=ppro->ListGetItemPtrFromIndex( i )) != NULL ) {
- if ( _tcschr( item->jid, '@' )==NULL && _tcschr( item->jid, '/' )==NULL && item->subscription!=SUB_NONE ) {
- HANDLE hContact = ppro->HContactFromJID( item->jid );
- if ( hContact == NULL ) continue;
+ if ((item=ppro->ListGetItemPtrFromIndex(i)) != NULL) {
+ if (_tcschr(item->jid, '@')==NULL && _tcschr(item->jid, '/')==NULL && item->subscription!=SUB_NONE) {
+ HANDLE hContact = ppro->HContactFromJID(item->jid);
+ if (hContact == NULL) continue;
char name[128];
char *jid_copy = mir_t2a(item->jid);
@@ -1255,7 +1255,7 @@ void CJabberProto::RebuildInfoFrame() ////////////////////////////////////////////////////////////////////////
// case-insensitive _tcsstr
-const TCHAR *JabberStrIStr( const TCHAR *str, const TCHAR *substr)
+const TCHAR *JabberStrIStr(const TCHAR *str, const TCHAR *substr)
{
TCHAR *str_up = NEWTSTR_ALLOCA(str);
TCHAR *substr_up = NEWTSTR_ALLOCA(substr);
@@ -1271,7 +1271,7 @@ const TCHAR *JabberStrIStr( const TCHAR *str, const TCHAR *substr) // clipboard processing
void JabberCopyText(HWND hwnd, TCHAR *text)
{
- if (!hwnd || !text) return;
+ if ( !hwnd || !text) return;
OpenClipboard(hwnd);
EmptyClipboard();
@@ -1317,20 +1317,20 @@ static int sttEnterStringResizer(HWND, LPARAM, UTILRESIZECONTROL *urc) return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
}
-static INT_PTR CALLBACK sttEnterStringDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- JabberEnterStringParams *params = (JabberEnterStringParams *)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ JabberEnterStringParams *params = (JabberEnterStringParams *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
{
- //SetWindowPos( hwndDlg, HWND_TOPMOST ,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE );
- TranslateDialogDefault( hwndDlg );
+ //SetWindowPos(hwndDlg, HWND_TOPMOST ,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
+ TranslateDialogDefault(hwndDlg);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIconBig(SKINICON_OTHER_RENAME));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_RENAME));
JabberEnterStringParams *params = (JabberEnterStringParams *)lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR )params );
- SetWindowText( hwndDlg, params->caption );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params);
+ SetWindowText(hwndDlg, params->caption);
RECT rc; GetWindowRect(hwndDlg, &rc);
switch (params->type)
@@ -1370,7 +1370,7 @@ static INT_PTR CALLBACK sttEnterStringDlgProc( HWND hwndDlg, UINT msg, WPARAM wP }
ShowWindow(GetDlgItem(hwndDlg, params->idcControl), SW_SHOW);
- SetDlgItemText( hwndDlg, params->idcControl, params->result );
+ SetDlgItemText(hwndDlg, params->idcControl, params->result);
if (params->windowName)
Utils_RestoreWindowPosition(hwndDlg, NULL, params->ppro->m_szModuleName, params->windowName);
@@ -1388,7 +1388,7 @@ static INT_PTR CALLBACK sttEnterStringDlgProc( HWND hwndDlg, UINT msg, WPARAM wP return TRUE;
}
case WM_DESTROY:
- WindowFreeIcon( hwndDlg );
+ WindowFreeIcon(hwndDlg);
break;
case WM_TIMER:
{
@@ -1456,9 +1456,9 @@ static INT_PTR CALLBACK sttEnterStringDlgProc( HWND hwndDlg, UINT msg, WPARAM wP return TRUE;
}
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDOK:
- GetDlgItemText( hwndDlg, params->idcControl, params->result, (int)params->resultLen );
+ GetDlgItemText(hwndDlg, params->idcControl, params->result, (int)params->resultLen);
params->result[ params->resultLen-1 ] = 0;
if ((params->type == JES_COMBO) && params->windowName && params->recentCount)
@@ -1466,14 +1466,14 @@ static INT_PTR CALLBACK sttEnterStringDlgProc( HWND hwndDlg, UINT msg, WPARAM wP if (params->windowName)
Utils_SaveWindowPosition(hwndDlg, NULL, params->ppro->m_szModuleName, params->windowName);
- EndDialog( hwndDlg, 1 );
+ EndDialog(hwndDlg, 1);
break;
case IDCANCEL:
if (params->windowName)
Utils_SaveWindowPosition(hwndDlg, NULL, params->ppro->m_szModuleName, params->windowName);
- EndDialog( hwndDlg, 0 );
+ EndDialog(hwndDlg, 0);
break;
case IDC_TXT_MULTILINE:
@@ -1500,18 +1500,18 @@ static INT_PTR CALLBACK sttEnterStringDlgProc( HWND hwndDlg, UINT msg, WPARAM wP BOOL CJabberProto::EnterString(TCHAR *result, size_t resultLen, TCHAR *caption, int type, char *windowName, int recentCount, int timeout)
{
bool free_caption = false;
- if (!caption || (caption==result))
+ if ( !caption || (caption==result))
{
free_caption = true;
- caption = mir_tstrdup( result );
+ caption = mir_tstrdup(result);
result[ 0 ] = _T('\0');
}
JabberEnterStringParams params = { this, type, caption, result, resultLen, windowName, recentCount, timeout };
- BOOL bRetVal = DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_GROUPCHAT_INPUT ), GetForegroundWindow(), sttEnterStringDlgProc, LPARAM( ¶ms ));
+ BOOL bRetVal = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_GROUPCHAT_INPUT), GetForegroundWindow(), sttEnterStringDlgProc, LPARAM(¶ms));
- if (free_caption) mir_free( caption );
+ if (free_caption) mir_free(caption);
return bRetVal;
}
@@ -1560,73 +1560,73 @@ void JabberBitmapPremultiplyChannels(HBITMAP hBitmap) // Last resource map
void CJabberProto::CleanLastResourceMap()
{
- EnterCriticalSection( &m_csLastResourceMap );
+ EnterCriticalSection(&m_csLastResourceMap);
m_dwResourceMapPointer = 0;
- ZeroMemory( m_ulpResourceToDbEventMap, sizeof( m_ulpResourceToDbEventMap ));
+ ZeroMemory(m_ulpResourceToDbEventMap, sizeof(m_ulpResourceToDbEventMap));
- while ( m_pLastResourceList ) {
- void *pNext = (( void ** )m_pLastResourceList )[ 0 ];
- mir_free( m_pLastResourceList );
+ while (m_pLastResourceList) {
+ void *pNext = ((void **)m_pLastResourceList)[ 0 ];
+ mir_free(m_pLastResourceList);
m_pLastResourceList = pNext;
}
- LeaveCriticalSection( &m_csLastResourceMap );
+ LeaveCriticalSection(&m_csLastResourceMap);
}
// lock CS before use
-BOOL CJabberProto::IsLastResourceExists( void *pResource )
+BOOL CJabberProto::IsLastResourceExists(void *pResource)
{
- if ( !pResource )
+ if ( !pResource)
return FALSE;
void *pOurResource = m_pLastResourceList;
- while ( pOurResource ) {
- if ( pOurResource == pResource )
+ while (pOurResource) {
+ if (pOurResource == pResource)
return TRUE;
- pOurResource = (( void ** )pOurResource)[ 0 ];
+ pOurResource = ((void **)pOurResource)[ 0 ];
}
return FALSE;
}
// lock CS before use
-void* CJabberProto::AddToLastResourceMap( LPCTSTR szFullJid )
+void* CJabberProto::AddToLastResourceMap(LPCTSTR szFullJid)
{
// detach resource from full jid
- const TCHAR* szResource = _tcschr( szFullJid, '/' );
- if ( szResource == NULL )
+ const TCHAR *szResource = _tcschr(szFullJid, '/');
+ if (szResource == NULL)
return NULL;
- if ( *++szResource == '\0' )
+ if (*++szResource == '\0')
return NULL;
DWORD dwResourceCount = 0;
void *pNewTailResource = NULL;
void *pOurResource = m_pLastResourceList;
- while ( pOurResource ) {
+ while (pOurResource) {
dwResourceCount++;
- if ( !_tcscmp(( TCHAR * )(( BYTE * )pOurResource + sizeof( void * )), szResource ))
+ if ( !_tcscmp((TCHAR *)((BYTE *)pOurResource + sizeof(void *)), szResource))
return pOurResource;
- void *pTmp = (( void ** )pOurResource )[ 0 ];
- if ( pTmp && !((( void ** )pTmp )[ 0 ]))
+ void *pTmp = ((void **)pOurResource)[ 0 ];
+ if (pTmp && !(((void **)pTmp)[ 0 ]))
pNewTailResource = pOurResource;
pOurResource = pTmp;
}
- if ( pNewTailResource && ( dwResourceCount > ( SIZEOF( m_ulpResourceToDbEventMap ) / 2 ))) {
- void *pTmp = (( void ** )pNewTailResource )[ 0 ];
- (( void ** )pNewTailResource )[ 0 ] = NULL;
- mir_free( pTmp );
+ if (pNewTailResource && (dwResourceCount > (SIZEOF(m_ulpResourceToDbEventMap) / 2))) {
+ void *pTmp = ((void **)pNewTailResource)[ 0 ];
+ ((void **)pNewTailResource)[ 0 ] = NULL;
+ mir_free(pTmp);
}
- void *pNewResource = mir_alloc( sizeof( void * ) + sizeof( TCHAR ) * ( _tcslen( szResource ) + 1 ));
- if ( !pNewResource )
+ void *pNewResource = mir_alloc(sizeof(void *) + sizeof(TCHAR) * (_tcslen(szResource) + 1));
+ if ( !pNewResource)
return NULL;
- (( void ** )pNewResource)[ 0 ] = m_pLastResourceList;
- _tcscpy(( TCHAR * )(( BYTE * )pNewResource + sizeof( void * )), szResource );
+ ((void **)pNewResource)[ 0 ] = m_pLastResourceList;
+ _tcscpy((TCHAR *)((BYTE *)pNewResource + sizeof(void *)), szResource);
m_pLastResourceList = pNewResource;
@@ -1634,11 +1634,11 @@ void* CJabberProto::AddToLastResourceMap( LPCTSTR szFullJid ) }
// lock CS before use
-TCHAR* CJabberProto::FindLastResourceByDbEvent( HANDLE hDbEvent )
+TCHAR* CJabberProto::FindLastResourceByDbEvent(HANDLE hDbEvent)
{
- for ( int i = 0; i < SIZEOF( m_ulpResourceToDbEventMap ); i += 2 ) {
- if ( m_ulpResourceToDbEventMap[ i ] == ( ULONG_PTR )hDbEvent ) {
- TCHAR *szRetVal = ( TCHAR * )( m_ulpResourceToDbEventMap[ i + 1 ] + sizeof( void * ));
+ for (int i = 0; i < SIZEOF(m_ulpResourceToDbEventMap); i += 2) {
+ if (m_ulpResourceToDbEventMap[ i ] == (ULONG_PTR)hDbEvent) {
+ TCHAR *szRetVal = (TCHAR *)(m_ulpResourceToDbEventMap[ i + 1 ] + sizeof(void *));
m_ulpResourceToDbEventMap[ i ] = 0;
m_ulpResourceToDbEventMap[ i + 1 ] = 0;
return szRetVal;
@@ -1647,31 +1647,31 @@ TCHAR* CJabberProto::FindLastResourceByDbEvent( HANDLE hDbEvent ) return NULL;
}
-BOOL CJabberProto::IsMyOwnJID( LPCTSTR szJID )
+BOOL CJabberProto::IsMyOwnJID(LPCTSTR szJID)
{
- if ( !m_ThreadInfo )
+ if ( !m_ThreadInfo)
return FALSE;
- TCHAR* szFrom = JabberPrepareJid( szJID );
- if ( !szFrom )
+ TCHAR* szFrom = JabberPrepareJid(szJID);
+ if ( !szFrom)
return FALSE;
- TCHAR* szTo = JabberPrepareJid( m_ThreadInfo->fullJID );
- if ( !szTo ) {
- mir_free( szFrom );
+ TCHAR* szTo = JabberPrepareJid(m_ThreadInfo->fullJID);
+ if ( !szTo) {
+ mir_free(szFrom);
return FALSE;
}
- TCHAR* pDelimiter = _tcschr( szFrom, _T('/'));
- if ( pDelimiter ) *pDelimiter = _T('\0');
+ TCHAR* pDelimiter = _tcschr(szFrom, _T('/'));
+ if (pDelimiter) *pDelimiter = _T('\0');
- pDelimiter = _tcschr( szTo, _T('/'));
- if ( pDelimiter ) *pDelimiter = _T('\0');
+ pDelimiter = _tcschr(szTo, _T('/'));
+ if (pDelimiter) *pDelimiter = _T('\0');
- BOOL bRetVal = _tcscmp( szFrom, szTo ) == 0;
+ BOOL bRetVal = _tcscmp(szFrom, szTo) == 0;
- mir_free( szFrom );
- mir_free( szTo );
+ mir_free(szFrom);
+ mir_free(szTo);
return bRetVal;
}
@@ -1693,9 +1693,9 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) if (res)
{
hHttpCon = res->nlc;
- if ( res->resultCode == 200 && res->dataLength )
+ if (res->resultCode == 200 && res->dataLength)
{
- int pictureType = JabberGetPictureType( res->pData );
+ int pictureType = JabberGetPictureType(res->pData);
if (pictureType != PA_FORMAT_UNKNOWN)
{
TCHAR tszFileName[ MAX_PATH ];
@@ -1705,36 +1705,36 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) AI.format = pictureType;
AI.hContact = avs[i].hContact;
- if ( JGetByte( AI.hContact, "AvatarType", PA_FORMAT_UNKNOWN ) != (unsigned char)pictureType ) {
- GetAvatarFileName( AI.hContact, tszFileName, SIZEOF(tszFileName));
- DeleteFile( tszFileName );
+ if (JGetByte(AI.hContact, "AvatarType", PA_FORMAT_UNKNOWN) != (unsigned char)pictureType) {
+ GetAvatarFileName(AI.hContact, tszFileName, SIZEOF(tszFileName));
+ DeleteFile(tszFileName);
}
- JSetByte( AI.hContact, "AvatarType", pictureType );
+ JSetByte(AI.hContact, "AvatarType", pictureType);
char cmpsha[ 41 ];
char buffer[ 41 ];
mir_sha1_byte_t digest[20];
mir_sha1_ctx sha;
- mir_sha1_init( &sha );
- mir_sha1_append( &sha, ( mir_sha1_byte_t* )res->pData, res->dataLength );
- mir_sha1_finish( &sha, digest );
- for ( int i=0; i<20; i++ )
- sprintf( buffer+( i<<1 ), "%02x", digest[i] );
+ mir_sha1_init(&sha);
+ mir_sha1_append(&sha, (mir_sha1_byte_t*)res->pData, res->dataLength);
+ mir_sha1_finish(&sha, digest);
+ for (int i=0; i<20; i++)
+ sprintf(buffer+(i<<1), "%02x", digest[i]);
if (JGetStaticString("AvatarSaved", AI.hContact, cmpsha, sizeof(cmpsha)) || strnicmp(cmpsha, buffer, sizeof(buffer)))
{
- GetAvatarFileName( AI.hContact, tszFileName, SIZEOF(tszFileName));
+ GetAvatarFileName(AI.hContact, tszFileName, SIZEOF(tszFileName));
_tcsncpy(AI.filename, tszFileName, SIZEOF(AI.filename));
- FILE* out = _tfopen( tszFileName, _T("wb"));
- if ( out != NULL ) {
- fwrite( res->pData, res->dataLength, 1, out );
- fclose( out );
- JSetString( AI.hContact, "AvatarSaved", buffer );
- JSendBroadcast( AI.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0 );
+ FILE* out = _tfopen(tszFileName, _T("wb"));
+ if (out != NULL) {
+ fwrite(res->pData, res->dataLength, 1, out);
+ fclose(out);
+ JSetString(AI.hContact, "AvatarSaved", buffer);
+ JSendBroadcast(AI.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0);
Log("Broadcast new avatar: %s",AI.filename);
}
- else JSendBroadcast( AI.hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &AI, 0 );
+ else JSendBroadcast(AI.hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, &AI, 0);
}
}
}
@@ -1744,6 +1744,6 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) hHttpCon = NULL;
}
delete &avs;
- if ( hHttpCon )
+ if (hHttpCon)
Netlib_CloseHandle(hHttpCon);
}
\ No newline at end of file diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 691f3516ed..70b4ee433c 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.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
@@ -29,70 +29,70 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////////////////
-int CJabberProto::SendGetVcard( const TCHAR* jid )
+int CJabberProto::SendGetVcard(const TCHAR *jid)
{
- if (!m_bJabberOnline) return 0;
+ if ( !m_bJabberOnline) return 0;
int iqId = SerialNext();
- JABBER_IQ_PROCID procId = !lstrcmp( jid, m_szJabberJID ) ? IQ_PROC_GETVCARD : IQ_PROC_NONE;
+ JABBER_IQ_PROCID procId = !lstrcmp(jid, m_szJabberJID) ? IQ_PROC_GETVCARD : IQ_PROC_NONE;
- IqAdd( iqId, procId, &CJabberProto::OnIqResultGetVcard );
+ IqAdd(iqId, procId, &CJabberProto::OnIqResultGetVcard);
m_ThreadInfo->send(
- XmlNodeIq( _T("get"), iqId, jid ) << XCHILDNS( _T("vCard"), _T(JABBER_FEAT_VCARD_TEMP))
- << XATTR( _T("prodid"), _T("-//HandGen//NONSGML vGen v1.0//EN")) << XATTR( _T("version"), _T("2.0")));
+ XmlNodeIq(_T("get"), iqId, jid) << XCHILDNS(_T("vCard"), _T(JABBER_FEAT_VCARD_TEMP))
+ << XATTR(_T("prodid"), _T("-//HandGen//NONSGML vGen v1.0//EN")) << XATTR(_T("version"), _T("2.0")));
return iqId;
}
/////////////////////////////////////////////////////////////////////////////////////////
-static void SetDialogField( CJabberProto* ppro, HWND hwndDlg, int nDlgItem, char* key, bool bTranslate = false )
+static void SetDialogField(CJabberProto* ppro, HWND hwndDlg, int nDlgItem, char* key, bool bTranslate = false)
{
DBVARIANT dbv;
- if ( !DBGetContactSettingTString( NULL, ppro->m_szModuleName, key, &dbv )) {
- SetDlgItemText( hwndDlg, nDlgItem, ( bTranslate ) ? TranslateTS(dbv.ptszVal) : dbv.ptszVal );
- JFreeVariant( &dbv );
+ if ( !DBGetContactSettingTString(NULL, ppro->m_szModuleName, key, &dbv)) {
+ SetDlgItemText(hwndDlg, nDlgItem, (bTranslate) ? TranslateTS(dbv.ptszVal) : dbv.ptszVal);
+ db_free(&dbv);
}
- else SetDlgItemTextA( hwndDlg, nDlgItem, "" );
+ else SetDlgItemTextA(hwndDlg, nDlgItem, "");
}
-static INT_PTR CALLBACK PersonalDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK PersonalDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
const unsigned long iPageId = 0;
- CJabberProto* ppro = ( CJabberProto* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- if ( lParam ) {
- ppro = ( CJabberProto* )lParam;
- TranslateDialogDefault( hwndDlg );
- SendMessage( GetDlgItem( hwndDlg, IDC_GENDER ), CB_ADDSTRING, 0, ( LPARAM )TranslateT( "Male" ));
- SendMessage( GetDlgItem( hwndDlg, IDC_GENDER ), CB_ADDSTRING, 0, ( LPARAM )TranslateT( "Female" ));
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
- SendMessage( hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0 );
+ if (lParam) {
+ ppro = (CJabberProto*)lParam;
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(GetDlgItem(hwndDlg, IDC_GENDER), CB_ADDSTRING, 0, (LPARAM)TranslateT("Male"));
+ SendMessage(GetDlgItem(hwndDlg, IDC_GENDER), CB_ADDSTRING, 0, (LPARAM)TranslateT("Female"));
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
ppro->WindowSubscribe(hwndDlg);
}
break;
case WM_JABBER_REFRESH_VCARD:
- SetDialogField( ppro, hwndDlg, IDC_FULLNAME, "FullName" );
- SetDialogField( ppro, hwndDlg, IDC_NICKNAME, "Nick" );
- SetDialogField( ppro, hwndDlg, IDC_FIRSTNAME, "FirstName" );
- SetDialogField( ppro, hwndDlg, IDC_MIDDLE, "MiddleName" );
- SetDialogField( ppro, hwndDlg, IDC_LASTNAME, "LastName" );
- SetDialogField( ppro, hwndDlg, IDC_BIRTH, "BirthDate" );
- SetDialogField( ppro, hwndDlg, IDC_GENDER, "GenderString", true );
- SetDialogField( ppro, hwndDlg, IDC_OCCUPATION, "Role" );
- SetDialogField( ppro, hwndDlg, IDC_HOMEPAGE, "Homepage" );
+ SetDialogField(ppro, hwndDlg, IDC_FULLNAME, "FullName");
+ SetDialogField(ppro, hwndDlg, IDC_NICKNAME, "Nick");
+ SetDialogField(ppro, hwndDlg, IDC_FIRSTNAME, "FirstName");
+ SetDialogField(ppro, hwndDlg, IDC_MIDDLE, "MiddleName");
+ SetDialogField(ppro, hwndDlg, IDC_LASTNAME, "LastName");
+ SetDialogField(ppro, hwndDlg, IDC_BIRTH, "BirthDate");
+ SetDialogField(ppro, hwndDlg, IDC_GENDER, "GenderString", true);
+ SetDialogField(ppro, hwndDlg, IDC_OCCUPATION, "Role");
+ SetDialogField(ppro, hwndDlg, IDC_HOMEPAGE, "Homepage");
break;
case WM_COMMAND:
- if (( ( HWND )lParam==GetFocus() && HIWORD( wParam )==EN_CHANGE ) ||
- (( HWND )lParam==GetDlgItem( hwndDlg, IDC_GENDER ) && ( HIWORD( wParam )==CBN_EDITCHANGE||HIWORD( wParam )==CBN_SELCHANGE )))
+ if (((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) ||
+ ((HWND)lParam==GetDlgItem(hwndDlg, IDC_GENDER) && (HIWORD(wParam)==CBN_EDITCHANGE||HIWORD(wParam)==CBN_SELCHANGE)))
{
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -104,9 +104,9 @@ static INT_PTR CALLBACK PersonalDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, break;
case PSN_APPLY:
ppro->m_vCardUpdates &= ~(1UL<<iPageId);
- ppro->SaveVcardToDB( hwndDlg, iPageId );
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard( ppro->m_bPhotoChanged, ppro->m_szPhotoFileName );
+ ppro->SaveVcardToDB(hwndDlg, iPageId);
+ if ( !ppro->m_vCardUpdates)
+ ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
} }
break;
@@ -118,44 +118,44 @@ static INT_PTR CALLBACK PersonalDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, return FALSE;
}
-static INT_PTR CALLBACK HomeDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK HomeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
const unsigned long iPageId = 1;
- CJabberProto* ppro = ( CJabberProto* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- if ( lParam ) {
- ppro = ( CJabberProto* )lParam;
- TranslateDialogDefault( hwndDlg );
+ if (lParam) {
+ ppro = (CJabberProto*)lParam;
+ TranslateDialogDefault(hwndDlg);
for (int i = 0; i < g_cbCountries; i++) {
- if ( g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
+ if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
TCHAR *country = mir_a2t(g_countries[i].szName);
- SendMessage( GetDlgItem( hwndDlg, IDC_COUNTRY ), CB_ADDSTRING, 0, ( LPARAM )TranslateTS(country));
+ SendMessage(GetDlgItem(hwndDlg, IDC_COUNTRY), CB_ADDSTRING, 0, (LPARAM)TranslateTS(country));
mir_free(country);
}
}
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
- SendMessage( hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0 );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
ppro->WindowSubscribe(hwndDlg);
}
break;
case WM_JABBER_REFRESH_VCARD:
- SetDialogField( ppro, hwndDlg, IDC_ADDRESS1, "Street" );
- SetDialogField( ppro, hwndDlg, IDC_ADDRESS2, "Street2" );
- SetDialogField( ppro, hwndDlg, IDC_CITY, "City" );
- SetDialogField( ppro, hwndDlg, IDC_STATE, "State" );
- SetDialogField( ppro, hwndDlg, IDC_ZIP, "ZIP" );
- SetDialogField( ppro, hwndDlg, IDC_COUNTRY, "Country", true );
+ SetDialogField(ppro, hwndDlg, IDC_ADDRESS1, "Street");
+ SetDialogField(ppro, hwndDlg, IDC_ADDRESS2, "Street2");
+ SetDialogField(ppro, hwndDlg, IDC_CITY, "City");
+ SetDialogField(ppro, hwndDlg, IDC_STATE, "State");
+ SetDialogField(ppro, hwndDlg, IDC_ZIP, "ZIP");
+ SetDialogField(ppro, hwndDlg, IDC_COUNTRY, "Country", true);
break;
case WM_COMMAND:
- if ((( HWND )lParam==GetFocus() && HIWORD( wParam )==EN_CHANGE) ||
- (( HWND )lParam==GetDlgItem( hwndDlg, IDC_COUNTRY ) && ( HIWORD( wParam )==CBN_EDITCHANGE||HIWORD( wParam )==CBN_SELCHANGE )))
+ if (((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) ||
+ ((HWND)lParam==GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam)==CBN_EDITCHANGE||HIWORD(wParam)==CBN_SELCHANGE)))
{
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -167,9 +167,9 @@ static INT_PTR CALLBACK HomeDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case PSN_APPLY:
ppro->m_vCardUpdates &= ~(1UL<<iPageId);
- ppro->SaveVcardToDB( hwndDlg, iPageId );
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard( ppro->m_bPhotoChanged, ppro->m_szPhotoFileName );
+ ppro->SaveVcardToDB(hwndDlg, iPageId);
+ if ( !ppro->m_vCardUpdates)
+ ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
} }
break;
@@ -181,47 +181,47 @@ static INT_PTR CALLBACK HomeDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE;
}
-static INT_PTR CALLBACK WorkDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
const unsigned long iPageId = 2;
- CJabberProto* ppro = ( CJabberProto* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- if ( lParam ) { // proto info is available
- ppro = ( CJabberProto* )lParam;
- TranslateDialogDefault( hwndDlg );
+ if (lParam) { // proto info is available
+ ppro = (CJabberProto*)lParam;
+ TranslateDialogDefault(hwndDlg);
for (int i = 0; i < g_cbCountries; i++) {
- if ( g_countries[i].id != 0xFFFF && g_countries[i].id != 0 ) {
- TCHAR *country = mir_a2t( g_countries[i].szName );
- SendMessage( GetDlgItem( hwndDlg, IDC_COUNTRY ), CB_ADDSTRING, 0, ( LPARAM )TranslateTS(country));
+ if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
+ TCHAR *country = mir_a2t(g_countries[i].szName);
+ SendMessage(GetDlgItem(hwndDlg, IDC_COUNTRY), CB_ADDSTRING, 0, (LPARAM)TranslateTS(country));
mir_free(country);
}
}
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
- SendMessage( hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0 );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
ppro->WindowSubscribe(hwndDlg);
}
break;
case WM_JABBER_REFRESH_VCARD:
- SetDialogField( ppro, hwndDlg, IDC_COMPANY, "Company" );
- SetDialogField( ppro, hwndDlg, IDC_DEPARTMENT, "CompanyDepartment" );
- SetDialogField( ppro, hwndDlg, IDC_TITLE, "CompanyPosition" );
- SetDialogField( ppro, hwndDlg, IDC_ADDRESS1, "CompanyStreet" );
- SetDialogField( ppro, hwndDlg, IDC_ADDRESS2, "CompanyStreet2" );
- SetDialogField( ppro, hwndDlg, IDC_CITY, "CompanyCity" );
- SetDialogField( ppro, hwndDlg, IDC_STATE, "CompanyState" );
- SetDialogField( ppro, hwndDlg, IDC_ZIP, "CompanyZIP" );
- SetDialogField( ppro, hwndDlg, IDC_COUNTRY, "CompanyCountry", true );
+ SetDialogField(ppro, hwndDlg, IDC_COMPANY, "Company");
+ SetDialogField(ppro, hwndDlg, IDC_DEPARTMENT, "CompanyDepartment");
+ SetDialogField(ppro, hwndDlg, IDC_TITLE, "CompanyPosition");
+ SetDialogField(ppro, hwndDlg, IDC_ADDRESS1, "CompanyStreet");
+ SetDialogField(ppro, hwndDlg, IDC_ADDRESS2, "CompanyStreet2");
+ SetDialogField(ppro, hwndDlg, IDC_CITY, "CompanyCity");
+ SetDialogField(ppro, hwndDlg, IDC_STATE, "CompanyState");
+ SetDialogField(ppro, hwndDlg, IDC_ZIP, "CompanyZIP");
+ SetDialogField(ppro, hwndDlg, IDC_COUNTRY, "CompanyCountry", true);
break;
case WM_COMMAND:
- if ((( HWND )lParam==GetFocus() && HIWORD( wParam )==EN_CHANGE) ||
- (( HWND )lParam==GetDlgItem( hwndDlg, IDC_COUNTRY ) && ( HIWORD( wParam )==CBN_EDITCHANGE||HIWORD( wParam )==CBN_SELCHANGE )))
+ if (((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) ||
+ ((HWND)lParam==GetDlgItem(hwndDlg, IDC_COUNTRY) && (HIWORD(wParam)==CBN_EDITCHANGE||HIWORD(wParam)==CBN_SELCHANGE)))
{
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -233,9 +233,9 @@ static INT_PTR CALLBACK WorkDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case PSN_APPLY:
ppro->m_vCardUpdates &= ~(1UL<<iPageId);
- ppro->SaveVcardToDB( hwndDlg, iPageId );
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard( ppro->m_bPhotoChanged, ppro->m_szPhotoFileName );
+ ppro->SaveVcardToDB(hwndDlg, iPageId);
+ if ( !ppro->m_vCardUpdates)
+ ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
} }
break;
@@ -257,77 +257,77 @@ struct PhotoDlgProcData HBITMAP hBitmap;
};
-static INT_PTR CALLBACK PhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
const unsigned long iPageId = 3;
TCHAR szAvatarFileName[ MAX_PATH ], szTempPath[MAX_PATH], szTempFileName[MAX_PATH];
- PhotoDlgProcData* dat = ( PhotoDlgProcData* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ PhotoDlgProcData* dat = (PhotoDlgProcData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- if (!lParam) break; // Launched from userinfo
- TranslateDialogDefault( hwndDlg );
- SendDlgItemMessage( hwndDlg, IDC_LOAD, BM_SETIMAGE, IMAGE_ICON, ( LPARAM )LoadImage( hInst, MAKEINTRESOURCE( IDI_OPEN ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 ));
- SendDlgItemMessage( hwndDlg, IDC_LOAD, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage( hwndDlg, IDC_DELETE, BM_SETIMAGE, IMAGE_ICON, ( LPARAM )LoadImage( hInst, MAKEINTRESOURCE( IDI_DELETE ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 ));
- SendDlgItemMessage( hwndDlg, IDC_DELETE, BUTTONSETASFLATBTN, TRUE, 0);
- ShowWindow( GetDlgItem( hwndDlg, IDC_SAVE ), SW_HIDE );
+ if ( !lParam) break; // Launched from userinfo
+ TranslateDialogDefault(hwndDlg);
+ SendDlgItemMessage(hwndDlg, IDC_LOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_OPEN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_LOAD, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_DELETE, BUTTONSETASFLATBTN, TRUE, 0);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE);
{
dat = new PhotoDlgProcData;
- dat->ppro = ( CJabberProto* )lParam;
+ dat->ppro = (CJabberProto*)lParam;
dat->hBitmap = NULL;
dat->ppro->m_bPhotoChanged = FALSE;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, ( LONG_PTR )dat );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->ppro->WindowSubscribe(hwndDlg);
}
- SendMessage( hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0 );
+ SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
break;
case WM_JABBER_REFRESH_VCARD:
- if ( dat->hBitmap ) {
- DeleteObject( dat->hBitmap );
+ if (dat->hBitmap) {
+ DeleteObject(dat->hBitmap);
dat->hBitmap = NULL;
- DeleteFile( dat->ppro->m_szPhotoFileName );
+ DeleteFile(dat->ppro->m_szPhotoFileName);
dat->ppro->m_szPhotoFileName[0] = '\0';
}
- EnableWindow( GetDlgItem( hwndDlg, IDC_DELETE ), FALSE );
- dat->ppro->GetAvatarFileName( NULL, szAvatarFileName, SIZEOF( szAvatarFileName ));
- if ( _taccess( szAvatarFileName, 0 ) == 0 ) {
- if ( GetTempPath( SIZEOF( szTempPath ), szTempPath ) <= 0 )
- _tcscpy( szTempPath, _T(".\\"));
- if ( GetTempFileName( szTempPath, _T("jab"), 0, szTempFileName ) > 0 ) {
- dat->ppro->Log( "Temp file = " TCHAR_STR_PARAM, szTempFileName );
- if ( CopyFile( szAvatarFileName, szTempFileName, FALSE ) == TRUE ) {
- char* p = mir_t2a( szTempFileName );
- if (( dat->hBitmap=( HBITMAP ) CallService( MS_UTILS_LOADBITMAP, 0, ( LPARAM )p )) != NULL ) {
- JabberBitmapPremultiplyChannels( dat->hBitmap );
- _tcscpy( dat->ppro->m_szPhotoFileName, szTempFileName );
- EnableWindow( GetDlgItem( hwndDlg, IDC_DELETE ), TRUE );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
+ dat->ppro->GetAvatarFileName(NULL, szAvatarFileName, SIZEOF(szAvatarFileName));
+ if (_taccess(szAvatarFileName, 0) == 0) {
+ if (GetTempPath(SIZEOF(szTempPath), szTempPath) <= 0)
+ _tcscpy(szTempPath, _T(".\\"));
+ if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
+ dat->ppro->Log("Temp file = " TCHAR_STR_PARAM, szTempFileName);
+ if (CopyFile(szAvatarFileName, szTempFileName, FALSE) == TRUE) {
+ char* p = mir_t2a(szTempFileName);
+ if ((dat->hBitmap=(HBITMAP) CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)p)) != NULL) {
+ JabberBitmapPremultiplyChannels(dat->hBitmap);
+ _tcscpy(dat->ppro->m_szPhotoFileName, szTempFileName);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
}
- else DeleteFile( szTempFileName );
+ else DeleteFile(szTempFileName);
mir_free(p);
}
- else DeleteFile( szTempFileName );
+ else DeleteFile(szTempFileName);
} }
dat->ppro->m_bPhotoChanged = FALSE;
- InvalidateRect( hwndDlg, NULL, TRUE );
- UpdateWindow( hwndDlg );
+ InvalidateRect(hwndDlg, NULL, TRUE);
+ UpdateWindow(hwndDlg);
break;
case WM_JABBER_CHANGED:
- dat->ppro->SetServerVcard( dat->ppro->m_bPhotoChanged, dat->ppro->m_szPhotoFileName );
+ dat->ppro->SetServerVcard(dat->ppro->m_bPhotoChanged, dat->ppro->m_szPhotoFileName);
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDC_LOAD:
{
TCHAR szFilter[512];
TCHAR szFileName[MAX_PATH];
- CallService( MS_UTILS_GETBITMAPFILTERSTRINGST, SIZEOF( szFilter ), ( LPARAM )szFilter );
+ CallService(MS_UTILS_GETBITMAPFILTERSTRINGST, SIZEOF(szFilter), (LPARAM)szFilter);
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(ofn);
@@ -338,63 +338,63 @@ static INT_PTR CALLBACK PhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPA ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_DONTADDTORECENT;
szFileName[0] = '\0';
- if ( GetOpenFileName( &ofn )) {
+ if (GetOpenFileName(&ofn)) {
struct _stat st;
HBITMAP hNewBitmap;
- dat->ppro->Log( "File selected is " TCHAR_STR_PARAM, szFileName );
- if ( _tstat( szFileName, &st )<0 || st.st_size>40*1024 ) {
- MessageBox( hwndDlg, TranslateT( "Only JPG, GIF, and BMP image files smaller than 40 KB are supported." ), TranslateT( "Jabber vCard" ), MB_OK|MB_SETFOREGROUND );
+ dat->ppro->Log("File selected is " TCHAR_STR_PARAM, szFileName);
+ if (_tstat(szFileName, &st)<0 || st.st_size>40*1024) {
+ MessageBox(hwndDlg, TranslateT("Only JPG, GIF, and BMP image files smaller than 40 KB are supported."), TranslateT("Jabber vCard"), MB_OK|MB_SETFOREGROUND);
break;
}
- if ( GetTempPath( SIZEOF( szTempPath ), szTempPath ) <= 0 )
- _tcscpy( szTempPath, _T(".\\"));
- if ( GetTempFileName( szTempPath, _T("jab"), 0, szTempFileName ) > 0 ) {
- dat->ppro->Log( "Temp file = " TCHAR_STR_PARAM, szTempFileName );
- if ( CopyFile( szFileName, szTempFileName, FALSE ) == TRUE ) {
- char* pszTemp = mir_t2a( szTempFileName );
- if (( hNewBitmap=( HBITMAP ) CallService( MS_UTILS_LOADBITMAP, 0, ( LPARAM )pszTemp )) != NULL ) {
- if ( dat->hBitmap ) {
- DeleteObject( dat->hBitmap );
- DeleteFile( dat->ppro->m_szPhotoFileName );
+ if (GetTempPath(SIZEOF(szTempPath), szTempPath) <= 0)
+ _tcscpy(szTempPath, _T(".\\"));
+ if (GetTempFileName(szTempPath, _T("jab"), 0, szTempFileName) > 0) {
+ dat->ppro->Log("Temp file = " TCHAR_STR_PARAM, szTempFileName);
+ if (CopyFile(szFileName, szTempFileName, FALSE) == TRUE) {
+ char* pszTemp = mir_t2a(szTempFileName);
+ if ((hNewBitmap=(HBITMAP) CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)pszTemp)) != NULL) {
+ if (dat->hBitmap) {
+ DeleteObject(dat->hBitmap);
+ DeleteFile(dat->ppro->m_szPhotoFileName);
}
dat->hBitmap = hNewBitmap;
- _tcscpy( dat->ppro->m_szPhotoFileName, szTempFileName );
+ _tcscpy(dat->ppro->m_szPhotoFileName, szTempFileName);
dat->ppro->m_bPhotoChanged = TRUE;
- EnableWindow( GetDlgItem( hwndDlg, IDC_DELETE ), TRUE );
- InvalidateRect( hwndDlg, NULL, TRUE );
- UpdateWindow( hwndDlg );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
+ InvalidateRect(hwndDlg, NULL, TRUE);
+ UpdateWindow(hwndDlg);
dat->ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- else DeleteFile( szTempFileName );
+ else DeleteFile(szTempFileName);
- mir_free( pszTemp );
+ mir_free(pszTemp);
}
- else DeleteFile( szTempFileName );
+ else DeleteFile(szTempFileName);
}
}
}
break;
case IDC_DELETE:
- if ( dat->hBitmap ) {
- DeleteObject( dat->hBitmap );
+ if (dat->hBitmap) {
+ DeleteObject(dat->hBitmap);
dat->hBitmap = NULL;
- DeleteFile( dat->ppro->m_szPhotoFileName );
+ DeleteFile(dat->ppro->m_szPhotoFileName);
dat->ppro->m_szPhotoFileName[0] = '\0';
dat->ppro->m_bPhotoChanged = TRUE;
- EnableWindow( GetDlgItem( hwndDlg, IDC_DELETE ), FALSE );
- InvalidateRect( hwndDlg, NULL, TRUE );
- UpdateWindow( hwndDlg );
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
+ InvalidateRect(hwndDlg, NULL, TRUE);
+ UpdateWindow(hwndDlg);
dat->ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
}
break;
case WM_PAINT:
- if ( dat->hBitmap ) {
+ if (dat->hBitmap) {
BITMAP bm;
HDC hdcMem;
HWND hwndCanvas;
@@ -402,36 +402,36 @@ static INT_PTR CALLBACK PhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPA POINT ptSize, ptOrg, pt, ptFitSize;
RECT rect;
- hwndCanvas = GetDlgItem( hwndDlg, IDC_CANVAS );
- hdcCanvas = GetDC( hwndCanvas );
- hdcMem = CreateCompatibleDC( hdcCanvas );
- SelectObject( hdcMem, dat->hBitmap );
- SetMapMode( hdcMem, GetMapMode( hdcCanvas ));
- GetObject( dat->hBitmap, sizeof( BITMAP ), ( LPVOID ) &bm );
+ hwndCanvas = GetDlgItem(hwndDlg, IDC_CANVAS);
+ hdcCanvas = GetDC(hwndCanvas);
+ hdcMem = CreateCompatibleDC(hdcCanvas);
+ SelectObject(hdcMem, dat->hBitmap);
+ SetMapMode(hdcMem, GetMapMode(hdcCanvas));
+ GetObject(dat->hBitmap, sizeof(BITMAP), (LPVOID) &bm);
ptSize.x = bm.bmWidth;
ptSize.y = bm.bmHeight;
- DPtoLP( hdcCanvas, &ptSize, 1 );
+ DPtoLP(hdcCanvas, &ptSize, 1);
ptOrg.x = ptOrg.y = 0;
- DPtoLP( hdcMem, &ptOrg, 1 );
- GetClientRect( hwndCanvas, &rect );
- InvalidateRect( hwndCanvas, NULL, TRUE );
- UpdateWindow( hwndCanvas );
- if ( ptSize.x<=rect.right && ptSize.y<=rect.bottom ) {
- pt.x = ( rect.right - ptSize.x )/2;
- pt.y = ( rect.bottom - ptSize.y )/2;
+ DPtoLP(hdcMem, &ptOrg, 1);
+ GetClientRect(hwndCanvas, &rect);
+ InvalidateRect(hwndCanvas, NULL, TRUE);
+ UpdateWindow(hwndCanvas);
+ if (ptSize.x<=rect.right && ptSize.y<=rect.bottom) {
+ pt.x = (rect.right - ptSize.x)/2;
+ pt.y = (rect.bottom - ptSize.y)/2;
ptFitSize = ptSize;
}
else {
- if (( ( float )( ptSize.x-rect.right ))/ptSize.x > (( float )( ptSize.y-rect.bottom ))/ptSize.y ) {
+ if (((float)(ptSize.x-rect.right))/ptSize.x > ((float)(ptSize.y-rect.bottom))/ptSize.y) {
ptFitSize.x = rect.right;
- ptFitSize.y = ( ptSize.y*rect.right )/ptSize.x;
+ ptFitSize.y = (ptSize.y*rect.right)/ptSize.x;
pt.x = 0;
- pt.y = ( rect.bottom - ptFitSize.y )/2;
+ pt.y = (rect.bottom - ptFitSize.y)/2;
}
else {
- ptFitSize.x = ( ptSize.x*rect.bottom )/ptSize.y;
+ ptFitSize.x = (ptSize.x*rect.bottom)/ptSize.y;
ptFitSize.y = rect.bottom;
- pt.x = ( rect.right - ptFitSize.x )/2;
+ pt.x = (rect.right - ptFitSize.x)/2;
pt.y = 0;
}
}
@@ -448,14 +448,14 @@ static INT_PTR CALLBACK PhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPA bf.AlphaFormat = AC_SRC_ALPHA;
bf.BlendOp = AC_SRC_OVER;
bf.SourceConstantAlpha = 255;
- JabberAlphaBlend( hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, bf );
+ JabberAlphaBlend(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, bf);
}
else {
- SetStretchBltMode( hdcCanvas, COLORONCOLOR );
- StretchBlt( hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, SRCCOPY );
+ SetStretchBltMode(hdcCanvas, COLORONCOLOR);
+ StretchBlt(hdcCanvas, pt.x, pt.y, ptFitSize.x, ptFitSize.y, hdcMem, ptOrg.x, ptOrg.y, ptSize.x, ptSize.y, SRCCOPY);
}
- DeleteDC( hdcMem );
+ DeleteDC(hdcMem);
}
break;
@@ -467,21 +467,21 @@ static INT_PTR CALLBACK PhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPA break;
case PSN_APPLY:
dat->ppro->m_vCardUpdates &= ~(1UL<<iPageId);
- dat->ppro->SaveVcardToDB( hwndDlg, iPageId );
- if (!dat->ppro->m_vCardUpdates)
- dat->ppro->SetServerVcard( dat->ppro->m_bPhotoChanged, dat->ppro->m_szPhotoFileName );
+ dat->ppro->SaveVcardToDB(hwndDlg, iPageId);
+ if ( !dat->ppro->m_vCardUpdates)
+ dat->ppro->SetServerVcard(dat->ppro->m_bPhotoChanged, dat->ppro->m_szPhotoFileName);
break;
} }
break;
case WM_DESTROY:
- DestroyIcon(( HICON )SendDlgItemMessage( hwndDlg, IDC_LOAD, BM_SETIMAGE, IMAGE_ICON, 0 ));
- DestroyIcon(( HICON )SendDlgItemMessage( hwndDlg, IDC_DELETE, BM_SETIMAGE, IMAGE_ICON, 0 ));
+ DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_LOAD, BM_SETIMAGE, IMAGE_ICON, 0));
+ DestroyIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_DELETE, BM_SETIMAGE, IMAGE_ICON, 0));
dat->ppro->WindowUnsubscribe(hwndDlg);
- if ( dat->hBitmap ) {
- dat->ppro->Log( "Delete bitmap" );
- DeleteObject( dat->hBitmap );
- DeleteFile( dat->ppro->m_szPhotoFileName );
+ if (dat->hBitmap) {
+ dat->ppro->Log("Delete bitmap");
+ DeleteObject(dat->hBitmap);
+ DeleteFile(dat->ppro->m_szPhotoFileName);
}
delete dat;
break;
@@ -491,30 +491,30 @@ static INT_PTR CALLBACK PhotoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPA /////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR CALLBACK NoteDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK NoteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
const unsigned long iPageId = 4;
- CJabberProto* ppro = ( CJabberProto* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- if (!lParam) break; // Launched from userinfo
- ppro = ( CJabberProto* )lParam;
- TranslateDialogDefault( hwndDlg );
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
- SendMessage( hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0 );
+ if ( !lParam) break; // Launched from userinfo
+ ppro = (CJabberProto*)lParam;
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SendMessage(hwndDlg, WM_JABBER_REFRESH_VCARD, 0, 0);
ppro->WindowSubscribe(hwndDlg);
break;
case WM_JABBER_REFRESH_VCARD:
{
- SetDialogField( ppro, hwndDlg, IDC_DESC, "About" );
+ SetDialogField(ppro, hwndDlg, IDC_DESC, "About");
break;
}
case WM_COMMAND:
- if (( HWND )lParam==GetFocus() && HIWORD( wParam )==EN_CHANGE )
+ if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE)
{
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
case WM_NOTIFY:
@@ -525,9 +525,9 @@ static INT_PTR CALLBACK NoteDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
case PSN_APPLY:
ppro->m_vCardUpdates &= ~(1UL<<iPageId);
- ppro->SaveVcardToDB( hwndDlg, iPageId );
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard( ppro->m_bPhotoChanged, ppro->m_szPhotoFileName );
+ ppro->SaveVcardToDB(hwndDlg, iPageId);
+ if ( !ppro->m_vCardUpdates)
+ ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
} }
break;
@@ -546,39 +546,39 @@ struct EditDlgParam CJabberProto* ppro;
};
-static INT_PTR CALLBACK EditEmailDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- EditDlgParam* dat = ( EditDlgParam* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ EditDlgParam* dat = (EditDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
{
- EditDlgParam* dat = ( EditDlgParam* )lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ EditDlgParam* dat = (EditDlgParam*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
- if ( lParam >= 0 ) {
+ if (lParam >= 0) {
DBVARIANT dbv;
char idstr[33];
WORD nFlag;
- SetWindowText( hwndDlg, TranslateT( "Jabber vCard: Edit Email Address" ));
- wsprintfA( idstr, "e-mail%d", dat->id );
- if ( !DBGetContactSettingString( NULL, dat->ppro->m_szModuleName, idstr, &dbv )) {
- SetDlgItemTextA( hwndDlg, IDC_EMAIL, dbv.pszVal );
- JFreeVariant( &dbv );
- wsprintfA( idstr, "e-mailFlag%d", lParam );
- nFlag = DBGetContactSettingWord( NULL, dat->ppro->m_szModuleName, idstr, 0 );
- if ( nFlag & JABBER_VCEMAIL_HOME ) CheckDlgButton( hwndDlg, IDC_HOME, TRUE );
- if ( nFlag & JABBER_VCEMAIL_WORK ) CheckDlgButton( hwndDlg, IDC_WORK, TRUE );
- if ( nFlag & JABBER_VCEMAIL_INTERNET ) CheckDlgButton( hwndDlg, IDC_INTERNET, TRUE );
- if ( nFlag & JABBER_VCEMAIL_X400 ) CheckDlgButton( hwndDlg, IDC_X400, TRUE );
+ SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Email Address"));
+ wsprintfA(idstr, "e-mail%d", dat->id);
+ if ( !DBGetContactSettingString(NULL, dat->ppro->m_szModuleName, idstr, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
+ db_free(&dbv);
+ wsprintfA(idstr, "e-mailFlag%d", lParam);
+ nFlag = db_get_w(NULL, dat->ppro->m_szModuleName, idstr, 0);
+ if (nFlag & JABBER_VCEMAIL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
+ if (nFlag & JABBER_VCEMAIL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
+ if (nFlag & JABBER_VCEMAIL_INTERNET) CheckDlgButton(hwndDlg, IDC_INTERNET, TRUE);
+ if (nFlag & JABBER_VCEMAIL_X400) CheckDlgButton(hwndDlg, IDC_X400, TRUE);
} } }
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDOK:
{
TCHAR text[128];
@@ -586,73 +586,73 @@ static INT_PTR CALLBACK EditEmailDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, DBVARIANT dbv;
WORD nFlag;
- if ( dat->id < 0 ) {
- for ( dat->id=0;;dat->id++ ) {
- mir_snprintf( idstr, SIZEOF(idstr), "e-mail%d", dat->id );
- if ( DBGetContactSettingString( NULL, dat->ppro->m_szModuleName, idstr, &dbv )) break;
- JFreeVariant( &dbv );
+ if (dat->id < 0) {
+ for (dat->id=0;;dat->id++) {
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
+ if (DBGetContactSettingString(NULL, dat->ppro->m_szModuleName, idstr, &dbv)) break;
+ db_free(&dbv);
} }
- GetDlgItemText( hwndDlg, IDC_EMAIL, text, SIZEOF( text ));
- mir_snprintf( idstr, SIZEOF(idstr), "e-mail%d", dat->id );
- dat->ppro->JSetStringT( NULL, idstr, text );
+ GetDlgItemText(hwndDlg, IDC_EMAIL, text, SIZEOF(text));
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
+ dat->ppro->JSetStringT(NULL, idstr, text);
nFlag = 0;
- if ( IsDlgButtonChecked( hwndDlg, IDC_HOME )) nFlag |= JABBER_VCEMAIL_HOME;
- if ( IsDlgButtonChecked( hwndDlg, IDC_WORK )) nFlag |= JABBER_VCEMAIL_WORK;
- if ( IsDlgButtonChecked( hwndDlg, IDC_INTERNET )) nFlag |= JABBER_VCEMAIL_INTERNET;
- if ( IsDlgButtonChecked( hwndDlg, IDC_X400 )) nFlag |= JABBER_VCEMAIL_X400;
- mir_snprintf( idstr, SIZEOF(idstr), "e-mailFlag%d", dat->id );
- dat->ppro->JSetWord( NULL, idstr, nFlag );
+ if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCEMAIL_HOME;
+ if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCEMAIL_WORK;
+ if (IsDlgButtonChecked(hwndDlg, IDC_INTERNET)) nFlag |= JABBER_VCEMAIL_INTERNET;
+ if (IsDlgButtonChecked(hwndDlg, IDC_X400)) nFlag |= JABBER_VCEMAIL_X400;
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mailFlag%d", dat->id);
+ dat->ppro->JSetWord(NULL, idstr, nFlag);
}
// fall through
case IDCANCEL:
- EndDialog( hwndDlg, wParam );
+ EndDialog(hwndDlg, wParam);
break;
}
}
return FALSE;
}
-static INT_PTR CALLBACK EditPhoneDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
+static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- EditDlgParam* dat = ( EditDlgParam* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ EditDlgParam* dat = (EditDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
{
- EditDlgParam* dat = ( EditDlgParam* )lParam;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ EditDlgParam* dat = (EditDlgParam*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault( hwndDlg );
- if ( dat->id >= 0 ) {
+ TranslateDialogDefault(hwndDlg);
+ if (dat->id >= 0) {
DBVARIANT dbv;
char idstr[33];
WORD nFlag;
- SetWindowText( hwndDlg, TranslateT( "Jabber vCard: Edit Phone Number" ));
- wsprintfA( idstr, "Phone%d", dat->id );
- if ( !DBGetContactSettingString( NULL, dat->ppro->m_szModuleName, idstr, &dbv )) {
- SetDlgItemTextA( hwndDlg, IDC_PHONE, dbv.pszVal );
- JFreeVariant( &dbv );
- wsprintfA( idstr, "PhoneFlag%d", dat->id );
- nFlag = dat->ppro->JGetWord( NULL, idstr, 0 );
- if ( nFlag & JABBER_VCTEL_HOME ) CheckDlgButton( hwndDlg, IDC_HOME, TRUE );
- if ( nFlag & JABBER_VCTEL_WORK ) CheckDlgButton( hwndDlg, IDC_WORK, TRUE );
- if ( nFlag & JABBER_VCTEL_VOICE ) CheckDlgButton( hwndDlg, IDC_VOICE, TRUE );
- if ( nFlag & JABBER_VCTEL_FAX ) CheckDlgButton( hwndDlg, IDC_FAX, TRUE );
- if ( nFlag & JABBER_VCTEL_PAGER ) CheckDlgButton( hwndDlg, IDC_PAGER, TRUE );
- if ( nFlag & JABBER_VCTEL_MSG ) CheckDlgButton( hwndDlg, IDC_MSG, TRUE );
- if ( nFlag & JABBER_VCTEL_CELL ) CheckDlgButton( hwndDlg, IDC_CELL, TRUE );
- if ( nFlag & JABBER_VCTEL_VIDEO ) CheckDlgButton( hwndDlg, IDC_VIDEO, TRUE );
- if ( nFlag & JABBER_VCTEL_BBS ) CheckDlgButton( hwndDlg, IDC_BBS, TRUE );
- if ( nFlag & JABBER_VCTEL_MODEM ) CheckDlgButton( hwndDlg, IDC_MODEM, TRUE );
- if ( nFlag & JABBER_VCTEL_ISDN ) CheckDlgButton( hwndDlg, IDC_ISDN, TRUE );
- if ( nFlag & JABBER_VCTEL_PCS ) CheckDlgButton( hwndDlg, IDC_PCS, TRUE );
+ SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Phone Number"));
+ wsprintfA(idstr, "Phone%d", dat->id);
+ if ( !DBGetContactSettingString(NULL, dat->ppro->m_szModuleName, idstr, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_PHONE, dbv.pszVal);
+ db_free(&dbv);
+ wsprintfA(idstr, "PhoneFlag%d", dat->id);
+ nFlag = dat->ppro->JGetWord(NULL, idstr, 0);
+ if (nFlag & JABBER_VCTEL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
+ if (nFlag & JABBER_VCTEL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
+ if (nFlag & JABBER_VCTEL_VOICE) CheckDlgButton(hwndDlg, IDC_VOICE, TRUE);
+ if (nFlag & JABBER_VCTEL_FAX) CheckDlgButton(hwndDlg, IDC_FAX, TRUE);
+ if (nFlag & JABBER_VCTEL_PAGER) CheckDlgButton(hwndDlg, IDC_PAGER, TRUE);
+ if (nFlag & JABBER_VCTEL_MSG) CheckDlgButton(hwndDlg, IDC_MSG, TRUE);
+ if (nFlag & JABBER_VCTEL_CELL) CheckDlgButton(hwndDlg, IDC_CELL, TRUE);
+ if (nFlag & JABBER_VCTEL_VIDEO) CheckDlgButton(hwndDlg, IDC_VIDEO, TRUE);
+ if (nFlag & JABBER_VCTEL_BBS) CheckDlgButton(hwndDlg, IDC_BBS, TRUE);
+ if (nFlag & JABBER_VCTEL_MODEM) CheckDlgButton(hwndDlg, IDC_MODEM, TRUE);
+ if (nFlag & JABBER_VCTEL_ISDN) CheckDlgButton(hwndDlg, IDC_ISDN, TRUE);
+ if (nFlag & JABBER_VCTEL_PCS) CheckDlgButton(hwndDlg, IDC_PCS, TRUE);
} } }
break;
case WM_COMMAND:
- switch ( LOWORD( wParam )) {
+ switch (LOWORD(wParam)) {
case IDOK:
{
char text[128];
@@ -660,73 +660,73 @@ static INT_PTR CALLBACK EditPhoneDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, DBVARIANT dbv;
WORD nFlag;
- if ( dat->id < 0 ) {
- for ( dat->id=0;;dat->id++ ) {
- wsprintfA( idstr, "Phone%d", dat->id );
- if ( DBGetContactSettingString( NULL, dat->ppro->m_szModuleName, idstr, &dbv )) break;
- JFreeVariant( &dbv );
+ if (dat->id < 0) {
+ for (dat->id=0;;dat->id++) {
+ wsprintfA(idstr, "Phone%d", dat->id);
+ if (DBGetContactSettingString(NULL, dat->ppro->m_szModuleName, idstr, &dbv)) break;
+ db_free(&dbv);
}
}
- GetDlgItemTextA( hwndDlg, IDC_PHONE, text, SIZEOF( text ));
- wsprintfA( idstr, "Phone%d", dat->id );
- dat->ppro->JSetString( NULL, idstr, text );
+ GetDlgItemTextA(hwndDlg, IDC_PHONE, text, SIZEOF(text));
+ wsprintfA(idstr, "Phone%d", dat->id);
+ dat->ppro->JSetString(NULL, idstr, text);
nFlag = 0;
- if ( IsDlgButtonChecked( hwndDlg, IDC_HOME )) nFlag |= JABBER_VCTEL_HOME;
- if ( IsDlgButtonChecked( hwndDlg, IDC_WORK )) nFlag |= JABBER_VCTEL_WORK;
- if ( IsDlgButtonChecked( hwndDlg, IDC_VOICE )) nFlag |= JABBER_VCTEL_VOICE;
- if ( IsDlgButtonChecked( hwndDlg, IDC_FAX )) nFlag |= JABBER_VCTEL_FAX;
- if ( IsDlgButtonChecked( hwndDlg, IDC_PAGER )) nFlag |= JABBER_VCTEL_PAGER;
- if ( IsDlgButtonChecked( hwndDlg, IDC_MSG )) nFlag |= JABBER_VCTEL_MSG;
- if ( IsDlgButtonChecked( hwndDlg, IDC_CELL )) nFlag |= JABBER_VCTEL_CELL;
- if ( IsDlgButtonChecked( hwndDlg, IDC_VIDEO )) nFlag |= JABBER_VCTEL_VIDEO;
- if ( IsDlgButtonChecked( hwndDlg, IDC_BBS )) nFlag |= JABBER_VCTEL_BBS;
- if ( IsDlgButtonChecked( hwndDlg, IDC_MODEM )) nFlag |= JABBER_VCTEL_MODEM;
- if ( IsDlgButtonChecked( hwndDlg, IDC_ISDN )) nFlag |= JABBER_VCTEL_ISDN;
- if ( IsDlgButtonChecked( hwndDlg, IDC_PCS )) nFlag |= JABBER_VCTEL_PCS;
- wsprintfA( idstr, "PhoneFlag%d", dat->id );
- dat->ppro->JSetWord( NULL, idstr, nFlag );
+ if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCTEL_HOME;
+ if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCTEL_WORK;
+ if (IsDlgButtonChecked(hwndDlg, IDC_VOICE)) nFlag |= JABBER_VCTEL_VOICE;
+ if (IsDlgButtonChecked(hwndDlg, IDC_FAX)) nFlag |= JABBER_VCTEL_FAX;
+ if (IsDlgButtonChecked(hwndDlg, IDC_PAGER)) nFlag |= JABBER_VCTEL_PAGER;
+ if (IsDlgButtonChecked(hwndDlg, IDC_MSG)) nFlag |= JABBER_VCTEL_MSG;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CELL)) nFlag |= JABBER_VCTEL_CELL;
+ if (IsDlgButtonChecked(hwndDlg, IDC_VIDEO)) nFlag |= JABBER_VCTEL_VIDEO;
+ if (IsDlgButtonChecked(hwndDlg, IDC_BBS)) nFlag |= JABBER_VCTEL_BBS;
+ if (IsDlgButtonChecked(hwndDlg, IDC_MODEM)) nFlag |= JABBER_VCTEL_MODEM;
+ if (IsDlgButtonChecked(hwndDlg, IDC_ISDN)) nFlag |= JABBER_VCTEL_ISDN;
+ if (IsDlgButtonChecked(hwndDlg, IDC_PCS)) nFlag |= JABBER_VCTEL_PCS;
+ wsprintfA(idstr, "PhoneFlag%d", dat->id);
+ dat->ppro->JSetWord(NULL, idstr, nFlag);
}
// fall through
case IDCANCEL:
- EndDialog( hwndDlg, wParam );
+ EndDialog(hwndDlg, wParam);
break;
}
}
return FALSE;
}
-#define M_REMAKELISTS ( WM_USER+1 )
-static INT_PTR CALLBACK ContactDlgProc( HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam )
+#define M_REMAKELISTS (WM_USER+1)
+static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
{
const unsigned long iPageId = 5;
- CJabberProto* ppro = ( CJabberProto* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
+ CJabberProto* ppro = (CJabberProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch( msg ) {
+ switch(msg) {
case WM_INITDIALOG:
- if (!lParam) break; // Launched from userinfo
- ppro = ( CJabberProto* )lParam;
+ if ( !lParam) break; // Launched from userinfo
+ ppro = (CJabberProto*)lParam;
{
LVCOLUMN lvc;
RECT rc;
- SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault( hwndDlg );
- GetClientRect( GetDlgItem( hwndDlg,IDC_EMAILS ), &rc );
- rc.right -= GetSystemMetrics( SM_CXVSCROLL );
+ TranslateDialogDefault(hwndDlg);
+ GetClientRect(GetDlgItem(hwndDlg,IDC_EMAILS), &rc);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
lvc.mask = LVCF_WIDTH;
lvc.cx = 30;
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_EMAILS ), 0, &lvc );
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_PHONES ), 0, &lvc );
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 0, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 0, &lvc);
lvc.cx = rc.right - 30 - 40;
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_EMAILS ), 1, &lvc );
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_PHONES ), 1, &lvc );
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 1, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 1, &lvc);
lvc.cx = 20;
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_EMAILS ), 2, &lvc );
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_EMAILS ), 3, &lvc );
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_PHONES ), 2, &lvc );
- ListView_InsertColumn( GetDlgItem( hwndDlg,IDC_PHONES ), 3, &lvc );
- SendMessage( hwndDlg, M_REMAKELISTS, 0, 0 );
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 2, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS), 3, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 2, &lvc);
+ ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES), 3, &lvc);
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
ppro->WindowSubscribe(hwndDlg);
}
@@ -740,47 +740,47 @@ static INT_PTR CALLBACK ContactDlgProc( HWND hwndDlg, UINT msg, WPARAM, LPARAM l DBVARIANT dbv;
//e-mails
- ListView_DeleteAllItems( GetDlgItem( hwndDlg, IDC_EMAILS ));
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS));
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iSubItem = 0;
lvi.iItem = 0;
- for ( i=0;;i++ ) {
- wsprintfA( idstr, "e-mail%d", i );
- if ( DBGetContactSettingTString( NULL, ppro->m_szModuleName, idstr, &dbv )) break;
- wsprintf( number, _T("%d"), i+1 );
+ for (i=0;;i++) {
+ wsprintfA(idstr, "e-mail%d", i);
+ if (DBGetContactSettingTString(NULL, ppro->m_szModuleName, idstr, &dbv)) break;
+ wsprintf(number, _T("%d"), i+1);
lvi.pszText = number;
- lvi.lParam = ( LPARAM )i;
- ListView_InsertItem( GetDlgItem( hwndDlg, IDC_EMAILS ), &lvi );
- ListView_SetItemText( GetDlgItem( hwndDlg, IDC_EMAILS ), lvi.iItem, 1, dbv.ptszVal );
- JFreeVariant( &dbv );
+ lvi.lParam = (LPARAM)i;
+ ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal);
+ db_free(&dbv);
lvi.iItem++;
}
lvi.mask = LVIF_PARAM;
- lvi.lParam = ( LPARAM )( -1 );
- ListView_InsertItem( GetDlgItem( hwndDlg, IDC_EMAILS ), &lvi );
+ lvi.lParam = (LPARAM)(-1);
+ ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
//phones
- ListView_DeleteAllItems( GetDlgItem( hwndDlg, IDC_PHONES ));
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES));
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iSubItem = 0;
lvi.iItem = 0;
- for ( i=0;;i++ ) {
- wsprintfA( idstr, "Phone%d", i );
- if ( DBGetContactSettingTString( NULL, ppro->m_szModuleName, idstr, &dbv )) break;
- wsprintf( number, _T("%d"), i+1 );
+ for (i=0;;i++) {
+ wsprintfA(idstr, "Phone%d", i);
+ if (DBGetContactSettingTString(NULL, ppro->m_szModuleName, idstr, &dbv)) break;
+ wsprintf(number, _T("%d"), i+1);
lvi.pszText = number;
- lvi.lParam = ( LPARAM )i;
- ListView_InsertItem( GetDlgItem( hwndDlg, IDC_PHONES ), &lvi );
- ListView_SetItemText( GetDlgItem( hwndDlg, IDC_PHONES ), lvi.iItem, 1, dbv.ptszVal );
- JFreeVariant( &dbv );
+ lvi.lParam = (LPARAM)i;
+ ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
+ ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
+ db_free(&dbv);
lvi.iItem++;
}
lvi.mask = LVIF_PARAM;
- lvi.lParam = ( LPARAM )( -1 );
- ListView_InsertItem( GetDlgItem( hwndDlg, IDC_PHONES ), &lvi );
+ lvi.lParam = (LPARAM)(-1);
+ ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
}
break;
case WM_NOTIFY:
- switch (( ( LPNMHDR )lParam )->idFrom ) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0: {
switch (((LPNMHDR)lParam)->code) {
case PSN_PARAMCHANGED:
@@ -788,41 +788,41 @@ static INT_PTR CALLBACK ContactDlgProc( HWND hwndDlg, UINT msg, WPARAM, LPARAM l break;
case PSN_APPLY:
ppro->m_vCardUpdates &= ~(1UL<<iPageId);
- ppro->SaveVcardToDB( hwndDlg, iPageId );
- if (!ppro->m_vCardUpdates)
- ppro->SetServerVcard( ppro->m_bPhotoChanged, ppro->m_szPhotoFileName );
+ ppro->SaveVcardToDB(hwndDlg, iPageId);
+ if ( !ppro->m_vCardUpdates)
+ ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
} }
break;
case IDC_EMAILS:
case IDC_PHONES:
- switch (( ( LPNMHDR )lParam )->code ) {
+ switch (((LPNMHDR)lParam)->code) {
case NM_CUSTOMDRAW:
{
- NMLVCUSTOMDRAW *nm = ( NMLVCUSTOMDRAW * ) lParam;
+ NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW *) lParam;
- switch ( nm->nmcd.dwDrawStage ) {
+ switch (nm->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
case CDDS_ITEMPREPAINT:
- SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW );
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
return TRUE;
case CDDS_SUBITEM|CDDS_ITEMPREPAINT:
{
RECT rc;
HICON hIcon;
- ListView_GetSubItemRect( nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc );
- if ( nm->nmcd.lItemlParam==( LPARAM )( -1 ) && nm->iSubItem==3 )
- hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_ADDCONTACT ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
- else if ( nm->iSubItem==2 && nm->nmcd.lItemlParam!=( LPARAM )( -1 ))
- hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_EDIT ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
- else if ( nm->iSubItem==3 && nm->nmcd.lItemlParam!=( LPARAM )( -1 ))
- hIcon = ( HICON )LoadImage( hInst, MAKEINTRESOURCE( IDI_DELETE ), IMAGE_ICON, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0 );
+ ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
+ if (nm->nmcd.lItemlParam==(LPARAM)(-1) && nm->iSubItem==3)
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ else if (nm->iSubItem==2 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_EDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ else if (nm->iSubItem==3 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
else break;
- DrawIconEx( nm->nmcd.hdc, ( rc.left+rc.right-GetSystemMetrics( SM_CXSMICON ))/2, ( rc.top+rc.bottom-GetSystemMetrics( SM_CYSMICON ))/2,hIcon, GetSystemMetrics( SM_CXSMICON ), GetSystemMetrics( SM_CYSMICON ), 0, NULL, DI_NORMAL );
- DestroyIcon( hIcon );
- SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT );
+ DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2,hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ DestroyIcon(hIcon);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
}
return TRUE;
}
@@ -830,77 +830,77 @@ static INT_PTR CALLBACK ContactDlgProc( HWND hwndDlg, UINT msg, WPARAM, LPARAM l break;
case NM_CLICK:
{
- NMLISTVIEW *nm = ( NMLISTVIEW * ) lParam;
+ NMLISTVIEW *nm = (NMLISTVIEW *) lParam;
LVITEM lvi;
const char* szIdTemplate = nm->hdr.idFrom==IDC_PHONES?"Phone%d":"e-mail%d";
const char* szFlagTemplate = nm->hdr.idFrom==IDC_PHONES?"PhoneFlag%d":"e-mailFlag%d";
LVHITTESTINFO hti;
- if ( nm->iSubItem < 2 ) break;
- hti.pt.x = ( short ) LOWORD( GetMessagePos());
- hti.pt.y = ( short ) HIWORD( GetMessagePos());
- ScreenToClient( nm->hdr.hwndFrom, &hti.pt );
- if ( ListView_SubItemHitTest( nm->hdr.hwndFrom, &hti ) == -1 ) break;
+ if (nm->iSubItem < 2) break;
+ hti.pt.x = (short) LOWORD(GetMessagePos());
+ hti.pt.y = (short) HIWORD(GetMessagePos());
+ ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
+ if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break;
lvi.mask = LVIF_PARAM;
lvi.iItem = hti.iItem;
lvi.iSubItem = 0;
- ListView_GetItem( nm->hdr.hwndFrom, &lvi );
- if ( lvi.lParam == ( LPARAM )( -1 )) {
- if ( hti.iSubItem == 3 ) {
+ ListView_GetItem(nm->hdr.hwndFrom, &lvi);
+ if (lvi.lParam == (LPARAM)(-1)) {
+ if (hti.iSubItem == 3) {
//add
EditDlgParam param = { -1, ppro };
int res;
- if ( nm->hdr.idFrom == IDC_PHONES )
- res = DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_VCARD_ADDPHONE ), hwndDlg, EditPhoneDlgProc, ( LPARAM )¶m );
+ if (nm->hdr.idFrom == IDC_PHONES)
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
else
- res = DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_VCARD_ADDEMAIL ), hwndDlg, EditEmailDlgProc, ( LPARAM )¶m );
- if ( res != IDOK )
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
+ if (res != IDOK)
break;
- SendMessage( hwndDlg, M_REMAKELISTS, 0, 0 );
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
else {
- if ( hti.iSubItem == 3 ) {
+ if (hti.iSubItem == 3) {
//delete
int i;
char idstr[33];
DBVARIANT dbv;
- for ( i=lvi.lParam;;i++ ) {
+ for (i=lvi.lParam;;i++) {
WORD nFlag;
- wsprintfA( idstr, szIdTemplate, i+1 );
- if ( DBGetContactSettingString( NULL, ppro->m_szModuleName, idstr, &dbv )) break;
- wsprintfA( idstr,szIdTemplate,i );
- ppro->JSetString( NULL, idstr, dbv.pszVal );
- wsprintfA( idstr, szFlagTemplate, i+1 );
- JFreeVariant( &dbv );
- nFlag = ppro->JGetWord( NULL, idstr, 0 );
- wsprintfA( idstr, szFlagTemplate, i );
- ppro->JSetWord( NULL, idstr, nFlag );
+ wsprintfA(idstr, szIdTemplate, i+1);
+ if (DBGetContactSettingString(NULL, ppro->m_szModuleName, idstr, &dbv)) break;
+ wsprintfA(idstr,szIdTemplate,i);
+ ppro->JSetString(NULL, idstr, dbv.pszVal);
+ wsprintfA(idstr, szFlagTemplate, i+1);
+ db_free(&dbv);
+ nFlag = ppro->JGetWord(NULL, idstr, 0);
+ wsprintfA(idstr, szFlagTemplate, i);
+ ppro->JSetWord(NULL, idstr, nFlag);
}
- wsprintfA( idstr, szIdTemplate, i );
- ppro->JDeleteSetting( NULL, idstr );
- wsprintfA( idstr, szFlagTemplate, i );
- ppro->JDeleteSetting( NULL, idstr );
- SendMessage( hwndDlg, M_REMAKELISTS, 0, 0 );
+ wsprintfA(idstr, szIdTemplate, i);
+ ppro->JDeleteSetting(NULL, idstr);
+ wsprintfA(idstr, szFlagTemplate, i);
+ ppro->JDeleteSetting(NULL, idstr);
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- else if ( hti.iSubItem == 2 ) {
+ else if (hti.iSubItem == 2) {
EditDlgParam param = { lvi.lParam, ppro };
int res;
- if ( nm->hdr.idFrom == IDC_PHONES )
- res = DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_VCARD_ADDPHONE ), hwndDlg, EditPhoneDlgProc, ( LPARAM )¶m );
+ if (nm->hdr.idFrom == IDC_PHONES)
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
else
- res = DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_VCARD_ADDEMAIL ), hwndDlg, EditEmailDlgProc, ( LPARAM )¶m );
- if ( res != IDOK )
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
+ if (res != IDOK)
break;
- SendMessage( hwndDlg,M_REMAKELISTS,0,0 );
+ SendMessage(hwndDlg,M_REMAKELISTS,0,0);
ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
}
@@ -910,12 +910,12 @@ static INT_PTR CALLBACK ContactDlgProc( HWND hwndDlg, UINT msg, WPARAM, LPARAM l }
break;
case WM_SETCURSOR:
- if ( LOWORD( lParam ) != HTCLIENT ) break;
- if ( GetForegroundWindow() == GetParent( hwndDlg )) {
+ if (LOWORD(lParam) != HTCLIENT) break;
+ if (GetForegroundWindow() == GetParent(hwndDlg)) {
POINT pt;
- GetCursorPos( &pt );
- ScreenToClient( hwndDlg,&pt );
- SetFocus( ChildWindowFromPoint( hwndDlg,pt )); //ugly hack because listviews ignore their first click
+ GetCursorPos(&pt);
+ ScreenToClient(hwndDlg,&pt);
+ SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click
}
break;
case WM_DESTROY:
@@ -925,78 +925,78 @@ static INT_PTR CALLBACK ContactDlgProc( HWND hwndDlg, UINT msg, WPARAM, LPARAM l return FALSE;
}
-void CJabberProto::SaveVcardToDB( HWND hwndPage, int iPage )
+void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage)
{
TCHAR text[2048];
// Page 0: Personal
switch (iPage) {
case 0:
- GetDlgItemText( hwndPage, IDC_FULLNAME, text, SIZEOF( text ));
- JSetStringT( NULL, "FullName", text );
- GetDlgItemText( hwndPage, IDC_NICKNAME, text, SIZEOF( text ));
- JSetStringT( NULL, "Nick", text );
- GetDlgItemText( hwndPage, IDC_FIRSTNAME, text, SIZEOF( text ));
- JSetStringT( NULL, "FirstName", text );
- GetDlgItemText( hwndPage, IDC_MIDDLE, text, SIZEOF( text ));
- JSetStringT( NULL, "MiddleName", text );
- GetDlgItemText( hwndPage, IDC_LASTNAME, text, SIZEOF( text ));
- JSetStringT( NULL, "LastName", text );
- GetDlgItemText( hwndPage, IDC_BIRTH, text, SIZEOF( text ));
- JSetStringT( NULL, "BirthDate", text );
- switch( SendMessage( GetDlgItem( hwndPage, IDC_GENDER ), CB_GETCURSEL, 0, 0 )) {
- case 0: JSetString( NULL, "GenderString", "Male" ); break;
- case 1: JSetString( NULL, "GenderString", "Female" ); break;
- default: JSetString( NULL, "GenderString", "" ); break;
+ GetDlgItemText(hwndPage, IDC_FULLNAME, text, SIZEOF(text));
+ JSetStringT(NULL, "FullName", text);
+ GetDlgItemText(hwndPage, IDC_NICKNAME, text, SIZEOF(text));
+ JSetStringT(NULL, "Nick", text);
+ GetDlgItemText(hwndPage, IDC_FIRSTNAME, text, SIZEOF(text));
+ JSetStringT(NULL, "FirstName", text);
+ GetDlgItemText(hwndPage, IDC_MIDDLE, text, SIZEOF(text));
+ JSetStringT(NULL, "MiddleName", text);
+ GetDlgItemText(hwndPage, IDC_LASTNAME, text, SIZEOF(text));
+ JSetStringT(NULL, "LastName", text);
+ GetDlgItemText(hwndPage, IDC_BIRTH, text, SIZEOF(text));
+ JSetStringT(NULL, "BirthDate", text);
+ switch(SendMessage(GetDlgItem(hwndPage, IDC_GENDER), CB_GETCURSEL, 0, 0)) {
+ case 0: JSetString(NULL, "GenderString", "Male"); break;
+ case 1: JSetString(NULL, "GenderString", "Female"); break;
+ default: JSetString(NULL, "GenderString", ""); break;
}
- GetDlgItemText( hwndPage, IDC_OCCUPATION, text, SIZEOF( text ));
- JSetStringT( NULL, "Role", text );
- GetDlgItemText( hwndPage, IDC_HOMEPAGE, text, SIZEOF( text ));
- JSetStringT( NULL, "Homepage", text );
+ GetDlgItemText(hwndPage, IDC_OCCUPATION, text, SIZEOF(text));
+ JSetStringT(NULL, "Role", text);
+ GetDlgItemText(hwndPage, IDC_HOMEPAGE, text, SIZEOF(text));
+ JSetStringT(NULL, "Homepage", text);
break;
// Page 1: Home
case 1:
- GetDlgItemText( hwndPage, IDC_ADDRESS1, text, SIZEOF( text ));
- JSetStringT( NULL, "Street", text );
- GetDlgItemText( hwndPage, IDC_ADDRESS2, text, SIZEOF( text ));
- JSetStringT( NULL, "Street2", text );
- GetDlgItemText( hwndPage, IDC_CITY, text, SIZEOF( text ));
- JSetStringT( NULL, "City", text );
- GetDlgItemText( hwndPage, IDC_STATE, text, SIZEOF( text ));
- JSetStringT( NULL, "State", text );
- GetDlgItemText( hwndPage, IDC_ZIP, text, SIZEOF( text ));
- JSetStringT( NULL, "ZIP", text );
+ GetDlgItemText(hwndPage, IDC_ADDRESS1, text, SIZEOF(text));
+ JSetStringT(NULL, "Street", text);
+ GetDlgItemText(hwndPage, IDC_ADDRESS2, text, SIZEOF(text));
+ JSetStringT(NULL, "Street2", text);
+ GetDlgItemText(hwndPage, IDC_CITY, text, SIZEOF(text));
+ JSetStringT(NULL, "City", text);
+ GetDlgItemText(hwndPage, IDC_STATE, text, SIZEOF(text));
+ JSetStringT(NULL, "State", text);
+ GetDlgItemText(hwndPage, IDC_ZIP, text, SIZEOF(text));
+ JSetStringT(NULL, "ZIP", text);
{
- int i = SendMessage( GetDlgItem( hwndPage, IDC_COUNTRY ), CB_GETCURSEL, 0, 0 );
+ int i = SendMessage(GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETCURSEL, 0, 0);
TCHAR *country = mir_a2t((i) ? g_countries[i+2].szName : g_countries[1].szName);
- JSetStringT( NULL, "Country", country );
+ JSetStringT(NULL, "Country", country);
mir_free(country);
}
break;
// Page 2: Work
case 2:
- GetDlgItemText( hwndPage, IDC_COMPANY, text, SIZEOF( text ));
- JSetStringT( NULL, "Company", text );
- GetDlgItemText( hwndPage, IDC_DEPARTMENT, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyDepartment", text );
- GetDlgItemText( hwndPage, IDC_TITLE, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyPosition", text );
- GetDlgItemText( hwndPage, IDC_ADDRESS1, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyStreet", text );
- GetDlgItemText( hwndPage, IDC_ADDRESS2, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyStreet2", text );
- GetDlgItemText( hwndPage, IDC_CITY, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyCity", text );
- GetDlgItemText( hwndPage, IDC_STATE, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyState", text );
- GetDlgItemText( hwndPage, IDC_ZIP, text, SIZEOF( text ));
- JSetStringT( NULL, "CompanyZIP", text );
+ GetDlgItemText(hwndPage, IDC_COMPANY, text, SIZEOF(text));
+ JSetStringT(NULL, "Company", text);
+ GetDlgItemText(hwndPage, IDC_DEPARTMENT, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyDepartment", text);
+ GetDlgItemText(hwndPage, IDC_TITLE, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyPosition", text);
+ GetDlgItemText(hwndPage, IDC_ADDRESS1, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyStreet", text);
+ GetDlgItemText(hwndPage, IDC_ADDRESS2, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyStreet2", text);
+ GetDlgItemText(hwndPage, IDC_CITY, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyCity", text);
+ GetDlgItemText(hwndPage, IDC_STATE, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyState", text);
+ GetDlgItemText(hwndPage, IDC_ZIP, text, SIZEOF(text));
+ JSetStringT(NULL, "CompanyZIP", text);
{
- int i = SendMessage( GetDlgItem( hwndPage, IDC_COUNTRY ), CB_GETCURSEL, 0, 0 );
+ int i = SendMessage(GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETCURSEL, 0, 0);
TCHAR *country = mir_a2t((i) ? g_countries[i+2].szName : g_countries[1].szName);
- JSetStringT( NULL, "CompanyCountry", country );
+ JSetStringT(NULL, "CompanyCountry", country);
mir_free(country);
}
break;
@@ -1006,30 +1006,30 @@ void CJabberProto::SaveVcardToDB( HWND hwndPage, int iPage ) // Page 4: Note
case 4:
- GetDlgItemText( hwndPage, IDC_DESC, text, SIZEOF( text ));
- JSetStringT( NULL, "About", text );
+ GetDlgItemText(hwndPage, IDC_DESC, text, SIZEOF(text));
+ JSetStringT(NULL, "About", text);
break;
// Page 5: Contacts
// is always synced with db
} }
-void CJabberProto::AppendVcardFromDB( HXML n, char* tag, char* key )
+void CJabberProto::AppendVcardFromDB(HXML n, char* tag, char* key)
{
- if ( n == NULL || tag == NULL || key == NULL )
+ if (n == NULL || tag == NULL || key == NULL)
return;
DBVARIANT dbv;
- if ( DBGetContactSettingTString( NULL, m_szModuleName, key, &dbv ))
- n << XCHILD( _A2T(tag));
+ if (DBGetContactSettingTString(NULL, m_szModuleName, key, &dbv))
+ n << XCHILD(_A2T(tag));
else {
- n << XCHILD( _A2T(tag), dbv.ptszVal );
- JFreeVariant( &dbv );
+ n << XCHILD(_A2T(tag), dbv.ptszVal);
+ db_free(&dbv);
} }
-void CJabberProto::SetServerVcard( BOOL bPhotoChanged, TCHAR* szPhotoFileName )
+void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
{
- if (!m_bJabberOnline) return;
+ if ( !m_bJabberOnline) return;
DBVARIANT dbv;
int iqId;
@@ -1039,108 +1039,108 @@ void CJabberProto::SetServerVcard( BOOL bPhotoChanged, TCHAR* szPhotoFileName ) WORD nFlag;
iqId = SerialNext();
- IqAdd( iqId, IQ_PROC_SETVCARD, &CJabberProto::OnIqResultSetVcard );
+ IqAdd(iqId, IQ_PROC_SETVCARD, &CJabberProto::OnIqResultSetVcard);
- XmlNodeIq iq( _T("set"), iqId );
- HXML v = iq << XCHILDNS( _T("vCard"), _T(JABBER_FEAT_VCARD_TEMP));
+ XmlNodeIq iq(_T("set"), iqId);
+ HXML v = iq << XCHILDNS(_T("vCard"), _T(JABBER_FEAT_VCARD_TEMP));
- AppendVcardFromDB( v, "FN", "FullName" );
+ AppendVcardFromDB(v, "FN", "FullName");
- HXML n = v << XCHILD( _T("N"));
- AppendVcardFromDB( n, "GIVEN", "FirstName" );
- AppendVcardFromDB( n, "MIDDLE", "MiddleName" );
- AppendVcardFromDB( n, "FAMILY", "LastName" );
+ HXML n = v << XCHILD(_T("N"));
+ AppendVcardFromDB(n, "GIVEN", "FirstName");
+ AppendVcardFromDB(n, "MIDDLE", "MiddleName");
+ AppendVcardFromDB(n, "FAMILY", "LastName");
- AppendVcardFromDB( v, "NICKNAME", "Nick" );
- AppendVcardFromDB( v, "BDAY", "BirthDate" );
- AppendVcardFromDB( v, "GENDER", "GenderString" );
+ AppendVcardFromDB(v, "NICKNAME", "Nick");
+ AppendVcardFromDB(v, "BDAY", "BirthDate");
+ AppendVcardFromDB(v, "GENDER", "GenderString");
- for ( i=0;;i++ ) {
- wsprintfA( idstr, "e-mail%d", i );
- if ( DBGetContactSettingTString( NULL, m_szModuleName, idstr, &dbv ))
+ for (i=0;;i++) {
+ wsprintfA(idstr, "e-mail%d", i);
+ if (DBGetContactSettingTString(NULL, m_szModuleName, idstr, &dbv))
break;
- HXML e = v << XCHILD( _T("EMAIL"), dbv.ptszVal );
- JFreeVariant( &dbv );
- AppendVcardFromDB( e, "USERID", idstr );
+ HXML e = v << XCHILD(_T("EMAIL"), dbv.ptszVal);
+ db_free(&dbv);
+ AppendVcardFromDB(e, "USERID", idstr);
- wsprintfA( idstr, "e-mailFlag%d", i );
- nFlag = DBGetContactSettingWord( NULL, m_szModuleName, idstr, 0 );
- if ( nFlag & JABBER_VCEMAIL_HOME ) e << XCHILD( _T("HOME"));
- if ( nFlag & JABBER_VCEMAIL_WORK ) e << XCHILD( _T("WORK"));
- if ( nFlag & JABBER_VCEMAIL_INTERNET ) e << XCHILD( _T("INTERNET"));
- if ( nFlag & JABBER_VCEMAIL_X400 ) e << XCHILD( _T("X400"));
+ wsprintfA(idstr, "e-mailFlag%d", i);
+ nFlag = db_get_w(NULL, m_szModuleName, idstr, 0);
+ if (nFlag & JABBER_VCEMAIL_HOME) e << XCHILD(_T("HOME"));
+ if (nFlag & JABBER_VCEMAIL_WORK) e << XCHILD(_T("WORK"));
+ if (nFlag & JABBER_VCEMAIL_INTERNET) e << XCHILD(_T("INTERNET"));
+ if (nFlag & JABBER_VCEMAIL_X400) e << XCHILD(_T("X400"));
}
- n = v << XCHILD( _T("ADR"));
- n << XCHILD( _T("HOME"));
- AppendVcardFromDB( n, "STREET", "Street" );
- AppendVcardFromDB( n, "EXTADR", "Street2" );
- AppendVcardFromDB( n, "EXTADD", "Street2" ); // for compatibility with client using old vcard format
- AppendVcardFromDB( n, "LOCALITY", "City" );
- AppendVcardFromDB( n, "REGION", "State" );
- AppendVcardFromDB( n, "PCODE", "ZIP" );
- AppendVcardFromDB( n, "CTRY", "Country" );
- AppendVcardFromDB( n, "COUNTRY", "Country" ); // for compatibility with client using old vcard format
-
- n = v << XCHILD( _T("ADR"));
- n << XCHILD( _T("WORK"));
- AppendVcardFromDB( n, "STREET", "CompanyStreet" );
- AppendVcardFromDB( n, "EXTADR", "CompanyStreet2" );
- AppendVcardFromDB( n, "EXTADD", "CompanyStreet2" ); // for compatibility with client using old vcard format
- AppendVcardFromDB( n, "LOCALITY", "CompanyCity" );
- AppendVcardFromDB( n, "REGION", "CompanyState" );
- AppendVcardFromDB( n, "PCODE", "CompanyZIP" );
- AppendVcardFromDB( n, "CTRY", "CompanyCountry" );
- AppendVcardFromDB( n, "COUNTRY", "CompanyCountry" ); // for compatibility with client using old vcard format
-
- n = v << XCHILD( _T("ORG"));
- AppendVcardFromDB( n, "ORGNAME", "Company" );
- AppendVcardFromDB( n, "ORGUNIT", "CompanyDepartment" );
+ n = v << XCHILD(_T("ADR"));
+ n << XCHILD(_T("HOME"));
+ AppendVcardFromDB(n, "STREET", "Street");
+ AppendVcardFromDB(n, "EXTADR", "Street2");
+ AppendVcardFromDB(n, "EXTADD", "Street2"); // for compatibility with client using old vcard format
+ AppendVcardFromDB(n, "LOCALITY", "City");
+ AppendVcardFromDB(n, "REGION", "State");
+ AppendVcardFromDB(n, "PCODE", "ZIP");
+ AppendVcardFromDB(n, "CTRY", "Country");
+ AppendVcardFromDB(n, "COUNTRY", "Country"); // for compatibility with client using old vcard format
+
+ n = v << XCHILD(_T("ADR"));
+ n << XCHILD(_T("WORK"));
+ AppendVcardFromDB(n, "STREET", "CompanyStreet");
+ AppendVcardFromDB(n, "EXTADR", "CompanyStreet2");
+ AppendVcardFromDB(n, "EXTADD", "CompanyStreet2"); // for compatibility with client using old vcard format
+ AppendVcardFromDB(n, "LOCALITY", "CompanyCity");
+ AppendVcardFromDB(n, "REGION", "CompanyState");
+ AppendVcardFromDB(n, "PCODE", "CompanyZIP");
+ AppendVcardFromDB(n, "CTRY", "CompanyCountry");
+ AppendVcardFromDB(n, "COUNTRY", "CompanyCountry"); // for compatibility with client using old vcard format
+
+ n = v << XCHILD(_T("ORG"));
+ AppendVcardFromDB(n, "ORGNAME", "Company");
+ AppendVcardFromDB(n, "ORGUNIT", "CompanyDepartment");
- AppendVcardFromDB( v, "TITLE", "CompanyPosition" );
- AppendVcardFromDB( v, "ROLE", "Role" );
- AppendVcardFromDB( v, "URL", "Homepage" );
- AppendVcardFromDB( v, "DESC", "About" );
-
- for ( i=0;;i++ ) {
- wsprintfA( idstr, "Phone%d", i );
- if ( DBGetContactSettingTString( NULL, m_szModuleName, idstr, &dbv )) break;
- JFreeVariant( &dbv );
-
- n = v << XCHILD( _T("TEL"));
- AppendVcardFromDB( n, "NUMBER", idstr );
-
- wsprintfA( idstr, "PhoneFlag%d", i );
- nFlag = JGetWord( NULL, idstr, 0 );
- if ( nFlag & JABBER_VCTEL_HOME ) n << XCHILD( _T("HOME"));
- if ( nFlag & JABBER_VCTEL_WORK ) n << XCHILD( _T("WORK"));
- if ( nFlag & JABBER_VCTEL_VOICE ) n << XCHILD( _T("VOICE"));
- if ( nFlag & JABBER_VCTEL_FAX ) n << XCHILD( _T("FAX"));
- if ( nFlag & JABBER_VCTEL_PAGER ) n << XCHILD( _T("PAGER"));
- if ( nFlag & JABBER_VCTEL_MSG ) n << XCHILD( _T("MSG"));
- if ( nFlag & JABBER_VCTEL_CELL ) n << XCHILD( _T("CELL"));
- if ( nFlag & JABBER_VCTEL_VIDEO ) n << XCHILD( _T("VIDEO"));
- if ( nFlag & JABBER_VCTEL_BBS ) n << XCHILD( _T("BBS"));
- if ( nFlag & JABBER_VCTEL_MODEM ) n << XCHILD( _T("MODEM"));
- if ( nFlag & JABBER_VCTEL_ISDN ) n << XCHILD( _T("ISDN"));
- if ( nFlag & JABBER_VCTEL_PCS ) n << XCHILD( _T("PCS"));
+ AppendVcardFromDB(v, "TITLE", "CompanyPosition");
+ AppendVcardFromDB(v, "ROLE", "Role");
+ AppendVcardFromDB(v, "URL", "Homepage");
+ AppendVcardFromDB(v, "DESC", "About");
+
+ for (i=0;;i++) {
+ wsprintfA(idstr, "Phone%d", i);
+ if (DBGetContactSettingTString(NULL, m_szModuleName, idstr, &dbv)) break;
+ db_free(&dbv);
+
+ n = v << XCHILD(_T("TEL"));
+ AppendVcardFromDB(n, "NUMBER", idstr);
+
+ wsprintfA(idstr, "PhoneFlag%d", i);
+ nFlag = JGetWord(NULL, idstr, 0);
+ if (nFlag & JABBER_VCTEL_HOME) n << XCHILD(_T("HOME"));
+ if (nFlag & JABBER_VCTEL_WORK) n << XCHILD(_T("WORK"));
+ if (nFlag & JABBER_VCTEL_VOICE) n << XCHILD(_T("VOICE"));
+ if (nFlag & JABBER_VCTEL_FAX) n << XCHILD(_T("FAX"));
+ if (nFlag & JABBER_VCTEL_PAGER) n << XCHILD(_T("PAGER"));
+ if (nFlag & JABBER_VCTEL_MSG) n << XCHILD(_T("MSG"));
+ if (nFlag & JABBER_VCTEL_CELL) n << XCHILD(_T("CELL"));
+ if (nFlag & JABBER_VCTEL_VIDEO) n << XCHILD(_T("VIDEO"));
+ if (nFlag & JABBER_VCTEL_BBS) n << XCHILD(_T("BBS"));
+ if (nFlag & JABBER_VCTEL_MODEM) n << XCHILD(_T("MODEM"));
+ if (nFlag & JABBER_VCTEL_ISDN) n << XCHILD(_T("ISDN"));
+ if (nFlag & JABBER_VCTEL_PCS) n << XCHILD(_T("PCS"));
}
TCHAR szAvatarName[ MAX_PATH ];
- GetAvatarFileName( NULL, szAvatarName, SIZEOF( szAvatarName ));
- if ( bPhotoChanged )
+ GetAvatarFileName(NULL, szAvatarName, SIZEOF(szAvatarName));
+ if (bPhotoChanged)
szFileName = szPhotoFileName;
else
szFileName = szAvatarName;
// Set photo element, also update the global jabberVcardPhotoFileName to reflect the update
- Log( "Before update, file name = " TCHAR_STR_PARAM, szFileName );
- if ( szFileName == NULL || szFileName[0] == 0 ) {
- v << XCHILD( _T("PHOTO"));
- DeleteFile( szAvatarName );
- JDeleteSetting( NULL, "AvatarSaved" );
- JDeleteSetting( NULL, "AvatarHash" );
+ Log("Before update, file name = " TCHAR_STR_PARAM, szFileName);
+ if (szFileName == NULL || szFileName[0] == 0) {
+ v << XCHILD(_T("PHOTO"));
+ DeleteFile(szAvatarName);
+ JDeleteSetting(NULL, "AvatarSaved");
+ JDeleteSetting(NULL, "AvatarHash");
}
else {
HANDLE hFile;
@@ -1148,62 +1148,62 @@ void CJabberProto::SetServerVcard( BOOL bPhotoChanged, TCHAR* szPhotoFileName ) char* buffer, *str;
DWORD nRead;
- Log( "Saving picture from " TCHAR_STR_PARAM, szFileName );
- if ( _tstat( szFileName, &st ) >= 0 ) {
+ Log("Saving picture from " TCHAR_STR_PARAM, szFileName);
+ if (_tstat(szFileName, &st) >= 0) {
// Note the FILE_SHARE_READ attribute so that the CopyFile can succeed
- if (( hFile=CreateFile( szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL )) != INVALID_HANDLE_VALUE ) {
- if (( buffer=( char* )mir_alloc( st.st_size )) != NULL ) {
- if ( ReadFile( hFile, buffer, st.st_size, &nRead, NULL )) {
- if (( str=JabberBase64Encode( buffer, nRead )) != NULL ) {
- n = v << XCHILD( _T("PHOTO"));
+ if ((hFile=CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
+ if ((buffer=(char*)mir_alloc(st.st_size)) != NULL) {
+ if (ReadFile(hFile, buffer, st.st_size, &nRead, NULL)) {
+ if ((str=JabberBase64Encode(buffer, nRead)) != NULL) {
+ n = v << XCHILD(_T("PHOTO"));
TCHAR* szFileType;
- switch( JabberGetPictureType( buffer )) {
+ switch(JabberGetPictureType(buffer)) {
case PA_FORMAT_PNG: szFileType = _T("image/png"); break;
case PA_FORMAT_GIF: szFileType = _T("image/gif"); break;
case PA_FORMAT_BMP: szFileType = _T("image/bmp"); break;
default: szFileType = _T("image/jpeg"); break;
}
- n << XCHILD( _T("TYPE"), szFileType );
+ n << XCHILD(_T("TYPE"), szFileType);
- n << XCHILD( _T("BINVAL"), _A2T(str));
- mir_free( str );
+ n << XCHILD(_T("BINVAL"), _A2T(str));
+ mir_free(str);
// NEED TO UPDATE OUR AVATAR HASH:
mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
mir_sha1_ctx sha1ctx;
- mir_sha1_init( &sha1ctx );
- mir_sha1_append( &sha1ctx, (mir_sha1_byte_t*)buffer, nRead );
- mir_sha1_finish( &sha1ctx, digest );
+ mir_sha1_init(&sha1ctx);
+ mir_sha1_append(&sha1ctx, (mir_sha1_byte_t*)buffer, nRead);
+ mir_sha1_finish(&sha1ctx, digest);
char buf[MIR_SHA1_HASH_SIZE*2+1];
- for ( int j=0; j<MIR_SHA1_HASH_SIZE; j++ )
- sprintf( buf+( j<<1 ), "%02x", digest[j] );
+ for (int j=0; j<MIR_SHA1_HASH_SIZE; j++)
+ sprintf(buf+(j<<1), "%02x", digest[j]);
- m_options.AvatarType = JabberGetPictureType( buffer );
+ m_options.AvatarType = JabberGetPictureType(buffer);
- if ( bPhotoChanged ) {
- DeleteFile( szAvatarName );
+ if (bPhotoChanged) {
+ DeleteFile(szAvatarName);
- GetAvatarFileName( NULL, szAvatarName, SIZEOF( szAvatarName ));
+ GetAvatarFileName(NULL, szAvatarName, SIZEOF(szAvatarName));
- CopyFile( szFileName, szAvatarName, FALSE );
+ CopyFile(szFileName, szAvatarName, FALSE);
}
- JSetString( NULL, "AvatarHash", buf );
- JSetString( NULL, "AvatarSaved", buf );
+ JSetString(NULL, "AvatarHash", buf);
+ JSetString(NULL, "AvatarSaved", buf);
} }
- mir_free( buffer );
+ mir_free(buffer);
}
- CloseHandle( hFile );
+ CloseHandle(hFile);
} } }
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void CJabberProto::OnUserInfoInit_VCard( WPARAM wParam, LPARAM )
+void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM)
{
m_vCardUpdates = 0;
m_bPhotoChanged = FALSE;
@@ -1246,5 +1246,5 @@ void CJabberProto::OnUserInfoInit_VCard( WPARAM wParam, LPARAM ) odp.ptszTab = LPGENT("Note");
UserInfo_AddPage(wParam, &odp);
- SendGetVcard( m_szJabberJID );
+ SendGetVcard(m_szJabberJID);
}
diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp index 494dcf3454..b9b7ecd4bd 100644 --- a/protocols/JabberG/src/jabber_ws.cpp +++ b/protocols/JabberG/src/jabber_ws.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
@@ -22,68 +22,68 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber.h"
-BOOL CJabberProto::WsInit( void )
+BOOL CJabberProto::WsInit(void)
{
m_lastTicks = ::GetTickCount();
TCHAR name[128];
- mir_sntprintf( name, SIZEOF(name), TranslateT("%s connection"), m_tszUserName);
+ mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), m_tszUserName);
NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof( nlu );
+ nlu.cbSize = sizeof(nlu);
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = name;
nlu.szSettingsModule = m_szModuleName;
//nlu.szHttpGatewayHello = "http://http.proxy.icq.com/hello";
- //nlu.szHttpGatewayUserAgent = "Mozilla/4.08 [en] ( WinNT; U ;Nav )";
+ //nlu.szHttpGatewayUserAgent = "Mozilla/4.08 [en] (WinNT; U ;Nav)";
//nlu.pfnHttpGatewayInit = JabberHttpGatewayInit;
//nlu.pfnHttpGatewayBegin = JabberHttpGatewayBegin;
//nlu.pfnHttpGatewayWrapSend = JabberHttpGatewayWrapSend;
//nlu.pfnHttpGatewayUnwrapRecv = JabberHttpGatewayUnwrapRecv;
- m_hNetlibUser = ( HANDLE ) CallService( MS_NETLIB_REGISTERUSER, 0, ( LPARAM )&nlu );
+ m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
return m_hNetlibUser != NULL;
}
-void CJabberProto::WsUninit( void )
+void CJabberProto::WsUninit(void)
{
- Netlib_CloseHandle( m_hNetlibUser );
+ Netlib_CloseHandle(m_hNetlibUser);
m_hNetlibUser = NULL;
}
-JABBER_SOCKET CJabberProto::WsConnect( char* host, WORD port )
+JABBER_SOCKET CJabberProto::WsConnect(char* host, WORD port)
{
NETLIBOPENCONNECTION nloc = { 0 };
- nloc.cbSize = sizeof( nloc );
+ nloc.cbSize = sizeof(nloc);
nloc.szHost = host;
nloc.wPort = port;
nloc.timeout = 6;
- return ( HANDLE )CallService( MS_NETLIB_OPENCONNECTION, ( WPARAM ) m_hNetlibUser, ( LPARAM )&nloc );
+ return (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&nloc);
}
-int CJabberProto::WsSend( JABBER_SOCKET hConn, char* data, int datalen, int flags )
+int CJabberProto::WsSend(JABBER_SOCKET hConn, char* data, int datalen, int flags)
{
m_lastTicks = ::GetTickCount();
int len;
- if (( len = Netlib_Send( hConn, data, datalen, flags )) == SOCKET_ERROR || len != datalen ) {
- Log( "Netlib_Send() failed, error=%d", WSAGetLastError());
+ if ((len = Netlib_Send(hConn, data, datalen, flags)) == SOCKET_ERROR || len != datalen) {
+ Log("Netlib_Send() failed, error=%d", WSAGetLastError());
return SOCKET_ERROR;
}
return len;
}
-int CJabberProto::WsRecv( JABBER_SOCKET hConn, char* data, long datalen, int flags )
+int CJabberProto::WsRecv(JABBER_SOCKET hConn, char* data, long datalen, int flags)
{
int ret;
- ret = Netlib_Recv( hConn, data, datalen, flags );
- if ( ret == SOCKET_ERROR ) {
- Log( "Netlib_Recv() failed, error=%d", WSAGetLastError());
+ ret = Netlib_Recv(hConn, data, datalen, flags);
+ if (ret == SOCKET_ERROR) {
+ Log("Netlib_Recv() failed, error=%d", WSAGetLastError());
return 0;
}
- if ( ret == 0 ) {
- Log( "Connection closed gracefully" );
+ if (ret == 0) {
+ Log("Connection closed gracefully");
return 0;
}
return ret;
diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp index 287a335243..7c7317bfcc 100644 --- a/protocols/JabberG/src/jabber_xml.cpp +++ b/protocols/JabberG/src/jabber_xml.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -31,229 +31,229 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////////////////
// XmlNodeIq class members
-XmlNodeIq::XmlNodeIq( const TCHAR* type, int id, LPCTSTR to ) :
- XmlNode( _T( "iq" ))
+XmlNodeIq::XmlNodeIq(const TCHAR *type, int id, LPCTSTR to) :
+ XmlNode(_T("iq"))
{
- if ( type != NULL ) *this << XATTR( _T("type"), type );
- if ( to != NULL ) *this << XATTR( _T("to"), to );
- if ( id != -1 ) *this << XATTRID( id );
+ if (type != NULL) *this << XATTR(_T("type"), type);
+ if (to != NULL) *this << XATTR(_T("to"), to);
+ if (id != -1 ) *this << XATTRID(id);
}
-XmlNodeIq::XmlNodeIq( const TCHAR* type, LPCTSTR idStr, LPCTSTR to ) :
- XmlNode( _T( "iq" ))
+XmlNodeIq::XmlNodeIq(const TCHAR *type, LPCTSTR idStr, LPCTSTR to) :
+ XmlNode(_T("iq"))
{
- if ( type != NULL ) *this << XATTR( _T("type"), type );
- if ( to != NULL ) *this << XATTR( _T("to"), to );
- if ( idStr != NULL ) *this << XATTR( _T("id"), idStr );
+ if (type != NULL) *this << XATTR(_T("type"), type );
+ if (to != NULL) *this << XATTR(_T("to"), to );
+ if (idStr != NULL) *this << XATTR(_T("id"), idStr);
}
-XmlNodeIq::XmlNodeIq( const TCHAR* type, HXML node, LPCTSTR to ) :
- XmlNode( _T( "iq" ))
+XmlNodeIq::XmlNodeIq(const TCHAR *type, HXML node, LPCTSTR to) :
+ XmlNode(_T("iq"))
{
- if ( type != NULL ) *this << XATTR( _T("type"), type );
- if ( to != NULL ) *this << XATTR( _T("to"), to );
- if ( node != NULL ) {
- const TCHAR *iqId = xmlGetAttrValue( *this, _T( "id" ));
- if ( iqId != NULL ) *this << XATTR( _T("id"), iqId );
+ if (type != NULL) *this << XATTR(_T("type"), type );
+ if (to != NULL) *this << XATTR(_T("to"), to );
+ if (node != NULL) {
+ const TCHAR *iqId = xmlGetAttrValue(*this, _T("id"));
+ if (iqId != NULL) *this << XATTR(_T("id"), iqId);
}
}
-XmlNodeIq::XmlNodeIq( CJabberIqInfo* pInfo ) :
- XmlNode( _T( "iq" ))
+XmlNodeIq::XmlNodeIq(CJabberIqInfo* pInfo) :
+ XmlNode(_T("iq"))
{
- if ( pInfo ) {
- if ( pInfo->GetCharIqType() != NULL ) *this << XATTR( _T("type"), _A2T(pInfo->GetCharIqType()));
- if ( pInfo->GetReceiver() != NULL ) *this << XATTR( _T("to"), pInfo->GetReceiver());
- if ( pInfo->GetIqId() != -1 ) *this << XATTRID( pInfo->GetIqId());
+ if (pInfo) {
+ if (pInfo->GetCharIqType() != NULL) *this << XATTR(_T("type"), _A2T(pInfo->GetCharIqType()));
+ if (pInfo->GetReceiver() != NULL) *this << XATTR(_T("to"), pInfo->GetReceiver());
+ if (pInfo->GetIqId() != -1) *this << XATTRID(pInfo->GetIqId());
}
}
-XmlNodeIq::XmlNodeIq( const TCHAR* type, CJabberIqInfo* pInfo ) :
- XmlNode( _T( "iq" ))
+XmlNodeIq::XmlNodeIq(const TCHAR *type, CJabberIqInfo* pInfo) :
+ XmlNode(_T("iq"))
{
- if ( type != NULL ) *this << XATTR( _T("type"), type );
- if ( pInfo ) {
- if ( pInfo->GetFrom() != NULL ) *this << XATTR( _T("to"), pInfo->GetFrom());
- if ( pInfo->GetIdStr() != NULL ) *this << XATTR( _T("id"), pInfo->GetIdStr());
+ if (type != NULL) *this << XATTR(_T("type"), type);
+ if (pInfo) {
+ if (pInfo->GetFrom() != NULL) *this << XATTR(_T("to"), pInfo->GetFrom());
+ if (pInfo->GetIdStr() != NULL) *this << XATTR(_T("id"), pInfo->GetIdStr());
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// XmlNode class members
-XmlNode::XmlNode( LPCTSTR pszName )
+XmlNode::XmlNode(LPCTSTR pszName)
{
- m_hXml = xi.createNode( T2UTF(pszName), NULL, 0 );
+ m_hXml = xi.createNode(T2UTF(pszName), NULL, 0);
}
-XmlNode::XmlNode( LPCTSTR pszName, LPCTSTR ptszText )
+XmlNode::XmlNode(LPCTSTR pszName, LPCTSTR ptszText)
{
- m_hXml = xi.createNode( T2UTF(pszName), ptszText, 0 );
+ m_hXml = xi.createNode(T2UTF(pszName), ptszText, 0);
}
-XmlNode::XmlNode( const XmlNode& n )
+XmlNode::XmlNode(const XmlNode& n)
{
- m_hXml = xi.copyNode( n );
+ m_hXml = xi.copyNode(n);
}
-XmlNode& XmlNode::operator =( const XmlNode& n )
+XmlNode& XmlNode::operator =(const XmlNode& n)
{
- if ( m_hXml )
- xi.destroyNode( m_hXml );
- m_hXml = xi.copyNode( n );
+ if (m_hXml)
+ xi.destroyNode(m_hXml);
+ m_hXml = xi.copyNode(n);
return *this;
}
XmlNode::~XmlNode()
{
- if ( m_hXml ) {
- xi.destroyNode( m_hXml );
+ if (m_hXml) {
+ xi.destroyNode(m_hXml);
m_hXml = NULL;
} }
/////////////////////////////////////////////////////////////////////////////////////////
-HXML __fastcall operator<<( HXML node, const XCHILDNS& child )
+HXML __fastcall operator<<(HXML node, const XCHILDNS& child)
{
- HXML res = xmlAddChild( node, child.name );
- xmlAddAttr( res, _T("xmlns"), child.ns );
+ HXML res = xmlAddChild(node, child.name);
+ xmlAddAttr(res, _T("xmlns"), child.ns);
return res;
}
-HXML __fastcall operator<<( HXML node, const XQUERY& child )
+HXML __fastcall operator<<(HXML node, const XQUERY& child)
{
- HXML n = xmlAddChild( node, _T("query"));
- if ( n )
- xmlAddAttr( n, _T("xmlns"), child.ns );
+ HXML n = xmlAddChild(node, _T("query"));
+ if (n)
+ xmlAddAttr(n, _T("xmlns"), child.ns);
return n;
}
/////////////////////////////////////////////////////////////////////////////////////////
-void __fastcall xmlAddAttr( HXML hXml, LPCTSTR name, LPCTSTR value )
+void __fastcall xmlAddAttr(HXML hXml, LPCTSTR name, LPCTSTR value)
{
- if ( value )
- xi.addAttr( hXml, name, T2UTF(value));
+ if (value)
+ xi.addAttr(hXml, name, T2UTF(value));
}
-void __fastcall xmlAddAttr( HXML hXml, LPCTSTR pszName, int value )
+void __fastcall xmlAddAttr(HXML hXml, LPCTSTR pszName, int value)
{
- xi.addAttrInt( hXml, T2UTF(pszName), value );
+ xi.addAttrInt(hXml, T2UTF(pszName), value);
}
-void __fastcall xmlAddAttr( HXML hXml, LPCTSTR pszName, unsigned __int64 value )
+void __fastcall xmlAddAttr(HXML hXml, LPCTSTR pszName, unsigned __int64 value)
{
TCHAR buf[60];
- _ui64tot( value, buf, 10 );
+ _ui64tot(value, buf, 10);
- xi.addAttr( hXml, T2UTF(pszName), T2UTF(buf));
+ xi.addAttr(hXml, T2UTF(pszName), T2UTF(buf));
}
-void __fastcall xmlAddAttrID( HXML hXml, int id )
+void __fastcall xmlAddAttrID(HXML hXml, int id)
{
TCHAR text[ 100 ];
- mir_sntprintf( text, SIZEOF(text), _T("mir_%d"), id );
- xmlAddAttr( hXml, _T("id"), text );
+ mir_sntprintf(text, SIZEOF(text), _T("mir_%d"), id);
+ xmlAddAttr(hXml, _T("id"), text);
}
/////////////////////////////////////////////////////////////////////////////////////////
-LPCTSTR __fastcall xmlGetAttr( HXML hXml, int n )
+LPCTSTR __fastcall xmlGetAttr(HXML hXml, int n)
{
- return xi.getAttr( hXml, n );
+ return xi.getAttr(hXml, n);
}
-int __fastcall xmlGetAttrCount( HXML hXml )
+int __fastcall xmlGetAttrCount(HXML hXml)
{
- return xi.getAttrCount( hXml );
+ return xi.getAttrCount(hXml);
}
-LPCTSTR __fastcall xmlGetAttrName( HXML hXml, int n )
+LPCTSTR __fastcall xmlGetAttrName(HXML hXml, int n)
{
- return xi.getAttrName( hXml, n );
+ return xi.getAttrName(hXml, n);
}
/////////////////////////////////////////////////////////////////////////////////////////
-void __fastcall xmlAddChild( HXML hXml, HXML n )
+void __fastcall xmlAddChild(HXML hXml, HXML n)
{
- xi.addChild2( n, hXml );
+ xi.addChild2(n, hXml);
}
-HXML __fastcall xmlAddChild( HXML hXml, LPCTSTR name )
+HXML __fastcall xmlAddChild(HXML hXml, LPCTSTR name)
{
- return xi.addChild( hXml, T2UTF(name), NULL );
+ return xi.addChild(hXml, T2UTF(name), NULL);
}
-HXML __fastcall xmlAddChild( HXML hXml, LPCTSTR name, LPCTSTR value )
+HXML __fastcall xmlAddChild(HXML hXml, LPCTSTR name, LPCTSTR value)
{
- return xi.addChild( hXml, T2UTF(name), T2UTF(value));
+ return xi.addChild(hXml, T2UTF(name), T2UTF(value));
}
-HXML __fastcall xmlAddChild( HXML hXml, LPCTSTR name, int value )
+HXML __fastcall xmlAddChild(HXML hXml, LPCTSTR name, int value)
{
TCHAR buf[40];
- _itot( value, buf, 10 );
- return xi.addChild( hXml, T2UTF(name), buf );
+ _itot(value, buf, 10);
+ return xi.addChild(hXml, T2UTF(name), buf);
}
/////////////////////////////////////////////////////////////////////////////////////////
-LPCTSTR __fastcall xmlGetAttrValue( HXML hXml, LPCTSTR key )
+LPCTSTR __fastcall xmlGetAttrValue(HXML hXml, LPCTSTR key)
{
- return xi.getAttrValue( hXml, key );
+ return xi.getAttrValue(hXml, key);
}
-HXML __fastcall xmlGetChild( HXML hXml, int n )
+HXML __fastcall xmlGetChild(HXML hXml, int n)
{
- return xi.getChild( hXml, n );
+ return xi.getChild(hXml, n);
}
-HXML __fastcall xmlGetChild( HXML hXml, LPCTSTR key )
+HXML __fastcall xmlGetChild(HXML hXml, LPCTSTR key)
{
- return xi.getNthChild( hXml, key, 0 );
+ return xi.getNthChild(hXml, key, 0);
}
-HXML __fastcall xmlGetChild( HXML hXml, LPCSTR key )
+HXML __fastcall xmlGetChild(HXML hXml, LPCSTR key)
{
- LPTSTR wszKey = mir_a2t( key );
- HXML result = xi.getNthChild( hXml, wszKey, 0 );
- mir_free( wszKey );
+ LPTSTR wszKey = mir_a2t(key);
+ HXML result = xi.getNthChild(hXml, wszKey, 0);
+ mir_free(wszKey);
return result;
}
-HXML __fastcall xmlGetChildByTag( HXML hXml, LPCTSTR key, LPCTSTR attrName, LPCTSTR attrValue )
+HXML __fastcall xmlGetChildByTag(HXML hXml, LPCTSTR key, LPCTSTR attrName, LPCTSTR attrValue)
{
- return xi.getChildByAttrValue( hXml, key, attrName, attrValue );
+ return xi.getChildByAttrValue(hXml, key, attrName, attrValue);
}
-HXML __fastcall xmlGetChildByTag( HXML hXml, LPCSTR key, LPCSTR attrName, LPCTSTR attrValue )
+HXML __fastcall xmlGetChildByTag(HXML hXml, LPCSTR key, LPCSTR attrName, LPCTSTR attrValue)
{
- LPTSTR wszKey = mir_a2t( key ), wszName = mir_a2t( attrName );
- HXML result = xi.getChildByAttrValue( hXml, wszKey, wszName, attrValue );
- mir_free( wszKey ), mir_free( wszName );
+ LPTSTR wszKey = mir_a2t(key), wszName = mir_a2t(attrName);
+ HXML result = xi.getChildByAttrValue(hXml, wszKey, wszName, attrValue);
+ mir_free(wszKey), mir_free(wszName);
return result;
}
-int __fastcall xmlGetChildCount( HXML hXml )
+int __fastcall xmlGetChildCount(HXML hXml)
{
- return xi.getChildCount( hXml );
+ return xi.getChildCount(hXml);
}
-HXML __fastcall xmlGetNthChild( HXML hXml, LPCTSTR tag, int nth )
+HXML __fastcall xmlGetNthChild(HXML hXml, LPCTSTR tag, int nth)
{
int i, num;
- if ( !hXml || tag == NULL || _tcslen( tag ) <= 0 || nth < 1 )
+ if ( !hXml || tag == NULL || _tcslen(tag) <= 0 || nth < 1)
return NULL;
num = 1;
- for ( i=0; ; i++ ) {
- HXML n = xi.getChild( hXml, i );
- if ( !n )
+ for (i=0; ; i++) {
+ HXML n = xi.getChild(hXml, i);
+ if ( !n)
break;
- if ( !lstrcmp( tag, xmlGetName( n ))) {
- if ( num == nth )
+ if ( !lstrcmp(tag, xmlGetName(n))) {
+ if (num == nth)
return n;
num++;
@@ -262,21 +262,21 @@ HXML __fastcall xmlGetNthChild( HXML hXml, LPCTSTR tag, int nth ) return NULL;
}
-LPCTSTR __fastcall xmlGetName( HXML xml )
+LPCTSTR __fastcall xmlGetName(HXML xml)
{
- return xi.getName( xml );
+ return xi.getName(xml);
}
-LPCTSTR __fastcall xmlGetText( HXML xml )
+LPCTSTR __fastcall xmlGetText(HXML xml)
{
- return xi.getText( xml );
+ return xi.getText(xml);
}
/////////////////////////////////////////////////////////////////////////////////////////
void XPath::ProcessPath(LookupInfo &info, bool bCreate)
{
- if (!info.nodeName) return;
+ if ( !info.nodeName) return;
TCHAR *nodeName = (TCHAR *)alloca(sizeof(TCHAR) * (info.nodeName.length+1));
lstrcpyn(nodeName, info.nodeName.p, info.nodeName.length+1);
@@ -318,7 +318,7 @@ XPath::PathType XPath::LookupImpl(bool bCreate) case S_START:
{
ProcessPath(info, bCreate);
- if (!m_hXml)
+ if ( !m_hXml)
{
state = S_FINAL_ERROR;
break;
@@ -501,7 +501,7 @@ XPath::PathType XPath::LookupImpl(bool bCreate) }
}
- if (!*p && (state < S_FINAL))
+ if ( !*p && (state < S_FINAL))
{
state = S_FINAL_ERROR;
}
diff --git a/protocols/JabberG/src/jabber_xml.h b/protocols/JabberG/src/jabber_xml.h index 0a1b41e511..c034e001cb 100644 --- a/protocols/JabberG/src/jabber_xml.h +++ b/protocols/JabberG/src/jabber_xml.h @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -26,48 +26,48 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_xml.h>
-void __fastcall xmlAddChild( HXML, HXML );
-HXML __fastcall xmlAddChild( HXML, LPCTSTR pszName );
-HXML __fastcall xmlAddChild( HXML, LPCTSTR pszName, LPCTSTR ptszValue );
-HXML __fastcall xmlAddChild( HXML, LPCTSTR pszName, int iValue );
-
-LPCTSTR __fastcall xmlGetAttrValue( HXML, LPCTSTR key );
-HXML __fastcall xmlGetChild( HXML, int n = 0 );
-HXML __fastcall xmlGetChild( HXML, LPCSTR key );
-HXML __fastcall xmlGetChild( HXML, LPCTSTR key );
-int __fastcall xmlGetChildCount( HXML );
-HXML __fastcall xmlGetChildByTag( HXML, LPCTSTR key, LPCTSTR attrName, LPCTSTR attrValue );
-HXML __fastcall xmlGetChildByTag( HXML, LPCSTR key, LPCSTR attrName, LPCTSTR attrValue );
-HXML __fastcall xmlGetNthChild( HXML, LPCTSTR key, int n = 0 );
-
-LPCTSTR __fastcall xmlGetName( HXML );
-LPCTSTR __fastcall xmlGetText( HXML );
-
-void __fastcall xmlAddAttr( HXML, LPCTSTR pszName, LPCTSTR ptszValue );
-void __fastcall xmlAddAttr( HXML, LPCTSTR pszName, int value );
-void __fastcall xmlAddAttr( HXML hXml, LPCTSTR pszName, unsigned __int64 value );
-void __fastcall xmlAddAttrID( HXML, int id );
-
-int __fastcall xmlGetAttrCount( HXML );
-LPCTSTR __fastcall xmlGetAttr( HXML, int n );
-LPCTSTR __fastcall xmlGetAttrName( HXML, int n );
-LPCTSTR __fastcall xmlGetAttrValue( HXML, LPCTSTR key );
+void __fastcall xmlAddChild(HXML, HXML);
+HXML __fastcall xmlAddChild(HXML, LPCTSTR pszName);
+HXML __fastcall xmlAddChild(HXML, LPCTSTR pszName, LPCTSTR ptszValue);
+HXML __fastcall xmlAddChild(HXML, LPCTSTR pszName, int iValue);
+
+LPCTSTR __fastcall xmlGetAttrValue(HXML, LPCTSTR key);
+HXML __fastcall xmlGetChild(HXML, int n = 0);
+HXML __fastcall xmlGetChild(HXML, LPCSTR key);
+HXML __fastcall xmlGetChild(HXML, LPCTSTR key);
+int __fastcall xmlGetChildCount(HXML);
+HXML __fastcall xmlGetChildByTag(HXML, LPCTSTR key, LPCTSTR attrName, LPCTSTR attrValue);
+HXML __fastcall xmlGetChildByTag(HXML, LPCSTR key, LPCSTR attrName, LPCTSTR attrValue);
+HXML __fastcall xmlGetNthChild(HXML, LPCTSTR key, int n = 0);
+
+LPCTSTR __fastcall xmlGetName(HXML);
+LPCTSTR __fastcall xmlGetText(HXML);
+
+void __fastcall xmlAddAttr(HXML, LPCTSTR pszName, LPCTSTR ptszValue);
+void __fastcall xmlAddAttr(HXML, LPCTSTR pszName, int value);
+void __fastcall xmlAddAttr(HXML hXml, LPCTSTR pszName, unsigned __int64 value);
+void __fastcall xmlAddAttrID(HXML, int id);
+
+int __fastcall xmlGetAttrCount(HXML);
+LPCTSTR __fastcall xmlGetAttr(HXML, int n);
+LPCTSTR __fastcall xmlGetAttrName(HXML, int n);
+LPCTSTR __fastcall xmlGetAttrValue(HXML, LPCTSTR key);
struct XmlNode
{
__forceinline XmlNode() { m_hXml = NULL; }
- __forceinline XmlNode( LPCTSTR pszString, int* numBytes, LPCTSTR ptszTag )
+ __forceinline XmlNode(LPCTSTR pszString, int* numBytes, LPCTSTR ptszTag)
{
- m_hXml = xi.parseString( pszString, numBytes, ptszTag );
+ m_hXml = xi.parseString(pszString, numBytes, ptszTag);
}
- XmlNode( const XmlNode& n );
- XmlNode( LPCTSTR name );
- XmlNode( LPCTSTR pszName, LPCTSTR ptszText );
+ XmlNode(const XmlNode& n);
+ XmlNode(LPCTSTR name);
+ XmlNode(LPCTSTR pszName, LPCTSTR ptszText);
~XmlNode();
- XmlNode& operator =( const XmlNode& n );
+ XmlNode& operator =(const XmlNode& n);
__forceinline operator HXML() const
{ return m_hXml;
@@ -81,16 +81,16 @@ class CJabberIqInfo; struct XmlNodeIq : public XmlNode
{
- XmlNodeIq( const TCHAR* type, int id = -1, const TCHAR* to = NULL );
- XmlNodeIq( const TCHAR* type, const TCHAR* idStr, const TCHAR* to );
- XmlNodeIq( const TCHAR* type, HXML node, const TCHAR* to );
+ XmlNodeIq(const TCHAR *type, int id = -1, const TCHAR *to = NULL);
+ XmlNodeIq(const TCHAR *type, const TCHAR *idStr, const TCHAR *to);
+ XmlNodeIq(const TCHAR *type, HXML node, const TCHAR *to);
// new request
- XmlNodeIq( CJabberIqInfo* pInfo );
+ XmlNodeIq(CJabberIqInfo* pInfo);
// answer to request
- XmlNodeIq( const TCHAR* type, CJabberIqInfo* pInfo );
+ XmlNodeIq(const TCHAR *type, CJabberIqInfo* pInfo);
};
-typedef void ( *JABBER_XML_CALLBACK )( HXML, void* );
+typedef void (*JABBER_XML_CALLBACK)(HXML, void*);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -98,14 +98,14 @@ struct XATTR {
LPCTSTR name, value;
- __forceinline XATTR( LPCTSTR _name, LPCTSTR _value ) :
- name( _name ),
- value( _value )
+ __forceinline XATTR(LPCTSTR _name, LPCTSTR _value) :
+ name(_name),
+ value(_value)
{}
};
-HXML __forceinline operator<<( HXML node, const XATTR& attr )
-{ xmlAddAttr( node, attr.name, attr.value );
+HXML __forceinline operator<<(HXML node, const XATTR& attr)
+{ xmlAddAttr(node, attr.name, attr.value);
return node;
}
@@ -116,14 +116,14 @@ struct XATTRI LPCTSTR name;
int value;
- __forceinline XATTRI( LPCTSTR _name, int _value ) :
- name( _name ),
- value( _value )
+ __forceinline XATTRI(LPCTSTR _name, int _value) :
+ name(_name),
+ value(_value)
{}
};
-HXML __forceinline operator<<( HXML node, const XATTRI& attr )
-{ xmlAddAttr( node, attr.name, attr.value );
+HXML __forceinline operator<<(HXML node, const XATTRI& attr)
+{ xmlAddAttr(node, attr.name, attr.value);
return node;
}
@@ -134,14 +134,14 @@ struct XATTRI64 LPCTSTR name;
unsigned __int64 value;
- __forceinline XATTRI64( LPCTSTR _name, unsigned __int64 _value ) :
- name( _name ),
- value( _value )
+ __forceinline XATTRI64(LPCTSTR _name, unsigned __int64 _value) :
+ name(_name),
+ value(_value)
{}
};
-HXML __forceinline operator<<( HXML node, const XATTRI64& attr )
-{ xmlAddAttr( node, attr.name, attr.value );
+HXML __forceinline operator<<(HXML node, const XATTRI64& attr)
+{ xmlAddAttr(node, attr.name, attr.value);
return node;
}
@@ -151,13 +151,13 @@ struct XATTRID {
int id;
- __forceinline XATTRID( int _value ) :
- id( _value )
+ __forceinline XATTRID(int _value) :
+ id(_value)
{}
};
-HXML __forceinline operator<<( HXML node, const XATTRID& attr )
-{ xmlAddAttrID( node, attr.id );
+HXML __forceinline operator<<(HXML node, const XATTRID& attr)
+{ xmlAddAttrID(node, attr.id);
return node;
}
@@ -167,14 +167,14 @@ struct XCHILD {
LPCTSTR name, value;
- __forceinline XCHILD( LPCTSTR _name, LPCTSTR _value = NULL ) :
- name( _name ),
- value( _value )
+ __forceinline XCHILD(LPCTSTR _name, LPCTSTR _value = NULL) :
+ name(_name),
+ value(_value)
{}
};
-HXML __forceinline operator<<( HXML node, const XCHILD& child )
-{ return xmlAddChild( node, child.name, child.value );
+HXML __forceinline operator<<(HXML node, const XCHILD& child)
+{ return xmlAddChild(node, child.name, child.value);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -183,13 +183,13 @@ struct XCHILDNS {
LPCTSTR name, ns;
- __forceinline XCHILDNS( LPCTSTR _name, LPCTSTR _ns = NULL ) :
- name( _name ),
- ns( _ns )
+ __forceinline XCHILDNS(LPCTSTR _name, LPCTSTR _ns = NULL) :
+ name(_name),
+ ns(_ns)
{}
};
-HXML __fastcall operator<<( HXML node, const XCHILDNS& child );
+HXML __fastcall operator<<(HXML node, const XCHILDNS& child);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -197,12 +197,12 @@ struct XQUERY {
LPCTSTR ns;
- __forceinline XQUERY( LPCTSTR _ns ) :
- ns( _ns )
+ __forceinline XQUERY(LPCTSTR _ns) :
+ ns(_ns)
{}
};
-HXML __fastcall operator<<( HXML node, const XQUERY& child );
+HXML __fastcall operator<<(HXML node, const XQUERY& child);
/////////////////////////////////////////////////////////////////////////////////////////
// Limited XPath support
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index af82e9c761..9a33eb270e 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
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
@@ -159,7 +159,7 @@ private: bool m_subitem;
CStatusMode(LPARAM id, char *name, HICON hIcon, TCHAR *title, bool subitem): m_id(id), m_name(name), m_hIcon(hIcon), m_title(title), m_subitem(subitem) {}
- ~CStatusMode() { g_ReleaseIcon( m_hIcon ); }
+ ~CStatusMode() { g_ReleaseIcon(m_hIcon); }
};
OBJLIST<CStatusMode> m_modes;
@@ -228,7 +228,7 @@ void CJabberDlgPepSimple::OnInitDialog() {
CSuper::OnInitDialog();
- WindowSetIcon( m_hwnd, m_proto, "main" );
+ WindowSetIcon(m_hwnd, m_proto, "main");
SetWindowText(m_hwnd, m_title);
m_txtDescription.Enable(false);
@@ -290,9 +290,9 @@ void CJabberDlgPepSimple::cbModes_OnChange(CCtrlData *) mir_snprintf(szSetting, SIZEOF(szSetting), "PepMsg_%s", m_modes[m_cbModes.GetItemData(m_prevSelected)].m_name);
DBVARIANT dbv;
- if (!m_proto->JGetStringT(NULL, szSetting, &dbv)) {
+ if ( !m_proto->JGetStringT(NULL, szSetting, &dbv)) {
m_txtDescription.SetText(dbv.ptszVal);
- JFreeVariant(&dbv);
+ db_free(&dbv);
}
else m_txtDescription.SetTextA("");
@@ -344,11 +344,11 @@ BOOL CJabberDlgPepSimple::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
}
- if (!mode->m_subitem || (lpdis->itemState & ODS_COMBOBOXEDIT)) {
+ if ( !mode->m_subitem || (lpdis->itemState & ODS_COMBOBOXEDIT)) {
TCHAR text[128];
if (mode->m_subitem) {
for (int i = lpdis->itemData; i >= 0; --i)
- if (!m_modes[i].m_subitem) {
+ if ( !m_modes[i].m_subitem) {
mir_sntprintf(text, SIZEOF(text), _T("%s [%s]"), m_modes[i].m_title, mode->m_title);
break;
}
@@ -392,29 +392,29 @@ CPepService::~CPepService() void CPepService::Publish()
{
- XmlNodeIq iq( _T("set"), m_proto->SerialNext());
+ XmlNodeIq iq(_T("set"), m_proto->SerialNext());
CreateData(
- iq << XCHILDNS( _T("pubsub"), _T(JABBER_FEAT_PUBSUB))
- << XCHILD( _T("publish")) << XATTR( _T("node"), m_node )
- << XCHILD( _T("item")) << XATTR( _T("id"), _T("current")));
- m_proto->m_ThreadInfo->send( iq );
+ iq << XCHILDNS(_T("pubsub"), _T(JABBER_FEAT_PUBSUB))
+ << XCHILD(_T("publish")) << XATTR(_T("node"), m_node)
+ << XCHILD(_T("item")) << XATTR(_T("id"), _T("current")));
+ m_proto->m_ThreadInfo->send(iq);
m_wasPublished = TRUE;
}
void CPepService::Retract()
{
- TCHAR* tempName = mir_a2t( m_name );
- _tcslwr( tempName );
+ TCHAR* tempName = mir_a2t(m_name);
+ _tcslwr(tempName);
m_proto->m_ThreadInfo->send(
- XmlNodeIq( _T("set"), m_proto->SerialNext())
- << XCHILDNS( _T("pubsub"), _T(JABBER_FEAT_PUBSUB))
- << XCHILD( _T("publish")) << XATTR( _T("node"), m_node )
- << XCHILD( _T("item"))
- << XCHILDNS( tempName, m_node ));
+ XmlNodeIq(_T("set"), m_proto->SerialNext())
+ << XCHILDNS(_T("pubsub"), _T(JABBER_FEAT_PUBSUB))
+ << XCHILD(_T("publish")) << XATTR(_T("node"), m_node)
+ << XCHILD(_T("item"))
+ << XCHILDNS(tempName, m_node));
- mir_free( tempName );
+ mir_free(tempName);
}
void CPepService::ResetPublish()
@@ -424,7 +424,7 @@ void CPepService::ResetPublish() void CPepService::ForceRepublishOnLogin()
{
- if (!m_wasPublished)
+ if ( !m_wasPublished)
Publish();
}
@@ -464,8 +464,8 @@ void CPepGuiService::InitGui() void CPepGuiService::RebuildMenu()
{
- HGENMENU hJabberRoot = MO_GetProtoRootMenu( m_proto->m_szModuleName );
- if ( hJabberRoot ) {
+ HGENMENU hJabberRoot = MO_GetProtoRootMenu(m_proto->m_szModuleName);
+ if (hJabberRoot) {
char szService[128];
mir_snprintf(szService, SIZEOF(szService), "%s/AdvStatusSet/%s", m_proto->m_szModuleName, m_name);
@@ -498,7 +498,7 @@ void CPepGuiService::UpdateMenuItem(HANDLE hIcolibIcon, TCHAR *text) if (m_szText) mir_free(m_szText);
m_szText = text ? mir_tstrdup(text) : NULL;
- if (!m_hMenuItem) return;
+ if ( !m_hMenuItem) return;
CLISTMENUITEM mi = {0};
mi.cbSize = sizeof(mi);
@@ -632,58 +632,58 @@ void CPepMood::InitGui() char szFile[MAX_PATH];
GetModuleFileNameA(hInst, szFile, MAX_PATH);
if (char *p = strrchr(szFile, '\\'))
- strcpy( p+1, "..\\Icons\\xstatus_jabber.dll" );
+ strcpy(p+1, "..\\Icons\\xstatus_jabber.dll");
TCHAR szSection[100];
mir_sntprintf(szSection, SIZEOF(szSection), _T("Status Icons/%s/Moods"), m_proto->m_tszUserName);
for (int i = 1; i < SIZEOF(g_arrMoods); i++)
- m_icons.RegisterIcon( g_arrMoods[i].szTag, szFile, -(200+i), szSection, TranslateTS(g_arrMoods[i].szName));
+ m_icons.RegisterIcon(g_arrMoods[i].szTag, szFile, -(200+i), szSection, TranslateTS(g_arrMoods[i].szName));
}
void CPepMood::ProcessItems(const TCHAR *from, HXML itemsNode)
{
HANDLE hContact = NULL, hSelfContact = NULL;
- if ( !m_proto->IsMyOwnJID( from )) {
+ if ( !m_proto->IsMyOwnJID(from)) {
hContact = m_proto->HContactFromJID(from);
- if (!hContact) return;
+ if ( !hContact) return;
}
else hSelfContact = m_proto->HContactFromJID(from);
- if ( xmlGetChild( itemsNode, _T("retract"))) {
+ if (xmlGetChild(itemsNode, _T("retract"))) {
if (hSelfContact)
SetMood(hSelfContact, NULL, NULL);
SetMood(hContact, NULL, NULL);
return;
}
- HXML n, moodNode = XPath( itemsNode, _T("item/mood[@xmlns='") _T(JABBER_FEAT_USER_MOOD) _T("']"));
- if ( !moodNode ) return;
+ HXML n, moodNode = XPath(itemsNode, _T("item/mood[@xmlns='") _T(JABBER_FEAT_USER_MOOD) _T("']"));
+ if ( !moodNode) return;
LPCTSTR moodType = NULL, moodText = NULL;
- for ( int i = 0; n = xmlGetChild( moodNode, i ); i++ ) {
- if ( !_tcscmp( xmlGetName( n ), _T("text")))
- moodText = xmlGetText( n );
+ for (int i = 0; n = xmlGetChild(moodNode, i); i++) {
+ if ( !_tcscmp(xmlGetName(n), _T("text")))
+ moodText = xmlGetText(n);
else
- moodType = xmlGetName( n );
+ moodType = xmlGetName(n);
}
- TCHAR *fixedText = JabberStrFixLines( moodText );
+ TCHAR *fixedText = JabberStrFixLines(moodText);
if (hSelfContact)
SetMood(hSelfContact, moodType, fixedText);
SetMood(hContact, moodType, fixedText);
- mir_free( fixedText );
+ mir_free(fixedText);
- if (!hContact && m_mode >= 0)
+ if ( !hContact && m_mode >= 0)
ForceRepublishOnLogin();
}
-void CPepMood::CreateData( HXML n )
+void CPepMood::CreateData(HXML n)
{
- HXML moodNode = n << XCHILDNS( _T("mood"), _T(JABBER_FEAT_USER_MOOD));
- moodNode << XCHILD( _A2T(g_arrMoods[m_mode].szTag));
- if ( m_text )
- moodNode << XCHILD( _T("text"), m_text );
+ HXML moodNode = n << XCHILDNS(_T("mood"), _T(JABBER_FEAT_USER_MOOD));
+ moodNode << XCHILD(_A2T(g_arrMoods[m_mode].szTag));
+ if (m_text)
+ moodNode << XCHILD(_T("text"), m_text);
}
void CPepMood::ResetExtraIcon(HANDLE hContact)
@@ -702,21 +702,21 @@ void CPepMood::SetMood(HANDLE hContact, const TCHAR *szMood, const TCHAR *szText {
int mood = -1;
if (szMood) {
- char* p = mir_t2a( szMood );
+ char* p = mir_t2a(szMood);
for (int i = 1; i < SIZEOF(g_arrMoods); ++i)
- if (!lstrcmpA(g_arrMoods[i].szTag, p )) {
+ if ( !lstrcmpA(g_arrMoods[i].szTag, p)) {
mood = i;
break;
}
- mir_free( p );
+ mir_free(p);
if (mood < 0)
return;
}
- if (!hContact) {
+ if ( !hContact) {
m_mode = mood;
replaceStrT(m_text, szText);
@@ -761,13 +761,13 @@ void CPepMood::SetMood(HANDLE hContact, const TCHAR *szMood, const TCHAR *szText void CPepMood::ShowSetDialog(BYTE bQuiet)
{
- if ( !bQuiet ) {
+ if ( !bQuiet) {
CJabberDlgPepSimple dlg(m_proto, TranslateT("Set Mood"));
for (int i = 1; i < SIZEOF(g_arrMoods); ++i)
dlg.AddStatusMode(i, g_arrMoods[i].szTag, m_icons.GetIcon(g_arrMoods[i].szTag), TranslateTS(g_arrMoods[i].szName));
dlg.SetActiveStatus(m_mode, m_text);
dlg.DoModal();
- if (!dlg.OkClicked())
+ if ( !dlg.OkClicked())
return;
m_mode = dlg.GetStatusMode();
@@ -803,79 +803,79 @@ struct }
static g_arrActivities[] =
{
- { "doing_chores", NULL, _T("Doing chores"), ACTIVITY_ICON( 0, 0) },
- { NULL, "buying_groceries", _T("buying groceries"), ACTIVITY_ICON( 0, 1) },
- { NULL, "cleaning", _T("cleaning"), ACTIVITY_ICON( 0, 2) },
- { NULL, "cooking", _T("cooking"), ACTIVITY_ICON( 0, 3) },
- { NULL, "doing_maintenance", _T("doing maintenance"), ACTIVITY_ICON( 0, 4) },
- { NULL, "doing_the_dishes", _T("doing the dishes"), ACTIVITY_ICON( 0, 5) },
- { NULL, "doing_the_laundry", _T("doing the laundry"), ACTIVITY_ICON( 0, 6) },
- { NULL, "gardening", _T("gardening"), ACTIVITY_ICON( 0, 7) },
- { NULL, "running_an_errand", _T("running an errand"), ACTIVITY_ICON( 0, 8) },
- { NULL, "walking_the_dog", _T("walking the dog"), ACTIVITY_ICON( 0, 9) },
- { "drinking", NULL, _T("Drinking"), ACTIVITY_ICON( 1, 0) },
- { NULL, "having_a_beer", _T("having a beer"), ACTIVITY_ICON( 1, 1) },
- { NULL, "having_coffee", _T("having coffee"), ACTIVITY_ICON( 1, 2) },
- { NULL, "having_tea", _T("having tea"), ACTIVITY_ICON( 1, 3) },
- { "eating", NULL, _T("Eating"), ACTIVITY_ICON( 2, 0) },
- { NULL, "having_a_snack", _T("having a snack"), ACTIVITY_ICON( 2, 1) },
- { NULL, "having_breakfast", _T("having breakfast"), ACTIVITY_ICON( 2, 2) },
- { NULL, "having_dinner", _T("having dinner"), ACTIVITY_ICON( 2, 3) },
- { NULL, "having_lunch", _T("having lunch"), ACTIVITY_ICON( 2, 4) },
- { "exercising", NULL, _T("Exercising"), ACTIVITY_ICON( 3, 0) },
- { NULL, "cycling", _T("cycling"), ACTIVITY_ICON( 3, 1) },
- { NULL, "dancing", _T("dancing"), ACTIVITY_ICON( 3, 2) },
- { NULL, "hiking", _T("hiking"), ACTIVITY_ICON( 3, 3) },
- { NULL, "jogging", _T("jogging"), ACTIVITY_ICON( 3, 4) },
- { NULL, "playing_sports", _T("playing sports"), ACTIVITY_ICON( 3, 5) },
- { NULL, "running", _T("running"), ACTIVITY_ICON( 3, 6) },
- { NULL, "skiing", _T("skiing"), ACTIVITY_ICON( 3, 7) },
- { NULL, "swimming", _T("swimming"), ACTIVITY_ICON( 3, 8) },
- { NULL, "working_out", _T("working out"), ACTIVITY_ICON( 3, 9) },
- { "grooming", NULL, _T("Grooming"), ACTIVITY_ICON( 4, 0) },
- { NULL, "at_the_spa", _T("at the spa"), ACTIVITY_ICON( 4, 1) },
- { NULL, "brushing_teeth", _T("brushing teeth"), ACTIVITY_ICON( 4, 2) },
- { NULL, "getting_a_haircut", _T("getting a haircut"), ACTIVITY_ICON( 4, 3) },
- { NULL, "shaving", _T("shaving"), ACTIVITY_ICON( 4, 4) },
- { NULL, "taking_a_bath", _T("taking a bath"), ACTIVITY_ICON( 4, 5) },
- { NULL, "taking_a_shower", _T("taking a shower"), ACTIVITY_ICON( 4, 6) },
- { "having_appointment", NULL, _T("Having appointment"), ACTIVITY_ICON( 5, 0) },
- { "inactive", NULL, _T("Inactive"), ACTIVITY_ICON( 6, 0) },
- { NULL, "day_off", _T("day off"), ACTIVITY_ICON( 6, 1) },
- { NULL, "hanging_out", _T("hanging out"), ACTIVITY_ICON( 6, 2) },
- { NULL, "hiding", _T("hiding"), ACTIVITY_ICON( 6, 3) },
- { NULL, "on_vacation", _T("on vacation"), ACTIVITY_ICON( 6, 4) },
- { NULL, "praying", _T("praying"), ACTIVITY_ICON( 6, 5) },
- { NULL, "scheduled_holiday", _T("scheduled holiday"), ACTIVITY_ICON( 6, 6) },
- { NULL, "sleeping", _T("sleeping"), ACTIVITY_ICON( 6, 7) },
- { NULL, "thinking", _T("thinking"), ACTIVITY_ICON( 6, 8) },
- { "relaxing", NULL, _T("Relaxing"), ACTIVITY_ICON( 7, 0) },
- { NULL, "fishing", _T("fishing"), ACTIVITY_ICON( 7, 1) },
- { NULL, "gaming", _T("gaming"), ACTIVITY_ICON( 7, 2) },
- { NULL, "going_out", _T("going out"), ACTIVITY_ICON( 7, 3) },
- { NULL, "partying", _T("partying"), ACTIVITY_ICON( 7, 4) },
- { NULL, "reading", _T("reading"), ACTIVITY_ICON( 7, 5) },
- { NULL, "rehearsing", _T("rehearsing"), ACTIVITY_ICON( 7, 6) },
- { NULL, "shopping", _T("shopping"), ACTIVITY_ICON( 7, 7) },
- { NULL, "smoking", _T("smoking"), ACTIVITY_ICON( 7, 8) },
- { NULL, "socializing", _T("socializing"), ACTIVITY_ICON( 7, 9) },
- { NULL, "sunbathing", _T("sunbathing"), ACTIVITY_ICON( 7, 10) },
- { NULL, "watching_tv", _T("watching TV"), ACTIVITY_ICON( 7, 11) },
- { NULL, "watching_a_movie", _T("watching a movie"), ACTIVITY_ICON( 7, 12) },
- { "talking", NULL, _T("Talking"), ACTIVITY_ICON( 8, 0) },
- { NULL, "in_real_life", _T("in real life"), ACTIVITY_ICON( 8, 1) },
- { NULL, "on_the_phone", _T("on the phone"), ACTIVITY_ICON( 8, 2) },
- { NULL, "on_video_phone", _T("on video phone"), ACTIVITY_ICON( 8, 3) },
- { "traveling", NULL, _T("Traveling"), ACTIVITY_ICON( 9, 0) },
- { NULL, "commuting", _T("commuting"), ACTIVITY_ICON( 9, 1) },
- { NULL, "cycling", _T("cycling"), ACTIVITY_ICON( 9, 2) },
- { NULL, "driving", _T("driving"), ACTIVITY_ICON( 9, 3) },
- { NULL, "in_a_car", _T("in a car"), ACTIVITY_ICON( 9, 4) },
- { NULL, "on_a_bus", _T("on a bus"), ACTIVITY_ICON( 9, 5) },
- { NULL, "on_a_plane", _T("on a plane"), ACTIVITY_ICON( 9, 6) },
- { NULL, "on_a_train", _T("on a train"), ACTIVITY_ICON( 9, 7) },
- { NULL, "on_a_trip", _T("on a trip"), ACTIVITY_ICON( 9, 8) },
- { NULL, "walking", _T("walking"), ACTIVITY_ICON( 9, 9) },
+ { "doing_chores", NULL, _T("Doing chores"), ACTIVITY_ICON(0, 0) },
+ { NULL, "buying_groceries", _T("buying groceries"), ACTIVITY_ICON(0, 1) },
+ { NULL, "cleaning", _T("cleaning"), ACTIVITY_ICON(0, 2) },
+ { NULL, "cooking", _T("cooking"), ACTIVITY_ICON(0, 3) },
+ { NULL, "doing_maintenance", _T("doing maintenance"), ACTIVITY_ICON(0, 4) },
+ { NULL, "doing_the_dishes", _T("doing the dishes"), ACTIVITY_ICON(0, 5) },
+ { NULL, "doing_the_laundry", _T("doing the laundry"), ACTIVITY_ICON(0, 6) },
+ { NULL, "gardening", _T("gardening"), ACTIVITY_ICON(0, 7) },
+ { NULL, "running_an_errand", _T("running an errand"), ACTIVITY_ICON(0, 8) },
+ { NULL, "walking_the_dog", _T("walking the dog"), ACTIVITY_ICON(0, 9) },
+ { "drinking", NULL, _T("Drinking"), ACTIVITY_ICON(1, 0) },
+ { NULL, "having_a_beer", _T("having a beer"), ACTIVITY_ICON(1, 1) },
+ { NULL, "having_coffee", _T("having coffee"), ACTIVITY_ICON(1, 2) },
+ { NULL, "having_tea", _T("having tea"), ACTIVITY_ICON(1, 3) },
+ { "eating", NULL, _T("Eating"), ACTIVITY_ICON(2, 0) },
+ { NULL, "having_a_snack", _T("having a snack"), ACTIVITY_ICON(2, 1) },
+ { NULL, "having_breakfast", _T("having breakfast"), ACTIVITY_ICON(2, 2) },
+ { NULL, "having_dinner", _T("having dinner"), ACTIVITY_ICON(2, 3) },
+ { NULL, "having_lunch", _T("having lunch"), ACTIVITY_ICON(2, 4) },
+ { "exercising", NULL, _T("Exercising"), ACTIVITY_ICON(3, 0) },
+ { NULL, "cycling", _T("cycling"), ACTIVITY_ICON(3, 1) },
+ { NULL, "dancing", _T("dancing"), ACTIVITY_ICON(3, 2) },
+ { NULL, "hiking", _T("hiking"), ACTIVITY_ICON(3, 3) },
+ { NULL, "jogging", _T("jogging"), ACTIVITY_ICON(3, 4) },
+ { NULL, "playing_sports", _T("playing sports"), ACTIVITY_ICON(3, 5) },
+ { NULL, "running", _T("running"), ACTIVITY_ICON(3, 6) },
+ { NULL, "skiing", _T("skiing"), ACTIVITY_ICON(3, 7) },
+ { NULL, "swimming", _T("swimming"), ACTIVITY_ICON(3, 8) },
+ { NULL, "working_out", _T("working out"), ACTIVITY_ICON(3, 9) },
+ { "grooming", NULL, _T("Grooming"), ACTIVITY_ICON(4, 0) },
+ { NULL, "at_the_spa", _T("at the spa"), ACTIVITY_ICON(4, 1) },
+ { NULL, "brushing_teeth", _T("brushing teeth"), ACTIVITY_ICON(4, 2) },
+ { NULL, "getting_a_haircut", _T("getting a haircut"), ACTIVITY_ICON(4, 3) },
+ { NULL, "shaving", _T("shaving"), ACTIVITY_ICON(4, 4) },
+ { NULL, "taking_a_bath", _T("taking a bath"), ACTIVITY_ICON(4, 5) },
+ { NULL, "taking_a_shower", _T("taking a shower"), ACTIVITY_ICON(4, 6) },
+ { "having_appointment", NULL, _T("Having appointment"), ACTIVITY_ICON(5, 0) },
+ { "inactive", NULL, _T("Inactive"), ACTIVITY_ICON(6, 0) },
+ { NULL, "day_off", _T("day off"), ACTIVITY_ICON(6, 1) },
+ { NULL, "hanging_out", _T("hanging out"), ACTIVITY_ICON(6, 2) },
+ { NULL, "hiding", _T("hiding"), ACTIVITY_ICON(6, 3) },
+ { NULL, "on_vacation", _T("on vacation"), ACTIVITY_ICON(6, 4) },
+ { NULL, "praying", _T("praying"), ACTIVITY_ICON(6, 5) },
+ { NULL, "scheduled_holiday", _T("scheduled holiday"), ACTIVITY_ICON(6, 6) },
+ { NULL, "sleeping", _T("sleeping"), ACTIVITY_ICON(6, 7) },
+ { NULL, "thinking", _T("thinking"), ACTIVITY_ICON(6, 8) },
+ { "relaxing", NULL, _T("Relaxing"), ACTIVITY_ICON(7, 0) },
+ { NULL, "fishing", _T("fishing"), ACTIVITY_ICON(7, 1) },
+ { NULL, "gaming", _T("gaming"), ACTIVITY_ICON(7, 2) },
+ { NULL, "going_out", _T("going out"), ACTIVITY_ICON(7, 3) },
+ { NULL, "partying", _T("partying"), ACTIVITY_ICON(7, 4) },
+ { NULL, "reading", _T("reading"), ACTIVITY_ICON(7, 5) },
+ { NULL, "rehearsing", _T("rehearsing"), ACTIVITY_ICON(7, 6) },
+ { NULL, "shopping", _T("shopping"), ACTIVITY_ICON(7, 7) },
+ { NULL, "smoking", _T("smoking"), ACTIVITY_ICON(7, 8) },
+ { NULL, "socializing", _T("socializing"), ACTIVITY_ICON(7, 9) },
+ { NULL, "sunbathing", _T("sunbathing"), ACTIVITY_ICON(7, 10) },
+ { NULL, "watching_tv", _T("watching TV"), ACTIVITY_ICON(7, 11) },
+ { NULL, "watching_a_movie", _T("watching a movie"), ACTIVITY_ICON(7, 12) },
+ { "talking", NULL, _T("Talking"), ACTIVITY_ICON(8, 0) },
+ { NULL, "in_real_life", _T("in real life"), ACTIVITY_ICON(8, 1) },
+ { NULL, "on_the_phone", _T("on the phone"), ACTIVITY_ICON(8, 2) },
+ { NULL, "on_video_phone", _T("on video phone"), ACTIVITY_ICON(8, 3) },
+ { "traveling", NULL, _T("Traveling"), ACTIVITY_ICON(9, 0) },
+ { NULL, "commuting", _T("commuting"), ACTIVITY_ICON(9, 1) },
+ { NULL, "cycling", _T("cycling"), ACTIVITY_ICON(9, 2) },
+ { NULL, "driving", _T("driving"), ACTIVITY_ICON(9, 3) },
+ { NULL, "in_a_car", _T("in a car"), ACTIVITY_ICON(9, 4) },
+ { NULL, "on_a_bus", _T("on a bus"), ACTIVITY_ICON(9, 5) },
+ { NULL, "on_a_plane", _T("on a plane"), ACTIVITY_ICON(9, 6) },
+ { NULL, "on_a_train", _T("on a train"), ACTIVITY_ICON(9, 7) },
+ { NULL, "on_a_trip", _T("on a trip"), ACTIVITY_ICON(9, 8) },
+ { NULL, "walking", _T("walking"), ACTIVITY_ICON(9, 9) },
{ "working", NULL, _T("Working"), ACTIVITY_ICON(10, 0) },
{ NULL, "coding", _T("coding"), ACTIVITY_ICON(10, 1) },
{ NULL, "in_a_meeting", _T("in a meeting"), ACTIVITY_ICON(10, 2) },
@@ -890,25 +890,25 @@ inline char *ActivityGetId(int id) }
// -1 if not found, otherwise activity number
-static int ActivityCheck( LPCTSTR szFirstNode, LPCTSTR szSecondNode )
+static int ActivityCheck(LPCTSTR szFirstNode, LPCTSTR szSecondNode)
{
- if (!szFirstNode) return 0;
+ if ( !szFirstNode) return 0;
- char *s1 = mir_t2a( szFirstNode ), *s2 = mir_t2a( szSecondNode );
+ char *s1 = mir_t2a(szFirstNode), *s2 = mir_t2a(szSecondNode);
int i = 0, nFirst = -1, nSecond = -1;
- while ( g_arrActivities[i].szFirst || g_arrActivities[i].szSecond ) {
+ while (g_arrActivities[i].szFirst || g_arrActivities[i].szSecond) {
// check first node
- if ( g_arrActivities[i].szFirst && !strcmp( s1, g_arrActivities[i].szFirst )) {
+ if (g_arrActivities[i].szFirst && !strcmp(s1, g_arrActivities[i].szFirst)) {
// first part found
nFirst = i;
- if ( !s2 ) {
+ if ( !s2) {
nSecond = i;
break;
}
i++; // move to next
- while ( g_arrActivities[i].szSecond ) {
- if ( !strcmp( g_arrActivities[i].szSecond, s2 )) {
+ while (g_arrActivities[i].szSecond) {
+ if ( !strcmp(g_arrActivities[i].szSecond, s2)) {
nSecond = i;
break;
}
@@ -919,10 +919,10 @@ static int ActivityCheck( LPCTSTR szFirstNode, LPCTSTR szSecondNode ) i++;
}
- mir_free( s1 );
- mir_free( s2 );
+ mir_free(s1);
+ mir_free(s2);
- if ( nSecond != -1 )
+ if (nSecond != -1)
return nSecond;
return nFirst;
@@ -951,7 +951,7 @@ char *ActivityGetFirst(int id) char *ActivityGetFirst(char *szId)
{
- if (!szId) return NULL;
+ if ( !szId) return NULL;
int id = SIZEOF(g_arrActivities) - 1;
bool found_second = false;
@@ -1026,7 +1026,7 @@ void CPepActivity::InitGui() char szFile[MAX_PATH];
GetModuleFileNameA(hInst, szFile, MAX_PATH);
if (char *p = strrchr(szFile, '\\'))
- strcpy( p+1, "..\\Icons\\xstatus_jabber.dll" );
+ strcpy(p+1, "..\\Icons\\xstatus_jabber.dll");
TCHAR szSection[100];
@@ -1042,60 +1042,60 @@ void CPepActivity::InitGui() void CPepActivity::ProcessItems(const TCHAR *from, HXML itemsNode)
{
HANDLE hContact = NULL, hSelfContact = NULL;
- if ( !m_proto->IsMyOwnJID( from )) {
+ if ( !m_proto->IsMyOwnJID(from)) {
hContact = m_proto->HContactFromJID(from);
- if (!hContact) return;
+ if ( !hContact) return;
}
else hSelfContact = m_proto->HContactFromJID(from);
- if ( xmlGetChild( itemsNode, "retract")) {
+ if (xmlGetChild(itemsNode, "retract")) {
if (hSelfContact)
SetActivity(hSelfContact, NULL, NULL, NULL);
SetActivity(hContact, NULL, NULL, NULL);
return;
}
- HXML actNode = XPath( itemsNode, _T("item/activity[@xmlns='") _T(JABBER_FEAT_USER_ACTIVITY) _T("']"));
- if ( !actNode )
+ HXML actNode = XPath(itemsNode, _T("item/activity[@xmlns='") _T(JABBER_FEAT_USER_ACTIVITY) _T("']"));
+ if ( !actNode)
return;
- LPCTSTR szText = XPathT( actNode, "text" );
+ LPCTSTR szText = XPathT(actNode, "text");
LPCTSTR szFirstNode = NULL, szSecondNode = NULL;
HXML n;
- for ( int i = 0; n = xmlGetChild( actNode, i ); i++ ) {
- if ( lstrcmp( xmlGetName( n ), _T("text"))) {
- szFirstNode = xmlGetName( n );
- HXML secondNode = xmlGetChild( n, 0 );
- if (szFirstNode && secondNode && xmlGetName( secondNode ))
- szSecondNode = xmlGetName( secondNode );
+ for (int i = 0; n = xmlGetChild(actNode, i); i++) {
+ if (lstrcmp(xmlGetName(n), _T("text"))) {
+ szFirstNode = xmlGetName(n);
+ HXML secondNode = xmlGetChild(n, 0);
+ if (szFirstNode && secondNode && xmlGetName(secondNode))
+ szSecondNode = xmlGetName(secondNode);
break;
}
}
- TCHAR *fixedText = JabberStrFixLines( szText );
+ TCHAR *fixedText = JabberStrFixLines(szText);
if (hSelfContact)
SetActivity(hSelfContact, szFirstNode, szSecondNode, fixedText);
SetActivity(hContact, szFirstNode, szSecondNode, fixedText);
- mir_free( fixedText );
+ mir_free(fixedText);
- if (!hContact && m_mode >= 0)
+ if ( !hContact && m_mode >= 0)
ForceRepublishOnLogin();
}
-void CPepActivity::CreateData( HXML n )
+void CPepActivity::CreateData(HXML n)
{
char *szFirstNode = ActivityGetFirst(m_mode);
char *szSecondNode = ActivityGetSecond(m_mode);
- HXML activityNode = n << XCHILDNS( _T("activity"), _T(JABBER_FEAT_USER_ACTIVITY));
- HXML firstNode = activityNode << XCHILD( _A2T( szFirstNode ));
+ HXML activityNode = n << XCHILDNS(_T("activity"), _T(JABBER_FEAT_USER_ACTIVITY));
+ HXML firstNode = activityNode << XCHILD(_A2T(szFirstNode));
if (firstNode && szSecondNode)
- firstNode << XCHILD( _A2T(szSecondNode));
+ firstNode << XCHILD(_A2T(szSecondNode));
if (m_text)
- activityNode << XCHILD( _T("text"), m_text);
+ activityNode << XCHILD(_T("text"), m_text);
}
void CPepActivity::ResetExtraIcon(HANDLE hContact)
@@ -1122,7 +1122,7 @@ void CPepActivity::SetActivity(HANDLE hContact, LPCTSTR szFirst, LPCTSTR szSecon TCHAR activityTitle[128];
ActivityBuildTitle(activity, activityTitle, SIZEOF(activityTitle));
- if (!hContact) {
+ if ( !hContact) {
m_mode = activity;
replaceStrT(m_text, szText);
@@ -1145,9 +1145,9 @@ void CPepActivity::SetActivity(HANDLE hContact, LPCTSTR szFirst, LPCTSTR szSecon else SetExtraIcon(hContact, activity < 0 ? NULL : returnActivity(activity));
if (activity >= 0) {
- TCHAR* p = mir_a2t( ActivityGetId(activity));
+ TCHAR* p = mir_a2t(ActivityGetId(activity));
m_proto->WriteAdvStatus(hContact, ADVSTATUS_ACTIVITY, p, m_icons.GetIcolibName(returnActivity(activity)), activityTitle, szText);
- mir_free( p );
+ mir_free(p);
}
else m_proto->ResetAdvStatus(hContact, ADVSTATUS_ACTIVITY);
}
@@ -1161,7 +1161,7 @@ void CPepActivity::ShowSetDialog(BYTE bQuiet) dlg.SetActiveStatus(m_mode, m_text);
dlg.DoModal();
- if (!dlg.OkClicked()) return;
+ if ( !dlg.OkClicked()) return;
m_mode = dlg.GetStatusMode();
if (m_mode >= 0) {
@@ -1187,19 +1187,19 @@ HICON CJabberProto::GetXStatusIcon(int bStatus, UINT flags) {
CPepMood *pepMood = (CPepMood *)m_pepServices.Find(_T(JABBER_FEAT_USER_MOOD));
HICON icon = pepMood->m_icons.GetIcon(g_arrMoods[bStatus].szTag, (flags & LR_BIGICON) != 0);
- return ( flags & LR_SHARED ) ? icon : CopyIcon( icon );
+ return (flags & LR_SHARED) ? icon : CopyIcon(icon);
}
/////////////////////////////////////////////////////////////////////////////////////////
// JabberGetXStatus - gets the extended status info (mood)
-INT_PTR __cdecl CJabberProto::OnGetXStatus( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::OnGetXStatus(WPARAM wParam, LPARAM lParam)
{
- if ( !m_bJabberOnline || !m_bPepSupported )
+ if ( !m_bJabberOnline || !m_bPepSupported)
return 0;
- if ( wParam ) *(( char** )wParam ) = DBSETTING_XSTATUSNAME;
- if ( lParam ) *(( char** )lParam ) = DBSETTING_XSTATUSMSG;
+ if (wParam) *((char**)wParam) = DBSETTING_XSTATUSNAME;
+ if (lParam) *((char**)lParam) = DBSETTING_XSTATUSMSG;
return ((CPepMood *)m_pepServices.Find(_T(JABBER_FEAT_USER_MOOD)))->m_mode;
}
@@ -1209,112 +1209,112 @@ INT_PTR __cdecl CJabberProto::OnGetXStatus( WPARAM wParam, LPARAM lParam ) // lParam = flags // use LR_SHARED for shared HICON
// return = HICON // custom status icon (use DestroyIcon to release resources if not LR_SHARED)
-INT_PTR __cdecl CJabberProto::OnGetXStatusIcon( WPARAM wParam, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::OnGetXStatusIcon(WPARAM wParam, LPARAM lParam)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return 0;
- if ( !wParam )
+ if ( !wParam)
wParam = ((CPepMood *)m_pepServices.Find(_T(JABBER_FEAT_USER_MOOD)))->m_mode;
- if ( wParam < 1 || wParam >= SIZEOF(g_arrMoods))
+ if (wParam < 1 || wParam >= SIZEOF(g_arrMoods))
return 0;
int flags = 0;
- if ( lParam & LR_SHARED ) flags |= LR_SHARED;
- if ( lParam & LR_BIGICON ) flags |= LR_BIGICON;
+ if (lParam & LR_SHARED) flags |= LR_SHARED;
+ if (lParam & LR_BIGICON) flags |= LR_BIGICON;
- return (INT_PTR)GetXStatusIcon( wParam, flags );
+ return (INT_PTR)GetXStatusIcon(wParam, flags);
}
/////////////////////////////////////////////////////////////////////////////////////////
// SendPepMood - sends mood
-BOOL CJabberProto::SendPepTune( TCHAR* szArtist, TCHAR* szLength, TCHAR* szSource, TCHAR* szTitle, TCHAR* szTrack, TCHAR* szUri )
+BOOL CJabberProto::SendPepTune(TCHAR* szArtist, TCHAR* szLength, TCHAR* szSource, TCHAR* szTitle, TCHAR* szTrack, TCHAR* szUri)
{
- if ( !m_bJabberOnline || !m_bPepSupported )
+ if ( !m_bJabberOnline || !m_bPepSupported)
return FALSE;
- XmlNodeIq iq( _T("set"), SerialNext());
- HXML tuneNode = iq << XCHILDNS( _T("pubsub"), _T(JABBER_FEAT_PUBSUB))
- << XCHILD( _T("publish")) << XATTR( _T("node"), _T(JABBER_FEAT_USER_TUNE))
- << XCHILD( _T("item")) << XCHILDNS( _T("tune"), _T(JABBER_FEAT_USER_TUNE));
-
- if ( szArtist || szLength || szSource || szTitle || szUri ) {
- if ( szArtist ) tuneNode << XCHILD( _T("artist"), szArtist );
- if ( szLength ) tuneNode << XCHILD( _T("length"), szLength );
- if ( szSource ) tuneNode << XCHILD( _T("source"), szSource );
- if ( szTitle ) tuneNode << XCHILD( _T("title"), szTitle );
- if ( szTrack ) tuneNode << XCHILD( _T("track"), szTrack );
- if ( szUri ) tuneNode << XCHILD( _T("uri"), szUri );
+ XmlNodeIq iq(_T("set"), SerialNext());
+ HXML tuneNode = iq << XCHILDNS(_T("pubsub"), _T(JABBER_FEAT_PUBSUB))
+ << XCHILD(_T("publish")) << XATTR(_T("node"), _T(JABBER_FEAT_USER_TUNE))
+ << XCHILD(_T("item")) << XCHILDNS(_T("tune"), _T(JABBER_FEAT_USER_TUNE));
+
+ if (szArtist || szLength || szSource || szTitle || szUri) {
+ if (szArtist) tuneNode << XCHILD(_T("artist"), szArtist);
+ if (szLength) tuneNode << XCHILD(_T("length"), szLength);
+ if (szSource) tuneNode << XCHILD(_T("source"), szSource);
+ if (szTitle) tuneNode << XCHILD(_T("title"), szTitle);
+ if (szTrack) tuneNode << XCHILD(_T("track"), szTrack);
+ if (szUri) tuneNode << XCHILD(_T("uri"), szUri);
}
- m_ThreadInfo->send( iq );
+ m_ThreadInfo->send(iq);
return TRUE;
}
-void CJabberProto::SetContactTune( HANDLE hContact, LPCTSTR szArtist, LPCTSTR szLength, LPCTSTR szSource, LPCTSTR szTitle, LPCTSTR szTrack )
+void CJabberProto::SetContactTune(HANDLE hContact, LPCTSTR szArtist, LPCTSTR szLength, LPCTSTR szSource, LPCTSTR szTitle, LPCTSTR szTrack)
{
- if ( !szArtist && !szTitle ) {
- JDeleteSetting( hContact, "ListeningTo" );
- ResetAdvStatus( hContact, ADVSTATUS_TUNE );
+ if ( !szArtist && !szTitle) {
+ JDeleteSetting(hContact, "ListeningTo");
+ ResetAdvStatus(hContact, ADVSTATUS_TUNE);
return;
}
TCHAR *szListeningTo;
- if ( ServiceExists( MS_LISTENINGTO_GETPARSEDTEXT )) {
+ if (ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT)) {
LISTENINGTOINFO li;
- ZeroMemory( &li, sizeof( li ));
- li.cbSize = sizeof( li );
+ ZeroMemory(&li, sizeof(li));
+ li.cbSize = sizeof(li);
li.dwFlags = LTI_TCHAR;
- li.ptszArtist = ( TCHAR* )szArtist;
- li.ptszLength = ( TCHAR* )szLength;
- li.ptszAlbum = ( TCHAR* )szSource;
- li.ptszTitle = ( TCHAR* )szTitle;
- li.ptszTrack = ( TCHAR* )szTrack;
- szListeningTo = (TCHAR *)CallService( MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)_T("%title% - %artist%"), (LPARAM)&li );
+ li.ptszArtist = (TCHAR*)szArtist;
+ li.ptszLength = (TCHAR*)szLength;
+ li.ptszAlbum = (TCHAR*)szSource;
+ li.ptszTitle = (TCHAR*)szTitle;
+ li.ptszTrack = (TCHAR*)szTrack;
+ szListeningTo = (TCHAR *)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM)_T("%title% - %artist%"), (LPARAM)&li);
}
else {
- szListeningTo = (TCHAR *) mir_alloc( 2048 * sizeof( TCHAR ));
- mir_sntprintf( szListeningTo, 2047, _T("%s - %s"), szTitle ? szTitle : _T(""), szArtist ? szArtist : _T(""));
+ szListeningTo = (TCHAR *) mir_alloc(2048 * sizeof(TCHAR));
+ mir_sntprintf(szListeningTo, 2047, _T("%s - %s"), szTitle ? szTitle : _T(""), szArtist ? szArtist : _T(""));
}
- JSetStringT( hContact, "ListeningTo", szListeningTo );
+ JSetStringT(hContact, "ListeningTo", szListeningTo);
char tuneIcon[128];
mir_snprintf(tuneIcon, SIZEOF(tuneIcon), "%s_%s", m_szModuleName, "main");
- WriteAdvStatus( hContact, ADVSTATUS_TUNE, _T("listening_to"), tuneIcon, TranslateT("Listening To"), szListeningTo );
+ WriteAdvStatus(hContact, ADVSTATUS_TUNE, _T("listening_to"), tuneIcon, TranslateT("Listening To"), szListeningTo);
- mir_free( szListeningTo );
+ mir_free(szListeningTo);
}
-TCHAR* a2tf( const TCHAR* str, BOOL unicode )
+TCHAR* a2tf(const TCHAR *str, BOOL unicode)
{
- if ( str == NULL )
+ if (str == NULL)
return NULL;
- return ( unicode ) ? mir_tstrdup( str ) : mir_a2t(( char* )str );
+ return (unicode) ? mir_tstrdup(str) : mir_a2t((char*)str);
}
-void overrideStr( TCHAR*& dest, const TCHAR* src, BOOL unicode, const TCHAR* def = NULL )
+void overrideStr(TCHAR*& dest, const TCHAR *src, BOOL unicode, const TCHAR *def = NULL)
{
- if ( dest != NULL ) {
- mir_free( dest );
+ if (dest != NULL) {
+ mir_free(dest);
dest = NULL;
}
- if ( src != NULL )
- dest = a2tf( src, unicode );
- else if ( def != NULL )
- dest = mir_tstrdup( def );
+ if (src != NULL)
+ dest = a2tf(src, unicode);
+ else if (def != NULL)
+ dest = mir_tstrdup(def);
}
-INT_PTR __cdecl CJabberProto::OnSetListeningTo( WPARAM, LPARAM lParam )
+INT_PTR __cdecl CJabberProto::OnSetListeningTo(WPARAM, LPARAM lParam)
{
LISTENINGTOINFO *cm = (LISTENINGTOINFO *)lParam;
if ( !cm || cm->cbSize != sizeof(LISTENINGTOINFO)) {
- SendPepTune( NULL, NULL, NULL, NULL, NULL, NULL );
- JDeleteSetting( NULL, "ListeningTo" );
+ SendPepTune(NULL, NULL, NULL, NULL, NULL, NULL);
+ JDeleteSetting(NULL, "ListeningTo");
}
else {
TCHAR *szArtist = NULL, *szLength = NULL, *szSource = NULL;
@@ -1322,42 +1322,42 @@ INT_PTR __cdecl CJabberProto::OnSetListeningTo( WPARAM, LPARAM lParam ) BOOL unicode = cm->dwFlags & LTI_UNICODE;
- overrideStr( szArtist, cm->ptszArtist, unicode );
- overrideStr( szSource, cm->ptszAlbum, unicode );
- overrideStr( szTitle, cm->ptszTitle, unicode );
- overrideStr( szTrack, cm->ptszTrack, unicode );
- overrideStr( szLength, cm->ptszLength, unicode );
+ overrideStr(szArtist, cm->ptszArtist, unicode);
+ overrideStr(szSource, cm->ptszAlbum, unicode);
+ overrideStr(szTitle, cm->ptszTitle, unicode);
+ overrideStr(szTrack, cm->ptszTrack, unicode);
+ overrideStr(szLength, cm->ptszLength, unicode);
TCHAR szLengthInSec[ 32 ];
szLengthInSec[ 0 ] = _T('\0');
- if ( szLength ) {
+ if (szLength) {
unsigned int multiplier = 1, result = 0;
- for ( TCHAR *p = szLength; *p; p++ )
- if ( *p == _T(':'))
+ for (TCHAR *p = szLength; *p; p++)
+ if (*p == _T(':'))
multiplier *= 60;
- if ( multiplier <= 3600 ) {
+ if (multiplier <= 3600) {
TCHAR *szTmp = szLength;
- while ( szTmp[0] ) {
- result += ( _ttoi( szTmp ) * multiplier );
+ while (szTmp[0]) {
+ result += (_ttoi(szTmp) * multiplier);
multiplier /= 60;
- szTmp = _tcschr( szTmp, _T(':'));
- if ( !szTmp )
+ szTmp = _tcschr(szTmp, _T(':'));
+ if ( !szTmp)
break;
szTmp++;
}
}
- mir_sntprintf( szLengthInSec, SIZEOF( szLengthInSec ), _T("%d"), result );
+ mir_sntprintf(szLengthInSec, SIZEOF(szLengthInSec), _T("%d"), result);
}
- SendPepTune( szArtist, szLength ? szLengthInSec : NULL, szSource, szTitle, szTrack, NULL );
- SetContactTune( NULL, szArtist, szLength, szSource, szTitle, szTrack );
+ SendPepTune(szArtist, szLength ? szLengthInSec : NULL, szSource, szTitle, szTrack, NULL);
+ SetContactTune(NULL, szArtist, szLength, szSource, szTitle, szTrack);
- mir_free( szArtist );
- mir_free( szLength );
- mir_free( szSource );
- mir_free( szTitle );
- mir_free( szTrack );
+ mir_free(szArtist);
+ mir_free(szLength);
+ mir_free(szSource);
+ mir_free(szTitle);
+ mir_free(szTrack);
}
return 0;
}
@@ -1387,42 +1387,42 @@ void CJabberProto::XStatusInit() void CJabberProto::XStatusUninit()
{
- if ( m_hHookExtraIconsRebuild )
- UnhookEvent( m_hHookExtraIconsRebuild );
+ if (m_hHookExtraIconsRebuild)
+ UnhookEvent(m_hHookExtraIconsRebuild);
- if ( m_hHookExtraIconsApply )
- UnhookEvent( m_hHookExtraIconsApply );
+ if (m_hHookExtraIconsApply)
+ UnhookEvent(m_hHookExtraIconsApply);
}
/////////////////////////////////////////////////////////////////////////////////////////
// JabberSetXStatus - sets the extended status info (mood)
-INT_PTR __cdecl CJabberProto::OnSetXStatus( WPARAM wParam, LPARAM )
+INT_PTR __cdecl CJabberProto::OnSetXStatus(WPARAM wParam, LPARAM)
{
- if ( !m_bPepSupported || !m_bJabberOnline )
+ if ( !m_bPepSupported || !m_bJabberOnline)
return 0;
CPepMood *pepMood = (CPepMood *)m_pepServices.Find(_T(JABBER_FEAT_USER_MOOD));
- if ( !wParam ) {
+ if ( !wParam) {
pepMood->m_mode = -1;
pepMood->Retract();
return 0;
}
- if ( wParam > 0 && wParam < SIZEOF(g_arrMoods)) {
+ if (wParam > 0 && wParam < SIZEOF(g_arrMoods)) {
pepMood->m_mode = wParam;
- pepMood->LaunchSetGui( 0 );
+ pepMood->LaunchSetGui(0);
return wParam;
}
return 0;
}
-INT_PTR __cdecl CJabberProto::OnSetXStatusEx( WPARAM wParam, LPARAM lParam)
+INT_PTR __cdecl CJabberProto::OnSetXStatusEx(WPARAM wParam, LPARAM lParam)
{
JABBER_CUSTOM_STATUS *pData = (JABBER_CUSTOM_STATUS*)lParam;
- if ( !m_bPepSupported || !m_bJabberOnline )
+ if ( !m_bPepSupported || !m_bJabberOnline)
return 1;
if (pData->cbSize < sizeof(JABBER_CUSTOM_STATUS)) return 1; // Failure
@@ -1432,8 +1432,8 @@ INT_PTR __cdecl CJabberProto::OnSetXStatusEx( WPARAM wParam, LPARAM lParam) int status = *pData->status;
if (status > 0 && status < SIZEOF(g_arrMoods)) {
pepMood->m_mode = status;
- pepMood->m_text = JabberStrFixLines( pData->ptszMessage );
- pepMood->LaunchSetGui( 1 );
+ pepMood->m_text = JabberStrFixLines(pData->ptszMessage);
+ pepMood->LaunchSetGui(1);
return 0;
}
@@ -1466,19 +1466,19 @@ void CJabberProto::ResetAdvStatus(HANDLE hContact, const char *pszSlot) char szSetting[128];
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/id", m_szModuleName, pszSlot);
- DBWriteContactSettingString(hContact, "AdvStatus", szSetting, "");
+ db_set_s(hContact, "AdvStatus", szSetting, "");
DBDeleteContactSetting(hContact, "AdvStatus", szSetting);
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/icon", m_szModuleName, pszSlot);
- DBWriteContactSettingString(hContact, "AdvStatus", szSetting, "");
+ db_set_s(hContact, "AdvStatus", szSetting, "");
DBDeleteContactSetting(hContact, "AdvStatus", szSetting);
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/title", m_szModuleName, pszSlot);
- DBWriteContactSettingString(hContact, "AdvStatus", szSetting, "");
+ db_set_s(hContact, "AdvStatus", szSetting, "");
DBDeleteContactSetting(hContact, "AdvStatus", szSetting);
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/text", m_szModuleName, pszSlot);
- DBWriteContactSettingString(hContact, "AdvStatus", szSetting, "");
+ db_set_s(hContact, "AdvStatus", szSetting, "");
DBDeleteContactSetting(hContact, "AdvStatus", szSetting);
}
@@ -1487,21 +1487,21 @@ void CJabberProto::WriteAdvStatus(HANDLE hContact, const char *pszSlot, const TC char szSetting[128];
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/id", m_szModuleName, pszSlot);
- DBWriteContactSettingTString(hContact, "AdvStatus", szSetting, pszMode);
+ db_set_ts(hContact, "AdvStatus", szSetting, pszMode);
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/icon", m_szModuleName, pszSlot);
- DBWriteContactSettingString(hContact, "AdvStatus", szSetting, pszIcon);
+ db_set_s(hContact, "AdvStatus", szSetting, pszIcon);
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/title", m_szModuleName, pszSlot);
- DBWriteContactSettingTString(hContact, "AdvStatus", szSetting, pszTitle);
+ db_set_ts(hContact, "AdvStatus", szSetting, pszTitle);
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/text", m_szModuleName, pszSlot);
if (pszText) {
- DBWriteContactSettingTString(hContact, "AdvStatus", szSetting, pszText);
+ db_set_ts(hContact, "AdvStatus", szSetting, pszText);
} else
{
// set empty text before DBDeleteContactSetting to make resident setting manager happy
- DBWriteContactSettingString(hContact, "AdvStatus", szSetting, "");
+ db_set_s(hContact, "AdvStatus", szSetting, "");
DBDeleteContactSetting(hContact, "AdvStatus", szSetting);
}
}
@@ -1512,7 +1512,7 @@ char *CJabberProto::ReadAdvStatusA(HANDLE hContact, const char *pszSlot, const c mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", m_szModuleName, pszSlot, pszValue);
DBVARIANT dbv;
- if ( DBGetContactSettingString(hContact, "AdvStatus", szSetting, &dbv))
+ if (DBGetContactSettingString(hContact, "AdvStatus", szSetting, &dbv))
return NULL;
char *res = mir_strdup(dbv.pszVal);
@@ -1526,7 +1526,7 @@ TCHAR *CJabberProto::ReadAdvStatusT(HANDLE hContact, const char *pszSlot, const mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", m_szModuleName, pszSlot, pszValue);
DBVARIANT dbv;
- if ( DBGetContactSettingTString(hContact, "AdvStatus", szSetting, &dbv))
+ if (DBGetContactSettingTString(hContact, "AdvStatus", szSetting, &dbv))
return NULL;
TCHAR *res = mir_tstrdup(dbv.ptszVal);
@@ -1586,7 +1586,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): m_nextTooltipId = 0;
m_hhkFontsChanged = 0;
- if (!proto->m_options.DisableFrame && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ if ( !proto->m_options.DisableFrame && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
InitClass();
CLISTFrame frame = {0};
@@ -1625,7 +1625,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto): CJabberInfoFrame::~CJabberInfoFrame()
{
- if (!m_hwnd) return;
+ if ( !m_hwnd) return;
if (m_hhkFontsChanged) UnhookEvent(m_hhkFontsChanged);
CallService(MS_CLIST_FRAMES_REMOVEFRAME, (WPARAM)m_frameId, 0);
@@ -1774,14 +1774,14 @@ void CJabberInfoFrame::ReloadFonts() void CJabberInfoFrame::UpdateSize()
{
- if (!m_hwnd || m_bLocked)
+ if ( !m_hwnd || m_bLocked)
return;
int line_count = m_compact ? 1 : (m_pItems.getCount() - m_hiddenItemCount);
int height = 2 * SZ_FRAMEPADDING + line_count * (GetSystemMetrics(SM_CYSMICON) + SZ_LINEPADDING) + (line_count - 1) * SZ_LINESPACING;
if (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, m_frameId), 0) & F_VISIBLE) {
- if (!ServiceExists(MS_SKIN_DRAWGLYPH)) {
+ if ( !ServiceExists(MS_SKIN_DRAWGLYPH)) {
// crazy resizing for clist_nicer...
CallService(MS_CLIST_FRAMES_SHFRAME, m_frameId, 0);
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, m_frameId), height);
@@ -1825,15 +1825,15 @@ void CJabberInfoFrame::SetToolTip(int id, RECT *rc, TCHAR *pszText) void CJabberInfoFrame::PaintSkinGlyph(HDC hdc, RECT *rc, char **glyphs, COLORREF fallback)
{
- if ( ServiceExists(MS_SKIN_DRAWGLYPH)) {
+ if (ServiceExists(MS_SKIN_DRAWGLYPH)) {
SKINDRAWREQUEST rq = {0};
rq.hDC = hdc;
rq.rcDestRect = *rc;
rq.rcClipRect = *rc;
- for ( ; *glyphs; ++glyphs) {
+ for (; *glyphs; ++glyphs) {
strncpy(rq.szObjectID, *glyphs, sizeof(rq.szObjectID));
- if (!CallService(MS_SKIN_DRAWGLYPH, (WPARAM)&rq, 0))
+ if ( !CallService(MS_SKIN_DRAWGLYPH, (WPARAM)&rq, 0))
return;
}
}
@@ -1859,12 +1859,12 @@ void CJabberInfoFrame::PaintCompact(HDC hdc) int cy_icon = GetSystemMetrics(SM_CYSMICON);
int cx = rc.right - cx_icon - SZ_FRAMEPADDING;
- for (int i = m_pItems.getCount(); i--; ) {
+ for (int i = m_pItems.getCount(); i--;) {
CJabberInfoFrameItem &item = m_pItems[i];
SetRect(&item.m_rcItem, 0, 0, 0, 0);
- if (!item.m_bShow) continue;
- if (!item.m_bCompact) continue;
+ if ( !item.m_bShow) continue;
+ if ( !item.m_bCompact) continue;
int depth = 0;
for (char *p = item.m_pszName; p = strchr(p+1, '/'); ++depth) ;
@@ -1917,7 +1917,7 @@ void CJabberInfoFrame::PaintNormal(HDC hdc) for (int i = 0; i < m_pItems.getCount(); ++i) {
CJabberInfoFrameItem &item = m_pItems[i];
- if (!item.m_bShow) {
+ if ( !item.m_bShow) {
SetRect(&item.m_rcItem, 0, 0, 0, 0);
continue;
}
@@ -2000,8 +2000,8 @@ void CJabberInfoFrame::RemoveInfoItem(char *pszName) bool bUpdate = false;
size_t length = strlen(pszName);
for (int i = 0; i < m_pItems.getCount(); ++i)
- if (!strncmp(m_pItems[i].m_pszName, pszName, length)) {
- if (!m_pItems[i].m_bShow) --m_hiddenItemCount;
+ if ( !strncmp(m_pItems[i].m_pszName, pszName, length)) {
+ if ( !m_pItems[i].m_bShow) --m_hiddenItemCount;
RemoveTooltip(m_pItems[i].m_tooltipId);
m_pItems.remove(i);
bUpdate = true;
diff --git a/protocols/JabberG/src/jabber_xstatus.h b/protocols/JabberG/src/jabber_xstatus.h index ae12ebae86..5454f8638a 100644 --- a/protocols/JabberG/src/jabber_xstatus.h +++ b/protocols/JabberG/src/jabber_xstatus.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
@@ -54,7 +54,7 @@ protected: int m_wasPublished;
- virtual void CreateData( HXML ) = 0;
+ virtual void CreateData(HXML) = 0;
void ForceRepublishOnLogin();
};
@@ -68,8 +68,8 @@ public: for (int i = 0; i < getCount(); ++i)
{
CPepService &pepSvc = (*this)[i];
- HXML itemsNode = xmlGetChildByTag( eventNode, _T("items"), _T("node"), pepSvc.GetNode());
- if ( itemsNode )
+ HXML itemsNode = xmlGetChildByTag(eventNode, _T("items"), _T("node"), pepSvc.GetNode());
+ if (itemsNode)
pepSvc.ProcessItems(from, itemsNode);
}
}
@@ -113,7 +113,7 @@ public: CPepService *Find(TCHAR *node)
{
for (int i = 0; i < getCount(); ++i)
- if (!lstrcmp((*this)[i].GetNode(), node))
+ if ( !lstrcmp((*this)[i].GetNode(), node))
return &((*this)[i]);
return NULL;
}
@@ -159,7 +159,7 @@ public: // FIXME: ugly hack int m_mode;
protected:
- void CreateData( HXML );
+ void CreateData(HXML);
void ShowSetDialog(BYTE bQuiet);
void SetExtraIcon(HANDLE hContact, char *szMood);
@@ -181,7 +181,7 @@ protected: TCHAR *m_text;
int m_mode;
- void CreateData( HXML );
+ void CreateData(HXML);
void ShowSetDialog(BYTE bQuiet);
void SetExtraIcon(HANDLE hContact, char *szActivity);
diff --git a/protocols/JabberG/src/jabber_zstream.cpp b/protocols/JabberG/src/jabber_zstream.cpp index 11829bf401..f5417b2470 100644 --- a/protocols/JabberG/src/jabber_zstream.cpp +++ b/protocols/JabberG/src/jabber_zstream.cpp @@ -3,13 +3,13 @@ Jabber Protocol Plugin for Miranda IM
XEP-0138 (Stream Compression) implementation
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Kostya Chukavin, Taras Zackrepa
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Kostya Chukavin, Taras Zackrepa
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
@@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber.h"
-BOOL ThreadData::zlibInit( void )
+BOOL ThreadData::zlibInit(void)
{
- proto->Log( "Zlib init..." );
+ proto->Log("Zlib init...");
zStreamIn.zalloc = Z_NULL;
zStreamIn.zfree = Z_NULL;
zStreamIn.opaque = Z_NULL;
@@ -37,92 +37,92 @@ BOOL ThreadData::zlibInit( void ) zStreamOut.zfree = Z_NULL;
zStreamOut.opaque = Z_NULL;
- if ( deflateInit( &zStreamOut, Z_BEST_COMPRESSION) != Z_OK ) return FALSE;
- if ( inflateInit( &zStreamIn ) != Z_OK ) return FALSE;
+ if (deflateInit(&zStreamOut, Z_BEST_COMPRESSION) != Z_OK) return FALSE;
+ if (inflateInit(&zStreamIn) != Z_OK) return FALSE;
zRecvReady = true;
return TRUE;
}
-void ThreadData::zlibUninit( void )
+void ThreadData::zlibUninit(void)
{
- deflateEnd( &zStreamOut );
- inflateEnd( &zStreamIn );
+ deflateEnd(&zStreamOut);
+ inflateEnd(&zStreamIn);
}
-int ThreadData::zlibSend( char* data, int datalen )
+int ThreadData::zlibSend(char* data, int datalen)
{
char send_data[ ZLIB_CHUNK_SIZE ];
int bytesOut = 0;
zStreamOut.avail_in = datalen;
- zStreamOut.next_in = ( unsigned char* )data;
+ zStreamOut.next_in = (unsigned char*)data;
do {
zStreamOut.avail_out = ZLIB_CHUNK_SIZE;
- zStreamOut.next_out = ( unsigned char* )send_data;
+ zStreamOut.next_out = (unsigned char*)send_data;
- switch ( deflate( &zStreamOut, Z_SYNC_FLUSH )) {
- case Z_OK: proto->Log( "Deflate: Z_OK" ); break;
- case Z_BUF_ERROR: proto->Log( "Deflate: Z_BUF_ERROR" ); break;
- case Z_DATA_ERROR: proto->Log( "Deflate: Z_DATA_ERROR" ); break;
- case Z_MEM_ERROR: proto->Log( "Deflate: Z_MEM_ERROR" ); break;
+ switch (deflate(&zStreamOut, Z_SYNC_FLUSH)) {
+ case Z_OK: proto->Log("Deflate: Z_OK"); break;
+ case Z_BUF_ERROR: proto->Log("Deflate: Z_BUF_ERROR"); break;
+ case Z_DATA_ERROR: proto->Log("Deflate: Z_DATA_ERROR"); break;
+ case Z_MEM_ERROR: proto->Log("Deflate: Z_MEM_ERROR"); break;
}
int len, send_datalen = ZLIB_CHUNK_SIZE - zStreamOut.avail_out;
- if (( len = sendws( send_data, send_datalen, MSG_NODUMP )) == SOCKET_ERROR || len != send_datalen ) {
- proto->Log( "Netlib_Send() failed, error=%d", WSAGetLastError());
+ if ((len = sendws(send_data, send_datalen, MSG_NODUMP)) == SOCKET_ERROR || len != send_datalen) {
+ proto->Log("Netlib_Send() failed, error=%d", WSAGetLastError());
return FALSE;
}
bytesOut += len;
}
- while ( zStreamOut.avail_out == 0 );
+ while (zStreamOut.avail_out == 0);
- if ( DBGetContactSettingByte( NULL, "Netlib", "DumpSent", TRUE ) == TRUE )
- proto->Log( "(ZLIB) Data sent\n%s\n===OUT: %d(%d) bytes", data, datalen, bytesOut );
+ if (db_get_b(NULL, "Netlib", "DumpSent", TRUE) == TRUE)
+ proto->Log("(ZLIB) Data sent\n%s\n===OUT: %d(%d) bytes", data, datalen, bytesOut);
return TRUE;
}
-int ThreadData::zlibRecv( char* data, long datalen )
+int ThreadData::zlibRecv(char* data, long datalen)
{
- if ( zRecvReady ) {
+ if (zRecvReady) {
retry:
- zRecvDatalen = recvws( zRecvData, ZLIB_CHUNK_SIZE, MSG_NODUMP );
- if ( zRecvDatalen == SOCKET_ERROR ) {
- proto->Log( "Netlib_Recv() failed, error=%d", WSAGetLastError());
+ zRecvDatalen = recvws(zRecvData, ZLIB_CHUNK_SIZE, MSG_NODUMP);
+ if (zRecvDatalen == SOCKET_ERROR) {
+ proto->Log("Netlib_Recv() failed, error=%d", WSAGetLastError());
return SOCKET_ERROR;
}
- if ( zRecvDatalen == 0 )
+ if (zRecvDatalen == 0)
return 0;
zStreamIn.avail_in = zRecvDatalen;
- zStreamIn.next_in = ( Bytef* )zRecvData;
+ zStreamIn.next_in = (Bytef*)zRecvData;
}
zStreamIn.avail_out = datalen;
- zStreamIn.next_out = ( BYTE* )data;
+ zStreamIn.next_out = (BYTE*)data;
- switch ( inflate( &zStreamIn, Z_NO_FLUSH )) {
- case Z_OK: proto->Log( "Inflate: Z_OK" ); break;
- case Z_BUF_ERROR: proto->Log( "Inflate: Z_BUF_ERROR" ); break;
- case Z_DATA_ERROR: proto->Log( "Inflate: Z_DATA_ERROR" ); break;
- case Z_MEM_ERROR: proto->Log( "Inflate: Z_MEM_ERROR" ); break;
+ switch (inflate(&zStreamIn, Z_NO_FLUSH)) {
+ case Z_OK: proto->Log("Inflate: Z_OK"); break;
+ case Z_BUF_ERROR: proto->Log("Inflate: Z_BUF_ERROR"); break;
+ case Z_DATA_ERROR: proto->Log("Inflate: Z_DATA_ERROR"); break;
+ case Z_MEM_ERROR: proto->Log("Inflate: Z_MEM_ERROR"); break;
}
int len = datalen - zStreamIn.avail_out;
- if ( DBGetContactSettingByte( NULL, "Netlib", "DumpRecv", TRUE ) == TRUE ) {
- char* szLogBuffer = ( char* )alloca( len+32 );
- memcpy( szLogBuffer, data, len );
+ if (db_get_b(NULL, "Netlib", "DumpRecv", TRUE) == TRUE) {
+ char* szLogBuffer = (char*)alloca(len+32);
+ memcpy(szLogBuffer, data, len);
szLogBuffer[ len ]='\0';
- proto->Log( "(ZLIB) Data received\n%s\n===IN: %d(%d) bytes", szLogBuffer, len, zRecvDatalen );
+ proto->Log("(ZLIB) Data received\n%s\n===IN: %d(%d) bytes", szLogBuffer, len, zRecvDatalen);
}
- if ( len == 0 )
+ if (len == 0)
goto retry;
- zRecvReady = ( zStreamIn.avail_out != 0 );
+ zRecvReady = (zStreamIn.avail_out != 0);
return len;
}
diff --git a/protocols/JabberG/src/ui_utils.cpp b/protocols/JabberG/src/ui_utils.cpp index 10e26a0130..da8a4531f1 100644 --- a/protocols/JabberG/src/ui_utils.cpp +++ b/protocols/JabberG/src/ui_utils.cpp @@ -6,7 +6,7 @@ Copyright (C) 2008 Victor Pavlychko, 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
@@ -75,8 +75,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) m_initialized = false;
TranslateDialogDefault(m_hwnd);
- for ( CCtrlBase* p = m_first; p != NULL; p = p->m_next )
- AddControl( p );
+ for (CCtrlBase* p = m_first; p != NULL; p = p->m_next)
+ AddControl(p);
NotifyControls(&CCtrlBase::OnInit);
OnInitDialog();
@@ -119,7 +119,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) WORD idCode = HIWORD(wParam);
if (CCtrlBase *ctrl = FindControl(idCtrl)) {
BOOL result = ctrl->OnCommand(hwndCtrl, idCtrl, idCode);
- if ( result != FALSE )
+ if (result != FALSE)
return result;
}
@@ -127,7 +127,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) ((idCtrl == IDOK) && (m_autoClose & CLOSE_ON_OK) ||
(idCtrl == IDCANCEL) && (m_autoClose & CLOSE_ON_CANCEL)))
{
- PostMessage( m_hwnd, WM_CLOSE, 0, 0 );
+ PostMessage(m_hwnd, WM_CLOSE, 0, 0);
}
return FALSE;
}
@@ -176,7 +176,7 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) {
m_lresult = FALSE;
OnClose();
- if ( !m_lresult )
+ if ( !m_lresult)
{
if (m_isModal)
EndDialog(m_hwnd, 0);
@@ -220,7 +220,7 @@ INT_PTR CALLBACK CDlgBase::GlobalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA wnd = (CDlgBase *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
}
- if (!wnd) return FALSE;
+ if ( !wnd) return FALSE;
wnd->m_msg.hwnd = hwnd;
wnd->m_msg.message = msg;
@@ -232,7 +232,7 @@ INT_PTR CALLBACK CDlgBase::GlobalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA int CDlgBase::GlobalDlgResizer(HWND hwnd, LPARAM, UTILRESIZECONTROL *urc)
{
CDlgBase *wnd = (CDlgBase *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!wnd) return 0;
+ if ( !wnd) return 0;
return wnd->Resizer(urc);
}
@@ -240,7 +240,7 @@ int CDlgBase::GlobalDlgResizer(HWND hwnd, LPARAM, UTILRESIZECONTROL *urc) CDlgBase::pfnEnableThemeDialogTexture CDlgBase::MyEnableThemeDialogTexture = NULL;
void CDlgBase::ThemeDialogBackground(BOOL tabbed)
{
- if (!MyEnableThemeDialogTexture && IsWinVerXPPlus())
+ if ( !MyEnableThemeDialogTexture && IsWinVerXPPlus())
{
HMODULE hThemeAPI = GetModuleHandleA("uxtheme");
if (hThemeAPI)
@@ -273,15 +273,15 @@ CCtrlBase* CDlgBase::FindControl(int idCtrl) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlCombo class
-CCtrlCombo::CCtrlCombo( CDlgBase* dlg, int ctrlId ) :
- CCtrlData( dlg, ctrlId )
+CCtrlCombo::CCtrlCombo(CDlgBase* dlg, int ctrlId) :
+ CCtrlData(dlg, ctrlId)
{
}
int CCtrlCombo::AddString(const TCHAR *text, LPARAM data)
{
int iItem = SendMessage(m_hwnd, CB_ADDSTRING, 0, (LPARAM)text);
- if ( data )
+ if (data)
SendMessage(m_hwnd, CB_SETITEMDATA, iItem, data);
return iItem;
}
@@ -289,7 +289,7 @@ int CCtrlCombo::AddString(const TCHAR *text, LPARAM data) int CCtrlCombo::AddStringA(const char *text, LPARAM data)
{
int iItem = SendMessageA(m_hwnd, CB_ADDSTRING, 0, (LPARAM)text);
- if ( data )
+ if (data)
SendMessage(m_hwnd, CB_SETITEMDATA, iItem, data);
return iItem;
}
@@ -298,11 +298,11 @@ void CCtrlCombo::DeleteString(int index) { SendMessage(m_hwnd, CB_DELETESTRING, index, 0);
}
-int CCtrlCombo::FindString(const TCHAR *str, int index, bool exact )
+int CCtrlCombo::FindString(const TCHAR *str, int index, bool exact)
{ return SendMessage(m_hwnd, exact?CB_FINDSTRINGEXACT:CB_FINDSTRING, index, (LPARAM)str);
}
-int CCtrlCombo::FindStringA(const char *str, int index, bool exact )
+int CCtrlCombo::FindStringA(const char *str, int index, bool exact)
{ return SendMessageA(m_hwnd, exact?CB_FINDSTRINGEXACT:CB_FINDSTRING, index, (LPARAM)str);
}
@@ -367,8 +367,8 @@ void CCtrlCombo::ShowDropdown(bool show) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlListBox class
-CCtrlListBox::CCtrlListBox( CDlgBase* dlg, int ctrlId ) :
- CCtrlBase( dlg, ctrlId )
+CCtrlListBox::CCtrlListBox(CDlgBase* dlg, int ctrlId) :
+ CCtrlBase(dlg, ctrlId)
{
}
@@ -394,7 +394,7 @@ void CCtrlListBox::DeleteString(int index) { SendMessage(m_hwnd, LB_DELETESTRING, index, 0);
}
-int CCtrlListBox::FindString( TCHAR *str, int index, bool exact)
+int CCtrlListBox::FindString(TCHAR *str, int index, bool exact)
{ return SendMessage(m_hwnd, exact?LB_FINDSTRINGEXACT:LB_FINDSTRING, index, (LPARAM)str);
}
@@ -478,8 +478,8 @@ void CCtrlListBox::SetSel(int index, bool sel) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlCheck class
-CCtrlCheck::CCtrlCheck( CDlgBase* dlg, int ctrlId ) :
- CCtrlData( dlg, ctrlId )
+CCtrlCheck::CCtrlCheck(CDlgBase* dlg, int ctrlId) :
+ CCtrlData(dlg, ctrlId)
{
}
@@ -496,17 +496,17 @@ void CCtrlCheck::SetState(int state) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlEdit class
-CCtrlEdit::CCtrlEdit( CDlgBase* dlg, int ctrlId ) :
- CCtrlData( dlg, ctrlId )
+CCtrlEdit::CCtrlEdit(CDlgBase* dlg, int ctrlId) :
+ CCtrlData(dlg, ctrlId)
{
}
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlData class
-CCtrlData::CCtrlData( CDlgBase *wnd, int idCtrl ) :
- CCtrlBase( wnd, idCtrl ),
- m_dbLink( NULL )
+CCtrlData::CCtrlData(CDlgBase *wnd, int idCtrl) :
+ CCtrlBase(wnd, idCtrl),
+ m_dbLink(NULL)
{
}
@@ -518,55 +518,55 @@ void CCtrlData::OnInit() void CCtrlData::NotifyChange()
{
- if (!m_parentWnd || m_parentWnd->IsInitialized()) m_changed = true;
- if ( m_parentWnd ) {
+ if ( !m_parentWnd || m_parentWnd->IsInitialized()) m_changed = true;
+ if (m_parentWnd) {
m_parentWnd->OnChange(this);
- if ( m_parentWnd->IsInitialized())
- ::SendMessage( ::GetParent( m_parentWnd->GetHwnd()), PSM_CHANGED, 0, 0 );
+ if (m_parentWnd->IsInitialized())
+ ::SendMessage(::GetParent(m_parentWnd->GetHwnd()), PSM_CHANGED, 0, 0);
}
OnChange(this);
}
-void CCtrlData::CreateDbLink( const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue, bool bSigned )
+void CCtrlData::CreateDbLink(const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue, bool bSigned)
{
- m_dbLink = new CDbLink( szModuleName, szSetting, type, iValue, bSigned );
+ m_dbLink = new CDbLink(szModuleName, szSetting, type, iValue, bSigned);
}
-void CCtrlData::CreateDbLink( const char* szModuleName, const char* szSetting, TCHAR* szValue )
+void CCtrlData::CreateDbLink(const char* szModuleName, const char* szSetting, TCHAR* szValue)
{
- m_dbLink = new CDbLink( szModuleName, szSetting, DBVT_TCHAR, szValue );
+ m_dbLink = new CDbLink(szModuleName, szSetting, DBVT_TCHAR, szValue);
}
/////////////////////////////////////////////////////////////////////////////////////////
// CCtrlMButton
-CCtrlMButton::CCtrlMButton( CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip ) :
- CCtrlButton( dlg, ctrlId ),
- m_hIcon( hIcon ),
- m_toolTip( tooltip )
+CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip) :
+ CCtrlButton(dlg, ctrlId),
+ m_hIcon(hIcon),
+ m_toolTip(tooltip)
{
}
-CCtrlMButton::CCtrlMButton( CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip ) :
- CCtrlButton( dlg, ctrlId ),
- m_hIcon( LoadSkinnedIcon(iCoreIcon)),
- m_toolTip( tooltip )
+CCtrlMButton::CCtrlMButton(CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip) :
+ CCtrlButton(dlg, ctrlId),
+ m_hIcon(LoadSkinnedIcon(iCoreIcon)),
+ m_toolTip(tooltip)
{
}
CCtrlMButton::~CCtrlMButton()
{
- g_ReleaseIcon( m_hIcon );
+ g_ReleaseIcon(m_hIcon);
}
void CCtrlMButton::OnInit()
{
CCtrlButton::OnInit();
- SendMessage( m_hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hIcon );
- SendMessage( m_hwnd, BUTTONADDTOOLTIP, (WPARAM)m_toolTip, 0);
- SendMessage( m_hwnd, BUTTONSETASFLATBTN, (WPARAM)m_toolTip, 0);
+ SendMessage(m_hwnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hIcon);
+ SendMessage(m_hwnd, BUTTONADDTOOLTIP, (WPARAM)m_toolTip, 0);
+ SendMessage(m_hwnd, BUTTONSETASFLATBTN, (WPARAM)m_toolTip, 0);
}
void CCtrlMButton::MakeFlat()
@@ -582,14 +582,14 @@ void CCtrlMButton::MakePush() /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlButton
-CCtrlButton::CCtrlButton( CDlgBase* wnd, int idCtrl ) :
- CCtrlBase( wnd, idCtrl )
+CCtrlButton::CCtrlButton(CDlgBase* wnd, int idCtrl) :
+ CCtrlBase(wnd, idCtrl)
{
}
BOOL CCtrlButton::OnCommand(HWND, WORD, WORD idCode)
{
- if ( idCode == BN_CLICKED || idCode == STN_CLICKED )
+ if (idCode == BN_CLICKED || idCode == STN_CLICKED)
OnClick(this);
return FALSE;
}
@@ -597,8 +597,8 @@ BOOL CCtrlButton::OnCommand(HWND, WORD, WORD idCode) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlHyperlink
-CCtrlHyperlink::CCtrlHyperlink( CDlgBase* wnd, int idCtrl, const char* url ) :
- CCtrlBase( wnd, idCtrl ),
+CCtrlHyperlink::CCtrlHyperlink(CDlgBase* wnd, int idCtrl, const char* url) :
+ CCtrlBase(wnd, idCtrl),
m_url(url)
{
}
@@ -611,7 +611,7 @@ BOOL CCtrlHyperlink::OnCommand(HWND, WORD, WORD) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlClc
-CCtrlClc::CCtrlClc( CDlgBase* dlg, int ctrlId ):
+CCtrlClc::CCtrlClc(CDlgBase* dlg, int ctrlId):
CCtrlBase(dlg, ctrlId)
{
}
@@ -824,7 +824,7 @@ void CCtrlClc::SetTextColor(int iFontId, COLORREF clText) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlListView
-CCtrlListView::CCtrlListView( CDlgBase* dlg, int ctrlId ) :
+CCtrlListView::CCtrlListView(CDlgBase* dlg, int ctrlId) :
CCtrlBase(dlg, ctrlId)
{
}
@@ -1403,7 +1403,7 @@ void CCtrlFilterListView::OnInit() static LRESULT CALLBACK sttEditBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
CFilterData *fdat = (CFilterData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!fdat) return DefWindowProc(hwnd, msg, wParam, lParam);
+ if ( !fdat) return DefWindowProc(hwnd, msg, wParam, lParam);
switch (msg)
{
@@ -1472,7 +1472,7 @@ void CCtrlFilterListView::FilterHighlight(TCHAR *str) for (int j = 0; j < 10; ++j)
{
GetItemText(i, j, buf, SIZEOF(buf));
- if (!*buf)
+ if ( !*buf)
break;
if (_tcsstr(buf, str))
@@ -1498,7 +1498,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara case 0:
{
OnFilterChanged(this);
- if (!m_keepHiglight) FilterHighlight(NULL);
+ if ( !m_keepHiglight) FilterHighlight(NULL);
break;
}
@@ -1684,9 +1684,9 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara pt.y = HIWORD(lParam);
MapWindowPoints(NULL, m_hwnd, &pt, 1);
- if(PtInRect(&fdat->m_rcButtonClear, pt))
+ if (PtInRect(&fdat->m_rcButtonClear, pt))
return HTBORDER;
- if(PtInRect(&fdat->m_rcEditBox, pt))
+ if (PtInRect(&fdat->m_rcEditBox, pt))
return HTBORDER;
break;
@@ -1699,7 +1699,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara pt.y = HIWORD(lParam);
MapWindowPoints(NULL, m_hwnd, &pt, 1);
- if(PtInRect(&fdat->m_rcButtonClear, pt))
+ if (PtInRect(&fdat->m_rcButtonClear, pt))
{
SetFocus(m_hwnd);
if (fdat->m_filterText) mir_free(fdat->m_filterText);
@@ -1708,7 +1708,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara OnFilterChanged(this);
FilterHighlight(NULL);
} else
- if(PtInRect(&fdat->m_rcEditBox, pt))
+ if (PtInRect(&fdat->m_rcEditBox, pt))
{
PostMessage(m_hwnd, WM_APP, 2, 0);
}
@@ -1729,7 +1729,7 @@ LRESULT CCtrlFilterListView::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lPara /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlTreeView
-CCtrlTreeView::CCtrlTreeView( CDlgBase* dlg, int ctrlId ):
+CCtrlTreeView::CCtrlTreeView(CDlgBase* dlg, int ctrlId):
CCtrlBase(dlg, ctrlId)
{
}
@@ -1786,7 +1786,7 @@ void CCtrlTreeView::TranslateTree() {
while (1)
{
- if (!(hItem = GetParent(hItem))) break;
+ if ( !(hItem = GetParent(hItem))) break;
if (hItemTmp = GetNextSibling(hItem))
{
hItem = hItemTmp;
@@ -1807,7 +1807,7 @@ HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name) else
tvi.hItem = GetRoot();
- if (!name)
+ if ( !name)
return tvi.hItem;
tvi.mask = TVIF_TEXT;
@@ -1818,7 +1818,7 @@ HTREEITEM CCtrlTreeView::FindNamedItem(HTREEITEM hItem, const TCHAR *name) {
GetItem(&tvi);
- if (!lstrcmp(tvi.pszText, name))
+ if ( !lstrcmp(tvi.pszText, name))
return tvi.hItem;
tvi.hItem = GetNextSibling(tvi.hItem);
@@ -2089,7 +2089,7 @@ void CCtrlTreeView::SortChildrenCB(TVSORTCB *cb, BOOL fRecurse) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlPages
-CCtrlPages::CCtrlPages( CDlgBase* dlg, int ctrlId ):
+CCtrlPages::CCtrlPages(CDlgBase* dlg, int ctrlId):
CCtrlBase(dlg, ctrlId), m_hIml(NULL), m_pActivePage(NULL)
{
}
@@ -2110,7 +2110,7 @@ LRESULT CCtrlPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) return CSuper::CustomWndProc(msg, wParam, lParam);
}
-void CCtrlPages::AddPage( TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate, void *param )
+void CCtrlPages::AddPage(TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate, void *param)
{
TPageInfo *info = new TPageInfo;
info->m_onCreate = onCreate;
@@ -2123,7 +2123,7 @@ void CCtrlPages::AddPage( TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate tci.pszText = ptszName;
if (hIcon)
{
- if (!m_hIml)
+ if ( !m_hIml)
{
m_hIml = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32|ILC_MASK : ILC_COLOR16|ILC_MASK, 0, 1);
TabCtrl_SetImageList(m_hwnd, m_hIml);
@@ -2136,7 +2136,7 @@ void CCtrlPages::AddPage( TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate TabCtrl_InsertItem(m_hwnd, TabCtrl_GetItemCount(m_hwnd), &tci);
}
-void CCtrlPages::AttachDialog( int iPage, CDlgBase *pDlg )
+void CCtrlPages::AttachDialog(int iPage, CDlgBase *pDlg)
{
if ((iPage < 0) || (iPage >= TabCtrl_GetItemCount(m_hwnd)))
return;
@@ -2163,7 +2163,7 @@ void CCtrlPages::AttachDialog( int iPage, CDlgBase *pDlg ) void CCtrlPages::ShowPage(CDlgBase *pDlg)
{
- if (!pDlg) return;
+ if ( !pDlg) return;
RECT rc;
GetClientRect(m_hwnd, &rc);
@@ -2172,13 +2172,13 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg) SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_SHOWWINDOW);
}
-void CCtrlPages::ActivatePage( int iPage )
+void CCtrlPages::ActivatePage(int iPage)
{
TabCtrl_SetCurSel(m_hwnd, iPage);
//ShowPage(iPage);
}
-BOOL CCtrlPages::OnNotify( int /*idCtrl*/, NMHDR *pnmh )
+BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
{
switch (pnmh->code)
{
@@ -2257,12 +2257,12 @@ void CCtrlPages::OnDestroy() // CCtrlBase
CCtrlBase::CCtrlBase(CDlgBase *wnd, int idCtrl) :
- m_parentWnd( wnd ),
- m_idCtrl( idCtrl ),
- m_hwnd( NULL ),
- m_wndproc( NULL )
+ m_parentWnd(wnd),
+ m_idCtrl(idCtrl),
+ m_hwnd(NULL),
+ m_wndproc(NULL)
{
- if ( wnd ) {
+ if (wnd) {
m_next = wnd->m_first;
wnd->m_first = this;
} }
@@ -2278,29 +2278,29 @@ void CCtrlBase::OnDestroy() m_hwnd = NULL;
}
-void CCtrlBase::Enable( int bIsEnable )
+void CCtrlBase::Enable(int bIsEnable)
{
- ::EnableWindow( m_hwnd, bIsEnable );
+ ::EnableWindow(m_hwnd, bIsEnable);
}
BOOL CCtrlBase::Enabled() const
{
- return ( m_hwnd ) ? IsWindowEnabled( m_hwnd ) : FALSE;
+ return (m_hwnd) ? IsWindowEnabled(m_hwnd) : FALSE;
}
-LRESULT CCtrlBase::SendMsg( UINT Msg, WPARAM wParam, LPARAM lParam )
+LRESULT CCtrlBase::SendMsg(UINT Msg, WPARAM wParam, LPARAM lParam)
{
- return ::SendMessage( m_hwnd, Msg, wParam, lParam );
+ return ::SendMessage(m_hwnd, Msg, wParam, lParam);
}
void CCtrlBase::SetText(const TCHAR *text)
{
- ::SetWindowText( m_hwnd, text );
+ ::SetWindowText(m_hwnd, text);
}
void CCtrlBase::SetTextA(const char *text)
{
- ::SetWindowTextA( m_hwnd, text );
+ ::SetWindowTextA(m_hwnd, text);
}
void CCtrlBase::SetInt(int value)
@@ -2401,9 +2401,9 @@ CDbLink::~CDbLink() DWORD CDbLink::LoadUnsigned()
{
switch (m_type) {
- case DBVT_BYTE: return DBGetContactSettingByte(NULL, m_szModule, m_szSetting, m_iDefault);
- case DBVT_WORD: return DBGetContactSettingWord(NULL, m_szModule, m_szSetting, m_iDefault);
- case DBVT_DWORD: return DBGetContactSettingDword(NULL, m_szModule, m_szSetting, m_iDefault);
+ case DBVT_BYTE: return db_get_b(NULL, m_szModule, m_szSetting, m_iDefault);
+ case DBVT_WORD: return db_get_w(NULL, m_szModule, m_szSetting, m_iDefault);
+ case DBVT_DWORD: return db_get_dw(NULL, m_szModule, m_szSetting, m_iDefault);
default: return m_iDefault;
}
}
@@ -2411,9 +2411,9 @@ DWORD CDbLink::LoadUnsigned() int CDbLink::LoadSigned()
{
switch (m_type) {
- case DBVT_BYTE: return (signed char)DBGetContactSettingByte(NULL, m_szModule, m_szSetting, m_iDefault);
- case DBVT_WORD: return (signed short)DBGetContactSettingWord(NULL, m_szModule, m_szSetting, m_iDefault);
- case DBVT_DWORD: return (signed int)DBGetContactSettingDword(NULL, m_szModule, m_szSetting, m_iDefault);
+ case DBVT_BYTE: return (signed char)db_get_b(NULL, m_szModule, m_szSetting, m_iDefault);
+ case DBVT_WORD: return (signed short)db_get_w(NULL, m_szModule, m_szSetting, m_iDefault);
+ case DBVT_DWORD: return (signed int)db_get_dw(NULL, m_szModule, m_szSetting, m_iDefault);
default: return m_iDefault;
}
}
@@ -2421,16 +2421,16 @@ int CDbLink::LoadSigned() void CDbLink::SaveInt(DWORD value)
{
switch (m_type) {
- case DBVT_BYTE: DBWriteContactSettingByte(NULL, m_szModule, m_szSetting, (BYTE)value); break;
- case DBVT_WORD: DBWriteContactSettingWord(NULL, m_szModule, m_szSetting, (WORD)value); break;
- case DBVT_DWORD: DBWriteContactSettingDword(NULL, m_szModule, m_szSetting, value); break;
+ case DBVT_BYTE: db_set_b(NULL, m_szModule, m_szSetting, (BYTE)value); break;
+ case DBVT_WORD: db_set_w(NULL, m_szModule, m_szSetting, (WORD)value); break;
+ case DBVT_DWORD: db_set_dw(NULL, m_szModule, m_szSetting, value); break;
}
}
TCHAR* CDbLink::LoadText()
{
if (dbv.type != DBVT_DELETED) DBFreeVariant(&dbv);
- if (!DBGetContactSettingTString(NULL, m_szModule, m_szSetting, &dbv))
+ if ( !DBGetContactSettingTString(NULL, m_szModule, m_szSetting, &dbv))
{
if (dbv.type == DBVT_TCHAR)
return dbv.ptszVal;
@@ -2443,7 +2443,7 @@ TCHAR* CDbLink::LoadText() void CDbLink::SaveText(TCHAR *value)
{
- DBWriteContactSettingTString(NULL, m_szModule, m_szSetting, value);
+ db_set_ts(NULL, m_szModule, m_szSetting, value);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -2477,7 +2477,7 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) {
TCHAR *szTitle = (TCHAR *)lParam;
- if (!_tcsstr(szTitle, m_proto_interface->m_tszUserName))
+ if ( !_tcsstr(szTitle, m_proto_interface->m_tszUserName))
{
UpdateProtoTitle(szTitle);
return TRUE;
@@ -2514,7 +2514,7 @@ INT_PTR CProtoIntDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) void CProtoIntDlgBase::UpdateProtoTitle(TCHAR *szText)
{
- if (!m_show_label) return;
+ if ( !m_show_label) return;
int curLength;
TCHAR *curText;
@@ -2530,7 +2530,7 @@ void CProtoIntDlgBase::UpdateProtoTitle(TCHAR *szText) GetWindowText(m_hwnd, curText, curLength);
}
- if (!_tcsstr(curText, m_proto_interface->m_tszUserName))
+ if ( !_tcsstr(curText, m_proto_interface->m_tszUserName))
{
int length = curLength + lstrlen(m_proto_interface->m_tszUserName) + 256;
TCHAR *text = (TCHAR *)_alloca(length * sizeof(TCHAR));
diff --git a/protocols/JabberG/src/ui_utils.h b/protocols/JabberG/src/ui_utils.h index 05a7090710..a5aa1674f8 100644 --- a/protocols/JabberG/src/ui_utils.h +++ b/protocols/JabberG/src/ui_utils.h @@ -1,15 +1,15 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007-09 Maxim Mluhov
-Copyright ( C ) 2007-09 Victor Pavlychko
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007-09 Maxim Mluhov
+Copyright (C) 2007-09 Victor Pavlychko
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
@@ -141,12 +141,12 @@ public: protected:
template<typename TClass, typename TArgument>
- __inline CCallbackImp(TClass *object, void ( TClass::*func)(TArgument *argument)): m_object(( CDummy* )object), m_func((TFnCallback)func) {}
+ __inline CCallbackImp(TClass *object, void (TClass::*func)(TArgument *argument)): m_object((CDummy*)object), m_func((TFnCallback)func) {}
__inline void Invoke(void *argument) const { if (m_func && m_object) (m_object->*m_func)(argument); }
private:
- typedef void ( CDummy::*TFnCallback)( void *argument );
+ typedef void (CDummy::*TFnCallback)(void *argument);
CDummy* m_object;
TFnCallback m_func;
@@ -161,11 +161,11 @@ public: __inline CCallback() {}
template<typename TClass>
- __inline CCallback(TClass *object, void ( TClass::*func)(TArgument *argument)): CCallbackImp(object, func) {}
+ __inline CCallback(TClass *object, void (TClass::*func)(TArgument *argument)): CCallbackImp(object, func) {}
- __inline CCallback& operator=( const CCallbackImp& x ) { CSuper::operator =( x ); return *this; }
+ __inline CCallback& operator=(const CCallbackImp& x) { CSuper::operator =(x); return *this; }
- __inline void operator()(TArgument *argument) const { Invoke((void *)argument); }
+ __inline void operator()(TArgument *argument) const { Invoke((void*)argument); }
};
template<typename TClass, typename TArgument>
@@ -336,17 +336,17 @@ class CCtrlBase friend class CDlgBase;
public:
- CCtrlBase(CDlgBase *wnd, int idCtrl );
+ CCtrlBase(CDlgBase *wnd, int idCtrl);
virtual ~CCtrlBase() { Unsubclass(); }
__inline HWND GetHwnd() const { return m_hwnd; }
__inline CDlgBase *GetParent() { return m_parentWnd; }
- void Enable( int bIsEnable = true );
- __inline void Disable() { Enable( false ); }
- BOOL Enabled( void ) const;
+ void Enable(int bIsEnable = true);
+ __inline void Disable() { Enable(false); }
+ BOOL Enabled(void) const;
- LRESULT SendMsg( UINT Msg, WPARAM wParam, LPARAM lParam );
+ LRESULT SendMsg(UINT Msg, WPARAM wParam, LPARAM lParam);
void SetText(const TCHAR *text);
void SetTextA(const char *text);
@@ -410,7 +410,7 @@ class CCtrlButton : public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlButton( CDlgBase* dlg, int ctrlId );
+ CCtrlButton(CDlgBase* dlg, int ctrlId);
virtual BOOL OnCommand(HWND hwndCtrl, WORD idCtrl, WORD idCode);
@@ -422,8 +422,8 @@ class CCtrlMButton : public CCtrlButton typedef CCtrlButton CSuper;
public:
- CCtrlMButton( CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip );
- CCtrlMButton( CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip );
+ CCtrlMButton(CDlgBase* dlg, int ctrlId, HICON hIcon, const char* tooltip);
+ CCtrlMButton(CDlgBase* dlg, int ctrlId, int iCoreIcon, const char* tooltip);
~CCtrlMButton();
void MakeFlat();
@@ -442,7 +442,7 @@ class CCtrlHyperlink : public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlHyperlink( CDlgBase* dlg, int ctrlId, const char* url );
+ CCtrlHyperlink(CDlgBase* dlg, int ctrlId, const char* url);
virtual BOOL OnCommand(HWND hwndCtrl, WORD idCtrl, WORD idCode);
@@ -457,7 +457,7 @@ class CCtrlClc: public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlClc( CDlgBase* dlg, int ctrlId );
+ CCtrlClc(CDlgBase* dlg, int ctrlId);
void AddContact(HANDLE hContact);
void AddGroup(HANDLE hGroup);
@@ -537,7 +537,7 @@ class CCtrlData : public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlData( CDlgBase* dlg, int ctrlId );
+ CCtrlData(CDlgBase* dlg, int ctrlId);
virtual ~CCtrlData()
{
@@ -546,9 +546,9 @@ public: __inline bool IsChanged() const { return m_changed; }
- void CreateDbLink( const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue, bool bSigned = false );
- void CreateDbLink( const char* szModuleName, const char* szSetting, TCHAR* szValue );
- void CreateDbLink( CDataLink *link ) { m_dbLink = link; }
+ void CreateDbLink(const char* szModuleName, const char* szSetting, BYTE type, DWORD iValue, bool bSigned = false);
+ void CreateDbLink(const char* szModuleName, const char* szSetting, TCHAR* szValue);
+ void CreateDbLink(CDataLink *link) { m_dbLink = link; }
virtual void OnInit();
@@ -578,7 +578,7 @@ class CCtrlCheck : public CCtrlData typedef CCtrlData CSuper;
public:
- CCtrlCheck( CDlgBase* dlg, int ctrlId );
+ CCtrlCheck(CDlgBase* dlg, int ctrlId);
virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD /*idCode*/) { NotifyChange(); return TRUE; }
virtual void OnInit()
{
@@ -606,7 +606,7 @@ class CCtrlEdit : public CCtrlData typedef CCtrlData CSuper;
public:
- CCtrlEdit( CDlgBase* dlg, int ctrlId );
+ CCtrlEdit(CDlgBase* dlg, int ctrlId);
virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode)
{
if (idCode == EN_CHANGE)
@@ -649,7 +649,7 @@ class CCtrlListBox : public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlListBox( CDlgBase* dlg, int ctrlId );
+ CCtrlListBox(CDlgBase* dlg, int ctrlId);
int AddString(TCHAR *text, LPARAM data=0);
void DeleteString(int index);
@@ -687,7 +687,7 @@ class CCtrlCombo : public CCtrlData typedef CCtrlData CSuper;
public:
- CCtrlCombo( CDlgBase* dlg, int ctrlId );
+ CCtrlCombo(CDlgBase* dlg, int ctrlId);
virtual BOOL OnCommand(HWND /*hwndCtrl*/, WORD /*idCtrl*/, WORD idCode)
{
@@ -734,8 +734,8 @@ public: }
// Control interface
- int AddString(const TCHAR *text, LPARAM data = 0 );
- int AddStringA(const char *text, LPARAM data = 0 );
+ int AddString(const TCHAR *text, LPARAM data = 0);
+ int AddStringA(const char *text, LPARAM data = 0);
void DeleteString(int index);
int FindString(const TCHAR *str, int index = -1, bool exact = false);
int FindStringA(const char *str, int index = -1, bool exact = false);
@@ -765,7 +765,7 @@ class CCtrlListView : public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlListView( CDlgBase* dlg, int ctrlId );
+ CCtrlListView(CDlgBase* dlg, int ctrlId);
// Classic LV interface
DWORD ApproximateViewRect(int cx, int cy, int iCount);
@@ -985,7 +985,7 @@ class CCtrlTreeView : public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlTreeView( CDlgBase* dlg, int ctrlId );
+ CCtrlTreeView(CDlgBase* dlg, int ctrlId);
// Classic TV interface
HIMAGELIST CreateDragImage(HTREEITEM hItem);
@@ -1095,12 +1095,12 @@ class CCtrlPages: public CCtrlBase typedef CCtrlBase CSuper;
public:
- CCtrlPages( CDlgBase* dlg, int ctrlId );
+ CCtrlPages(CDlgBase* dlg, int ctrlId);
- void AddPage( TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate = CCallback<void>(), void *param = NULL );
- void AttachDialog( int iPage, CDlgBase *pDlg );
+ void AddPage(TCHAR *ptszName, HICON hIcon, CCallback<void> onCreate = CCallback<void>(), void *param = NULL);
+ void AttachDialog(int iPage, CDlgBase *pDlg);
- void ActivatePage( int iPage );
+ void ActivatePage(int iPage);
protected:
@@ -1218,24 +1218,24 @@ class CProtoIntDlgBase : public CDlgBase public:
__inline CProtoIntDlgBase(PROTO_INTERFACE *proto, int idDialog, HWND parent, bool show_label=true) :
- CDlgBase( idDialog, parent ),
- m_proto_interface( proto ),
- m_show_label( show_label ),
- m_hwndStatus( NULL )
+ CDlgBase(idDialog, parent),
+ m_proto_interface(proto),
+ m_show_label(show_label),
+ m_hwndStatus(NULL)
{
}
- __inline void CreateLink( CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue, bool bSigned = false )
+ __inline void CreateLink(CCtrlData& ctrl, char *szSetting, BYTE type, DWORD iValue, bool bSigned = false)
{
- ctrl.CreateDbLink(m_proto_interface->m_szModuleName, szSetting, type, iValue, bSigned );
+ ctrl.CreateDbLink(m_proto_interface->m_szModuleName, szSetting, type, iValue, bSigned);
}
- __inline void CreateLink( CCtrlData& ctrl, const char *szSetting, TCHAR *szValue )
+ __inline void CreateLink(CCtrlData& ctrl, const char *szSetting, TCHAR *szValue)
{
ctrl.CreateDbLink(m_proto_interface->m_szModuleName, szSetting, szValue);
}
template<class T>
- __inline void CreateLink( CCtrlData& ctrl, CMOption<T> &option )
+ __inline void CreateLink(CCtrlData& ctrl, CMOption<T> &option)
{
ctrl.CreateDbLink(new CMOptionLink<T>(option));
}
@@ -1266,9 +1266,9 @@ class CProtoDlgBase : public CProtoIntDlgBase typedef CProtoIntDlgBase CSuper;
public:
- __inline CProtoDlgBase<TProto>(TProto *proto, int idDialog, HWND parent, bool show_label=true ) :
- CProtoIntDlgBase( proto, idDialog, parent, show_label ),
- m_proto( proto )
+ __inline CProtoDlgBase<TProto>(TProto *proto, int idDialog, HWND parent, bool show_label=true) :
+ CProtoIntDlgBase(proto, idDialog, parent, show_label),
+ m_proto(proto)
{
}
@@ -1321,7 +1321,7 @@ protected: #define UI_SAFE_CLOSE(dlg) \
{ \
- if ( dlg ) { \
+ if (dlg) { \
(dlg)->Close(); \
(dlg) = NULL; \
} \
@@ -1329,8 +1329,8 @@ protected: #define UI_SAFE_CLOSE_HWND(hwnd) \
{ \
- if ( hwnd ) { \
- ::SendMessage( (hwnd), WM_CLOSE, 0, 0 ); \
+ if (hwnd) { \
+ ::SendMessage((hwnd), WM_CLOSE, 0, 0); \
(hwnd) = NULL; \
} \
}
@@ -1339,13 +1339,13 @@ protected: // NULL-Safe dialog notifications
#define UI_SAFE_NOTIFY(dlg, msg) \
{ \
- if ( dlg ) \
+ if (dlg) \
::SendMessage((dlg)->GetHwnd(), msg, 0, 0); \
}
#define UI_SAFE_NOTIFY_HWND(hwnd, msg) \
{ \
- if ( hwnd ) \
+ if (hwnd) \
::SendMessage((hwnd), msg, 0, 0); \
}
|