summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-08-01 13:27:40 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-08-01 13:27:40 +0000
commitf8525a5432212fd0e6593bb632743832550f3463 (patch)
treec768303e672337c5e49d7486b30e32f9a68ef395 /plugins
parent41872c8fb1e0130a80830b9013e42579ba29593f (diff)
don't import duplicates
git-svn-id: http://svn.miranda-ng.org/main/trunk@5547 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewsAggregator/Res/Resource.rc2
-rw-r--r--plugins/NewsAggregator/Src/CheckFeed.cpp2
-rw-r--r--plugins/NewsAggregator/Src/Common.h1
-rw-r--r--plugins/NewsAggregator/Src/ExportImport.cpp13
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp14
5 files changed, 28 insertions, 4 deletions
diff --git a/plugins/NewsAggregator/Res/Resource.rc b/plugins/NewsAggregator/Res/Resource.rc
index ab418aebdf..1f6777bf51 100644
--- a/plugins/NewsAggregator/Res/Resource.rc
+++ b/plugins/NewsAggregator/Res/Resource.rc
@@ -91,7 +91,7 @@ EXSTYLE WS_EX_CONTROLPARENT
CAPTION "Authentication"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- CTEXT "aaaa",IDC_FEEDNAME,7,5,196,8
+ CTEXT "Feed name",IDC_FEEDNAME,7,5,196,8
LTEXT "This feed seems to need authentication. Please fill username and password fields:",IDC_STATIC,7,19,196,22
RTEXT "Username",IDC_STATIC,25,49,42,8
EDITTEXT IDC_FEEDUSERNAME,71,46,80,14,ES_AUTOHSCROLL
diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp
index 4d73c75834..36ef8165a1 100644
--- a/plugins/NewsAggregator/Src/CheckFeed.cpp
+++ b/plugins/NewsAggregator/Src/CheckFeed.cpp
@@ -73,7 +73,7 @@ TCHAR * CheckFeed(TCHAR *tszURL, HWND hwndDlg)
}
TCHAR mes[MAX_PATH];
mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis not a valid feed's address."), tszURL);
- MessageBox(hwndDlg, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONERROR);
+ MessageBox(hwndDlg, mes, TranslateT("News Aggregator"), MB_OK|MB_ICONERROR);
return NULL;
}
diff --git a/plugins/NewsAggregator/Src/Common.h b/plugins/NewsAggregator/Src/Common.h
index a9b9696859..fa9117462d 100644
--- a/plugins/NewsAggregator/Src/Common.h
+++ b/plugins/NewsAggregator/Src/Common.h
@@ -139,6 +139,7 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
HANDLE GetContactByNick(const TCHAR *nick);
+HANDLE GetContactByURL(const TCHAR *url);
// =============== NewsAggregator SERVICES ================
// Check all Feeds info
diff --git a/plugins/NewsAggregator/Src/ExportImport.cpp b/plugins/NewsAggregator/Src/ExportImport.cpp
index 39ed12e99f..13ecd075aa 100644
--- a/plugins/NewsAggregator/Src/ExportImport.cpp
+++ b/plugins/NewsAggregator/Src/ExportImport.cpp
@@ -50,6 +50,8 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
HXML node = xi.getChildByPath(hXml, _T("opml/body/outline"), 0);
if ( !node)
node = xi.getChildByPath(hXml, _T("body/outline"), 0);
+ int count = SendMessage(FeedsImportList, LB_GETCOUNT, 0, 0);
+ int DUPES = 0;
if (node) {
while (node) {
int outlineAttr = xi.getAttrCount(node);
@@ -83,7 +85,6 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
} else
isTitleUTF = 1;
- int count = SendMessage(FeedsImportList, LB_GETCOUNT, 0, 0);
for (int i = 0; i < count; i++) {
TCHAR item[MAX_PATH];
SendMessage(FeedsImportList, LB_GETTEXT, i, (LPARAM)item);
@@ -101,6 +102,10 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
url = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
} else
isURLUTF = 1;
+ if (GetContactByURL(url) && NeedToImport) {
+ NeedToImport = FALSE;
+ DUPES += 1;
+ }
continue;
}
if (!lstrcmpi(xi.getAttrName(node, i), _T("htmlUrl"))) {
@@ -201,6 +206,12 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
DeleteAllItems(hwndList);
UpdateList(hwndList);
}
+ TCHAR mes[MAX_PATH];
+ if (DUPES)
+ mir_sntprintf(mes, SIZEOF(mes), TranslateT("Imported %d feed(s)\r\nNot imported %d duplicate(s)."), count - DUPES, DUPES);
+ else
+ mir_sntprintf(mes, SIZEOF(mes), TranslateT("Imported %d feed(s)."), count);
+ MessageBox(hwndDlg, mes, TranslateT("News Aggregator"), MB_OK | MB_ICONINFORMATION);
}
}
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index fadaaa99fa..f1ae9dcec7 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -598,8 +598,20 @@ HANDLE GetContactByNick(const TCHAR *nick)
for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
ptrW contactNick(::db_get_wsa(hContact, MODULE, "Nick"));
- if (::lstrcmpi(contactNick, nick) == 0)
+ if (!lstrcmpi(contactNick, nick))
break;
}
return hContact;
}
+
+HANDLE GetContactByURL(const TCHAR *url)
+{
+ HANDLE hContact = NULL;
+
+ for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ ptrW contactURL(::db_get_wsa(hContact, MODULE, "URL"));
+ if (!lstrcmpi(contactURL, url))
+ break;
+ }
+ return hContact;
+} \ No newline at end of file