summaryrefslogtreecommitdiff
path: root/plugins/NewsAggregator
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-01-12 20:15:30 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-01-12 20:15:30 +0000
commiteec8d5bd49a4f862ea926ad24ee07f19cdc10933 (patch)
tree074ce6b42c40ec84c48926dbe98679f05138b2f7 /plugins/NewsAggregator
parent69bacf13e2c85a5f57df9215288c9b2dcf205db7 (diff)
added options for not receiving news at startup
git-svn-id: http://svn.miranda-ng.org/main/trunk@3080 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewsAggregator')
-rw-r--r--plugins/NewsAggregator/Res/Resource.rc29
-rw-r--r--plugins/NewsAggregator/Src/Common.h9
-rw-r--r--plugins/NewsAggregator/Src/Options.cpp42
-rw-r--r--plugins/NewsAggregator/Src/Services.cpp30
-rw-r--r--plugins/NewsAggregator/Src/Update.cpp33
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp119
-rw-r--r--plugins/NewsAggregator/Src/resource.h59
7 files changed, 233 insertions, 88 deletions
diff --git a/plugins/NewsAggregator/Res/Resource.rc b/plugins/NewsAggregator/Res/Resource.rc
index f0af64b1f4..ce039b7049 100644
--- a/plugins/NewsAggregator/Res/Resource.rc
+++ b/plugins/NewsAggregator/Res/Resource.rc
@@ -13,19 +13,26 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
+// Русский (Россия) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+
+/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-IDI_ICON ICON "Main.ico"
-IDI_CHECKALL ICON "CheckAll.ico"
-IDI_ADDFEED ICON "AddFeed.ico"
-IDI_IMPORTFEEDS ICON "Import.ico"
-IDI_EXPORTFEEDS ICON "Export.ico"
-IDI_ENABLED ICON "Enabled.ico"
-IDI_DISABLED ICON "Disabled.ico"
+IDI_ICON ICON "Main.ico"
+IDI_CHECKALL ICON "CheckAll.ico"
+IDI_ADDFEED ICON "AddFeed.ico"
+IDI_IMPORTFEEDS ICON "Import.ico"
+IDI_EXPORTFEEDS ICON "Export.ico"
+IDI_ENABLED ICON "Enabled.ico"
+IDI_DISABLED ICON "Disabled.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -43,6 +50,7 @@ BEGIN
PUSHBUTTON "Remove",IDC_REMOVE,187,187,50,14
PUSHBUTTON "Import",IDC_IMORT,252,204,50,14
PUSHBUTTON "Export",IDC_EXORT,252,219,50,14
+ CONTROL "Retrieve news at startup",IDC_STARTUPRETRIEVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,9,205,203,10
END
IDD_ADDFEED DIALOGEX 0, 0, 250, 228
@@ -114,7 +122,7 @@ GUIDELINES DESIGNINFO
BEGIN
IDD_OPTIONS, DIALOG
BEGIN
- BOTTOMMARGIN, 189
+ BOTTOMMARGIN, 233
END
IDD_ADDFEED, DIALOG
@@ -126,6 +134,11 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
+#endif // Русский (Россия) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
diff --git a/plugins/NewsAggregator/Src/Common.h b/plugins/NewsAggregator/Src/Common.h
index e450ecc301..51824c6d07 100644
--- a/plugins/NewsAggregator/Src/Common.h
+++ b/plugins/NewsAggregator/Src/Common.h
@@ -79,7 +79,7 @@ extern UPDATELIST *UpdateListHead;
extern UPDATELIST *UpdateListTail;
void UpdateListAdd(HANDLE hContact);
-void UpdateThreadProc(LPVOID hWnd);
+void UpdateThreadProc(LPVOID AvatarCheck);
void DestroyUpdateList(void);
extern HANDLE hUpdateMutex;
@@ -119,11 +119,12 @@ VOID CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
BOOL IsMyContact(HANDLE hContact);
VOID GetNewsData(TCHAR *szUrl, char** szData, HANDLE hContact, HWND hwndDlg);
-VOID CreateList (HWND hwndList);
-VOID UpdateList (HWND hwndList);
+VOID CreateList(HWND hwndList);
+VOID UpdateList(HWND hwndList);
VOID DeleteAllItems(HWND hwndList);
time_t __stdcall DateToUnixTime(TCHAR *stamp, BOOL FeedType);
-VOID CheckCurrentFeed (HANDLE hContact);
+VOID CheckCurrentFeed(HANDLE hContact);
+VOID CheckCurrentFeedAvatar(HANDLE hContact);
TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg);
void UpdateMenu(BOOL State);
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp
index 919201eb00..6c14bf8762 100644
--- a/plugins/NewsAggregator/Src/Options.cpp
+++ b/plugins/NewsAggregator/Src/Options.cpp
@@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA.
INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
+ switch (msg)
{
case WM_INITDIALOG:
{
@@ -38,7 +38,7 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
case WM_COMMAND:
{
- switch (LOWORD(wParam))
+ switch (LOWORD(wParam))
{
case IDOK:
{
@@ -163,7 +163,7 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
+ switch (msg)
{
case WM_INITDIALOG:
{
@@ -172,12 +172,12 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
ItemInfo *nSelItem = new ItemInfo(SelItem);
SetWindowText(hwndDlg, TranslateT("Change Feed"));
SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0);
- SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
+ SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
HANDLE hContact = db_find_first();
- while (hContact != NULL)
+ while (hContact != NULL)
{
- if (IsMyContact(hContact))
+ if (IsMyContact(hContact))
{
DBVARIANT dbNick = {0};
if (DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
@@ -234,7 +234,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
case WM_COMMAND:
{
- switch (LOWORD(wParam))
+ switch (LOWORD(wParam))
{
case IDOK:
{
@@ -364,7 +364,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
+ switch (msg)
{
case WM_INITDIALOG:
{
@@ -418,7 +418,7 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
case WM_COMMAND:
{
- switch (LOWORD(wParam))
+ switch (LOWORD(wParam))
{
case IDOK:
{
@@ -551,12 +551,13 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
CreateList(hwndList);
UpdateList(hwndList);
+ CheckDlgButton(hwndDlg, IDC_STARTUPRETRIEVE, db_get_b(NULL, MODULE, "StartupRetrieve", 1));
return TRUE;
}
case WM_COMMAND:
{
- switch (LOWORD(wParam))
+ switch (LOWORD(wParam))
{
case IDC_ADD:
{
@@ -567,7 +568,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
{
ItemInfo SelItem = {0};
int sel = ListView_GetSelectionMark(hwndList);
- ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
SelItem.hwndList = hwndList;
SelItem.SelNumber = sel;
@@ -580,13 +581,13 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
{
TCHAR nick[MAX_PATH], url[MAX_PATH];
int sel = ListView_GetSelectionMark(hwndList);
- ListView_GetItemText(hwndList, sel, 0, nick, MAX_PATH);
- ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 0, nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH);
HANDLE hContact = db_find_first();
- while (hContact != NULL)
+ while (hContact != NULL)
{
- if(IsMyContact(hContact))
+ if(IsMyContact(hContact))
{
DBVARIANT dbNick = {0};
if (DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
@@ -613,6 +614,10 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
}
return FALSE;
}
+
+ case IDC_STARTUPRETRIEVE:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
}
break;
}
@@ -623,11 +628,12 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
{
case PSN_APPLY:
{
+ db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE));
HANDLE hContact = db_find_first();
int i = 0;
- while (hContact != NULL)
+ while (hContact != NULL)
{
- if(IsMyContact(hContact))
+ if(IsMyContact(hContact))
{
DBWriteContactSettingByte(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
if (!ListView_GetCheckState(hwndList, i))
@@ -673,7 +679,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
INT OptInit(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp = {0};
+ OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
odp.position = 100000000;
odp.hInstance = hInst;
diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp
index 33a9e8febf..266d386b32 100644
--- a/plugins/NewsAggregator/Src/Services.cpp
+++ b/plugins/NewsAggregator/Src/Services.cpp
@@ -32,11 +32,10 @@ void SetContactStatus(HANDLE hContact, int nNewStatus)
static void __cdecl WorkingThread(void* param)
{
int nStatus = (int)param;
-// UpdateAll(FALSE, FALSE);
HANDLE hContact= db_find_first();
- while (hContact != NULL)
+ while (hContact != NULL)
{
- if(IsMyContact(hContact))
+ if(IsMyContact(hContact))
{
SetContactStatus(hContact, nStatus);
}
@@ -47,10 +46,12 @@ static void __cdecl WorkingThread(void* param)
int NewsAggrInit(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = db_find_first();
- while (hContact != NULL)
+ while (hContact != NULL)
{
- if(IsMyContact(hContact))
+ if(IsMyContact(hContact))
{
+ if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1))
+ db_set_dw(hContact, MODULE, "LastCheck", time(NULL));
SetContactStatus(hContact, ID_STATUS_ONLINE);
}
hContact = db_find_next(hContact);
@@ -62,7 +63,7 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam)
HookEvent(ME_TTB_MODULELOADED, OnToolbarLoaded);
// timer for the first update
- timerId = SetTimer(NULL, 0, 5000, timerProc2); // first update is 5 sec after load
+ timerId = SetTimer(NULL, 0, 10000, timerProc2); // first update is 5 sec after load
return 0;
}
@@ -92,12 +93,12 @@ INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam)
{
return 1;
}
-}
+}
INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp)
{
switch(wp)
- {
+ {
case PFLAGNUM_1:
return PF1_IM | PF1_PEER2PEER;
case PFLAGNUM_3:
@@ -142,7 +143,7 @@ INT_PTR NewsAggrLoadIcon(WPARAM wParam,LPARAM lParam)
return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0;
}
-static void __cdecl AckThreadProc(HANDLE param)
+static void __cdecl AckThreadProc(HANDLE param)
{
Sleep(100);
ProtoBroadcastAck(MODULE, param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
@@ -158,17 +159,16 @@ INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam)
INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = db_find_first();
- while (hContact != NULL)
+ while (hContact != NULL)
{
- if (IsMyContact(hContact) && lParam && DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60))
+ if (IsMyContact(hContact) && lParam && DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60))
UpdateListAdd(hContact);
else if (IsMyContact(hContact) && !lParam)
UpdateListAdd(hContact);
hContact = db_find_next(hContact);
}
if (!ThreadRunning)
- mir_forkthread(UpdateThreadProc, NULL);
-
+ mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
return 0;
}
@@ -213,7 +213,7 @@ INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam)
if(IsMyContact(hContact))
UpdateListAdd(hContact);
if (!ThreadRunning)
- mir_forkthread(UpdateThreadProc, NULL);
+ mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
return 0;
}
@@ -229,7 +229,7 @@ INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam)
if (wParam & GAIF_FORCE && DBGetContactSettingDword(pai->hContact, MODULE, "UpdateTime", 60))
UpdateListAdd(pai->hContact);
if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && !ThreadRunning)
- mir_forkthread(UpdateThreadProc, NULL);
+ mir_forkthread(UpdateThreadProc, (LPVOID)TRUE);
DBVARIANT dbv = {0};
if(DBGetContactSettingTString(pai->hContact, MODULE, "ImageURL", &dbv))
diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp
index 2ad280a968..c049043128 100644
--- a/plugins/NewsAggregator/Src/Update.cpp
+++ b/plugins/NewsAggregator/Src/Update.cpp
@@ -34,7 +34,7 @@ VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
HANDLE hContact = db_find_first();
while (hContact != NULL)
{
- if(IsMyContact(hContact))
+ if(IsMyContact(hContact))
{
if (DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60))
{
@@ -49,7 +49,7 @@ VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
hContact = db_find_next(hContact);
}
if (!ThreadRunning && HaveUpdates)
- mir_forkthread(UpdateThreadProc, NULL);
+ mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
}
}
@@ -60,7 +60,7 @@ VOID CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
KillTimer(NULL, timerId);
ThreadRunning = FALSE;
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && !Miranda_Terminated())
+ if (db_get_b(NULL, MODULE, "AutoUpdate", 1) && !Miranda_Terminated() && db_get_b(NULL, MODULE, "StartupRetrieve", 1))
{
CheckAllFeeds(0, 1);
timerId = SetTimer(NULL, 0, 30000, (TIMERPROC)timerProc);
@@ -77,28 +77,30 @@ void UpdateListAdd(HANDLE hContact)
WaitForSingleObject(hUpdateMutex, INFINITE);
- if (UpdateListTail == NULL) UpdateListHead = newItem;
+ if (UpdateListTail == NULL)
+ UpdateListHead = newItem;
else UpdateListTail->next = newItem;
UpdateListTail = newItem;
ReleaseMutex(hUpdateMutex);
}
-HANDLE UpdateGetFirst()
+HANDLE UpdateGetFirst()
{
HANDLE hContact = NULL;
WaitForSingleObject(hUpdateMutex, INFINITE);
- if (UpdateListHead != NULL)
+ if (UpdateListHead != NULL)
{
- UPDATELIST* Item = UpdateListHead;
+ UPDATELIST* Item = UpdateListHead;
hContact = Item->hContact;
UpdateListHead = Item->next;
mir_free(Item);
- if (UpdateListHead == NULL) UpdateListTail = NULL;
+ if (UpdateListHead == NULL)
+ UpdateListTail = NULL;
}
ReleaseMutex(hUpdateMutex);
@@ -106,7 +108,7 @@ HANDLE UpdateGetFirst()
return hContact;
}
-void DestroyUpdateList(void)
+void DestroyUpdateList(void)
{
UPDATELIST *temp;
@@ -115,7 +117,7 @@ void DestroyUpdateList(void)
temp = UpdateListHead;
// free the list one by one
- while (temp != NULL)
+ while (temp != NULL)
{
UpdateListHead = temp->next;
mir_free(temp);
@@ -127,7 +129,7 @@ void DestroyUpdateList(void)
ReleaseMutex(hUpdateMutex);
}
-void UpdateThreadProc(LPVOID hWnd)
+void UpdateThreadProc(LPVOID AvatarCheck)
{
WaitForSingleObject(hUpdateMutex, INFINITE);
if (ThreadRunning)
@@ -138,9 +140,12 @@ void UpdateThreadProc(LPVOID hWnd)
ThreadRunning = TRUE; // prevent 2 instance of this thread running
ReleaseMutex(hUpdateMutex);
- // update weather by getting the first station from the queue until the queue is empty
- while (UpdateListHead != NULL && !Miranda_Terminated())
- CheckCurrentFeed(UpdateGetFirst());
+ // update news by getting the first station from the queue until the queue is empty
+ while (UpdateListHead != NULL && !Miranda_Terminated())
+ if ((BOOL)AvatarCheck)
+ CheckCurrentFeedAvatar(UpdateGetFirst());
+ else
+ CheckCurrentFeed(UpdateGetFirst());
// exit the update thread
ThreadRunning = FALSE;
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index d4bf2be460..c88584a4b7 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -1394,4 +1394,123 @@ VOID CheckCurrentFeed(HANDLE hContact)
}
DBWriteContactSettingDword(hContact, MODULE, "LastCheck", time(NULL));
}
+}
+
+VOID CheckCurrentFeedAvatar(HANDLE hContact)
+{
+ char *szData = NULL;
+ DBVARIANT dbURL = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ return;
+ else if (db_get_b(hContact, MODULE, "CheckState", 1) != 0)
+ {
+ GetNewsData(dbURL.ptszVal, &szData, hContact, NULL);
+ DBFreeVariant(&dbURL);
+ if (szData)
+ {
+ TCHAR *tszData = mir_utf8decodeT(szData);
+ if (!tszData)
+ tszData = mir_a2t(szData);
+ int bytesParsed = 0;
+ HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
+ mir_free(tszData);
+ mir_free(szData);
+ if(hXml != NULL)
+ {
+ int childcount = 0;
+ HXML node = xi.getChild(hXml, childcount);
+ while (node)
+ {
+ if (!lstrcmpi(xi.getName(node), _T("rss")) || !lstrcmpi(xi.getName(node), _T("rdf")))
+ {
+ HXML chan = xi.getChild(node, 0);
+ for (int j = 0; j < xi.getChildCount(chan); j++)
+ {
+ HXML child = xi.getChild(chan, j);
+ if (!lstrcmpi(xi.getName(child), _T("image")))
+ {
+ for (int x = 0; x < xi.getChildCount(child); x++)
+ {
+ HXML imageval = xi.getChild(child, x);
+ if (!lstrcmpi(xi.getName(imageval), _T("url")))
+ {
+ LPCTSTR url = xi.getText(imageval);
+ DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+
+ PROTO_AVATAR_INFORMATIONT pai = {NULL};
+ pai.cbSize = sizeof(pai);
+ pai.hContact = hContact;
+ DBVARIANT dbVar = {0};
+
+ if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbVar))
+ {
+ TCHAR *ext = _tcsrchr((TCHAR*)url, _T('.')) + 1;
+ pai.format = GetImageFormat(ext);
+
+ TCHAR *filename = dbVar.ptszVal;
+ mir_sntprintf(pai.filename, SIZEOF(pai.filename), _T("%s\\%s.%s"), tszRoot, filename, ext);
+ if (DownloadFile(url, pai.filename))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "ImagePath", pai.filename);
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE) &pai, NULL);
+ }
+ else
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ DBFreeVariant(&dbVar);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (!lstrcmpi(xi.getName(node), _T("feed")))
+ {
+ for (int j = 0; j < xi.getChildCount(node); j++)
+ {
+ HXML child = xi.getChild(node, j);
+ if (!lstrcmpi(xi.getName(child), _T("icon")))
+ {
+ for (int x = 0; x < xi.getChildCount(child); x++)
+ {
+ HXML imageval = xi.getChild(child, x);
+ if (!lstrcmpi(xi.getName(imageval), _T("url")))
+ {
+ LPCTSTR url = xi.getText(imageval);
+ DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+
+ PROTO_AVATAR_INFORMATIONT pai = {NULL};
+ pai.cbSize = sizeof(pai);
+ pai.hContact = hContact;
+ DBVARIANT dbVar = {0};
+
+ if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbVar))
+ {
+ TCHAR *ext = _tcsrchr((TCHAR*)url, _T('.')) + 1;
+ pai.format = GetImageFormat(ext);
+
+ TCHAR *filename = dbVar.ptszVal;
+ mir_sntprintf(pai.filename, SIZEOF(pai.filename), _T("%s\\%s.%s"), tszRoot, filename, ext);
+ if (DownloadFile(url, pai.filename))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "ImagePath", pai.filename);
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE) &pai, NULL);
+ }
+ else
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ DBFreeVariant(&dbVar);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ childcount +=1;
+ node = xi.getChild(hXml, childcount);
+ }
+ xi.destroyNode(hXml);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/NewsAggregator/Src/resource.h b/plugins/NewsAggregator/Src/resource.h
index 471597847a..fbafab074f 100644
--- a/plugins/NewsAggregator/Src/resource.h
+++ b/plugins/NewsAggregator/Src/resource.h
@@ -1,33 +1,34 @@
//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by Resource.rc
+// Включаемый файл, созданный в Microsoft Visual C++.
+// Используется D:\Miranda NG\plugins\NewsAggregator\res\Resource.rc
//
-#define IDD_OPTIONS 101
-#define IDI_ICON 109
-#define IDD_ADDFEED 110
-#define IDI_CHECKALL 111
-#define IDI_ADDFEED 112
-#define IDI_IMPORTFEEDS 113
-#define IDI_EXPORTFEEDS 114
-#define IDI_ENABLED 115
-#define IDI_DISABLED 116
-#define IDC_TIMEOUT_VALUE_SPIN 1035
-#define IDC_FEEDLIST 1036
-#define IDC_ADD 1037
-#define IDC_CHANGE 1038
-#define IDC_REMOVE 1039
-#define IDC_IMORT 1040
-#define IDC_EXORT 1041
-#define IDC_FEEDTITLE 1042
-#define IDC_FEEDURL 1043
-#define IDC_CHECKTIME 1044
-#define IDC_DISCOVERY 1045
-#define IDC_USEAUTH 1046
-#define IDC_LOGIN 1047
-#define IDC_PASSWORD 1048
-#define IDC_TAGSEDIT 1049
-#define IDC_RESET 1050
-#define IDC_TAGHELP 1051
+#define IDD_OPTIONS 101
+#define IDI_ICON 109
+#define IDD_ADDFEED 110
+#define IDI_CHECKALL 111
+#define IDI_ADDFEED 112
+#define IDI_IMPORTFEEDS 113
+#define IDI_EXPORTFEEDS 114
+#define IDI_ENABLED 115
+#define IDI_DISABLED 116
+#define IDC_TIMEOUT_VALUE_SPIN 1035
+#define IDC_FEEDLIST 1036
+#define IDC_ADD 1037
+#define IDC_CHANGE 1038
+#define IDC_REMOVE 1039
+#define IDC_IMORT 1040
+#define IDC_EXORT 1041
+#define IDC_FEEDTITLE 1042
+#define IDC_FEEDURL 1043
+#define IDC_CHECKTIME 1044
+#define IDC_DISCOVERY 1045
+#define IDC_USEAUTH 1046
+#define IDC_LOGIN 1047
+#define IDC_PASSWORD 1048
+#define IDC_TAGSEDIT 1049
+#define IDC_RESET 1050
+#define IDC_TAGHELP 1051
+#define IDC_STARTUPRETRIEVE 1052
// Next default values for new objects
//
@@ -35,7 +36,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 117
#define _APS_NEXT_COMMAND_VALUE 40075
-#define _APS_NEXT_CONTROL_VALUE 1052
+#define _APS_NEXT_CONTROL_VALUE 1053
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif