From 0c2db8f67782848603cdd845713ca70e285c0f49 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Sun, 4 Apr 2010 23:41:11 +0000 Subject: Fixed incorrect time after time zone table changes Reduced size plugin size git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@487 4f64403b-2f21-0410-a795-97e2b3489a10 --- worldtime_protocol/time_display.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'worldtime_protocol/time_display.cpp') diff --git a/worldtime_protocol/time_display.cpp b/worldtime_protocol/time_display.cpp index 2e179ee..f49cde7 100644 --- a/worldtime_protocol/time_display.cpp +++ b/worldtime_protocol/time_display.cpp @@ -204,16 +204,39 @@ void time_windows_cleanup() { void time_windows_init() { LoadFonts(); - char *proto; HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact != NULL ) { - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (proto && lstrcmp( PROTO, proto) == 0) { - if(DBGetContactSettingByte(hContact, PROTO, "WindowWasOpen", 0) != 0) { + char* proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (proto && lstrcmp( PROTO, proto) == 0) + { + if (DBGetContactSettingByte(hContact, PROTO, "WindowWasOpen", 0) != 0) + { show_time(hContact); DBWriteContactSettingByte(hContact, PROTO, "WindowWasOpen", 0); } + + DBVARIANT dbv; + if (!DBGetContactSetting(hContact, PROTO, "TZName", &dbv)) + { + int list_index = DBGetContactSettingDword(hContact, PROTO, "TimezoneListIndex", -1); + if (list_index < 0 || list_index >= timezone_list.getCount()) + list_index = 0; + + if (strcmp(timezone_list[list_index].tcName, dbv.pszVal)) + { + for (int j = 0; j < timezone_list.getCount(); ++j) + { + if (!strcmp(timezone_list[j].tcName, dbv.pszVal)) + { + list_index = j; + break; + } + } + DBWriteContactSettingDword(hContact, PROTO, "TimezoneListIndex", list_index); + } + DBFreeVariant(&dbv); + } } hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); -- cgit v1.2.3