summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-08-14 14:55:43 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-08-14 14:55:43 +0000
commit88fdd523bdf7cd891dbbac4b1ae7fb2ff597cea3 (patch)
tree9401068579f21f8336e56189de0e3065c2789ff6
parentf4a0cae037bc54f6e14aee7366ee9c635ac7df81 (diff)
MS_SYSTEM_GETFILEVERSION added
git-svn-id: http://svn.miranda-ng.org/main/trunk@1454 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_system.h7
-rw-r--r--protocols/JabberG/jabber.cpp7
-rw-r--r--protocols/JabberG/jabber.h2
-rw-r--r--protocols/JabberG/jabber_caps.cpp7
-rw-r--r--protocols/JabberG/jabber_iq_handlers.cpp2
-rw-r--r--protocols/JabberG/jabber_util.cpp2
-rw-r--r--src/core/miranda.cpp38
7 files changed, 46 insertions, 19 deletions
diff --git a/include/m_system.h b/include/m_system.h
index 847aecc5f0..e179b58a8a 100644
--- a/include/m_system.h
+++ b/include/m_system.h
@@ -88,6 +88,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//version 1.2.3.10 is 0x0102030a
#define MS_SYSTEM_GETVERSION "Miranda/System/GetVersion"
+//gets the version number of Miranda encoded as four WORDs v0.92.2+
+//wParam = 0
+//lParam = WORD[4]*
+//returns the version number, encoded as one version per word, therefore
+//version 1.2.3.3210 is 0x0001, 0x0002, 0x0003, 0x0C8a
+#define MS_SYSTEM_GETFILEVERSION "Miranda/System/GetFileVersion"
+
//gets the version of Miranda encoded as text v0.1.0.1+
//wParam = cch
//lParam = (LPARAM)(char*)pszVersion
diff --git a/protocols/JabberG/jabber.cpp b/protocols/JabberG/jabber.cpp
index 950ffb6edb..5ea6fc7b84 100644
--- a/protocols/JabberG/jabber.cpp
+++ b/protocols/JabberG/jabber.cpp
@@ -43,7 +43,7 @@ int hLangpack;
int g_cbCountries;
struct CountryListEntry* g_countries;
-char szCoreVersion[200];
+TCHAR szCoreVersion[100];
PLUGININFOEX pluginInfo = {
sizeof( PLUGININFOEX ),
@@ -223,7 +223,10 @@ extern "C" int __declspec( dllexport ) Load()
mir_getTMI( &tmi );
mir_getLP( &pluginInfo );
- JCallService( MS_SYSTEM_GETVERSIONTEXT, SIZEOF(szCoreVersion), (LPARAM)szCoreVersion);
+ WORD v[4];
+ JCallService(MS_SYSTEM_GETFILEVERSION, 0, (LPARAM)v);
+ mir_sntprintf(szCoreVersion, SIZEOF(szCoreVersion), _T("%d.%d.%d.%d"), v[0], v[1], v[2], v[3]);
+
JCallService( MS_UTILS_GETCOUNTRYLIST, ( WPARAM )&g_cbCountries, ( LPARAM )&g_countries );
setlocale(LC_ALL, "");
diff --git a/protocols/JabberG/jabber.h b/protocols/JabberG/jabber.h
index 5620c17696..f9ffdda8a6 100644
--- a/protocols/JabberG/jabber.h
+++ b/protocols/JabberG/jabber.h
@@ -576,7 +576,7 @@ extern BOOL (WINAPI *JabberIsThemeActive)();
extern HRESULT (WINAPI *JabberDrawThemeParentBackground)(HWND, HDC, RECT *);
extern const TCHAR xmlnsOwner[];
-extern char szCoreVersion[];
+extern TCHAR szCoreVersion[];
extern int g_cbCountries;
extern struct CountryListEntry* g_countries;
diff --git a/protocols/JabberG/jabber_caps.cpp b/protocols/JabberG/jabber_caps.cpp
index 85f1c52b88..380cf03087 100644
--- a/protocols/JabberG/jabber_caps.cpp
+++ b/protocols/JabberG/jabber_caps.cpp
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_iq.h"
#include "jabber_caps.h"
#include "version.h"
-#include <m_version.h>
const JabberFeatCapPair g_JabberFeatCapPairs[] = {
{ _T(JABBER_FEAT_DISCO_INFO), JABBER_CAPS_DISCO_INFO, _T("Supports Service Discovery info"), },
@@ -82,7 +81,7 @@ const JabberFeatCapPair g_JabberFeatCapPairsExt[] = {
{ _T(JABBER_EXT_USER_ACTIVITY), JABBER_CAPS_USER_ACTIVITY_NOTIFY },
{ _T(JABBER_EXT_GTALK_PMUC), JABBER_CAPS_GTALK_PMUC },
{ _T(JABBER_EXT_MIR_NOTES), JABBER_CAPS_MIRANDA_NOTES, },
- { _T(MIRANDA_VERSION_DISPLAY), JABBER_CAPS_MIRANDA_PARTIAL },
+ { szCoreVersion, JABBER_CAPS_MIRANDA_PARTIAL },
{ NULL, 0 }
};
@@ -549,7 +548,7 @@ CJabberClientCaps * CJabberClientCapsManager::FindClient( const TCHAR *szNode )
}
void CJabberClientCapsManager::AddDefaultCaps() {
- SetClientCaps( _T(JABBER_CAPS_MIRANDA_NODE), _A2T(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 );
@@ -689,7 +688,7 @@ BOOL CJabberClientCapsManager::HandleInfoRequest( HXML, CJabberIqInfo* pInfo, co
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"), _A2T(szCoreVersion));
+ form << XCHILD( _T("field")) << XATTR( _T("var"), _T("software_version")) << XCHILD( _T("value"), szCoreVersion);
}
ppro->m_ThreadInfo->send( iq );
diff --git a/protocols/JabberG/jabber_iq_handlers.cpp b/protocols/JabberG/jabber_iq_handlers.cpp
index 6846d0d477..0ae93ec014 100644
--- a/protocols/JabberG/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/jabber_iq_handlers.cpp
@@ -293,7 +293,7 @@ BOOL CJabberProto::OnIqRequestVersion( HXML, CJabberIqInfo* pInfo )
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"), _A2T(szCoreVersion));
+ query << XCHILD( _T("version"), szCoreVersion);
if ( m_options.ShowOSVersion )
{
diff --git a/protocols/JabberG/jabber_util.cpp b/protocols/JabberG/jabber_util.cpp
index 8f2eaed3c3..eaf277099f 100644
--- a/protocols/JabberG/jabber_util.cpp
+++ b/protocols/JabberG/jabber_util.cpp
@@ -809,7 +809,7 @@ void CJabberProto::SendPresenceTo( int status, TCHAR* to, HXML extra, const TCHA
// 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"), _A2T(szCoreVersion));
+ << XATTR( _T("ver"), szCoreVersion);
TCHAR szExtCaps[ 512 ] = _T("");
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp
index 0ad716daf9..9f0da67b09 100644
--- a/src/core/miranda.cpp
+++ b/src/core/miranda.cpp
@@ -375,7 +375,7 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM)
GetModuleFileName(NULL, filename, SIZEOF(filename));
DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
- PVOID pVerInfo = mir_alloc(verInfoSize);
+ PVOID pVerInfo = _alloca(verInfoSize);
GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo);
UINT blockSize;
@@ -385,28 +385,45 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM)
((vsffi->dwProductVersionMS&0xFF)<<16)|
(((vsffi->dwProductVersionLS>>16)&0xFF)<<8)|
(vsffi->dwProductVersionLS&0xFF);
- mir_free(pVerInfo);
return (INT_PTR)ver;
}
-static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
+static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam)
{
- TCHAR filename[MAX_PATH], *productVersion;
- DWORD unused;
- DWORD verInfoSize;
+ TCHAR filename[MAX_PATH];
+ GetModuleFileName(NULL, filename, SIZEOF(filename));
+
+ DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
+ PVOID pVerInfo = _alloca(verInfoSize);
+ GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo);
+
UINT blockSize;
- PVOID pVerInfo;
+ VS_FIXEDFILEINFO *vsffi;
+ VerQueryValue(pVerInfo, _T("\\"), (PVOID*)&vsffi, &blockSize);
+ WORD* p = (WORD*)lParam;
+ p[0] = HIWORD(vsffi->dwProductVersionMS);
+ p[1] = LOWORD(vsffi->dwProductVersionMS);
+ p[2] = HIWORD(vsffi->dwProductVersionLS);
+ p[3] = LOWORD(vsffi->dwProductVersionLS);
+ return 0;
+}
+
+static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR filename[MAX_PATH], *productVersion;
GetModuleFileName(NULL, filename, SIZEOF(filename));
- verInfoSize = GetFileVersionInfoSize(filename, &unused);
- pVerInfo = mir_alloc(verInfoSize);
+
+ DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
+ PVOID pVerInfo = _alloca(verInfoSize);
GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo);
+
+ UINT blockSize;
VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\ProductVersion"), (LPVOID*)&productVersion, &blockSize);
strncpy((char*)lParam, _T2A(productVersion), wParam);
#if defined(_WIN64)
strcat_s((char*)lParam, wParam, " x64");
#endif
- mir_free(pVerInfo);
return 0;
}
@@ -452,6 +469,7 @@ int LoadSystemModule(void)
CreateServiceFunction(MS_SYSTEM_TERMINATED, MirandaIsTerminated);
CreateServiceFunction(MS_SYSTEM_OKTOEXIT, OkToExit);
CreateServiceFunction(MS_SYSTEM_GETVERSION, GetMirandaVersion);
+ CreateServiceFunction(MS_SYSTEM_GETFILEVERSION, GetMirandaFileVersion);
CreateServiceFunction(MS_SYSTEM_GETVERSIONTEXT, GetMirandaVersionText);
CreateServiceFunction(MS_SYSTEM_WAITONHANDLE, WaitOnHandle);
CreateServiceFunction(MS_SYSTEM_REMOVEWAIT, RemoveWait);