summaryrefslogtreecommitdiff
path: root/plugins/Weather/src/weather_data.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
commit3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c (patch)
treeefee912ee654baafeb98efcd117921db6b7489bc /plugins/Weather/src/weather_data.cpp
parentbcb27264ba737778e5d3edad36088bacf74f0236 (diff)
- the kernel filters out contacts by proto names much faster than a plugin;
- database cycles simplified git-svn-id: http://svn.miranda-ng.org/main/trunk@4404 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Weather/src/weather_data.cpp')
-rw-r--r--plugins/Weather/src/weather_data.cpp83
1 files changed, 40 insertions, 43 deletions
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp
index 3f6ce3b0f2..bcf0e22139 100644
--- a/plugins/Weather/src/weather_data.cpp
+++ b/plugins/Weather/src/weather_data.cpp
@@ -124,54 +124,51 @@ void EraseAllInfo()
HANDLE LastContact = NULL;
DBVARIANT dbv;
// loop through all contacts
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- // see if the contact is a weather contact
- if ( IsMyContact(hContact)) {
- db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
- db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE);
- db_unset(hContact, "CList", "MyHandle");
- // clear all data
- if ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
- db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
- db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
- db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
- db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None");
- }
- else db_free(&dbv);
-
- DBDataManage(hContact, WDBM_REMOVE, 0, 0);
- db_set_s(hContact, "UserInfo", "MyNotes", "");
- // reset update tag
- db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE);
- // reset logging settings
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) {
- db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0));
- db_free(&dbv);
- }
- else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE);
+ for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
+ db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
+ db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE);
+ db_unset(hContact, "CList", "MyHandle");
+ // clear all data
+ if ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
+ db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
+ db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
+ db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None");
+ }
+ else db_free(&dbv);
+
+ DBDataManage(hContact, WDBM_REMOVE, 0, 0);
+ db_set_s(hContact, "UserInfo", "MyNotes", "");
+ // reset update tag
+ db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE);
+ // reset logging settings
+ if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) {
+ db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0));
+ db_free(&dbv);
+ }
+ else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE);
- // if no default station find, assign a new one
- if (opt.Default[0] == 0) {
- GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
+ // if no default station find, assign a new one
+ if (opt.Default[0] == 0) {
+ GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
- opt.DefStn = hContact;
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
- db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
- }
+ opt.DefStn = hContact;
+ if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ db_free(&dbv);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
- // get the handle of the default station
- if (opt.DefStn == NULL) {
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) {
- if ( !_tcscmp(dbv.ptszVal, opt.Default))
- opt.DefStn = hContact;
- db_free(&dbv);
- }
+ }
+ // get the handle of the default station
+ if (opt.DefStn == NULL) {
+ if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) {
+ if ( !_tcscmp(dbv.ptszVal, opt.Default))
+ opt.DefStn = hContact;
+ db_free(&dbv);
}
- ContactCount++; // increment counter
- LastContact = hContact;
}
+ ContactCount++; // increment counter
+ LastContact = hContact;
}
// if weather contact exists, set the status to online so it is ready for update