From 1ce3da1cca093143d9629bc46e221dd8be962e12 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 31 May 2015 11:46:05 +0000 Subject: - MAllStrings: a handy union to hold an incoming string parameter of any type; - FNAMECHAR: atavism extincted; - PROTOSEARCHRESULT: structure prepared to use results of any type, including utf git-svn-id: http://svn.miranda-ng.org/main/trunk@13932 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Sametime/src/sametime.h | 25 ++++++++++--------------- protocols/Sametime/src/userlist.cpp | 27 ++++++++++++--------------- 2 files changed, 22 insertions(+), 30 deletions(-) (limited to 'protocols/Sametime') diff --git a/protocols/Sametime/src/sametime.h b/protocols/Sametime/src/sametime.h index d1a6f96a1a..22d07668e8 100644 --- a/protocols/Sametime/src/sametime.h +++ b/protocols/Sametime/src/sametime.h @@ -70,24 +70,19 @@ typedef struct Options_tag { bool idle_as_away; } SametimeOptions; -typedef struct { - int cbSize; - char* nick; - char* firstName; - char* lastName; - char* email; - char reserved[16]; +struct MYPROTOSEARCHRESULT : public PROTOSEARCHRESULT +{ char name[256]; char stid[256]; bool group; -} MYPROTOSEARCHRESULT; - -typedef struct { - size_t nSize; - int nFieldCount; - TCHAR** pszFields; - MYPROTOSEARCHRESULT psr; -} MYCUSTOMSEARCHRESULTS; +}; + +struct MYCUSTOMSEARCHRESULTS : public CUSTOMSEARCHRESULTS +{ + char name[256]; + char stid[256]; + bool group; +}; typedef struct FileTransferClientData_tag { char* save_path; diff --git a/protocols/Sametime/src/userlist.cpp b/protocols/Sametime/src/userlist.cpp index debe054ec3..6d631fc2ce 100644 --- a/protocols/Sametime/src/userlist.cpp +++ b/protocols/Sametime/src/userlist.cpp @@ -655,11 +655,10 @@ void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code CSametimeProto* proto = getProtoFromMwServiceResolve(srvc); BOOL advanced = (BOOL)data; - MYCUSTOMSEARCHRESULTS mcsr = { 0 }; + MYCUSTOMSEARCHRESULTS mcsr; + memset(&mcsr, 0, sizeof(mcsr)); mcsr.nSize = sizeof(MYCUSTOMSEARCHRESULTS); - //MYPROTOSEARCHRESULT mpsr = {0}; - //mpsr.cbSize = sizeof(MYPROTOSEARCHRESULT); - mcsr.psr.nick = mcsr.psr.name; + mcsr.psr.nick.a = mcsr.name; mcsr.nFieldCount = 4; TCHAR fields[4][512]; @@ -687,22 +686,19 @@ void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code for (; ri; ri = ri->next) { mri = ((mwResolveResult *)ri->data)->matches; for (; mri; mri = mri->next) { - strncpy(mcsr.psr.stid, ((mwResolveMatch *)mri->data)->id, 256); - mcsr.psr.stid[255] = 0; - MultiByteToWideChar(CP_UTF8, 0, mcsr.psr.stid, -1, mcsr.pszFields[0], 512); + strncpy_s(mcsr.stid, ((mwResolveMatch *)mri->data)->id, _TRUNCATE); + MultiByteToWideChar(CP_UTF8, 0, mcsr.stid, -1, mcsr.pszFields[0], 512); - strncpy(mcsr.psr.name, ((mwResolveMatch *)mri->data)->name, 256); - mcsr.psr.name[255] = 0; - MultiByteToWideChar(CP_UTF8, 0, mcsr.psr.name, -1, mcsr.pszFields[1], 512); + strncpy(mcsr.name, ((mwResolveMatch *)mri->data)->name, _TRUNCATE); + MultiByteToWideChar(CP_UTF8, 0, mcsr.name, -1, mcsr.pszFields[1], 512); if (((mwResolveMatch *)mri->data)->desc) MultiByteToWideChar(CP_UTF8, 0, ((mwResolveMatch *)mri->data)->desc, -1, mcsr.pszFields[2], 512); else mcsr.pszFields[2][0] = 0; - mcsr.psr.group = (((mwResolveMatch *)mri->data)->type == mwResolveMatch_GROUP); - //MultiByteToWideChar(CP_UTF8, 0, mcsr.psr.name, -1, mcsr.pszFields[1], 512); - _tcsncpy(mcsr.pszFields[3], mcsr.psr.group ? TranslateT("True") : TranslateT("False"), 512); + mcsr.group = (((mwResolveMatch *)mri->data)->type == mwResolveMatch_GROUP); + _tcsncpy_s(mcsr.pszFields[3], 512, mcsr.group ? TranslateT("True") : TranslateT("False"), _TRUNCATE); if (advanced == TRUE) proto->ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, (HANDLE)id, (LPARAM)&mcsr); @@ -718,9 +714,10 @@ void mwResolve_handler_details_callback(mwServiceResolve* srvc, guint32 id, guin { CSametimeProto* proto = getProtoFromMwServiceResolve(srvc); - MYPROTOSEARCHRESULT mpsr = { 0 }; + MYPROTOSEARCHRESULT mpsr; + memset(&mpsr, 0, sizeof(mpsr)); mpsr.cbSize = sizeof(mpsr); - mpsr.nick = mpsr.name; + mpsr.nick.a = mpsr.name; if (code == mwResolveCode_SUCCESS) { GList *ri = results, *mri; -- cgit v1.2.3