diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-02 16:46:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-02 16:46:22 +0000 |
commit | 0e130d1a06db358ed90d0ad30d633c4fad839d6e (patch) | |
tree | 0b7052aafb152385823b5ec7d876e58e6e1f2708 /protocols/JabberG/src/jabber_iq_handlers.cpp | |
parent | 6069deebf16c166dec9432853ce32dfaa6cc4f98 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_iq_handlers.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_iq_handlers.cpp | 135 |
1 files changed, 51 insertions, 84 deletions
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index d0acf58696..36e6ee9381 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -121,37 +121,25 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD); // slightly modified sample from MSDN
BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE)
{
- OSVERSIONINFOEX osvi;
- SYSTEM_INFO si;
- PGPI pGPI;
-
- DWORD dwType;
-
- ZeroMemory(&si, sizeof(SYSTEM_INFO));
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
-
+ OSVERSIONINFOEX osvi = { 0 };
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
-
BOOL bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi);
- if ( !bOsVersionInfoEx)
- {
+ if ( !bOsVersionInfoEx) {
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if ( !GetVersionEx((OSVERSIONINFO*)&osvi))
return FALSE;
}
+ SYSTEM_INFO si = { 0 };
GetNativeSystemInfo(&si);
// Some code from Crash Dumper Plugin :-)
- if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4)
- {
+ if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4) {
StringCchCopy(pszOS, BUFSIZE, TEXT("Microsoft "));
// Test for the specific product.
- if (osvi.dwMajorVersion == 6)
- {
- switch (osvi.dwMinorVersion)
- {
+ if (osvi.dwMajorVersion == 6) {
+ switch (osvi.dwMinorVersion) {
case 0:
if (osvi.wProductType == VER_NT_WORKSTATION)
StringCchCat(pszOS, BUFSIZE, TEXT("Windows Vista "));
@@ -174,13 +162,13 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) break;
}
+ DWORD dwType = 0;
HMODULE hKernel = GetModuleHandle(TEXT("kernel32.dll"));
- pGPI = (PGPI) GetProcAddress(hKernel, "GetProductInfo");
+ PGPI pGPI = (PGPI) GetProcAddress(hKernel, "GetProductInfo");
if (pGPI != NULL)
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
- switch(dwType)
- {
+ switch(dwType) {
case PRODUCT_ULTIMATE:
StringCchCat(pszOS, BUFSIZE, TEXT("Ultimate Edition"));
break;
@@ -239,49 +227,40 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) StringCchCat(pszOS, BUFSIZE, TEXT("Web Server Edition"));
break;
}
- if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
+ if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
StringCchCat(pszOS, BUFSIZE, TEXT(", 64-bit"));
- else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL)
+ 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 &&
- si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
- {
+ else if (osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
StringCchCat(pszOS, BUFSIZE, TEXT("Windows XP Professional x64 Edition"));
- }
- else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003, "));
+ else
+ StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003, "));
// Test for the server type.
- if (osvi.wProductType != VER_NT_WORKSTATION)
- {
- if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64)
- {
+ if (osvi.wProductType != VER_NT_WORKSTATION) {
+ 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"));
}
-
- 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"));
}
-
- else
- {
+ else {
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
StringCchCat(pszOS, BUFSIZE, TEXT("Compute Cluster Edition"));
else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
@@ -295,24 +274,19 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) }
}
- 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.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
- {
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) {
StringCchCat(pszOS, BUFSIZE, TEXT("Windows 2000 "));
if (osvi.wProductType == VER_NT_WORKSTATION)
- {
StringCchCat(pszOS, BUFSIZE, TEXT("Professional"));
- }
- else
- {
+ else {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Server"));
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
@@ -323,27 +297,22 @@ BOOL GetOSDisplayString(LPTSTR pszOS, int BUFSIZE) // 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);
}
TCHAR buf[80];
-
mir_sntprintf(buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
StringCchCat(pszOS, BUFSIZE, buf);
-
return TRUE;
}
- else
- {
- return FALSE;
- }
+
+ return FALSE;
}
-BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo* pInfo)
+BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo *pInfo)
{
if ( !pInfo->GetFrom())
return TRUE;
@@ -356,8 +325,7 @@ BOOL CJabberProto::OnIqRequestVersion(HXML, CJabberIqInfo* pInfo) 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)))
lstrcpyn(os, _T("Microsoft Windows"), SIZEOF(os));
@@ -610,7 +578,8 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo) }
}
mir_free(nick);
- } }
+ }
+ }
if ((item=ListGetItemPtr(LIST_ROSTER, jid)) != NULL) {
if ( !_tcscmp(str, _T("both"))) item->subscription = SUB_BOTH;
@@ -625,12 +594,14 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo) if ((hContact=HContactFromJID(jid)) != NULL) {
SetContactOfflineStatus(hContact);
ListRemove(LIST_ROSTER, jid);
- } }
+ }
+ }
else if ( isChatRoom(hContact))
db_unset(hContact, "CList", "Hidden");
else
UpdateSubscriptionInfo(hContact, item);
- } }
+ }
+ }
UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH);
RebuildInfoFrame();
@@ -654,10 +625,6 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) return TRUE;
}
- TCHAR text[ 1024 ];
- TCHAR *str, *p, *q;
-
- 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());
@@ -668,9 +635,11 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) ft->httpPath = NULL;
// Parse the URL
+ TCHAR *str = (TCHAR*)xmlGetText(n); // URL of the file to get
if ( !_tcsnicmp(str, _T("http://"), 7)) {
- p = str + 7;
+ TCHAR *p = str + 7, *q;
if ((q = _tcschr(p, '/')) != NULL) {
+ TCHAR text[1024];
if (q-p < SIZEOF(text)) {
_tcsncpy(text, p, q-p);
text[q-p] = '\0';
@@ -679,7 +648,9 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) *p = '\0';
}
ft->httpHostName = mir_t2a(text);
- } } }
+ }
+ }
+ }
if (pInfo->GetIdStr())
ft->iqId = mir_tstrdup(pInfo->GetIdStr());
@@ -720,7 +691,7 @@ BOOL CJabberProto::OnIqRequestOOB(HXML, CJabberIqInfo *pInfo) return TRUE;
}
-BOOL CJabberProto::OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo* pInfo)
+BOOL CJabberProto::OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo *pInfo)
{
if ( !pInfo->GetChildNode())
return TRUE;
@@ -742,7 +713,7 @@ BOOL CJabberProto::OnHandleDiscoInfoRequest(HXML iqNode, CJabberIqInfo* pInfo) return TRUE;
}
-BOOL CJabberProto::OnHandleDiscoItemsRequest(HXML iqNode, CJabberIqInfo* pInfo)
+BOOL CJabberProto::OnHandleDiscoItemsRequest(HXML iqNode, CJabberIqInfo *pInfo)
{
if ( !pInfo->GetChildNode())
return TRUE;
@@ -783,7 +754,7 @@ 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)
return TRUE;
@@ -798,21 +769,17 @@ BOOL CJabberProto::OnIqHttpAuth(HXML node, CJabberIqInfo* pInfo) 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)
return TRUE;
- CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams *)mir_alloc(sizeof(CJabberHttpAuthParams));
- if ( !pParams)
- return TRUE;
- 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);
-
- AddClistHttpAuthEvent(pParams);
-
+ CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams*)mir_calloc(sizeof(CJabberHttpAuthParams));
+ if (pParams) {
+ 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);
+ AddClistHttpAuthEvent(pParams);
+ }
return TRUE;
}
|