summaryrefslogtreecommitdiff
path: root/plugins/NewsAggregator/Src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-30 19:00:03 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-30 19:00:03 +0000
commit7555d4a9c79be387c6c151db7aa2ff26016e382b (patch)
treead972f32bd0a327d44be5c63393a142d5093e0b1 /plugins/NewsAggregator/Src
parentae4cd75ad09d77ce4a7a4412767c23a095ff6bab (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4258 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewsAggregator/Src')
-rw-r--r--plugins/NewsAggregator/Src/Icons.cpp24
-rw-r--r--plugins/NewsAggregator/Src/NewsAggregator.cpp43
-rw-r--r--plugins/NewsAggregator/Src/Options.cpp1293
-rw-r--r--plugins/NewsAggregator/Src/Services.cpp64
-rw-r--r--plugins/NewsAggregator/Src/Update.cpp41
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp825
6 files changed, 972 insertions, 1318 deletions
diff --git a/plugins/NewsAggregator/Src/Icons.cpp b/plugins/NewsAggregator/Src/Icons.cpp
index d6714cc37c..3fda249194 100644
--- a/plugins/NewsAggregator/Src/Icons.cpp
+++ b/plugins/NewsAggregator/Src/Icons.cpp
@@ -21,14 +21,14 @@ Boston, MA 02111-1307, USA.
static IconItem iconList[] =
{
- {LPGEN("Protocol icon"), "main", IDI_ICON},
- {LPGEN("Check All Feeds"), "checkall", IDI_CHECKALL},
- {LPGEN("Add Feed"), "addfeed", IDI_ADDFEED},
- {LPGEN("Import Feeds"), "importfeeds", IDI_IMPORTFEEDS},
- {LPGEN("Export Feeds"), "exportfeeds", IDI_EXPORTFEEDS},
- {LPGEN("Check Feed"), "checkfeed", IDI_CHECKALL},
- {LPGEN("Auto Update Enabled"), "enabled", IDI_ENABLED},
- {LPGEN("Auto Update Disabled"), "disabled", IDI_DISABLED}
+ { LPGEN("Protocol icon"), "main", IDI_ICON},
+ { LPGEN("Check All Feeds"), "checkall", IDI_CHECKALL},
+ { LPGEN("Add Feed"), "addfeed", IDI_ADDFEED},
+ { LPGEN("Import Feeds"), "importfeeds", IDI_IMPORTFEEDS},
+ { LPGEN("Export Feeds"), "exportfeeds", IDI_EXPORTFEEDS},
+ { LPGEN("Check Feed"), "checkfeed", IDI_CHECKALL},
+ { LPGEN("Auto Update Enabled"), "enabled", IDI_ENABLED},
+ { LPGEN("Auto Update Disabled"), "disabled", IDI_DISABLED}
};
VOID InitIcons()
@@ -36,18 +36,18 @@ VOID InitIcons()
Icon_Register(hInst, LPGEN("News Aggregator"), iconList, SIZEOF(iconList), MODULE);
}
-HICON LoadIconEx(const char* name, BOOL big)
+HICON LoadIconEx(const char *name, BOOL big)
{
char szSettingName[100];
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, name);
return Skin_GetIcon(szSettingName, big);
}
-HANDLE GetIconHandle(const char* name)
+HANDLE GetIconHandle(const char *name)
{
for (int i=0; i < SIZEOF(iconList); i++)
- if (strcmp(iconList[i].szName, name) == 0)
+ if ( !strcmp(iconList[i].szName, name))
return iconList[i].hIcolib;
return NULL;
-} \ No newline at end of file
+}
diff --git a/plugins/NewsAggregator/Src/NewsAggregator.cpp b/plugins/NewsAggregator/Src/NewsAggregator.cpp
index 786313b309..cb6ca96129 100644
--- a/plugins/NewsAggregator/Src/NewsAggregator.cpp
+++ b/plugins/NewsAggregator/Src/NewsAggregator.cpp
@@ -23,14 +23,11 @@ HINSTANCE hInst = NULL;
int hLangpack;
HANDLE hPrebuildMenuHook = NULL;
-HANDLE hProtoService[8];
HWND hAddFeedDlg;
HANDLE hChangeFeedDlgList = NULL;
XML_API xi = {0};
TCHAR tszRoot[MAX_PATH] = {0};
HANDLE hUpdateMutex;
-#define NUM_SERVICES 7
-HANDLE hService[NUM_SERVICES];
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
@@ -59,7 +56,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
extern "C" __declspec(dllexport) int Load(void)
{
-
mir_getLP(&pluginInfoEx);
mir_getXI(&xi);
@@ -77,33 +73,28 @@ extern "C" __declspec(dllexport) int Load(void)
pd.type = PROTOTYPE_VIRTUAL;
CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
- hProtoService[0] = CreateProtoServiceFunction(MODULE, PS_GETNAME, NewsAggrGetName);
- hProtoService[1] = CreateProtoServiceFunction(MODULE, PS_GETCAPS, NewsAggrGetCaps);
- hProtoService[2] = CreateProtoServiceFunction(MODULE, PS_SETSTATUS, NewsAggrSetStatus);
- hProtoService[3] = CreateProtoServiceFunction(MODULE, PS_GETSTATUS, NewsAggrGetStatus);
- 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_NEWSAGGREGATOR_CHECKALLFEEDS, CheckAllFeeds);
- hService[1] = CreateServiceFunction(MS_NEWSAGGREGATOR_ADDFEED, AddFeed);
- hService[2] = CreateServiceFunction(MS_NEWSAGGREGATOR_IMPORTFEEDS, ImportFeeds);
- hService[3] = CreateServiceFunction(MS_NEWSAGGREGATOR_EXPORTFEEDS, ExportFeeds);
- hService[4] = CreateServiceFunction(MS_NEWSAGGREGATOR_CHECKFEED, CheckFeed);
- hService[5] = CreateServiceFunction(MS_NEWSAGGREGATOR_CHANGEFEED, ChangeFeed);
- hService[6] = CreateServiceFunction(MS_NEWSAGGREGATOR_ENABLED, EnableDisable);
-
+ CreateProtoServiceFunction(MODULE, PS_GETNAME, NewsAggrGetName);
+ CreateProtoServiceFunction(MODULE, PS_GETCAPS, NewsAggrGetCaps);
+ CreateProtoServiceFunction(MODULE, PS_SETSTATUS, NewsAggrSetStatus);
+ CreateProtoServiceFunction(MODULE, PS_GETSTATUS, NewsAggrGetStatus);
+ CreateProtoServiceFunction(MODULE, PS_LOADICON, NewsAggrLoadIcon);
+ CreateProtoServiceFunction(MODULE, PSS_GETINFO, NewsAggrGetInfo);
+ CreateProtoServiceFunction(MODULE, PS_GETAVATARINFOT, NewsAggrGetAvatarInfo);
+ CreateProtoServiceFunction(MODULE, PSR_MESSAGE, NewsAggrRecvMessage);
+
+ CreateServiceFunction(MS_NEWSAGGREGATOR_CHECKALLFEEDS, CheckAllFeeds);
+ CreateServiceFunction(MS_NEWSAGGREGATOR_ADDFEED, AddFeed);
+ CreateServiceFunction(MS_NEWSAGGREGATOR_IMPORTFEEDS, ImportFeeds);
+ CreateServiceFunction(MS_NEWSAGGREGATOR_EXPORTFEEDS, ExportFeeds);
+ CreateServiceFunction(MS_NEWSAGGREGATOR_CHECKFEED, CheckFeed);
+ CreateServiceFunction(MS_NEWSAGGREGATOR_CHANGEFEED, ChangeFeed);
+ CreateServiceFunction(MS_NEWSAGGREGATOR_ENABLED, EnableDisable);
return 0;
}
extern "C" __declspec(dllexport) int Unload(void)
{
- for (int i = 0;i<NUM_SERVICES;i++)
- DestroyServiceFunction(hService[i]);
-
DestroyUpdateList();
CloseHandle(hUpdateMutex);
-
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp
index 271a3bc6d3..53d07110f4 100644
--- a/plugins/NewsAggregator/Src/Options.cpp
+++ b/plugins/NewsAggregator/Src/Options.cpp
@@ -21,141 +21,121 @@ Boston, MA 02111-1307, USA.
INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SetWindowText(hwndDlg, TranslateT("Add Feed"));
- SetDlgItemText(hwndDlg, IDC_FEEDURL, _T("http://"));
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
- SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0);
- SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DEFAULT_UPDATE_TIME, TRUE);
- SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
- Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,MODULE,"AddDlg");
- return TRUE;
- }
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDOK:
- {
- TCHAR str[MAX_PATH];
- if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)))
- {
- MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0)
- {
- MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0)
- {
- MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str)))
- {
- MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
- break;
- }
- else
- {
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)MODULE);
- GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "Nick", str);
- HWND hwndList = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "URL", str);
- DBWriteContactSettingByte(hContact, MODULE, "CheckState", 1);
- DBWriteContactSettingDword(hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
- GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "MsgFormat", str);
- DBWriteContactSettingWord(hContact, MODULE, "Status", CallProtoService(MODULE, PS_GETSTATUS, 0, 0));
- if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
- DBWriteContactSettingByte(hContact, MODULE, "UseAuth", 1);
- GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "Password", str);
- }
- DeleteAllItems(hwndList);
- UpdateList(hwndList);
- }
- }
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SetWindowText(hwndDlg, TranslateT("Add Feed"));
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, _T("http://"));
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DEFAULT_UPDATE_TIME, TRUE);
+ SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,MODULE,"AddDlg");
+ return TRUE;
- case IDCANCEL:
- DestroyWindow(hwndDlg);
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ TCHAR str[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
break;
-
- case IDC_USEAUTH:
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- }
- else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
- }
- }
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0) {
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
break;
-
- case IDC_TAGHELP:
- {
- TCHAR tszTagHelp[1024];
- mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
- _T("#<title>#"), TranslateT("The title of the item."),
- _T("#<description>#"), TranslateT("The item synopsis."),
- _T("#<link>#"), TranslateT("The URL of the item."),
- _T("#<author>#"), TranslateT("Email address of the author of the item."),
- _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."),
- _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."),
- _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")
- );
- MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
- }
+ }
+ if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0) {
+ MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
break;
-
- case IDC_RESET:
- if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
break;
+ }
+
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)MODULE);
+ GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "Nick", str);
+ HWND hwndList = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "URL", str);
+ DBWriteContactSettingByte(hContact, MODULE, "CheckState", 1);
+ DBWriteContactSettingDword(hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
+ GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "MsgFormat", str);
+ db_set_w(hContact, MODULE, "Status", CallProtoService(MODULE, PS_GETSTATUS, 0, 0));
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ DBWriteContactSettingByte(hContact, MODULE, "UseAuth", 1);
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "Login", str);
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "Password", str);
+ }
+ DeleteAllItems(hwndList);
+ UpdateList(hwndList);
+ }
- case IDC_DISCOVERY:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
- SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
- TCHAR tszURL[MAX_PATH] = {0}, *tszTitle = NULL;
- if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
- tszTitle = CheckFeed(tszURL, hwndDlg);
- else
- MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
- SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
- }
- break;
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case IDC_USEAUTH:
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
}
break;
- }
- case WM_CLOSE:
- {
- DestroyWindow(hwndDlg);
+
+ case IDC_TAGHELP:
+ {
+ TCHAR tszTagHelp[1024];
+ mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
+ _T("#<title>#"), TranslateT("The title of the item."),
+ _T("#<description>#"), TranslateT("The item synopsis."),
+ _T("#<link>#"), TranslateT("The URL of the item."),
+ _T("#<author>#"), TranslateT("Email address of the author of the item."),
+ _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."),
+ _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."),
+ _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")
+ );
+ MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
+ }
break;
+
+ case IDC_RESET:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ break;
+
+ case IDC_DISCOVERY:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
+ TCHAR tszURL[MAX_PATH] = {0}, *tszTitle = NULL;
+ if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
+ tszTitle = CheckFeed(tszURL, hwndDlg);
+ else
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
}
- case WM_DESTROY:
- {
- Utils_SaveWindowPosition(hwndDlg,NULL,MODULE,"AddDlg");
- }
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ Utils_SaveWindowPosition(hwndDlg,NULL,MODULE,"AddDlg");
+ break;
}
return FALSE;
@@ -163,11 +143,10 @@ 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)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
ItemInfo &SelItem = *(ItemInfo*)lParam;
ItemInfo *nSelItem = new ItemInfo(SelItem);
SetWindowText(hwndDlg, TranslateT("Change Feed"));
@@ -175,188 +154,158 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if (IsMyContact(hContact))
- {
+ while (hContact != NULL) {
+ if (IsMyContact(hContact)) {
DBVARIANT dbNick = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
+ if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
continue;
- else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0)
- {
- DBFreeVariant(&dbNick);
+ else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) {
+ db_free(&dbNick);
DBVARIANT dbURL = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ if (db_get_ts(hContact, MODULE, "URL", &dbURL))
continue;
- else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0)
- {
- DBFreeVariant(&dbURL);
+ else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) {
+ db_free(&dbURL);
nSelItem->hContact = hContact;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
- SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DBGetContactSettingDword(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
DBVARIANT dbMsg = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
- {
+ if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
- DBFreeVariant(&dbMsg);
+ db_free(&dbMsg);
}
- if (DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
- {
+ if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
DBVARIANT dbLogin = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Login", &dbLogin))
- {
+ if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
- DBFreeVariant(&dbLogin);
+ db_free(&dbLogin);
}
DBVARIANT dbPass = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Password", &dbPass))
- {
+ if (!db_get_ts(hContact, MODULE, "Password", &dbPass)) {
SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
- DBFreeVariant(&dbPass);
+ db_free(&dbPass);
}
}
break;
}
- DBFreeVariant(&dbURL);
+ db_free(&dbURL);
}
- DBFreeVariant(&dbNick);
+ db_free(&dbNick);
}
hContact = db_find_next(hContact);
}
WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact);
Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg");
- return TRUE;
}
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDOK:
- {
- ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- TCHAR str[MAX_PATH];
- if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)))
- {
- MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0)
- {
- MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0)
- {
- MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str)))
- {
- MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
- break;
- }
- else
- {
- GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
- DBWriteContactSettingTString(SelItem->hContact, MODULE, "URL", str);
- GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
- DBWriteContactSettingTString(SelItem->hContact, MODULE, "Nick", str);
- DBWriteContactSettingDword(SelItem->hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
- GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
- DBWriteContactSettingTString(SelItem->hContact, MODULE, "MsgFormat", str);
- if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
- DBWriteContactSettingByte(SelItem->hContact, MODULE, "UseAuth", 1);
- GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
- DBWriteContactSettingTString(SelItem->hContact, MODULE, "Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- DBWriteContactSettingTString(SelItem->hContact, MODULE, "Password", str);
- }
- DeleteAllItems(SelItem->hwndList);
- UpdateList(SelItem->hwndList);
- }
- }
+ return TRUE;
- case IDCANCEL:
- DestroyWindow(hwndDlg);
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ TCHAR str[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
break;
-
- case IDC_USEAUTH:
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- }
- else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
- }
- break;
- }
-
- case IDC_TAGHELP:
- {
- TCHAR tszTagHelp[1024];
- mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
- _T("#<title>#"), TranslateT("The title of the item."),
- _T("#<description>#"), TranslateT("The item synopsis."),
- _T("#<link>#"), TranslateT("The URL of the item."),
- _T("#<author>#"), TranslateT("Email address of the author of the item."),
- _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."),
- _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."),
- _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")
- );
- MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
- }
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0) {
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
break;
-
- case IDC_RESET:
- if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ }
+ if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0) {
+ MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
break;
-
- case IDC_DISCOVERY:
- {
- TCHAR tszURL[MAX_PATH] = {0};
- if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
- SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
- TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg);
- SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
- SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
- }
- else
- MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- }
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
break;
+ }
+
+ GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
+ db_set_ts(SelItem->hContact, MODULE, "URL", str);
+ GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
+ db_set_ts(SelItem->hContact, MODULE, "Nick", str);
+ DBWriteContactSettingDword(SelItem->hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
+ GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
+ db_set_ts(SelItem->hContact, MODULE, "MsgFormat", str);
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ DBWriteContactSettingByte(SelItem->hContact, MODULE, "UseAuth", 1);
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ db_set_ts(SelItem->hContact, MODULE, "Login", str);
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ db_set_ts(SelItem->hContact, MODULE, "Password", str);
+ }
+ DeleteAllItems(SelItem->hwndList);
+ UpdateList(SelItem->hwndList);
}
- break;
- }
- case WM_CLOSE:
- {
+ case IDCANCEL:
DestroyWindow(hwndDlg);
break;
- }
- case WM_DESTROY:
- {
- HANDLE hContact = (HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- Utils_SaveWindowPosition(hwndDlg, hContact, MODULE, "ChangeDlg");
- WindowList_Remove(hChangeFeedDlgList, hwndDlg);
- ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- delete SelItem;
+ case IDC_USEAUTH:
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
+ }
+ break;
+
+ case IDC_TAGHELP:
+ {
+ TCHAR tszTagHelp[1024];
+ mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
+ _T("#<title>#"), TranslateT("The title of the item."),
+ _T("#<description>#"), TranslateT("The item synopsis."),
+ _T("#<link>#"), TranslateT("The URL of the item."),
+ _T("#<author>#"), TranslateT("Email address of the author of the item."),
+ _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."),
+ _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."),
+ _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")
+ );
+ MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
+ }
break;
+
+ case IDC_RESET:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ break;
+
+ case IDC_DISCOVERY:
+ TCHAR tszURL[MAX_PATH] = {0};
+ if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
+ TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
+ }
+ else MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
}
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ HANDLE hContact = (HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Utils_SaveWindowPosition(hwndDlg, hContact, MODULE, "ChangeDlg");
+ WindowList_Remove(hChangeFeedDlgList, hwndDlg);
+ ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ delete SelItem;
+ break;
}
return FALSE;
@@ -364,177 +313,144 @@ 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)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
SetWindowText(hwndDlg, TranslateT("Change Feed"));
SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, UDM_SETRANGE32, 0, 999);
HANDLE hContact = (HANDLE)lParam;
WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact);
Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg");
- DBVARIANT dbNick = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
- {
- SetDlgItemText(hwndDlg, IDC_FEEDTITLE, dbNick.ptszVal);
- DBFreeVariant(&dbNick);
- DBVARIANT dbURL = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
- {
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)lParam);
- SetDlgItemText(hwndDlg, IDC_FEEDURL, dbURL.ptszVal);
- DBFreeVariant(&dbURL);
- SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DBGetContactSettingDword(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
- DBVARIANT dbMsg = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
- {
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
- DBFreeVariant(&dbMsg);
- }
- if (DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
- {
- CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- DBVARIANT dbLogin = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Login", &dbLogin))
- {
- SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
- DBFreeVariant(&dbLogin);
- }
- DBVARIANT dbPass = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Password", &dbPass))
- {
- SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
- DBFreeVariant(&dbPass);
- }
- }
- break;
+ DBVARIANT dbv;
+ if (!db_get_ts(hContact, MODULE, "Nick", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULE, "URL", &dbv)) {
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)lParam);
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
+ if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
+ CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ if (!db_get_ts(hContact, MODULE, "Login", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_LOGIN, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULE, "Password", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_PASSWORD, dbv.ptszVal);
+ db_free(&dbv);
}
}
- return TRUE;
}
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDOK:
- {
- HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- TCHAR str[MAX_PATH];
- if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)))
- {
- MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0)
- {
- MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0)
- {
- MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
- break;
- }
- else if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str)))
- {
- MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
- break;
- }
- else
- {
- GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "URL", str);
- GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "Nick", str);
- DBWriteContactSettingDword(hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
- GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "MsgFormat", str);
- if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
- DBWriteContactSettingByte(hContact, MODULE, "UseAuth", 1);
- GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "Login", str);
- GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- DBWriteContactSettingTString(hContact, MODULE, "Password", str);
- }
- }
- }
+ return TRUE;
- case IDCANCEL:
- DestroyWindow(hwndDlg);
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ TCHAR str[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0) {
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0) {
+ MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str))) {
+ MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
break;
+ }
- case IDC_USEAUTH:
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- }
- else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
- }
- break;
- }
+ GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "URL", str);
+ GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "Nick", str);
+ DBWriteContactSettingDword(hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
+ GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "MsgFormat", str);
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ DBWriteContactSettingByte(hContact, MODULE, "UseAuth", 1);
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "Login", str);
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ db_set_ts(hContact, MODULE, "Password", str);
+ }
+ }
- case IDC_TAGHELP:
- {
- TCHAR tszTagHelp[1024];
- mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
- _T("#<title>#"), TranslateT("The title of the item."),
- _T("#<description>#"), TranslateT("The item synopsis."),
- _T("#<link>#"), TranslateT("The URL of the item."),
- _T("#<author>#"), TranslateT("Email address of the author of the item."),
- _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."),
- _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."),
- _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")
- );
- MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
- }
- break;
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
- case IDC_RESET:
- if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
- break;
+ case IDC_USEAUTH:
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
+ }
+ break;
- case IDC_DISCOVERY:
- {
- TCHAR tszURL[MAX_PATH] = {0};
- if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
- SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
- TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg);
- SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
- SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
- }
- else
- MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
- }
- break;
+ case IDC_TAGHELP:
+ {
+ TCHAR tszTagHelp[1024];
+ mir_sntprintf(tszTagHelp, SIZEOF(tszTagHelp), _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"),
+ _T("#<title>#"), TranslateT("The title of the item."),
+ _T("#<description>#"), TranslateT("The item synopsis."),
+ _T("#<link>#"), TranslateT("The URL of the item."),
+ _T("#<author>#"), TranslateT("Email address of the author of the item."),
+ _T("#<comments>#"), TranslateT("URL of a page for comments relating to the item."),
+ _T("#<guid>#"), TranslateT("A string that uniquely identifies the item."),
+ _T("#<category>#"), TranslateT("Specify one or more categories that the item belongs to.")
+ );
+ MessageBox(hwndDlg, tszTagHelp, TranslateT("Feed Tag Help"), MB_OK);
}
break;
- }
- case WM_CLOSE:
- {
- DestroyWindow(hwndDlg);
+ case IDC_RESET:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
break;
+
+ case IDC_DISCOVERY:
+ TCHAR tszURL[MAX_PATH] = {0};
+ if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
+ TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
+ }
+ else MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
}
- case WM_DESTROY:
- {
- HANDLE hContact = (HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- Utils_SaveWindowPosition(hwndDlg,hContact,MODULE,"ChangeDlg");
- WindowList_Remove(hChangeFeedDlgList,hwndDlg);
- }
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ HANDLE hContact = (HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Utils_SaveWindowPosition(hwndDlg,hContact,MODULE,"ChangeDlg");
+ WindowList_Remove(hChangeFeedDlgList,hwndDlg);
}
return FALSE;
@@ -543,336 +459,302 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_FEEDLIST);
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
- CreateList(hwndList);
- UpdateList(hwndList);
- CheckDlgButton(hwndDlg, IDC_STARTUPRETRIEVE, db_get_b(NULL, MODULE, "StartupRetrieve", 1));
- return TRUE;
- }
+ TranslateDialogDefault(hwndDlg);
+ 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))
- {
- case IDC_ADD:
- {
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcAddFeedOpts, (LPARAM)hwndList);
- }
- return FALSE;
-
- case IDC_CHANGE:
- {
- ItemInfo SelItem = {0};
- int sel = ListView_GetSelectionMark(hwndList);
- ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
- ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
- SelItem.hwndList = hwndList;
- SelItem.SelNumber = sel;
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem);
- }
- return FALSE;
+ switch (LOWORD(wParam)) {
+ case IDC_ADD:
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcAddFeedOpts, (LPARAM)hwndList);
+ return FALSE;
- case IDC_REMOVE:
- {
- if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Contact deleting"), MB_YESNO | MB_ICONWARNING) == IDYES)
- {
- 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);
-
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if(IsMyContact(hContact))
- {
- DBVARIANT dbNick = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
- break;
- else if (lstrcmp(dbNick.ptszVal, nick) == 0)
- {
- DBFreeVariant(&dbNick);
- DBVARIANT dbURL = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
- break;
- else if (lstrcmp(dbURL.ptszVal, url) == 0)
- {
- DBFreeVariant(&dbURL);
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
- ListView_DeleteItem(hwndList, sel);
- break;
- }
- DBFreeVariant(&dbURL);
- }
- DBFreeVariant(&dbNick);
+ case IDC_CHANGE:
+ {
+ ItemInfo SelItem = {0};
+ int sel = ListView_GetSelectionMark(hwndList);
+ ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
+ SelItem.hwndList = hwndList;
+ SelItem.SelNumber = sel;
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem);
+ }
+ return FALSE;
+
+ case IDC_REMOVE:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Contact deleting"), MB_YESNO | MB_ICONWARNING) == IDYES) {
+ 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);
+
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL) {
+ if(IsMyContact(hContact)) {
+ DBVARIANT dbNick = {0};
+ if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ break;
+ else if (lstrcmp(dbNick.ptszVal, nick) == 0) {
+ db_free(&dbNick);
+ DBVARIANT dbURL = {0};
+ if (db_get_ts(hContact, MODULE, "URL", &dbURL))
+ break;
+ else if (lstrcmp(dbURL.ptszVal, url) == 0) {
+ db_free(&dbURL);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ ListView_DeleteItem(hwndList, sel);
+ break;
}
- hContact = db_find_next(hContact);
+ db_free(&dbURL);
}
+ db_free(&dbNick);
}
+ hContact = db_find_next(hContact);
}
- return FALSE;
+ }
+ 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 isUTF = 0;
- if ( !lstrcmpi(xi.getAttrValue(hXml, _T("encoding")), _T("UTF-8")))
- isUTF = 1;
- 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);
- LPCTSTR tmp = xi.getName(node);
- if (node)
- break;
- } while (lstrcmpi(xi.getName(node), _T("body")));
+ 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 isUTF = 0;
+ if ( !lstrcmpi(xi.getAttrValue(hXml, _T("encoding")), _T("UTF-8")))
+ isUTF = 1;
+ 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);
+ LPCTSTR tmp = xi.getName(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, *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)
- {
- isUTF = 1;
- title = (TCHAR*)xi.getAttrValue(node, xi.getAttrName(node, i));
- }
- continue;
- }
- if (!lstrcmpi(xi.getAttrName(node, i), _T("xmlUrl")))
- {
- url = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
- if ( !url)
- url = (TCHAR*)xi.getAttrValue(node, xi.getAttrName(node, i));
- continue;
+ }
+ else if (!type && outlineChildsCount)
+ node = xi.getFirstChild(node);
+ else if (type) {
+ TCHAR *title = NULL, *url = 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) {
+ isUTF = 1;
+ title = (TCHAR*)xi.getAttrValue(node, xi.getAttrName(node, i));
}
- if (title && url)
- break;
+ continue;
+ }
+ if (!lstrcmpi(xi.getAttrName(node, i), _T("xmlUrl"))) {
+ url = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i))));
+ if ( !url)
+ url = (TCHAR*)xi.getAttrValue(node, xi.getAttrName(node, i));
+ continue;
}
+ if (title && url)
+ break;
+ }
- HXML parent = xi.getParent(node);
- LPCTSTR tmp = xi.getName(parent);
- 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;
+ HXML parent = xi.getParent(node);
+ LPCTSTR tmp = xi.getName(parent);
+ 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)
- utfgroup = group;
}
+ parent = xi.getParent(parent);
+ }
- 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_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 (group) {
+ utfgroup = mir_utf8decodeT(_T2A(group));
+ if ( !utfgroup)
+ utfgroup = group;
+ }
- if(!GroupExist)
- CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)utfgroup);
- }
- if (isUTF)
- {
- mir_free(title);
- mir_free(url);
- mir_free(utfgroup);
+ 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_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);
- 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")));
+ if(!GroupExist)
+ CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)utfgroup);
+ }
+ if (isUTF) {
+ mir_free(title);
+ mir_free(url);
+ mir_free(utfgroup);
+ }
+
+ 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);
+ }
+ }
+ else MessageBox(NULL, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR);
+ xi.destroyNode(hXml);
}
- mir_free(tszMirDir);
+ else MessageBox(NULL, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR);
+
+ DeleteAllItems(hwndList);
+ UpdateList(hwndList);
}
- return FALSE;
+ mir_free(tszMirDir);
+ }
+ return FALSE;
- case IDC_EXPORT:
- {
- 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)%c*.opml%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 (GetSaveFileName(&ofn))
- {
- HXML hXML = xi.createNode(_T("opml"), NULL, FALSE);
- xi.addAttr(hXML, _T("version"), _T("1.0"));
- HXML head = xi.addChild(hXML, _T("head"), NULL);
- HXML title = xi.addChild(head, _T("title"), _T("Miranda NG NewsAggregator plugin export"));
- xi.toFile(hXML, FileName, 1);
- }
+ case IDC_EXPORT:
+ {
+ 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)%c*.opml%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 (GetSaveFileName(&ofn)) {
+ HXML hXML = xi.createNode(_T("opml"), NULL, FALSE);
+ xi.addAttr(hXML, _T("version"), _T("1.0"));
+ HXML head = xi.addChild(hXML, _T("head"), NULL);
+ HXML title = xi.addChild(head, _T("title"), _T("Miranda NG NewsAggregator plugin export"));
+ xi.toFile(hXML, FileName, 1);
}
- return FALSE;
+ }
+ return FALSE;
- case IDC_STARTUPRETRIEVE:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
+ case IDC_STARTUPRETRIEVE:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
}
break;
- }
+
case WM_NOTIFY:
{
NMHDR *hdr = (NMHDR *)lParam;
- switch (hdr->code)
- {
- case PSN_APPLY:
+ switch (hdr->code) {
+ case PSN_APPLY:
+ {
+ db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE));
+ HANDLE hContact = db_find_first();
+ int i = 0;
+ while (hContact != NULL)
{
- db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE));
- HANDLE hContact = db_find_first();
- int i = 0;
- while (hContact != NULL)
+ if(IsMyContact(hContact))
{
- if(IsMyContact(hContact))
- {
- DBWriteContactSettingByte(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
- if (!ListView_GetCheckState(hwndList, i))
- DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
- else
- DBDeleteContactSetting(hContact,"CList","Hidden");
- i += 1;
- }
- hContact = db_find_next(hContact);
+ DBWriteContactSettingByte(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
+ if (!ListView_GetCheckState(hwndList, i))
+ DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
+ else
+ DBDeleteContactSetting(hContact,"CList","Hidden");
+ i += 1;
}
- break;
+ hContact = db_find_next(hContact);
}
+ break;
+ }
- case NM_DBLCLK:
- {
- ItemInfo SelItem = {0};
- int sel = ListView_GetHotItem(hwndList);
- if (sel != -1)
- {
- ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
- ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
- SelItem.hwndList = hwndList;
- SelItem.SelNumber = sel;
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem);
- }
- break;
+ case NM_DBLCLK:
+ {
+ ItemInfo SelItem = {0};
+ int sel = ListView_GetHotItem(hwndList);
+ if (sel != -1) {
+ ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
+ SelItem.hwndList = hwndList;
+ SelItem.SelNumber = sel;
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem);
}
+ break;
+ }
case LVN_ITEMCHANGED:
{
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if (((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) && !UpdateListFlag)
- {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
break;
}
}
@@ -883,8 +765,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
INT OptInit(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 100000000;
odp.hInstance = hInst;
odp.flags = ODPF_BOLDGROUPS;
@@ -894,4 +775,4 @@ INT OptInit(WPARAM wParam, LPARAM lParam)
odp.pfnDlgProc = UpdateNotifyOptsProc;
Options_AddPage(wParam, &odp);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp
index 65b0210605..4b2e38950d 100644
--- a/plugins/NewsAggregator/Src/Services.cpp
+++ b/plugins/NewsAggregator/Src/Services.cpp
@@ -25,20 +25,18 @@ HANDLE hTBButton = NULL, hNewsAggregatorFolder = NULL;
void SetContactStatus(HANDLE hContact, int nNewStatus)
{
- if(DBGetContactSettingWord(hContact, MODULE, "Status", ID_STATUS_ONLINE) != nNewStatus)
- DBWriteContactSettingWord(hContact, MODULE, "Status", nNewStatus);
+ if(db_get_w(hContact, MODULE, "Status", ID_STATUS_ONLINE) != nNewStatus)
+ db_set_w(hContact, MODULE, "Status", nNewStatus);
}
static void __cdecl WorkingThread(void* param)
{
int nStatus = (int)param;
HANDLE hContact= db_find_first();
- while (hContact != NULL)
- {
+ while (hContact != NULL) {
if(IsMyContact(hContact))
- {
SetContactStatus(hContact, nStatus);
- }
+
hContact = db_find_next(hContact);
}
}
@@ -58,10 +56,8 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam)
lstrcpyn(tszRoot, VARST( _T("%miranda_userdata%\\Avatars\\"_T(DEFAULT_AVATARS_FOLDER))), SIZEOF(tszRoot));
HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if(IsMyContact(hContact))
- {
+ while (hContact != NULL) {
+ if(IsMyContact(hContact)) {
if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1))
db_set_dw(hContact, MODULE, "LastCheck", time(NULL));
SetContactStatus(hContact, ID_STATUS_ONLINE);
@@ -84,34 +80,28 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam)
int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam)
{
if (hAddFeedDlg)
- {
SendMessage(hAddFeedDlg, WM_CLOSE, 0, 0);
- }
+
WindowList_Broadcast(hChangeFeedDlgList, WM_CLOSE, 0, 0);
KillTimer(NULL, timerId);
NetlibUnInit();
-
return 0;
}
INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam)
{
- if(lParam)
- {
+ if(lParam) {
lstrcpynA((char*)lParam, MODULE, wParam);
return 0;
}
- else
- {
- return 1;
- }
+
+ return 1;
}
INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp)
{
- switch(wp)
- {
+ switch(wp) {
case PFLAGNUM_1:
return PF1_IM | PF1_PEER2PEER;
case PFLAGNUM_3:
@@ -131,16 +121,13 @@ INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp)
INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/)
{
int nStatus = wp;
- if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus))
- {
+ if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus)) {
int nOldStatus = g_nStatus;
- if(nStatus != g_nStatus)
- {
+ if(nStatus != g_nStatus) {
g_nStatus = nStatus;
mir_forkthread(WorkingThread, (void*)g_nStatus);
ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
}
-
}
return 0;
@@ -172,9 +159,8 @@ INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam)
INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if (IsMyContact(hContact) && lParam && DBGetContactSettingDword(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
+ while (hContact != NULL) {
+ if (IsMyContact(hContact) && lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(hContact);
else if (IsMyContact(hContact) && !lParam)
UpdateListAdd(hContact);
@@ -197,13 +183,11 @@ INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE) wParam;
HWND hChangeFeedDlg = WindowList_Find(hChangeFeedDlgList,hContact);
- if (!hChangeFeedDlg)
- {
+ if (!hChangeFeedDlg) {
hChangeFeedDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), NULL, DlgProcChangeFeedMenu, (LPARAM)hContact);
ShowWindow(hChangeFeedDlg, SW_SHOW);
}
- else
- {
+ else {
SetForegroundWindow(hChangeFeedDlg);
SetFocus(hChangeFeedDlg);
}
@@ -233,23 +217,21 @@ INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam)
INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
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
// otherwise, cached avatar is used
- if (wParam & GAIF_FORCE && DBGetContactSettingDword(pai->hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
+ if (wParam & GAIF_FORCE && db_get_dw(pai->hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(pai->hContact);
if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && !ThreadRunning)
mir_forkthread(UpdateThreadProc, (LPVOID)TRUE);
- DBVARIANT dbv = {0};
- if(DBGetContactSettingTString(pai->hContact, MODULE, "ImageURL", &dbv))
- {
+ DBVARIANT dbv;
+ if(db_get_ts(pai->hContact, MODULE, "ImageURL", &dbv))
return GAIR_NOAVATAR;
- }
- DBFreeVariant(&dbv);
+
+ db_free(&dbv);
return GAIR_WAITFOR;
}
@@ -297,4 +279,4 @@ int OnToolbarLoaded(WPARAM wParam, LPARAM lParam)
ttb.dwFlags = (db_get_b(NULL, MODULE, "AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE;
hTBButton = TopToolbar_AddButton(&ttb);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp
index 677cade12b..1846b7271a 100644
--- a/plugins/NewsAggregator/Src/Update.cpp
+++ b/plugins/NewsAggregator/Src/Update.cpp
@@ -28,19 +28,14 @@ UPDATELIST *UpdateListTail = NULL;
VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
// only run if it is not current updating and the auto update option is enabled
- if (!ThreadRunning && !Miranda_Terminated())
- {
+ if (!ThreadRunning && !Miranda_Terminated()) {
BOOL HaveUpdates = FALSE;
HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if(IsMyContact(hContact))
- {
- if (DBGetContactSettingDword(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
- {
- double diff = difftime(time(NULL), DBGetContactSettingDword(hContact, MODULE, "LastCheck", 0));
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= DBGetContactSettingDword(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60)
- {
+ while (hContact != NULL) {
+ if(IsMyContact(hContact)) {
+ if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) {
+ double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
+ if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
UpdateListAdd(hContact);
HaveUpdates = TRUE;
}
@@ -60,8 +55,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) && !Miranda_Terminated())
- {
+ if (db_get_b(NULL, MODULE, "AutoUpdate", 1) && !Miranda_Terminated()) {
if (db_get_b(NULL, MODULE, "StartupRetrieve", 1))
CheckAllFeeds(0, 1);
timerId = SetTimer(NULL, 0, 30000, (TIMERPROC)timerProc);
@@ -70,9 +64,7 @@ VOID CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
void UpdateListAdd(HANDLE hContact)
{
- UPDATELIST *newItem;
-
- newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
+ UPDATELIST *newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
newItem->hContact = hContact;
newItem->next = NULL;
@@ -92,10 +84,8 @@ HANDLE UpdateGetFirst()
WaitForSingleObject(hUpdateMutex, INFINITE);
- if (UpdateListHead != NULL)
- {
+ if (UpdateListHead != NULL) {
UPDATELIST* Item = UpdateListHead;
-
hContact = Item->hContact;
UpdateListHead = Item->next;
mir_free(Item);
@@ -111,15 +101,11 @@ HANDLE UpdateGetFirst()
void DestroyUpdateList(void)
{
- UPDATELIST *temp;
-
WaitForSingleObject(hUpdateMutex, INFINITE);
- temp = UpdateListHead;
-
// free the list one by one
- while (temp != NULL)
- {
+ UPDATELIST *temp = UpdateListHead;
+ while (temp != NULL) {
UpdateListHead = temp->next;
mir_free(temp);
temp = UpdateListHead;
@@ -133,8 +119,7 @@ void DestroyUpdateList(void)
void UpdateThreadProc(LPVOID AvatarCheck)
{
WaitForSingleObject(hUpdateMutex, INFINITE);
- if (ThreadRunning)
- {
+ if (ThreadRunning) {
ReleaseMutex(hUpdateMutex);
return;
}
@@ -150,4 +135,4 @@ void UpdateThreadProc(LPVOID AvatarCheck)
// exit the update thread
ThreadRunning = FALSE;
-} \ No newline at end of file
+}
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index 8ec665374a..6edc22936c 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -24,14 +24,13 @@ BOOL UpdateListFlag = FALSE;
BOOL IsMyContact(HANDLE hContact)
{
- const char* szProto = GetContactProto(hContact);
+ const char *szProto = GetContactProto(hContact);
return szProto != NULL && strcmp(MODULE, szProto) == 0;
}
VOID NetlibInit()
{
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof(nlu);
+ NETLIBUSER nlu = { sizeof(nlu) };
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = TranslateT("NewsAggregator HTTP connection");
nlu.szSettingsModule = MODULE;
@@ -47,8 +46,7 @@ VOID NetlibUnInit()
static void arrayToHex(BYTE* data, size_t datasz, char* res)
{
char* resptr = res;
- for (unsigned i=0; i<datasz ; i++)
- {
+ for (unsigned i=0; i < datasz ; i++) {
const BYTE ch = data[i];
const char ch0 = (char)(ch >> 4);
@@ -63,59 +61,45 @@ static void arrayToHex(BYTE* data, size_t datasz, char* res)
int GetImageFormat(const TCHAR* ext)
{
if (!lstrcmp(ext,_T(".jpg")) || !lstrcmp(ext,_T(".jpeg")))
- {
return PA_FORMAT_JPEG;
- }
- else if (!lstrcmp(ext,_T(".png")))
- {
+
+ if (!lstrcmp(ext,_T(".png")))
return PA_FORMAT_PNG;
- }
- else if (!lstrcmp(ext,_T(".gif")))
- {
+
+ if (!lstrcmp(ext,_T(".gif")))
return PA_FORMAT_GIF;
- }
- else if (!lstrcmp(ext,_T(".ico")))
- {
+
+ if (!lstrcmp(ext,_T(".ico")))
return PA_FORMAT_ICON;
- }
- else if (!lstrcmp(ext,_T(".bmp")))
- {
+
+ if (!lstrcmp(ext,_T(".bmp")))
return PA_FORMAT_BMP;
- }
- else if (!lstrcmp(ext,_T(".swf")))
- {
+
+ if (!lstrcmp(ext,_T(".swf")))
return PA_FORMAT_SWF;
- }
- else if (!lstrcmp(ext,_T(".xml")))
- {
+
+ if (!lstrcmp(ext,_T(".xml")))
return PA_FORMAT_XML;
- }
- else
- {
- return PA_FORMAT_UNKNOWN;
- }
+
+ return PA_FORMAT_UNKNOWN;
}
+
void CreateAuthString(char* auth, HANDLE hContact, HWND hwndDlg)
{
+ DBVARIANT dbv;
char *user = NULL, *pass = NULL;
TCHAR *tlogin = NULL, *tpass = NULL, buf[MAX_PATH] = {0};
- if (hContact && DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
- {
- DBVARIANT dbLogin = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Login", &dbLogin))
- {
- tlogin = mir_tstrdup(dbLogin.ptszVal);
- DBFreeVariant(&dbLogin);
+ if (hContact && db_get_b(hContact, MODULE, "UseAuth", 0)) {
+ if (!db_get_ts(hContact, MODULE, "Login", &dbv)) {
+ tlogin = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
- DBVARIANT dbPass = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Password", &dbPass))
- {
- tpass = mir_tstrdup(dbPass.ptszVal);
- DBFreeVariant(&dbPass);
+ if (!db_get_ts(hContact, MODULE, "Password", &dbv)) {
+ tpass = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
}
}
- else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
+ else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf));
tlogin = buf;
GetDlgItemText(hwndDlg, IDC_PASSWORD, buf, SIZEOF(buf));
@@ -162,8 +146,7 @@ VOID GetNewsData(TCHAR *tszUrl, char** szData, HANDLE hContact, HWND hwndDlg)
nlhr.headers[3].szValue = "close";
nlhr.headers[4].szName = "Accept";
nlhr.headers[4].szValue = "*/*";
- if (DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0) || IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- {
+ if (db_get_b(hContact, MODULE, "UseAuth", 0) || IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
nlhr.headersCount = 6;
nlhr.headers[5].szName = "Authorization";
@@ -171,67 +154,56 @@ VOID GetNewsData(TCHAR *tszUrl, char** szData, HANDLE hContact, HWND hwndDlg)
CreateAuthString(auth, hContact, hwndDlg);
nlhr.headers[5].szValue = auth;
}
- else
- nlhr.headersCount = 5;
+ else nlhr.headersCount = 5;
// download the page
NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
- if (nlhrReply)
- {
+ if (nlhrReply) {
// if the recieved code is 200 OK
- switch (nlhrReply->resultCode)
- {
- case 200:
- {
- if (nlhrReply->dataLength)
- {
- // allocate memory and save the retrieved data
- *szData = (char *)mir_alloc(nlhrReply->dataLength + 2);
- memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength);
- (*szData)[nlhrReply->dataLength] = 0;
- }
- break;
+ switch (nlhrReply->resultCode) {
+ case 200:
+ if (nlhrReply->dataLength) {
+ // allocate memory and save the retrieved data
+ *szData = (char *)mir_alloc(nlhrReply->dataLength + 2);
+ memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength);
+ (*szData)[nlhrReply->dataLength] = 0;
}
+ break;
- case 401:
- {
- //ShowMessage(0, TranslateT("Cannot upload VersionInfo. Incorrect username or password"));
- break;
- }
+ case 401:
+ //ShowMessage(0, TranslateT("Cannot upload VersionInfo. Incorrect username or password"));
+ break;
- case 301:
- case 302:
- case 307:
- // get the url for the new location and save it to szInfo
- // look for the reply header "Location"
- for (int i=0; i<nlhrReply->headersCount; i++)
- {
- if (!strcmp(nlhrReply->headers[i].szName, "Location"))
- {
- size_t rlen = 0;
- if (nlhrReply->headers[i].szValue[0] == '/')
- {
- const char* szPath;
- const char* szPref = strstr(szUrl, "://");
- szPref = szPref ? szPref + 3 : szUrl;
- szPath = strchr(szPref, '/');
- rlen = szPath != NULL ? szPath - szUrl : strlen(szUrl);
- }
+ case 301:
+ case 302:
+ case 307:
+ // get the url for the new location and save it to szInfo
+ // look for the reply header "Location"
+ for (int i=0; i<nlhrReply->headersCount; i++) {
+ if (!strcmp(nlhrReply->headers[i].szName, "Location")) {
+ size_t rlen = 0;
+ if (nlhrReply->headers[i].szValue[0] == '/') {
+ const char* szPath;
+ const char* szPref = strstr(szUrl, "://");
+ szPref = szPref ? szPref + 3 : szUrl;
+ szPath = strchr(szPref, '/');
+ 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);
-
- nlhr.szUrl = szRedirUrl;
- break;
- }
+ strncpy(szRedirUrl, szUrl, rlen);
+ strcpy(szRedirUrl+rlen, nlhrReply->headers[i].szValue);
+
+ nlhr.szUrl = szRedirUrl;
+ break;
}
- break;
+ }
+ break;
- default:
- //ShowMessage(0, TranslateT("Cannot upload VersionInfo. Unknown error"));
- break;
+ default:
+ //ShowMessage(0, TranslateT("Cannot upload VersionInfo. Unknown error"));
+ break;
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
}
@@ -269,30 +241,26 @@ VOID UpdateList(HWND hwndList)
// items.
HANDLE hContact = db_find_first();
int i = 0;
- while (hContact != NULL)
- {
- if (IsMyContact(hContact))
- {
+ while (hContact != NULL) {
+ if (IsMyContact(hContact)) {
UpdateListFlag = TRUE;
lvI.mask = LVIF_TEXT;
lvI.iSubItem = 0;
DBVARIANT dbNick = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
- {
+ if (!db_get_ts(hContact, MODULE, "Nick", &dbNick)) {
lvI.pszText = dbNick.ptszVal;
lvI.iItem = i;
ListView_InsertItem(hwndList, &lvI);
lvI.iSubItem = 1;
DBVARIANT dbURL = {0};
- if (!DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
- {
+ if (!db_get_ts(hContact, MODULE, "URL", &dbURL)) {
lvI.pszText = dbURL.ptszVal;
ListView_SetItem(hwndList, &lvI);
i += 1;
- ListView_SetCheckState(hwndList, lvI.iItem, DBGetContactSettingByte(hContact, MODULE, "CheckState", 1));
- DBFreeVariant(&dbURL);
+ ListView_SetCheckState(hwndList, lvI.iItem, db_get_b(hContact, MODULE, "CheckState", 1));
+ db_free(&dbURL);
}
- DBFreeVariant(&dbNick);
+ db_free(&dbNick);
}
}
hContact = db_find_next(hContact);
@@ -312,28 +280,25 @@ time_t __stdcall DateToUnixTime(TCHAR* stamp, BOOL FeedType)
int i, y;
time_t t;
- if ( stamp == NULL ) return ( time_t ) 0;
+ if ( stamp == NULL )
+ return 0;
TCHAR *p = stamp;
- if (FeedType)
- {
+ if (FeedType) {
// skip '-' chars
int si = 0, sj = 0;
- while (1) {
+ while (true) {
if ( p[si] == _T('-'))
si++;
- else
- if ( !( p[sj++] = p[si++] ))
- break;
- };
+ else if ( !( p[sj++] = p[si++] ))
+ break;
+ }
}
- else
- {
+ else {
TCHAR weekday[4], monthstr[4], timezonesign[2];
INT day, month, year, hour, min, sec, timezoneh, timezonem;
- if (_tcsstr(p, _T(",")))
- {
+ if (_tcsstr(p, _T(","))) {
_stscanf( p, _T("%3s, %d %3s %d %d:%d:%d %1s%02d%02d"), &weekday, &day, &monthstr, &year, &hour, &min, &sec, &timezonesign, &timezoneh, &timezonem);
if (!lstrcmpi(monthstr, _T("Jan")))
month = 1;
@@ -392,8 +357,8 @@ time_t __stdcall DateToUnixTime(TCHAR* stamp, BOOL FeedType)
y = ( date[0]-'0' )*1000 + ( date[1]-'0' )*100 + ( date[2]-'0' )*10 + date[3]-'0';
y -= 1900;
}
- else
- return ( time_t ) 0;
+ else return 0;
+
timestamp.tm_year = y;
// Parse month
timestamp.tm_mon = ( date[i-4]-'0' )*10 + date[i-3]-'0' - 1;
@@ -405,18 +370,14 @@ time_t __stdcall DateToUnixTime(TCHAR* stamp, BOOL FeedType)
// Parse time
if ( _stscanf( p, _T("%d:%d:%d"), &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec ) != 3 )
- return ( time_t ) 0;
+ return 0;
timestamp.tm_isdst = 0; // DST is already present in _timezone below
t = mktime( &timestamp );
_tzset();
t -= _timezone;
-
- if ( t >= 0 )
- return t;
- else
- return ( time_t ) 0;
+ return (t >= 0) ? t : 0;
}
TCHAR * _tcsistr(const TCHAR * str, const TCHAR * substr)
@@ -460,10 +421,8 @@ int StrReplace(TCHAR* lpszOld, TCHAR* lpszNew, TCHAR*& lpszStr)
TCHAR *pszTarget = NULL;
TCHAR * pszResultStr = NULL;
- while (pszStart < pszEnd)
- {
- while ((pszTarget = _tcsistr(pszStart, lpszOld)) != NULL)
- {
+ while (pszStart < pszEnd) {
+ while ((pszTarget = _tcsistr(pszStart, lpszOld)) != NULL) {
nCount++;
pszStart = pszTarget + nOldLen;
}
@@ -471,8 +430,7 @@ int StrReplace(TCHAR* lpszOld, TCHAR* lpszNew, TCHAR*& lpszStr)
}
// if any changes, make them now
- if (nCount > 0)
- {
+ if (nCount > 0) {
// allocate buffer for result string
size_t nResultStrSize = nStrLen + (nNewLen - nOldLen) * nCount + 2;
pszResultStr = new TCHAR [nResultStrSize];
@@ -483,10 +441,8 @@ int StrReplace(TCHAR* lpszOld, TCHAR* lpszNew, TCHAR*& lpszStr)
TCHAR *cp = pszResultStr;
// loop again to actually do the work
- while (pszStart < pszEnd)
- {
- while ((pszTarget = _tcsistr(pszStart, lpszOld)) != NULL)
- {
+ while (pszStart < pszEnd) {
+ while ((pszTarget = _tcsistr(pszStart, lpszOld)) != NULL) {
int nCopyLen = (int)(pszTarget - pszStart);
_tcsncpy(cp, &lpszStr[pszStart-lpszStr], nCopyLen);
@@ -507,8 +463,7 @@ int StrReplace(TCHAR* lpszOld, TCHAR* lpszNew, TCHAR*& lpszStr)
}
int nSize = 0;
- if (pszResultStr)
- {
+ if (pszResultStr) {
nSize = (int)_tcslen(pszResultStr);
delete [] pszResultStr;
}
@@ -540,48 +495,37 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
bool ret = false;
NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
-
- if (pReply)
- {
- if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
- {
+ if (pReply) {
+ if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
char *date = NULL, *size = NULL;
- for (int i = 0; i < pReply->headersCount; i++)
- {
- if (!lstrcmpiA(pReply->headers[i].szName, "Last-Modified"))
- {
+ for (int i = 0; i < pReply->headersCount; i++) {
+ if (!lstrcmpiA(pReply->headers[i].szName, "Last-Modified")) {
date = pReply->headers[i].szValue;
continue;
}
- if (!lstrcmpiA(pReply->headers[i].szName, "Content-Length"))
- {
+ if (!lstrcmpiA(pReply->headers[i].szName, "Content-Length")) {
size = pReply->headers[i].szValue;
continue;
}
}
- if (date != NULL && size != NULL)
- {
+ if (date != NULL && size != NULL) {
TCHAR *tdate = mir_a2t(date);
TCHAR *tsize = mir_a2t(size);
- int fh;
struct _stat buf;
- fh = _topen(tszLocal, _O_RDONLY);
- if (fh != -1)
- {
+ int fh = _topen(tszLocal, _O_RDONLY);
+ if (fh != -1) {
_fstat(fh, &buf);
time_t modtime = DateToUnixTime(tdate, 0);
time_t filemodtime = mktime(localtime(&buf.st_atime));
- if (modtime > filemodtime && buf.st_size != _ttoi(tsize))
- {
+ if (modtime > filemodtime && buf.st_size != _ttoi(tsize)) {
hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
ret = true;
}
_close(fh);
}
- else
- {
+ else {
hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
ret = true;
@@ -589,8 +533,7 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
mir_free(tdate);
mir_free(tsize);
}
- else
- {
+ else {
hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
ret = true;
@@ -612,66 +555,60 @@ typedef HRESULT (MarkupCallback)(IHTMLDocument3*, BSTR& message);
HRESULT TestMarkupServices(BSTR bstrHtml, MarkupCallback* pCallback, BSTR& message)
{
- IHTMLDocument3* pHtmlDocRoot = NULL;
-
- // Create the root document -- a "workspace" for parsing.
- HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pHtmlDocRoot));
- if (SUCCEEDED(hr) && pHtmlDocRoot)
- {
- IPersistStreamInit *pPersistStreamInit = NULL;
-
- HRESULT hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pPersistStreamInit));
- if (SUCCEEDED(hr))
- {
- // Initialize the root document to a default state -- ready for parsing.
- hr = pPersistStreamInit->InitNew();
-
- IMarkupServices *pMarkupServices = NULL;
- hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pMarkupServices));
- if (SUCCEEDED(hr))
- {
- IMarkupPointer *pMarkupBegin = NULL;
- IMarkupPointer *pMarkupEnd = NULL;
-
- // These markup pointers indicate the insertion point.
- hr = pMarkupServices->CreateMarkupPointer(&pMarkupBegin);
- if (SUCCEEDED(hr))
- hr = pMarkupServices->CreateMarkupPointer(&pMarkupEnd);
-
- if (SUCCEEDED(hr) && pMarkupBegin && pMarkupEnd)
- {
- IMarkupContainer *pMarkupContainer = NULL;
-
- // Parse the string -- the markup container contains the parsed HTML.
- // Markup pointers are updated to point to begining and end of new container.
- hr = pMarkupServices->ParseString(bstrHtml, 0, &pMarkupContainer, pMarkupBegin, pMarkupEnd);
- if (SUCCEEDED(hr) && pMarkupContainer)
- {
- IHTMLDocument3 *pHtmlDoc = NULL;
-
- // Retrieve the document interface to the markup container.
- hr = pMarkupContainer->QueryInterface(IID_PPV_ARGS(&pHtmlDoc));
- if (SUCCEEDED(hr) && pHtmlDoc)
- {
- // Invoke the user-defined action for this new fragment.
- hr = pCallback(pHtmlDoc, message);
-
- // Clean up.
- pHtmlDoc->Release();
- }
- pMarkupContainer->Release();
- }
- pMarkupEnd->Release();
- }
- if (pMarkupBegin)
- pMarkupBegin->Release();
- pMarkupServices->Release();
- }
- pPersistStreamInit->Release();
- }
- pHtmlDocRoot->Release();
- }
- return hr;
+ IHTMLDocument3* pHtmlDocRoot = NULL;
+
+ // Create the root document -- a "workspace" for parsing.
+ HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pHtmlDocRoot));
+ if (SUCCEEDED(hr) && pHtmlDocRoot) {
+ IPersistStreamInit *pPersistStreamInit = NULL;
+
+ HRESULT hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pPersistStreamInit));
+ if (SUCCEEDED(hr)) {
+ // Initialize the root document to a default state -- ready for parsing.
+ hr = pPersistStreamInit->InitNew();
+
+ IMarkupServices *pMarkupServices = NULL;
+ hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pMarkupServices));
+ if (SUCCEEDED(hr)) {
+ IMarkupPointer *pMarkupBegin = NULL;
+ IMarkupPointer *pMarkupEnd = NULL;
+
+ // These markup pointers indicate the insertion point.
+ hr = pMarkupServices->CreateMarkupPointer(&pMarkupBegin);
+ if (SUCCEEDED(hr))
+ hr = pMarkupServices->CreateMarkupPointer(&pMarkupEnd);
+
+ if (SUCCEEDED(hr) && pMarkupBegin && pMarkupEnd) {
+ IMarkupContainer *pMarkupContainer = NULL;
+
+ // Parse the string -- the markup container contains the parsed HTML.
+ // Markup pointers are updated to point to begining and end of new container.
+ hr = pMarkupServices->ParseString(bstrHtml, 0, &pMarkupContainer, pMarkupBegin, pMarkupEnd);
+ if (SUCCEEDED(hr) && pMarkupContainer) {
+ IHTMLDocument3 *pHtmlDoc = NULL;
+
+ // Retrieve the document interface to the markup container.
+ hr = pMarkupContainer->QueryInterface(IID_PPV_ARGS(&pHtmlDoc));
+ if (SUCCEEDED(hr) && pHtmlDoc) {
+ // Invoke the user-defined action for this new fragment.
+ hr = pCallback(pHtmlDoc, message);
+
+ // Clean up.
+ pHtmlDoc->Release();
+ }
+ pMarkupContainer->Release();
+ }
+ pMarkupEnd->Release();
+ }
+ if (pMarkupBegin)
+ pMarkupBegin->Release();
+ pMarkupServices->Release();
+ }
+ pPersistStreamInit->Release();
+ }
+ pHtmlDocRoot->Release();
+ }
+ return hr;
}
HRESULT TestDocumentText(IHTMLDocument3* pHtmlDoc, BSTR& message)
@@ -681,11 +618,9 @@ HRESULT TestDocumentText(IHTMLDocument3* pHtmlDoc, BSTR& message)
BSTR bstrId = SysAllocString(L"test");
HRESULT hr = pHtmlDoc->QueryInterface(IID_PPV_ARGS(&pDoc));
- if (SUCCEEDED(hr) && pDoc)
- {
+ if (SUCCEEDED(hr) && pDoc) {
hr = pDoc->get_body(&pElem);
- if (SUCCEEDED(hr) && pElem)
- {
+ if (SUCCEEDED(hr) && pElem) {
BSTR bstrText = NULL;
pElem->get_innerText(&bstrText);
message = SysAllocString(bstrText);
@@ -718,8 +653,7 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg)
char *szData = NULL;
DBVARIANT dbVar = {0};
GetNewsData(tszURL, &szData, NULL, hwndDlg);
- if (szData)
- {
+ if (szData) {
TCHAR *tszData = mir_utf8decodeT(szData);
if (!tszData)
tszData = mir_a2t(szData);
@@ -727,20 +661,15 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg)
HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
mir_free(tszData);
mir_free(szData);
- if (hXml != NULL)
- {
+ 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")))
- {
+ 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++)
- {
+ for (int j = 0; j < xi.getChildCount(chan); j++) {
HXML child = xi.getChild(chan, j);
- if (!lstrcmpi(xi.getName(child), _T("title")))
- {
+ if (!lstrcmpi(xi.getName(child), _T("title"))) {
TCHAR mes[MAX_PATH];
mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a valid feed's address."), tszURL);
MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONINFORMATION);
@@ -749,13 +678,10 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg)
}
}
}
- else if (!lstrcmpi(xi.getName(node), _T("feed")))
- {
- for (int j = 0; j < xi.getChildCount(node); j++)
- {
+ 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("title")))
- {
+ if (!lstrcmpi(xi.getName(child), _T("title"))) {
TCHAR mes[MAX_PATH];
mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a valid feed's address."), tszURL);
MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONINFORMATION);
@@ -770,8 +696,7 @@ TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg)
}
xi.destroyNode(hXml);
}
- else
- {
+ else {
TCHAR mes[MAX_PATH];
mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a not valid feed's address."), tszURL);
MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONERROR);
@@ -783,14 +708,13 @@ VOID CheckCurrentFeed(HANDLE hContact)
{
char *szData = NULL;
DBVARIANT dbURL = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ if (db_get_ts(hContact, MODULE, "URL", &dbURL))
return;
- else if (db_get_b(hContact, MODULE, "CheckState", 1) != 0)
- {
+
+ if (db_get_b(hContact, MODULE, "CheckState", 1) != 0) {
GetNewsData(dbURL.ptszVal, &szData, hContact, NULL);
- DBFreeVariant(&dbURL);
- if (szData)
- {
+ db_free(&dbURL);
+ if (szData) {
TCHAR *tszData = mir_utf8decodeT(szData);
if (!tszData)
tszData = mir_a2t(szData);
@@ -798,197 +722,163 @@ VOID CheckCurrentFeed(HANDLE hContact)
HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
mir_free(tszData);
mir_free(szData);
- if(hXml != NULL)
- {
+ 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")))
- {
- if (!lstrcmpi(xi.getName(node), _T("rss")))
- {
- for (int i = 0; i < xi.getAttrCount(node); i++)
- {
- if (!lstrcmpi(xi.getAttrName(node, i), _T("version")))
- {
+ while (node) {
+ if (!lstrcmpi(xi.getName(node), _T("rss")) || !lstrcmpi(xi.getName(node), _T("rdf"))) {
+ if (!lstrcmpi(xi.getName(node), _T("rss"))) {
+ for (int i = 0; i < xi.getAttrCount(node); i++) {
+ if (!lstrcmpi(xi.getAttrName(node, i), _T("version"))) {
TCHAR ver[MAX_PATH];
mir_sntprintf(ver, SIZEOF(ver), _T("RSS %s"), xi.getAttrValue(node, xi.getAttrName(node, i)));
- DBWriteContactSettingTString(hContact, MODULE, "MirVer", ver);
+ db_set_ts(hContact, MODULE, "MirVer", ver);
break;
}
}
}
else if (!lstrcmpi(xi.getName(node), _T("rdf")))
- {
- DBWriteContactSettingTString(hContact, MODULE, "MirVer", _T("RSS 1.0"));
- }
+ db_set_ts(hContact, MODULE, "MirVer", _T("RSS 1.0"));
HXML chan = xi.getChild(node, 0);
- for (int j = 0; j < xi.getChildCount(chan); j++)
- {
+ for (int j = 0; j < xi.getChildCount(chan); j++) {
HXML child = xi.getChild(chan, j);
- if (!lstrcmpi(xi.getName(child), _T("title")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("title")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
+ db_set_ts(hContact, MODULE, "FirstName", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("link")))
- {
- DBWriteContactSettingTString(hContact, MODULE, "Homepage", xi.getText(child));
+ if (!lstrcmpi(xi.getName(child), _T("link"))) {
+ db_set_ts(hContact, MODULE, "Homepage", xi.getText(child));
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("description")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("description")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "About", string);
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
+ db_set_ts(hContact, MODULE, "About", string);
+ db_set_ts(hContact, "CList", "StatusMsg", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("language")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("language")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
+ db_set_ts(hContact, MODULE, "Language1", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("managingEditor")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("managingEditor")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "e-mail", string);
+ db_set_ts(hContact, MODULE, "e-mail", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("category")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("category")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
+ db_set_ts(hContact, MODULE, "Interest0Text", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("image")))
- {
- for (int x = 0; x < xi.getChildCount(child); x++)
- {
+ 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")))
- {
+ if (!lstrcmpi(xi.getName(imageval), _T("url"))) {
LPCTSTR url = xi.getText(imageval);
- DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+ db_set_ts(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))
- {
+ if (!db_get_ts(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);
+ if (DownloadFile(url, pai.filename)) {
+ db_set_ts(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);
+ else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ db_free(&dbVar);
break;
}
}
}
}
- if (!lstrcmpi(xi.getName(child), _T("lastBuildDate")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("lastBuildDate")) && xi.getText(child)) {
TCHAR *lastupdtime = (TCHAR*)xi.getText(child);
time_t stamp = DateToUnixTime(lastupdtime, 0);
double deltaupd = difftime(time(NULL), stamp);
- double deltacheck = difftime(time(NULL), DBGetContactSettingDword(hContact, MODULE, "LastCheck", 0));
- if (deltaupd - deltacheck >= 0)
- {
+ double deltacheck = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
+ if (deltaupd - deltacheck >= 0) {
DBWriteContactSettingDword(hContact, MODULE, "LastCheck", time(NULL));
xi.destroyNode(hXml);
return;
}
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("item")))
- {
+ if (!lstrcmpi(xi.getName(child), _T("item"))) {
TCHAR *title = NULL, *link = NULL, *datetime = NULL, *descr = NULL, *author = NULL, *comments = NULL, *guid = NULL, *category = NULL;
- for (int z = 0; z < xi.getChildCount(child); z++)
- {
+ for (int z = 0; z < xi.getChildCount(child); z++) {
HXML itemval = xi.getChild(child, z);
- if (!lstrcmpi(xi.getName(itemval), _T("title")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("title"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
title = mir_tstrdup(string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("link")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("link"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
link = mir_tstrdup(string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("pubDate")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("pubDate"))) {
datetime = (TCHAR*)xi.getText(itemval);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("dc:date")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("dc:date"))) {
datetime = (TCHAR*)xi.getText(itemval);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("description")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("description"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
descr = mir_tstrdup(string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("author")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("author"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
author = mir_tstrdup(string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("comments")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("comments"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
comments = mir_tstrdup(string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("guid")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("guid"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
guid = mir_tstrdup(string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("category")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("category"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
category = mir_tstrdup(string);
@@ -998,57 +888,50 @@ VOID CheckCurrentFeed(HANDLE hContact)
}
TCHAR* message;
DBVARIANT dbMsg = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
+ if (db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg))
message = _T(TAGSDEFAULT);
else
message = mir_tstrdup(dbMsg.ptszVal);
- DBFreeVariant(&dbMsg);
+ db_free(&dbMsg);
if (!title)
StrReplace(_T("#<title>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<title>#"), title, message);
mir_free(title);
}
if (!link)
StrReplace(_T("#<link>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<link>#"), link, message);
mir_free(link);
}
if (!descr)
StrReplace(_T("#<description>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<description>#"), descr, message);
mir_free(descr);
}
if (!author)
StrReplace(_T("#<author>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<author>#"), author, message);
mir_free(author);
}
if (!comments)
StrReplace(_T("#<comments>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<comments>#"), comments, message);
mir_free(comments);
}
if (!guid)
StrReplace(_T("#<guid>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<guid>#"), guid, message);
mir_free(guid);
}
if (!category)
StrReplace(_T("#<category>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<category>#"), category, message);
mir_free(category);
}
@@ -1061,8 +944,7 @@ VOID CheckCurrentFeed(HANDLE hContact)
HANDLE hDbEvent = db_event_first(hContact);
BOOL MesExist = FALSE;
- while (hDbEvent)
- {
+ while (hDbEvent) {
DBEVENTINFO olddbei = { sizeof(olddbei) };
olddbei.cbBlob = db_event_getBlobSize(hDbEvent);
olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
@@ -1075,8 +957,7 @@ VOID CheckCurrentFeed(HANDLE hContact)
mir_free(pszTemp);
}
- if (!MesExist)
- {
+ if (!MesExist) {
PROTORECVEVENT recv;
recv.flags = PREF_TCHAR;
recv.timestamp = stamp;
@@ -1087,142 +968,114 @@ VOID CheckCurrentFeed(HANDLE hContact)
}
}
}
- else if (!lstrcmpi(xi.getName(node), _T("feed")))
- {
- DBWriteContactSettingTString(hContact, MODULE, "MirVer", _T("Atom 3"));
- for (int j = 0; j < xi.getChildCount(node); j++)
- {
+ else if (!lstrcmpi(xi.getName(node), _T("feed"))) {
+ db_set_ts(hContact, MODULE, "MirVer", _T("Atom 3"));
+ for (int j = 0; j < xi.getChildCount(node); j++) {
HXML child = xi.getChild(node, j);
- if (!lstrcmpi(xi.getName(child), _T("title")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("title")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
+ db_set_ts(hContact, MODULE, "FirstName", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("link")))
- {
- for (int x = 0; x < xi.getAttrCount(child); x++)
- {
+ if (!lstrcmpi(xi.getName(child), _T("link"))) {
+ for (int x = 0; x < xi.getAttrCount(child); x++) {
if (!lstrcmpi(xi.getAttrName(child, x), _T("rel")))
- {
if (!lstrcmpi(xi.getAttrValue(child, xi.getAttrName(child, x)), _T("self")))
break;
- }
+
if (!lstrcmpi(xi.getAttrName(child, x), _T("href")))
- {
- DBWriteContactSettingTString(hContact, MODULE, "Homepage", xi.getAttrValue(child, xi.getAttrName(child, x)));
- }
+ db_set_ts(hContact, MODULE, "Homepage", xi.getAttrValue(child, xi.getAttrName(child, x)));
}
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("subtitle")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("subtitle")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "About", string);
- DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
+ db_set_ts(hContact, MODULE, "About", string);
+ db_set_ts(hContact, "CList", "StatusMsg", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("language")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("language")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
+ db_set_ts(hContact, MODULE, "Language1", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("author")))
- {
- for (int x = 0; x < xi.getChildCount(child); x++)
- {
+ if (!lstrcmpi(xi.getName(child), _T("author"))) {
+ for (int x = 0; x < xi.getChildCount(child); x++) {
HXML authorval = xi.getChild(child, x);
- if (!lstrcmpi(xi.getName(authorval), _T("name")))
- {
- DBWriteContactSettingTString(hContact, MODULE, "e-mail", xi.getText(authorval));
+ if (!lstrcmpi(xi.getName(authorval), _T("name"))) {
+ db_set_ts(hContact, MODULE, "e-mail", xi.getText(authorval));
break;
}
}
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("category")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("category")) && xi.getText(child)) {
TCHAR *string = mir_tstrdup(xi.getText(child));
ClearText(string);
- DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
+ db_set_ts(hContact, MODULE, "Interest0Text", string);
mir_free(string);
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("icon")))
- {
- for (int x = 0; x < xi.getChildCount(child); x++)
- {
+ 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")))
- {
+ if (!lstrcmpi(xi.getName(imageval), _T("url"))) {
LPCTSTR url = xi.getText(imageval);
- DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+ db_set_ts(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))
- {
+ if (!db_get_ts(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);
+ if (DownloadFile(url, pai.filename)) {
+ db_set_ts(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);
+ else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ db_free(&dbVar);
break;
}
}
}
}
- if (!lstrcmpi(xi.getName(child), _T("updated")) && xi.getText(child))
- {
+ if (!lstrcmpi(xi.getName(child), _T("updated")) && xi.getText(child)) {
TCHAR *lastupdtime = (TCHAR*)xi.getText(child);
time_t stamp = DateToUnixTime(lastupdtime, 1);
double deltaupd = difftime(time(NULL), stamp);
- double deltacheck = difftime(time(NULL), DBGetContactSettingDword(hContact, MODULE, "LastCheck", 0));
- if (deltaupd - deltacheck >= 0)
- {
+ double deltacheck = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
+ if (deltaupd - deltacheck >= 0) {
DBWriteContactSettingDword(hContact, MODULE, "LastCheck", time(NULL));
xi.destroyNode(hXml);
return;
}
continue;
}
- if (!lstrcmpi(xi.getName(child), _T("entry")))
- {
+ if (!lstrcmpi(xi.getName(child), _T("entry"))) {
TCHAR *title = NULL, *link = NULL, *datetime = NULL, *descr = NULL, *author = NULL, *comments = NULL, *guid = NULL, *category = NULL;
- for (int z = 0; z < xi.getChildCount(child); z++)
- {
+ for (int z = 0; z < xi.getChildCount(child); z++) {
HXML itemval = xi.getChild(child, z);
- if (!lstrcmpi(xi.getName(itemval), _T("title")) && xi.getText(itemval))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("title")) && xi.getText(itemval)) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
title = string;
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("link")))
- {
- for (int x = 0; x < xi.getAttrCount(itemval); x++)
- {
- if (!lstrcmpi(xi.getAttrName(itemval, x), _T("href")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("link"))) {
+ for (int x = 0; x < xi.getAttrCount(itemval); x++) {
+ if (!lstrcmpi(xi.getAttrName(itemval, x), _T("href"))) {
TCHAR *string = mir_tstrdup(xi.getAttrValue(itemval, xi.getAttrName(itemval, x)));
ClearText(string);
link = string;
@@ -1231,25 +1084,20 @@ VOID CheckCurrentFeed(HANDLE hContact)
}
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("updated")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("updated"))) {
datetime = (TCHAR*)xi.getText(itemval);
continue;
}
- if ((!lstrcmpi(xi.getName(itemval), _T("summary")) || !lstrcmpi(xi.getName(itemval), _T("content"))) && xi.getText(itemval))
- {
+ if ((!lstrcmpi(xi.getName(itemval), _T("summary")) || !lstrcmpi(xi.getName(itemval), _T("content"))) && xi.getText(itemval)) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
descr = string;
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("author")))
- {
- for (int x = 0; x < xi.getChildCount(itemval); x++)
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("author"))) {
+ for (int x = 0; x < xi.getChildCount(itemval); x++) {
HXML authorval = xi.getChild(itemval, x);
- if (!lstrcmpi(xi.getName(authorval), _T("name")) && xi.getText(authorval))
- {
+ if (!lstrcmpi(xi.getName(authorval), _T("name")) && xi.getText(authorval)) {
TCHAR *string = mir_tstrdup(xi.getText(authorval));
ClearText(string);
author = string;
@@ -1258,26 +1106,21 @@ VOID CheckCurrentFeed(HANDLE hContact)
}
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("comments")) && xi.getText(itemval))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("comments")) && xi.getText(itemval)) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
comments = string;
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("id")))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("id"))) {
TCHAR *string = mir_tstrdup(xi.getText(itemval));
ClearText(string);
guid = string;
continue;
}
- if (!lstrcmpi(xi.getName(itemval), _T("category")))
- {
- for (int x = 0; x < xi.getAttrCount(itemval); x++)
- {
- if (!lstrcmpi(xi.getAttrName(itemval, x), _T("term")) && xi.getText(itemval))
- {
+ if (!lstrcmpi(xi.getName(itemval), _T("category"))) {
+ for (int x = 0; x < xi.getAttrCount(itemval); x++) {
+ if (!lstrcmpi(xi.getAttrName(itemval, x), _T("term")) && xi.getText(itemval)) {
TCHAR *string = mir_tstrdup(xi.getAttrValue(itemval, xi.getAttrName(itemval, x)));
ClearText(string);
category = string;
@@ -1289,58 +1132,51 @@ VOID CheckCurrentFeed(HANDLE hContact)
}
TCHAR* message;
DBVARIANT dbMsg = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
+ if (db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg))
message = _T(TAGSDEFAULT);
else
message = mir_tstrdup(dbMsg.ptszVal);
- DBFreeVariant(&dbMsg);
+ db_free(&dbMsg);
if (!title)
StrReplace(_T("#<title>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<title>#"), title, message);
mir_free(title);
}
if (!link)
StrReplace(_T("#<link>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<link>#"), link, message);
mir_free(link);
}
if (!descr)
StrReplace(_T("#<description>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<description>#"), descr, message);
mir_free(descr);
}
if (!author)
StrReplace(_T("#<author>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<author>#"), author, message);
mir_free(author);
}
if (!comments)
StrReplace(_T("#<comments>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<comments>#"), comments, message);
mir_free(comments);
}
if (!guid)
StrReplace(_T("#<guid>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<guid>#"), guid, message);
mir_free(guid);
}
if (!category)
StrReplace(_T("#<category>#"), TranslateT("empty"), message);
- else
- {
+ else {
StrReplace(_T("#<category>#"), category, message);
mir_free(category);
}
@@ -1353,8 +1189,7 @@ VOID CheckCurrentFeed(HANDLE hContact)
HANDLE hDbEvent = db_event_first(hContact);
BOOL MesExist = FALSE;
- while (hDbEvent)
- {
+ while (hDbEvent) {
DBEVENTINFO olddbei = { sizeof(olddbei) };
olddbei.cbBlob = db_event_getBlobSize(hDbEvent);
olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
@@ -1367,8 +1202,7 @@ VOID CheckCurrentFeed(HANDLE hContact)
mir_free(pszTemp);
}
- if (!MesExist)
- {
+ if (!MesExist) {
PROTORECVEVENT recv;
recv.flags = PREF_TCHAR;
recv.timestamp = stamp;
@@ -1393,14 +1227,13 @@ VOID CheckCurrentFeedAvatar(HANDLE hContact)
{
char *szData = NULL;
DBVARIANT dbURL = {0};
- if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ if (db_get_ts(hContact, MODULE, "URL", &dbURL))
return;
- else if (db_get_b(hContact, MODULE, "CheckState", 1) != 0)
- {
+
+ if (db_get_b(hContact, MODULE, "CheckState", 1) != 0) {
GetNewsData(dbURL.ptszVal, &szData, hContact, NULL);
- DBFreeVariant(&dbURL);
- if (szData)
- {
+ db_free(&dbURL);
+ if (szData) {
TCHAR *tszData = mir_utf8decodeT(szData);
if (!tszData)
tszData = mir_a2t(szData);
@@ -1408,48 +1241,38 @@ VOID CheckCurrentFeedAvatar(HANDLE hContact)
HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
mir_free(tszData);
mir_free(szData);
- if(hXml != NULL)
- {
+ 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")))
- {
+ 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++)
- {
+ 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++)
- {
+ 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")))
- {
+ if (!lstrcmpi(xi.getName(imageval), _T("url"))) {
LPCTSTR url = xi.getText(imageval);
- DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+ db_set_ts(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))
- {
+ if (!db_get_ts(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);
+ if (DownloadFile(url, pai.filename)) {
+ db_set_ts(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);
+ else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ db_free(&dbVar);
break;
}
}
@@ -1457,41 +1280,33 @@ VOID CheckCurrentFeedAvatar(HANDLE hContact)
}
}
}
- else if (!lstrcmpi(xi.getName(node), _T("feed")))
- {
- for (int j = 0; j < xi.getChildCount(node); j++)
- {
+ 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++)
- {
+ 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")))
- {
+ if (!lstrcmpi(xi.getName(imageval), _T("url"))) {
LPCTSTR url = xi.getText(imageval);
- DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+ db_set_ts(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))
- {
+ if (!db_get_ts(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);
+ if (DownloadFile(url, pai.filename)) {
+ db_set_ts(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);
+ else ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ db_free(&dbVar);
break;
}
}
@@ -1506,4 +1321,4 @@ VOID CheckCurrentFeedAvatar(HANDLE hContact)
}
}
}
-} \ No newline at end of file
+}