diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-06-20 19:15:25 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-06-20 19:15:25 +0000 |
commit | ac057302bf57012c40e3307e2fde6669f7c21322 (patch) | |
tree | a9c499c8a1d5602c54598fd7a5906732135cb3c5 /plugins | |
parent | f151d55145f7e656985faee8af3e75402e8c3f4b (diff) |
wbOSD changed codepage to utf-8
NewsAggregator: Import added in main menu
git-svn-id: http://svn.miranda-ng.org/main/trunk@5070 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NewsAggregator/Src/Common.h | 1 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 173 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Services.cpp | 38 | ||||
-rw-r--r-- | plugins/NewsAggregator/Src/Utils.cpp | 172 |
4 files changed, 196 insertions, 188 deletions
diff --git a/plugins/NewsAggregator/Src/Common.h b/plugins/NewsAggregator/Src/Common.h index 2c664d035b..15c40a1d85 100644 --- a/plugins/NewsAggregator/Src/Common.h +++ b/plugins/NewsAggregator/Src/Common.h @@ -129,6 +129,7 @@ VOID CheckCurrentFeed(HANDLE hContact); VOID CheckCurrentFeedAvatar(HANDLE hContact);
TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg);
void UpdateMenu(BOOL State);
+int ImportFeedsDialog();
// =============== NewsAggregator SERVICES ================
// Check all Feeds info
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 6a18c492bc..9144b68a85 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -300,7 +300,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
Utils_SaveWindowPosition(hwndDlg, hContact, MODULE, "ChangeDlg");
WindowList_Remove(hChangeFeedDlgList, hwndDlg);
- ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ ItemInfo *SelItem = (ItemInfo *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
delete SelItem;
break;
}
@@ -511,174 +511,9 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA return FALSE;
case IDC_IMPORT:
- {
- TCHAR FileName[MAX_PATH];
- TCHAR *tszMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
-
- OPENFILENAME ofn = {0};
- ofn.lStructSize = sizeof(ofn);
- TCHAR tmp[MAX_PATH];
- mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.opml, *.xml)%c*.opml;*.xml%c%c"), TranslateT("OPML files"), 0, 0, 0);
- ofn.lpstrFilter = tmp;
- ofn.hwndOwner = 0;
- ofn.lpstrFile = FileName;
- ofn.nMaxFile = MAX_PATH;
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.Flags = OFN_HIDEREADONLY;
- ofn.lpstrInitialDir = tszMirDir;
- *FileName = '\0';
- ofn.lpstrDefExt = _T("");
-
- if (GetOpenFileName(&ofn)) {
- int bytesParsed = 0;
- HXML hXml = xi.parseFile(FileName, &bytesParsed, NULL);
- if(hXml != NULL) {
- BYTE isTitleUTF = 0, isURLUTF = 0, isSiteURLUTF = 0, isGroupUTF = 0;
- HXML node = xi.getChildByPath(hXml, _T("opml/body/outline"), 0);
- if ( !node)
- node = xi.getChildByPath(hXml, _T("body/outline"), 0);
- if (node) {
- while (node) {
- int outlineAttr = xi.getAttrCount(node);
- int outlineChildsCount = xi.getChildCount(node);
- TCHAR *type = (TCHAR *)xi.getAttrValue(node, _T("type"));
- if ( !type && !outlineChildsCount) {
- HXML tmpnode = node;
- node = xi.getNextNode(node);
- if ( !node) {
- do {
- node = tmpnode;
- node = xi.getParent(node);
- tmpnode = node;
- node = xi.getNextNode(node);
- if (node)
- break;
- } while (lstrcmpi(xi.getName(node), _T("body")));
- }
- }
- else if (!type && outlineChildsCount)
- node = xi.getFirstChild(node);
- else if (type) {
- TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL, *utfgroup = NULL;
- for (int i = 0; i < outlineAttr; i++) {
- if (!lstrcmpi(xi.getAttrName(node, i), _T("title"))) {
- title = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
- if ( !title) {
- isTitleUTF = 0;
- title = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
- } else
- isTitleUTF = 1;
- continue;
- }
- if (!lstrcmpi(xi.getAttrName(node, i), _T("xmlUrl"))) {
- url = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
- if ( !url) {
- isURLUTF = 0;
- url = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
- } else
- isURLUTF = 1;
- continue;
- }
- if (!lstrcmpi(xi.getAttrName(node, i), _T("htmlUrl"))) {
- siteurl = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
- if ( !siteurl) {
- isSiteURLUTF = 0;
- siteurl = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
- } else
- isSiteURLUTF = 1;
- continue;
- }
- if (title && url && siteurl)
- break;
- }
-
- HXML parent = xi.getParent(node);
- while (lstrcmpi(xi.getName(parent), _T("body"))) {
- for (int i = 0; i < xi.getAttrCount(parent); i++) {
- if (!lstrcmpi(xi.getAttrName(parent, i), _T("title"))) {
- if ( !group)
- group = (TCHAR *)xi.getAttrValue(parent, xi.getAttrName(parent, i));
- else {
- TCHAR tmpgroup[1024];
- mir_sntprintf(tmpgroup, SIZEOF(tmpgroup), _T("%s\\%s"), xi.getAttrValue(parent, xi.getAttrName(parent, i)), group);
- group = tmpgroup;
- }
- break;
- }
- }
- parent = xi.getParent(parent);
- }
-
- if (group) {
- utfgroup = mir_utf8decodeT(_T2A(group));
- if ( !utfgroup) {
- isGroupUTF = 0;
- utfgroup = group;
- } else
- isGroupUTF = 1;
- }
-
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)MODULE);
- db_set_ts(hContact, MODULE, "Nick", title);
- db_set_ts(hContact, MODULE, "URL", url);
- db_set_ts(hContact, MODULE, "Homepage", siteurl);
- db_set_b(hContact, MODULE, "CheckState", 1);
- db_set_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME);
- db_set_ts(hContact, MODULE, "MsgFormat", _T(TAGSDEFAULT));
- db_set_w(hContact, MODULE, "Status", CallProtoService(MODULE, PS_GETSTATUS, 0, 0));
- if (utfgroup) {
- db_set_ts(hContact, "CList", "Group", utfgroup);
- int hGroup = 1;
- char *group_name;
- BYTE GroupExist = 0;
- do {
- group_name = (char *)CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, 0);
- if (group_name != NULL && !strcmp(group_name, _T2A(utfgroup))) {
- GroupExist = 1;
- break;
- }
- hGroup++;
- }
- while (group_name);
-
- if(!GroupExist)
- CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)utfgroup);
- }
- if (isTitleUTF)
- mir_free(title);
- if (isURLUTF)
- mir_free(url);
- if (isGroupUTF)
- mir_free(utfgroup);
- if (isSiteURLUTF)
- mir_free(siteurl);
-
- HXML tmpnode = node;
- node = xi.getNextNode(node);
- if ( !node) {
- do {
- node = tmpnode;
- node = xi.getParent(node);
- tmpnode = node;
- node = xi.getNextNode(node);
- if (node)
- break;
- }
- while (lstrcmpi(xi.getName(tmpnode), _T("body")));
- }
- }
- }
- }
- else MessageBox(NULL, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR);
- xi.destroyNode(hXml);
- }
- else MessageBox(NULL, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR);
-
- DeleteAllItems(hwndList);
- UpdateList(hwndList);
- }
- mir_free(tszMirDir);
+ if ( !ImportFeedsDialog()) {
+ DeleteAllItems(hwndList);
+ UpdateList(hwndList);
}
return FALSE;
diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp index 43ecd6bd14..e29d9902b7 100644 --- a/plugins/NewsAggregator/Src/Services.cpp +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -70,7 +70,7 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam) return 0;
}
-int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam)
+int NewsAggrPreShutdown(WPARAM wParam, LPARAM lParam)
{
if (hAddFeedDlg)
SendMessage(hAddFeedDlg, WM_CLOSE, 0, 0);
@@ -85,14 +85,14 @@ int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam) INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam)
{
if(lParam) {
- lstrcpynA((char*)lParam, MODULE, wParam);
+ lstrcpynA((char *)lParam, MODULE, wParam);
return 0;
}
return 1;
}
-INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp)
+INT_PTR NewsAggrGetCaps(WPARAM wp, LPARAM lp)
{
switch(wp) {
case PFLAGNUM_1:
@@ -111,14 +111,14 @@ INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp) }
}
-INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/)
+INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM)
{
int nStatus = wp;
if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus)) {
int nOldStatus = g_nStatus;
if(nStatus != g_nStatus) {
g_nStatus = nStatus;
- mir_forkthread(WorkingThread, (void*)g_nStatus);
+ mir_forkthread(WorkingThread, (void *)g_nStatus);
ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
}
}
@@ -126,12 +126,12 @@ INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/) return 0;
}
-INT_PTR NewsAggrGetStatus(WPARAM/* wp*/,LPARAM/* lp*/)
+INT_PTR NewsAggrGetStatus(WPARAM, LPARAM)
{
return g_nStatus;
}
-INT_PTR NewsAggrLoadIcon(WPARAM wParam,LPARAM lParam)
+INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM lParam)
{
return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0;
}
@@ -139,17 +139,17 @@ INT_PTR NewsAggrLoadIcon(WPARAM wParam,LPARAM lParam) static void __cdecl AckThreadProc(HANDLE param)
{
Sleep(100);
- ProtoBroadcastAck(MODULE, param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(MODULE, param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
-INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam)
+INT_PTR NewsAggrGetInfo(WPARAM wParam, LPARAM lParam)
{
- CCSDATA *ccs = (CCSDATA *) lParam;
+ CCSDATA *ccs = (CCSDATA *)lParam;
mir_forkthread(AckThreadProc, ccs->hContact);
return 0;
}
-INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam)
+INT_PTR CheckAllFeeds(WPARAM wParam, LPARAM lParam)
{
for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
if (lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
@@ -163,7 +163,7 @@ INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam) return 0;
}
-INT_PTR AddFeed(WPARAM wParam,LPARAM lParam)
+INT_PTR AddFeed(WPARAM wParam, LPARAM lParam)
{
hAddFeedDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADDFEED), NULL, DlgProcAddFeedOpts);
ShowWindow(hAddFeedDlg, SW_SHOW);
@@ -172,13 +172,12 @@ INT_PTR AddFeed(WPARAM wParam,LPARAM lParam) INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact = (HANDLE) wParam;
- HWND hChangeFeedDlg = WindowList_Find(hChangeFeedDlgList,hContact);
+ HANDLE hContact = (HANDLE)wParam;
+ HWND hChangeFeedDlg = WindowList_Find(hChangeFeedDlgList, hContact);
if (!hChangeFeedDlg) {
hChangeFeedDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), NULL, DlgProcChangeFeedMenu, (LPARAM)hContact);
ShowWindow(hChangeFeedDlg, SW_SHOW);
- }
- else {
+ } else {
SetForegroundWindow(hChangeFeedDlg);
SetFocus(hChangeFeedDlg);
}
@@ -187,6 +186,7 @@ INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam) INT_PTR ImportFeeds(WPARAM wParam, LPARAM lParam)
{
+ ImportFeedsDialog();
return 0;
}
@@ -200,15 +200,15 @@ INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam) HANDLE hContact = (HANDLE)wParam;
if(IsMyContact(hContact))
UpdateListAdd(hContact);
- if (!ThreadRunning)
+ if ( !ThreadRunning)
mir_forkthread(UpdateThreadProc, (LPVOID)FALSE);
return 0;
}
INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
- PROTO_AVATAR_INFORMATIONT* pai = (PROTO_AVATAR_INFORMATIONT*) lParam;
- if (!IsMyContact(pai->hContact))
+ PROTO_AVATAR_INFORMATIONT *pai = (PROTO_AVATAR_INFORMATIONT *)lParam;
+ if ( !IsMyContact(pai->hContact))
return GAIR_NOAVATAR;
// if GAIF_FORCE is set, we are updating the feed
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index 9d2181df73..d8e74617b1 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -1327,3 +1327,175 @@ VOID CheckCurrentFeedAvatar(HANDLE hContact) }
}
}
+
+int ImportFeedsDialog()
+ {
+ TCHAR FileName[MAX_PATH];
+ TCHAR *tszMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+
+ OPENFILENAME ofn = {0};
+ ofn.lStructSize = sizeof(ofn);
+ TCHAR tmp[MAX_PATH];
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.opml, *.xml)%c*.opml;*.xml%c%c"), TranslateT("OPML files"), 0, 0, 0);
+ ofn.lpstrFilter = tmp;
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = FileName;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = tszMirDir;
+ *FileName = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn)) {
+ int bytesParsed = 0;
+ HXML hXml = xi.parseFile(FileName, &bytesParsed, NULL);
+ if(hXml != NULL) {
+ BYTE isTitleUTF = 0, isURLUTF = 0, isSiteURLUTF = 0, isGroupUTF = 0;
+ HXML node = xi.getChildByPath(hXml, _T("opml/body/outline"), 0);
+ if ( !node)
+ node = xi.getChildByPath(hXml, _T("body/outline"), 0);
+ if (node) {
+ while (node) {
+ int outlineAttr = xi.getAttrCount(node);
+ int outlineChildsCount = xi.getChildCount(node);
+ TCHAR *type = (TCHAR *)xi.getAttrValue(node, _T("type"));
+ if ( !type && !outlineChildsCount) {
+ HXML tmpnode = node;
+ node = xi.getNextNode(node);
+ if ( !node) {
+ do {
+ node = tmpnode;
+ node = xi.getParent(node);
+ tmpnode = node;
+ node = xi.getNextNode(node);
+ if (node)
+ break;
+ } while (lstrcmpi(xi.getName(node), _T("body")));
+ }
+ }
+ else if (!type && outlineChildsCount)
+ node = xi.getFirstChild(node);
+ else if (type) {
+ TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL, *utfgroup = NULL;
+ for (int i = 0; i < outlineAttr; i++) {
+ if (!lstrcmpi(xi.getAttrName(node, i), _T("title"))) {
+ title = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
+ if ( !title) {
+ isTitleUTF = 0;
+ title = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
+ } else
+ isTitleUTF = 1;
+ continue;
+ }
+ if (!lstrcmpi(xi.getAttrName(node, i), _T("xmlUrl"))) {
+ url = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
+ if ( !url) {
+ isURLUTF = 0;
+ url = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
+ } else
+ isURLUTF = 1;
+ continue;
+ }
+ if (!lstrcmpi(xi.getAttrName(node, i), _T("htmlUrl"))) {
+ siteurl = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
+ if ( !siteurl) {
+ isSiteURLUTF = 0;
+ siteurl = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i));
+ } else
+ isSiteURLUTF = 1;
+ continue;
+ }
+ if (title && url && siteurl)
+ break;
+ }
+
+ HXML parent = xi.getParent(node);
+ while (lstrcmpi(xi.getName(parent), _T("body"))) {
+ for (int i = 0; i < xi.getAttrCount(parent); i++) {
+ if (!lstrcmpi(xi.getAttrName(parent, i), _T("title"))) {
+ if ( !group)
+ group = (TCHAR *)xi.getAttrValue(parent, xi.getAttrName(parent, i));
+ else {
+ TCHAR tmpgroup[1024];
+ mir_sntprintf(tmpgroup, SIZEOF(tmpgroup), _T("%s\\%s"), xi.getAttrValue(parent, xi.getAttrName(parent, i)), group);
+ group = tmpgroup;
+ }
+ break;
+ }
+ }
+ parent = xi.getParent(parent);
+ }
+
+ if (group) {
+ utfgroup = mir_utf8decodeT(_T2A(group));
+ if ( !utfgroup) {
+ isGroupUTF = 0;
+ utfgroup = group;
+ } else
+ isGroupUTF = 1;
+ }
+
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)MODULE);
+ db_set_ts(hContact, MODULE, "Nick", title);
+ db_set_ts(hContact, MODULE, "URL", url);
+ db_set_ts(hContact, MODULE, "Homepage", siteurl);
+ db_set_b(hContact, MODULE, "CheckState", 1);
+ db_set_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME);
+ db_set_ts(hContact, MODULE, "MsgFormat", _T(TAGSDEFAULT));
+ db_set_w(hContact, MODULE, "Status", CallProtoService(MODULE, PS_GETSTATUS, 0, 0));
+ if (utfgroup) {
+ db_set_ts(hContact, "CList", "Group", utfgroup);
+ int hGroup = 1;
+ char *group_name;
+ BYTE GroupExist = 0;
+ do {
+ group_name = (char *)CallService(MS_CLIST_GROUPGETNAME, (WPARAM)hGroup, 0);
+ if (group_name != NULL && !strcmp(group_name, _T2A(utfgroup))) {
+ GroupExist = 1;
+ break;
+ }
+ hGroup++;
+ }
+ while (group_name);
+
+ if(!GroupExist)
+ CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)utfgroup);
+ }
+ if (isTitleUTF)
+ mir_free(title);
+ if (isURLUTF)
+ mir_free(url);
+ if (isGroupUTF)
+ mir_free(utfgroup);
+ if (isSiteURLUTF)
+ mir_free(siteurl);
+
+ HXML tmpnode = node;
+ node = xi.getNextNode(node);
+ if ( !node) {
+ do {
+ node = tmpnode;
+ node = xi.getParent(node);
+ tmpnode = node;
+ node = xi.getNextNode(node);
+ if (node)
+ break;
+ }
+ while (lstrcmpi(xi.getName(tmpnode), _T("body")));
+ }
+ }
+ }
+ }
+ else MessageBox(NULL, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR);
+ xi.destroyNode(hXml);
+ }
+ else MessageBox(NULL, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR);
+
+ mir_free(tszMirDir);
+ return 0;
+ }
+ mir_free(tszMirDir);
+ return 1;
+ }
|