summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-06-05 01:28:37 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-06-05 01:28:37 +0000
commitb3861e72ec527e73bcbb44978e531f5731237c0c (patch)
tree512dc43e54920a25798215344a2de5a9647183b4
parent991f409e2eec6c19aed25c9daffd5f7297c96811 (diff)
try to override timezone list index by matching timezone name (list index inconsistent accross versions of windows)
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@199 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--worldtime/WorldTime.cpp2
-rw-r--r--worldtime/options.cpp5
-rw-r--r--worldtime/plugwin.cpp14
-rw-r--r--worldtime/timezone.cpp7
-rw-r--r--worldtime_protocol/timezone.cpp7
-rw-r--r--worldtime_protocol/timezone_list.cpp13
-rw-r--r--worldtime_protocol/worldtimeproto.cpp2
7 files changed, 36 insertions, 14 deletions
diff --git a/worldtime/WorldTime.cpp b/worldtime/WorldTime.cpp
index 8b1c839..90adb4a 100644
--- a/worldtime/WorldTime.cpp
+++ b/worldtime/WorldTime.cpp
@@ -7,7 +7,7 @@ PLUGINLINK *pluginLink;
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
"World Time",
- PLUGIN_MAKE_VERSION(0, 3, 0, 2),
+ PLUGIN_MAKE_VERSION(0, 3, 1, 0),
"Display world times.",
"Scott Ellis",
"mail@scottellis.com.au",
diff --git a/worldtime/options.cpp b/worldtime/options.cpp
index 7bac536..8dc5da8 100644
--- a/worldtime/options.cpp
+++ b/worldtime/options.cpp
@@ -6,18 +6,21 @@ void save_listbox_items() {
DBWriteContactSettingDword(0, "WorldTime", "NumEntries", listbox_items.size());
int index = 0;
for(ITEMLIST::iterator i = listbox_items.begin(); i != listbox_items.end(); i++, index++) {
- std::ostringstream p1, p2, p3, p4;
+ std::ostringstream p1, p2, p3, p4, p5;
p1 << "Label" << index;
p2 << "Index" << index;
p3 << "Sunrise" << index;
p4 << "Sunset" << index;
+ p5 << "TZName" << index;
DBWriteContactSettingString(0, "WorldTime", p1.str().c_str(), i->pszText);
DBWriteContactSettingDword(0, "WorldTime", p2.str().c_str(), i->timezone_list_index);
DBWriteContactSettingDword(0, "WorldTime", p3.str().c_str(), i->sunrise.wHour * 60 + i->sunrise.wMinute);
DBWriteContactSettingDword(0, "WorldTime", p4.str().c_str(), i->sunset.wHour * 60 + i->sunset.wMinute);
+ DBWriteContactSettingString(0, "WorldTime", p5.str().c_str(), timezone_list[i->timezone_list_index].tcName);
}
+ DBWriteContactSettingWord(0, "WorldTime", "DataVersion", 1);
}
void set_minmax(bool mm) {
diff --git a/worldtime/plugwin.cpp b/worldtime/plugwin.cpp
index 48bb576..569f1bb 100644
--- a/worldtime/plugwin.cpp
+++ b/worldtime/plugwin.cpp
@@ -820,19 +820,29 @@ void load_listbox_items() {
int num = DBGetContactSettingDword(0, "WorldTime", "NumEntries", 0);
for(int i = 0; i < num; i++) {
LISTITEM li = {0};
- std::ostringstream p1, p2, p3, p4;
+ std::ostringstream p1, p2, p3, p4, p5;
p1 << "Label" << i;
p2 << "Index" << i;
p3 << "Sunrise" << i;
p4 << "Sunset" << i;
+ p5 << "TZName" << i;
DBVARIANT dbv;
DBGetContactSetting(0, "WorldTime", p1.str().c_str(), &dbv);
strncpy(li.pszText, dbv.pszVal, MAX_NAME_LENGTH);
DBFreeVariant(&dbv);
- li.timezone_list_index = (int)DBGetContactSettingDword(0, "WorldTime", p2.str().c_str(), 0);
+ if(!DBGetContactSetting(0, "WorldTime", p5.str().c_str(), &dbv)) {
+ for(TimeList::iterator j = timezone_list.begin(); j != timezone_list.end(); j++) {
+ if(!strcmp(j->tcName, dbv.pszVal)) {
+ li.timezone_list_index = j->list_index;
+ break;
+ }
+ }
+ DBFreeVariant(&dbv);
+ } else
+ li.timezone_list_index = (int)DBGetContactSettingDword(0, "WorldTime", p2.str().c_str(), 0);
GetSystemTime(&li.sunrise);
GetSystemTime(&li.sunset);
diff --git a/worldtime/timezone.cpp b/worldtime/timezone.cpp
index ee4a8ed..5b2c31b 100644
--- a/worldtime/timezone.cpp
+++ b/worldtime/timezone.cpp
@@ -19,7 +19,6 @@ bool build_timezone_list() {
DWORD dwcbDLT;
LS_TZREG Temp;
FILETIME ftLastWrite;
- unsigned int list_index = 0;
bool win9x = false;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TZREG, 0, KEY_ENUMERATE_SUB_KEYS, &HKlmtz) != ERROR_SUCCESS) {
@@ -28,7 +27,7 @@ bool build_timezone_list() {
return false;
}
- while(RegEnumKeyEx(HKlmtz, dwIndex++, tcName, &dwcbName, NULL, NULL, NULL, &ftLastWrite) != ERROR_NO_MORE_ITEMS) {
+ while(RegEnumKeyEx(HKlmtz, dwIndex, tcName, &dwcbName, NULL, NULL, NULL, &ftLastWrite) != ERROR_NO_MORE_ITEMS) {
if(RegOpenKeyEx(HKlmtz, tcName, 0,KEY_QUERY_VALUE, &KKtz) != ERROR_SUCCESS) {
RegCloseKey(HKlmtz);
@@ -53,11 +52,11 @@ bool build_timezone_list() {
RegCloseKey(KKtz);
- Temp.list_index = list_index;
+ Temp.list_index = dwIndex;
timezone_list.push_back(Temp);
dwcbName = MAX_SIZE;
- list_index++;
+ dwIndex++;
}
RegCloseKey(HKlmtz);
diff --git a/worldtime_protocol/timezone.cpp b/worldtime_protocol/timezone.cpp
index ee4a8ed..5b2c31b 100644
--- a/worldtime_protocol/timezone.cpp
+++ b/worldtime_protocol/timezone.cpp
@@ -19,7 +19,6 @@ bool build_timezone_list() {
DWORD dwcbDLT;
LS_TZREG Temp;
FILETIME ftLastWrite;
- unsigned int list_index = 0;
bool win9x = false;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TZREG, 0, KEY_ENUMERATE_SUB_KEYS, &HKlmtz) != ERROR_SUCCESS) {
@@ -28,7 +27,7 @@ bool build_timezone_list() {
return false;
}
- while(RegEnumKeyEx(HKlmtz, dwIndex++, tcName, &dwcbName, NULL, NULL, NULL, &ftLastWrite) != ERROR_NO_MORE_ITEMS) {
+ while(RegEnumKeyEx(HKlmtz, dwIndex, tcName, &dwcbName, NULL, NULL, NULL, &ftLastWrite) != ERROR_NO_MORE_ITEMS) {
if(RegOpenKeyEx(HKlmtz, tcName, 0,KEY_QUERY_VALUE, &KKtz) != ERROR_SUCCESS) {
RegCloseKey(HKlmtz);
@@ -53,11 +52,11 @@ bool build_timezone_list() {
RegCloseKey(KKtz);
- Temp.list_index = list_index;
+ Temp.list_index = dwIndex;
timezone_list.push_back(Temp);
dwcbName = MAX_SIZE;
- list_index++;
+ dwIndex++;
}
RegCloseKey(HKlmtz);
diff --git a/worldtime_protocol/timezone_list.cpp b/worldtime_protocol/timezone_list.cpp
index 4927515..d70455e 100644
--- a/worldtime_protocol/timezone_list.cpp
+++ b/worldtime_protocol/timezone_list.cpp
@@ -17,7 +17,16 @@ void load_listbox_items() {
proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 );
if ( proto && !lstrcmp( PROTO, proto)) {
pa.hContact = hContact;
- pa.timezone_list_index = DBGetContactSettingDword(pa.hContact, PROTO, "TimezoneListIndex", -1);
+ if(!DBGetContactSetting(pa.hContact, PROTO, "TZName", &dbv)) {
+ for(TimeList::iterator j = timezone_list.begin(); j != timezone_list.end(); j++) {
+ if(!strcmp(j->tcName, dbv.pszVal)) {
+ pa.timezone_list_index = j->list_index;
+ break;
+ }
+ }
+ DBFreeVariant(&dbv);
+ } else
+ pa.timezone_list_index = DBGetContactSettingDword(pa.hContact, PROTO, "TimezoneListIndex", -1);
if(!DBGetContactSetting(pa.hContact, PROTO, "Nick", &dbv)) {
strncpy(pa.pszText, dbv.pszVal, MAX_NAME_LENGTH);
DBFreeVariant(&dbv);
@@ -46,7 +55,9 @@ void save_listbox_items() {
DBWriteContactSettingString(i->hContact, PROTO, "Nick", i->pszText);
DBWriteContactSettingDword(i->hContact, PROTO, "TimezoneListIndex", i->timezone_list_index);
DBWriteContactSettingWord(i->hContact, PROTO, "Status", ID_STATUS_ONLINE);
+ DBWriteContactSettingString(i->hContact, PROTO, "TZName", timezone_list[i->timezone_list_index].tcName);
}
+ DBWriteContactSettingWord(0, PROTO, "DataVersion", 1);
// remove contacts in DB that have been removed from the list
HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
diff --git a/worldtime_protocol/worldtimeproto.cpp b/worldtime_protocol/worldtimeproto.cpp
index 5ee4724..f782c0c 100644
--- a/worldtime_protocol/worldtimeproto.cpp
+++ b/worldtime_protocol/worldtimeproto.cpp
@@ -112,7 +112,7 @@ int GetStatus(WPARAM wParam,LPARAM lParam)
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
"World Time Protocol",
- PLUGIN_MAKE_VERSION(0, 1, 0, 1),
+ PLUGIN_MAKE_VERSION(0, 1, 1, 0),
"Adds 'contacts' showing the time at specified locations around the world.",
"Scott Ellis",
"mail@scottellis.com.au",