diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-09-06 19:45:03 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-09-06 19:45:03 +0000 |
commit | cbc0195ed4cd5d6b1b5527dcec69400c536d6853 (patch) | |
tree | 75f5133976603e49ef8fc41955d963f1b83bcb14 /protocols | |
parent | 0519e0eb7195cc22eee68d7b352cd3507ba94db0 (diff) |
fixed destroying some messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@1541 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/NewsAggregator/Src/Common.h | 13 | ||||
-rw-r--r-- | protocols/NewsAggregator/Src/NewsAggregator.cpp | 3 | ||||
-rw-r--r-- | protocols/NewsAggregator/Src/Services.cpp | 16 | ||||
-rw-r--r-- | protocols/NewsAggregator/Src/Utils.cpp | 265 |
4 files changed, 90 insertions, 207 deletions
diff --git a/protocols/NewsAggregator/Src/Common.h b/protocols/NewsAggregator/Src/Common.h index 63f436e667..470ee91f0e 100644 --- a/protocols/NewsAggregator/Src/Common.h +++ b/protocols/NewsAggregator/Src/Common.h @@ -107,12 +107,13 @@ VOID InitIcons(); HICON LoadIconEx(const char* name, BOOL big);
HANDLE GetIconHandle(const char* name);
INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam);
-INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp);
-INT_PTR NewsAggrSetStatus(WPARAM wp,LPARAM /*lp*/);
-INT_PTR NewsAggrGetStatus(WPARAM/* wp*/,LPARAM/* lp*/);
-INT_PTR NewsAggrLoadIcon(WPARAM wParam,LPARAM lParam);
-INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam);
-INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam,LPARAM lParam);
+INT_PTR NewsAggrGetCaps(WPARAM wp, LPARAM lp);
+INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/);
+INT_PTR NewsAggrGetStatus(WPARAM/* wp*/, LPARAM/* lp*/);
+INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrGetInfo(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrRecvMessage(WPARAM wParam,LPARAM lParam);
INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam);
INT_PTR AddFeed(WPARAM wParam,LPARAM lParam);
diff --git a/protocols/NewsAggregator/Src/NewsAggregator.cpp b/protocols/NewsAggregator/Src/NewsAggregator.cpp index c6d1cb735e..3c05847739 100644 --- a/protocols/NewsAggregator/Src/NewsAggregator.cpp +++ b/protocols/NewsAggregator/Src/NewsAggregator.cpp @@ -23,7 +23,7 @@ HINSTANCE hInst = NULL; int hLangpack;
HANDLE hOptHook = NULL, hLoadHook = NULL, hOnPreShutdown = NULL, hPrebuildMenuHook = NULL, hPackUpdaterFolder = NULL;
-HANDLE hProtoService[7];
+HANDLE hProtoService[8];
HWND hAddFeedDlg;
HANDLE hChangeFeedDlgList = NULL;
XML_API xi = {0};
@@ -99,6 +99,7 @@ extern "C" __declspec(dllexport) int Load(void) hProtoService[4] = CreateProtoServiceFunction(MODULE, PS_LOADICON, NewsAggrLoadIcon);
hProtoService[5] = CreateProtoServiceFunction(MODULE, PSS_GETINFO, NewsAggrGetInfo);
hProtoService[6] = CreateProtoServiceFunction(MODULE, PS_GETAVATARINFOT, NewsAggrGetAvatarInfo);
+ hProtoService[7] = CreateProtoServiceFunction(MODULE, PSR_MESSAGE, NewsAggrRecvMessage);
hService[0] = CreateServiceFunction(MS_NEWSAGGR_CHECKALLFEEDS, CheckAllFeeds);
hService[1] = CreateServiceFunction(MS_NEWSAGGR_ADDFEED, AddFeed);
diff --git a/protocols/NewsAggregator/Src/Services.cpp b/protocols/NewsAggregator/Src/Services.cpp index e1514ffe31..ed53a2a048 100644 --- a/protocols/NewsAggregator/Src/Services.cpp +++ b/protocols/NewsAggregator/Src/Services.cpp @@ -192,7 +192,7 @@ INT_PTR AddFeed(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR ChangeFeed(WPARAM wParam,LPARAM lParam)
+INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE) wParam;
HWND hChangeFeedDlg = WindowList_Find(hChangeFeedDlgList,hContact);
@@ -209,17 +209,17 @@ INT_PTR ChangeFeed(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR ImportFeeds(WPARAM wParam,LPARAM lParam)
+INT_PTR ImportFeeds(WPARAM wParam, LPARAM lParam)
{
return 0;
}
-INT_PTR ExportFeeds(WPARAM wParam,LPARAM lParam)
+INT_PTR ExportFeeds(WPARAM wParam, LPARAM lParam)
{
return 0;
}
-INT_PTR CheckFeed(WPARAM wParam,LPARAM lParam)
+INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
if(IsMyContact(hContact))
@@ -229,7 +229,7 @@ INT_PTR CheckFeed(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam,LPARAM lParam)
+INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
PROTO_AVATAR_INFORMATIONT* pai = (PROTO_AVATAR_INFORMATIONT*) lParam;
@@ -250,4 +250,10 @@ INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam,LPARAM lParam) }
DBFreeVariant(&dbv);
return GAIR_WAITFOR;
+}
+
+INT_PTR NewsAggrRecvMessage(WPARAM wParam, LPARAM lParam)
+{
+ CallService(MS_PROTO_RECVMSG, 0, lParam);
+ return 0;
}
\ No newline at end of file diff --git a/protocols/NewsAggregator/Src/Utils.cpp b/protocols/NewsAggregator/Src/Utils.cpp index 32ce78fcf9..b6007f7d39 100644 --- a/protocols/NewsAggregator/Src/Utils.cpp +++ b/protocols/NewsAggregator/Src/Utils.cpp @@ -62,31 +62,31 @@ static void arrayToHex(BYTE* data, size_t datasz, char* res) int GetImageFormat(const TCHAR* ext)
{
- if(!lstrcmp(ext,_T(".jpg")) || !lstrcmp(ext,_T(".jpeg")))
+ if (!lstrcmp(ext,_T(".jpg")) || !lstrcmp(ext,_T(".jpeg")))
{
return PA_FORMAT_JPEG;
}
- else if(!lstrcmp(ext,_T(".png")))
+ else if (!lstrcmp(ext,_T(".png")))
{
return PA_FORMAT_PNG;
}
- else if(!lstrcmp(ext,_T(".gif")))
+ else if (!lstrcmp(ext,_T(".gif")))
{
return PA_FORMAT_GIF;
}
- else if(!lstrcmp(ext,_T(".ico")))
+ else if (!lstrcmp(ext,_T(".ico")))
{
return PA_FORMAT_ICON;
}
- else if(!lstrcmp(ext,_T(".bmp")))
+ else if (!lstrcmp(ext,_T(".bmp")))
{
return PA_FORMAT_BMP;
}
- else if(!lstrcmp(ext,_T(".swf")))
+ else if (!lstrcmp(ext,_T(".swf")))
{
return PA_FORMAT_SWF;
}
- else if(!lstrcmp(ext,_T(".xml")))
+ else if (!lstrcmp(ext,_T(".xml")))
{
return PA_FORMAT_XML;
}
@@ -97,7 +97,7 @@ int GetImageFormat(const TCHAR* ext) }
void CreateAuthString(char* auth, HANDLE hContact, HWND hwndDlg)
{
- char *user = NULL, *pass = NULL;
+ char *user = NULL, *pass = NULL;
TCHAR *tlogin = NULL, *tpass = NULL, buf[MAX_PATH] = {0};
if (hContact && DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
{
@@ -125,7 +125,7 @@ void CreateAuthString(char* auth, HANDLE hContact, HWND hwndDlg) pass = mir_t2a(tpass);
char str[MAX_PATH];
- int len = mir_snprintf(str, SIZEOF(str), "%s:%s", user, pass);
+ int len = mir_snprintf(str, SIZEOF(str), "%s:%s", user, pass);
mir_free(user);
mir_free(pass);
mir_free(tlogin);
@@ -179,7 +179,7 @@ VOID GetNewsData(TCHAR *tszUrl, char** szData, HANDLE hContact, HWND hwndDlg) if (nlhrReply)
{
// if the recieved code is 200 OK
- switch(nlhrReply->resultCode)
+ switch (nlhrReply->resultCode)
{
case 200:
{
@@ -218,8 +218,7 @@ VOID GetNewsData(TCHAR *tszUrl, char** szData, HANDLE hContact, HWND hwndDlg) rlen = szPath != NULL ? szPath - szUrl : strlen(szUrl);
}
- szRedirUrl = (char*)mir_realloc(szRedirUrl,
- rlen + strlen(nlhrReply->headers[i].szValue)*3 + 1);
+ szRedirUrl = (char*)mir_realloc(szRedirUrl, rlen + strlen(nlhrReply->headers[i].szValue)*3 + 1);
strncpy(szRedirUrl, szUrl, rlen);
strcpy(szRedirUrl+rlen, nlhrReply->headers[i].szValue);
@@ -239,7 +238,7 @@ VOID GetNewsData(TCHAR *tszUrl, char** szData, HANDLE hContact, HWND hwndDlg) mir_free(szUrl);
}
-VOID CreateList (HWND hwndList)
+VOID CreateList(HWND hwndList)
{
SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
@@ -261,7 +260,7 @@ VOID CreateList (HWND hwndList) ListView_InsertColumn(hwndList, 1, &lvc);
}
-VOID UpdateList (HWND hwndList)
+VOID UpdateList(HWND hwndList)
{
LVITEM lvI = {0};
@@ -420,8 +419,6 @@ time_t __stdcall DateToUnixTime(TCHAR* stamp, BOOL FeedType) return ( time_t ) 0;
}
-/******************************************************************************/
-
TCHAR * _tcsistr(const TCHAR * str, const TCHAR * substr)
{
if (!str || !substr || (substr[0] == _T('\0')))
@@ -544,7 +541,7 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) bool ret = false;
NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
- if(pReply)
+ if (pReply)
{
if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
{
@@ -730,23 +727,18 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg) GetNewsData(tszURL, &szData, NULL, hwndDlg);
if (szData)
{
- TCHAR *tszData = mir_a2t(szData);
+ TCHAR *tszData = mir_utf8decodeT(szData);
+ if (!tszData)
+ tszData = mir_a2t(szData);
int bytesParsed = 0;
HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
- BOOL UtfEncode = FALSE;
- TCHAR *newtszData = mir_utf8decodeT(szData);
- if (newtszData)
- {
- UtfEncode = TRUE;
- mir_free(newtszData);
- }
mir_free(tszData);
mir_free(szData);
- if(hXml != NULL)
+ if (hXml != NULL)
{
int childcount = 0;
HXML node = xi.getChild(hXml, childcount);
- while(node)
+ while (node)
{
if (!lstrcmpi(xi.getName(node), _T("rss")) || !lstrcmpi(xi.getName(node), _T("rdf")))
{
@@ -760,15 +752,6 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg) mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a valid feed's address."), tszURL);
MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONINFORMATION);
TCHAR *tszTitle = (TCHAR*)xi.getText(child);
- if (UtfEncode)
- {
- char* szstring = mir_t2a(tszTitle);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- tszTitle = (TCHAR*)mir_alloc(sizeof(TCHAR)*lstrlen(tszstring)+1);
- _tcscpy(tszTitle, tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
return tszTitle;
}
}
@@ -784,15 +767,6 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg) mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a valid feed's address."), tszURL);
MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONINFORMATION);
TCHAR *tszTitle = (TCHAR*)xi.getText(child);
- if (UtfEncode)
- {
- char* szstring = mir_t2a(tszTitle);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- tszTitle = (TCHAR*)mir_alloc(sizeof(TCHAR)*lstrlen(tszstring)+1);
- _tcscpy(tszTitle, tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
return tszTitle;
}
}
@@ -825,23 +799,18 @@ VOID CheckCurrentFeed(HANDLE hContact) DBFreeVariant(&dbURL);
if (szData)
{
- TCHAR *tszData = mir_a2t(szData);
+ TCHAR *tszData = mir_utf8decodeT(szData);
+ if (!tszData)
+ tszData = mir_a2t(szData);
int bytesParsed = 0;
HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
- BOOL UtfEncode = FALSE;
- TCHAR *newtszData = mir_utf8decodeT(szData);
- if (newtszData)
- {
- UtfEncode = TRUE;
- mir_free(newtszData);
- }
mir_free(tszData);
mir_free(szData);
if(hXml != NULL)
{
int childcount = 0;
HXML node = xi.getChild(hXml, childcount);
- while(node)
+ while (node)
{
if (!lstrcmpi(xi.getName(node), _T("rss")) || !lstrcmpi(xi.getName(node), _T("rdf")))
{
@@ -871,16 +840,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "FirstName", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
+ DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
mir_free(string);
continue;
}
@@ -893,20 +853,8 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "About", tszstring);
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- {
- DBWriteContactSettingTString(hContact, MODULE, "About", string);
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
- }
+ DBWriteContactSettingTString(hContact, MODULE, "About", string);
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
mir_free(string);
continue;
}
@@ -914,16 +862,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "Language1", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
+ DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
mir_free(string);
continue;
}
@@ -931,16 +870,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "e-mail", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "e-mail", string);
+ DBWriteContactSettingTString(hContact, MODULE, "e-mail", string);
mir_free(string);
continue;
}
@@ -948,16 +878,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
+ DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
mir_free(string);
continue;
}
@@ -1140,47 +1061,43 @@ VOID CheckCurrentFeed(HANDLE hContact) mir_free(category);
}
- char* pszUtf;
- if (!UtfEncode)
- pszUtf = mir_utf8encodeT(message);
- else
- pszUtf = mir_t2a(message);
-
time_t stamp;
if (!datetime)
stamp = time(NULL);
else
stamp = DateToUnixTime(datetime, 0);
- DBEVENTINFO olddbei = { 0 };
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
BOOL MesExist = FALSE;
- while(hDbEvent)
+ while (hDbEvent)
{
- ZeroMemory(&olddbei, sizeof(olddbei));
+ DBEVENTINFO olddbei = {0};
olddbei.cbSize = sizeof(olddbei);
olddbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&olddbei);
- if (olddbei.cbBlob == lstrlenA(pszUtf) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszUtf))
+ char *pszTemp = mir_utf8encodeT(message);
+ if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp))
MesExist = TRUE;
hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
mir_free(olddbei.pBlob);
+ mir_free(pszTemp);
}
if (!MesExist)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_UTF;
- dbei.szModule = MODULE;
- dbei.timestamp = stamp;
- dbei.cbBlob = lstrlenA(pszUtf) + 1;
- dbei.pBlob = (PBYTE)pszUtf;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ PROTORECVEVENT recv;
+ recv.flags = PREF_TCHAR;
+ recv.timestamp = stamp;
+ recv.tszMessage = message;
+
+ CCSDATA ccs;
+ ccs.hContact = hContact;
+ ccs.wParam = 0;
+ ccs.szProtoService = PSR_MESSAGE;
+ ccs.lParam = ( LPARAM )&recv;
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
}
- mir_free(pszUtf);
mir_free(message);
}
}
@@ -1195,16 +1112,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "FirstName", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
+ DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
mir_free(string);
continue;
}
@@ -1228,20 +1136,8 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "About", tszstring);
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- {
- DBWriteContactSettingTString(hContact, MODULE, "About", string);
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
- }
+ DBWriteContactSettingTString(hContact, MODULE, "About", string);
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
mir_free(string);
continue;
}
@@ -1249,16 +1145,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "Language1", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
+ DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
mir_free(string);
continue;
}
@@ -1279,16 +1166,7 @@ VOID CheckCurrentFeed(HANDLE hContact) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- if (UtfEncode)
- {
- char *szstring = mir_t2a(string);
- TCHAR* tszstring = mir_utf8decodeT(szstring);
- DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", tszstring);
- mir_free(tszstring);
- mir_free(szstring);
- }
- else
- DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
+ DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
mir_free(string);
continue;
}
@@ -1482,46 +1360,43 @@ VOID CheckCurrentFeed(HANDLE hContact) mir_free(category);
}
- char* pszUtf;
- if (!UtfEncode)
- pszUtf = mir_utf8encodeT(message);
- else
- pszUtf = mir_t2a(message);
-
time_t stamp;
if (!datetime)
stamp = time(NULL);
else
stamp = DateToUnixTime(datetime, 1);
- DBEVENTINFO olddbei = { 0 };
- HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
BOOL MesExist = FALSE;
- while(hDbEvent)
+ while (hDbEvent)
{
- ZeroMemory(&olddbei, sizeof(olddbei));
+ DBEVENTINFO olddbei = {0};
olddbei.cbSize = sizeof(olddbei);
olddbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
- olddbei.pBlob = (PBYTE)malloc(olddbei.cbBlob);
+ olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&olddbei);
- if (olddbei.cbBlob == lstrlenA(pszUtf) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszUtf))
+ char *pszTemp = mir_utf8encodeT(message);
+ if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp))
MesExist = TRUE;
hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ mir_free(olddbei.pBlob);
+ mir_free(pszTemp);
}
if (!MesExist)
{
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_UTF;
- dbei.szModule = MODULE;
- dbei.timestamp = stamp;
- dbei.cbBlob = lstrlenA(pszUtf) + 1;
- dbei.pBlob = (PBYTE)pszUtf;
- CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ PROTORECVEVENT recv;
+ recv.flags = PREF_TCHAR;
+ recv.timestamp = stamp;
+ recv.tszMessage = message;
+
+ CCSDATA ccs;
+ ccs.hContact = hContact;
+ ccs.wParam = 0;
+ ccs.szProtoService = PSR_MESSAGE;
+ ccs.lParam = ( LPARAM )&recv;
+ CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
}
- mir_free(pszUtf);
mir_free(message);
}
}
|