Mercurial > pidgin
comparison libpurple/savedstatuses.c @ 26113:9fcff08ce726
propagate from branch 'im.pidgin.pidgin' (head e39dfbe6c3a61b035fc764dfaad7b49c84666d14)
to branch 'im.pidgin.pidgin.vv' (head 22553645a6b7273105d6333de2a0cec0f32b8478)
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Thu, 19 Feb 2009 11:29:08 +0000 |
parents | a946cffda321 |
children | 4b8c4870b13a |
comparison
equal
deleted
inserted
replaced
26112:1fa62c559a78 | 26113:9fcff08ce726 |
---|---|
146 g_return_if_fail(status != NULL); | 146 g_return_if_fail(status != NULL); |
147 | 147 |
148 /* Avoid using 0 because it's an invalid hash key */ | 148 /* Avoid using 0 because it's an invalid hash key */ |
149 status->creation_time = creation_time != 0 ? creation_time : 1; | 149 status->creation_time = creation_time != 0 ? creation_time : 1; |
150 | 150 |
151 while (g_hash_table_lookup(creation_times, &status->creation_time) != NULL) | 151 while (g_hash_table_lookup(creation_times, (gconstpointer)status->creation_time) != NULL) |
152 status->creation_time++; | 152 status->creation_time++; |
153 | 153 |
154 g_hash_table_insert(creation_times, | 154 g_hash_table_insert(creation_times, |
155 &status->creation_time, | 155 (gpointer)status->creation_time, |
156 status); | 156 status); |
157 } | 157 } |
158 | 158 |
159 /** | 159 /** |
160 * A magic number is calculated for each status, and then the | 160 * A magic number is calculated for each status, and then the |
215 { | 215 { |
216 if (saved_status != current_status) | 216 if (saved_status != current_status) |
217 { | 217 { |
218 saved_statuses = g_list_remove(saved_statuses, saved_status); | 218 saved_statuses = g_list_remove(saved_statuses, saved_status); |
219 creation_time = purple_savedstatus_get_creation_time(saved_status); | 219 creation_time = purple_savedstatus_get_creation_time(saved_status); |
220 g_hash_table_remove(creation_times, &creation_time); | 220 g_hash_table_remove(creation_times, (gconstpointer)creation_time); |
221 free_saved_status(saved_status); | 221 free_saved_status(saved_status); |
222 } | 222 } |
223 } | 223 } |
224 else | 224 else |
225 count++; | 225 count++; |
711 | 711 |
712 g_return_if_fail(status != NULL); | 712 g_return_if_fail(status != NULL); |
713 | 713 |
714 saved_statuses = g_list_remove(saved_statuses, status); | 714 saved_statuses = g_list_remove(saved_statuses, status); |
715 creation_time = purple_savedstatus_get_creation_time(status); | 715 creation_time = purple_savedstatus_get_creation_time(status); |
716 g_hash_table_remove(creation_times, &creation_time); | 716 g_hash_table_remove(creation_times, (gconstpointer)creation_time); |
717 free_saved_status(status); | 717 free_saved_status(status); |
718 | 718 |
719 schedule_save(); | 719 schedule_save(); |
720 | 720 |
721 /* | 721 /* |
799 } | 799 } |
800 | 800 |
801 PurpleSavedStatus * | 801 PurpleSavedStatus * |
802 purple_savedstatus_get_default() | 802 purple_savedstatus_get_default() |
803 { | 803 { |
804 int creation_time; | 804 time_t creation_time; |
805 PurpleSavedStatus *saved_status = NULL; | 805 PurpleSavedStatus *saved_status = NULL; |
806 | 806 |
807 creation_time = purple_prefs_get_int("/purple/savedstatus/default"); | 807 creation_time = purple_prefs_get_int("/purple/savedstatus/default"); |
808 | 808 |
809 if (creation_time != 0) | 809 if (creation_time != 0) |
810 saved_status = g_hash_table_lookup(creation_times, &creation_time); | 810 saved_status = g_hash_table_lookup(creation_times, (gconstpointer)creation_time); |
811 | 811 |
812 if (saved_status == NULL) | 812 if (saved_status == NULL) |
813 { | 813 { |
814 /* | 814 /* |
815 * We don't have a current saved status! This is either a new | 815 * We don't have a current saved status! This is either a new |
826 } | 826 } |
827 | 827 |
828 PurpleSavedStatus * | 828 PurpleSavedStatus * |
829 purple_savedstatus_get_idleaway() | 829 purple_savedstatus_get_idleaway() |
830 { | 830 { |
831 int creation_time; | 831 time_t creation_time; |
832 PurpleSavedStatus *saved_status = NULL; | 832 PurpleSavedStatus *saved_status = NULL; |
833 | 833 |
834 creation_time = purple_prefs_get_int("/purple/savedstatus/idleaway"); | 834 creation_time = purple_prefs_get_int("/purple/savedstatus/idleaway"); |
835 | 835 |
836 if (creation_time != 0) | 836 if (creation_time != 0) |
837 saved_status = g_hash_table_lookup(creation_times, &creation_time); | 837 saved_status = g_hash_table_lookup(creation_times, (gconstpointer)creation_time); |
838 | 838 |
839 if (saved_status == NULL) | 839 if (saved_status == NULL) |
840 { | 840 { |
841 /* We don't have a specified "idle" status! Weird. */ | 841 /* We don't have a specified "idle" status! Weird. */ |
842 saved_status = purple_savedstatus_find_transient_by_type_and_message( | 842 saved_status = purple_savedstatus_find_transient_by_type_and_message( |
905 } | 905 } |
906 | 906 |
907 PurpleSavedStatus * | 907 PurpleSavedStatus * |
908 purple_savedstatus_get_startup() | 908 purple_savedstatus_get_startup() |
909 { | 909 { |
910 int creation_time; | 910 time_t creation_time; |
911 PurpleSavedStatus *saved_status = NULL; | 911 PurpleSavedStatus *saved_status = NULL; |
912 | 912 |
913 creation_time = purple_prefs_get_int("/purple/savedstatus/startup"); | 913 creation_time = purple_prefs_get_int("/purple/savedstatus/startup"); |
914 | 914 |
915 if (creation_time != 0) | 915 if (creation_time != 0) |
916 saved_status = g_hash_table_lookup(creation_times, &creation_time); | 916 saved_status = g_hash_table_lookup(creation_times, (gconstpointer)creation_time); |
917 | 917 |
918 if (saved_status == NULL) | 918 if (saved_status == NULL) |
919 { | 919 { |
920 /* | 920 /* |
921 * We don't have a status to apply. | 921 * We don't have a status to apply. |
1185 void | 1185 void |
1186 purple_savedstatuses_init(void) | 1186 purple_savedstatuses_init(void) |
1187 { | 1187 { |
1188 void *handle = purple_savedstatuses_get_handle(); | 1188 void *handle = purple_savedstatuses_get_handle(); |
1189 | 1189 |
1190 creation_times = g_hash_table_new(g_int_hash, g_int_equal); | 1190 creation_times = g_hash_table_new(g_direct_hash, g_direct_equal); |
1191 | 1191 |
1192 /* | 1192 /* |
1193 * Using 0 as the creation_time is a special case. | 1193 * Using 0 as the creation_time is a special case. |
1194 * If someone calls purple_savedstatus_get_current() or | 1194 * If someone calls purple_savedstatus_get_current() or |
1195 * purple_savedstatus_get_idleaway() and either of those functions | 1195 * purple_savedstatus_get_idleaway() and either of those functions |