Mercurial > pidgin
comparison libpurple/savedstatuses.c @ 18193:09eb621782bc
explicit merge of 'f2eb358baf2c72cb37b6b9bcb4c036e44e0bcc2b'
and '2344c84a6e70c374b19936a127462d2f19c0139c'
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Tue, 19 Jun 2007 17:17:57 +0000 |
parents | ab6d2763b8d8 02f39842d28b |
children | 9cb31b7c2dd6 |
comparison
equal
deleted
inserted
replaced
18166:afeb35205669 | 18193:09eb621782bc |
---|---|
567 | 567 |
568 saved_statuses = g_list_insert_sorted(saved_statuses, status, saved_statuses_sort_func); | 568 saved_statuses = g_list_insert_sorted(saved_statuses, status, saved_statuses_sort_func); |
569 | 569 |
570 schedule_save(); | 570 schedule_save(); |
571 | 571 |
572 purple_signal_emit(purple_savedstatuses_get_handle(), "savedstatus-added", | |
573 status); | |
574 | |
572 return status; | 575 return status; |
573 } | 576 } |
574 | 577 |
575 void | 578 void |
576 purple_savedstatus_set_title(PurpleSavedStatus *status, const char *title) | 579 purple_savedstatus_set_title(PurpleSavedStatus *status, const char *title) |
582 | 585 |
583 g_free(status->title); | 586 g_free(status->title); |
584 status->title = g_strdup(title); | 587 status->title = g_strdup(title); |
585 | 588 |
586 schedule_save(); | 589 schedule_save(); |
590 | |
591 purple_signal_emit(purple_savedstatuses_get_handle(), | |
592 "savedstatus-modified", status); | |
587 } | 593 } |
588 | 594 |
589 void | 595 void |
590 purple_savedstatus_set_type(PurpleSavedStatus *status, PurpleStatusPrimitive type) | 596 purple_savedstatus_set_type(PurpleSavedStatus *status, PurpleStatusPrimitive type) |
591 { | 597 { |
592 g_return_if_fail(status != NULL); | 598 g_return_if_fail(status != NULL); |
593 | 599 |
594 status->type = type; | 600 status->type = type; |
595 | 601 |
596 schedule_save(); | 602 schedule_save(); |
603 purple_signal_emit(purple_savedstatuses_get_handle(), | |
604 "savedstatus-modified", status); | |
597 } | 605 } |
598 | 606 |
599 void | 607 void |
600 purple_savedstatus_set_message(PurpleSavedStatus *status, const char *message) | 608 purple_savedstatus_set_message(PurpleSavedStatus *status, const char *message) |
601 { | 609 { |
606 status->message = NULL; | 614 status->message = NULL; |
607 else | 615 else |
608 status->message = g_strdup(message); | 616 status->message = g_strdup(message); |
609 | 617 |
610 schedule_save(); | 618 schedule_save(); |
619 | |
620 purple_signal_emit(purple_savedstatuses_get_handle(), | |
621 "savedstatus-modified", status); | |
611 } | 622 } |
612 | 623 |
613 void | 624 void |
614 purple_savedstatus_set_substatus(PurpleSavedStatus *saved_status, | 625 purple_savedstatus_set_substatus(PurpleSavedStatus *saved_status, |
615 const PurpleAccount *account, | 626 const PurpleAccount *account, |
635 substatus->type = type; | 646 substatus->type = type; |
636 g_free(substatus->message); | 647 g_free(substatus->message); |
637 substatus->message = g_strdup(message); | 648 substatus->message = g_strdup(message); |
638 | 649 |
639 schedule_save(); | 650 schedule_save(); |
651 purple_signal_emit(purple_savedstatuses_get_handle(), | |
652 "savedstatus-modified", saved_status); | |
640 } | 653 } |
641 | 654 |
642 void | 655 void |
643 purple_savedstatus_unset_substatus(PurpleSavedStatus *saved_status, | 656 purple_savedstatus_unset_substatus(PurpleSavedStatus *saved_status, |
644 const PurpleAccount *account) | 657 const PurpleAccount *account) |
658 g_free(substatus->message); | 671 g_free(substatus->message); |
659 g_free(substatus); | 672 g_free(substatus); |
660 return; | 673 return; |
661 } | 674 } |
662 } | 675 } |
676 | |
677 purple_signal_emit(purple_savedstatuses_get_handle(), | |
678 "savedstatus-modified", saved_status); | |
663 } | 679 } |
664 | 680 |
665 /* | 681 /* |
666 * This gets called when an account is deleted. We iterate through | 682 * This gets called when an account is deleted. We iterate through |
667 * all of our saved statuses and delete any substatuses that may | 683 * all of our saved statuses and delete any substatuses that may |
681 status = (PurpleSavedStatus *)iter->data; | 697 status = (PurpleSavedStatus *)iter->data; |
682 purple_savedstatus_unset_substatus(status, account); | 698 purple_savedstatus_unset_substatus(status, account); |
683 } | 699 } |
684 } | 700 } |
685 | 701 |
686 gboolean | 702 void |
687 purple_savedstatus_delete(const char *title) | 703 purple_savedstatus_delete_by_status(PurpleSavedStatus *status) |
688 { | 704 { |
689 PurpleSavedStatus *status; | |
690 time_t creation_time, current, idleaway; | 705 time_t creation_time, current, idleaway; |
691 | 706 |
692 status = purple_savedstatus_find(title); | 707 g_return_if_fail(status != NULL); |
693 | |
694 if (status == NULL) | |
695 return FALSE; | |
696 | 708 |
697 saved_statuses = g_list_remove(saved_statuses, status); | 709 saved_statuses = g_list_remove(saved_statuses, status); |
698 creation_time = purple_savedstatus_get_creation_time(status); | 710 creation_time = purple_savedstatus_get_creation_time(status); |
699 g_hash_table_remove(creation_times, &creation_time); | 711 g_hash_table_remove(creation_times, &creation_time); |
700 free_saved_status(status); | 712 free_saved_status(status); |
710 purple_prefs_set_int("/purple/savedstatus/default", 0); | 722 purple_prefs_set_int("/purple/savedstatus/default", 0); |
711 | 723 |
712 idleaway = purple_prefs_get_int("/purple/savedstatus/idleaway"); | 724 idleaway = purple_prefs_get_int("/purple/savedstatus/idleaway"); |
713 if (idleaway == creation_time) | 725 if (idleaway == creation_time) |
714 purple_prefs_set_int("/purple/savedstatus/idleaway", 0); | 726 purple_prefs_set_int("/purple/savedstatus/idleaway", 0); |
727 | |
728 purple_signal_emit(purple_savedstatuses_get_handle(), | |
729 "savedstatus-deleted", status); | |
730 } | |
731 | |
732 gboolean | |
733 purple_savedstatus_delete(const char *title) | |
734 { | |
735 PurpleSavedStatus *status; | |
736 | |
737 status = purple_savedstatus_find(title); | |
738 | |
739 if (status == NULL) | |
740 return FALSE; | |
741 | |
742 if (purple_savedstatus_get_current() == status) | |
743 return FALSE; | |
744 | |
745 purple_savedstatus_delete_by_status(status); | |
715 | 746 |
716 return TRUE; | 747 return TRUE; |
717 } | 748 } |
718 | 749 |
719 GList * | 750 GList * |
1169 purple_value_new(PURPLE_TYPE_SUBTYPE, | 1200 purple_value_new(PURPLE_TYPE_SUBTYPE, |
1170 PURPLE_SUBTYPE_SAVEDSTATUS), | 1201 PURPLE_SUBTYPE_SAVEDSTATUS), |
1171 purple_value_new(PURPLE_TYPE_SUBTYPE, | 1202 purple_value_new(PURPLE_TYPE_SUBTYPE, |
1172 PURPLE_SUBTYPE_SAVEDSTATUS)); | 1203 PURPLE_SUBTYPE_SAVEDSTATUS)); |
1173 | 1204 |
1205 purple_signal_register(handle, "savedstatus-added", | |
1206 purple_marshal_VOID__POINTER, NULL, 1, | |
1207 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1208 PURPLE_SUBTYPE_SAVEDSTATUS)); | |
1209 | |
1210 purple_signal_register(handle, "savedstatus-deleted", | |
1211 purple_marshal_VOID__POINTER, NULL, 1, | |
1212 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1213 PURPLE_SUBTYPE_SAVEDSTATUS)); | |
1214 | |
1215 purple_signal_register(handle, "savedstatus-modified", | |
1216 purple_marshal_VOID__POINTER, NULL, 1, | |
1217 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1218 PURPLE_SUBTYPE_SAVEDSTATUS)); | |
1219 | |
1174 purple_signal_connect(purple_accounts_get_handle(), "account-removed", | 1220 purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
1175 handle, | 1221 handle, |
1176 PURPLE_CALLBACK(purple_savedstatus_unset_all_substatuses), | 1222 PURPLE_CALLBACK(purple_savedstatus_unset_all_substatuses), |
1177 NULL); | 1223 NULL); |
1178 } | 1224 } |