Mercurial > pidgin.yaz
comparison finch/gntpounce.c @ 22213:16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 20:45:41 +0000 |
parents | 665e04562de0 |
children | 5152a14d06a3 |
comparison
equal
deleted
inserted
replaced
22212:6bb29f94862c | 22213:16ff37f64e29 |
---|---|
806 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); | 806 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
807 } | 807 } |
808 | 808 |
809 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) | 809 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) |
810 { | 810 { |
811 char *tmp; | 811 char *tmp = NULL; |
812 const char *name_shown; | 812 const char *name_shown; |
813 const char *reason; | 813 const char *reason; |
814 struct { | |
815 PurplePounceEvent event; | |
816 const char *format; | |
817 } messages[] = { | |
818 {PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")}, | |
819 {PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")}, | |
820 {PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")}, | |
821 {PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")}, | |
822 {PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")}, | |
823 {PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")}, | |
824 {PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")}, | |
825 {PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")}, | |
826 {PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")}, | |
827 {PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")}, | |
828 {0, NULL} | |
829 }; | |
830 int i; | |
814 reason = purple_pounce_action_get_attribute(pounce, "popup-notify", | 831 reason = purple_pounce_action_get_attribute(pounce, "popup-notify", |
815 "reason"); | 832 "reason"); |
816 | 833 |
817 /* | 834 /* |
818 * Here we place the protocol name in the pounce dialog to lessen | 835 * Here we place the protocol name in the pounce dialog to lessen |
819 * confusion about what protocol a pounce is for. | 836 * confusion about what protocol a pounce is for. |
820 */ | 837 */ |
821 tmp = g_strdup_printf( | 838 for (i = 0; messages[i].format != NULL; i++) { |
822 (events & PURPLE_POUNCE_TYPING) ? | 839 if (messages[i].event & events) { |
823 _("%s has started typing to you (%s)") : | 840 tmp = g_strdup_printf(messages[i].format, alias, |
824 (events & PURPLE_POUNCE_TYPED) ? | 841 purple_account_get_protocol_name(account)); |
825 _("%s has paused while typing to you (%s)") : | 842 break; |
826 (events & PURPLE_POUNCE_SIGNON) ? | 843 } |
827 _("%s has signed on (%s)") : | 844 } |
828 (events & PURPLE_POUNCE_IDLE_RETURN) ? | 845 if (tmp == NULL) |
829 _("%s has returned from being idle (%s)") : | 846 tmp = g_strdup(_("Unknown pounce event. Please report this!")); |
830 (events & PURPLE_POUNCE_AWAY_RETURN) ? | |
831 _("%s has returned from being away (%s)") : | |
832 (events & PURPLE_POUNCE_TYPING_STOPPED) ? | |
833 _("%s has stopped typing to you (%s)") : | |
834 (events & PURPLE_POUNCE_SIGNOFF) ? | |
835 _("%s has signed off (%s)") : | |
836 (events & PURPLE_POUNCE_IDLE) ? | |
837 _("%s has become idle (%s)") : | |
838 (events & PURPLE_POUNCE_AWAY) ? | |
839 _("%s has gone away. (%s)") : | |
840 (events & PURPLE_POUNCE_MESSAGE_RECEIVED) ? | |
841 _("%s has sent you a message. (%s)") : | |
842 _("Unknown pounce event. Please report this!"), | |
843 alias, purple_account_get_protocol_name(account)); | |
844 | 847 |
845 /* | 848 /* |
846 * Ok here is where I change the second argument, title, from | 849 * Ok here is where I change the second argument, title, from |
847 * NULL to the account alias if we have it or the account | 850 * NULL to the account alias if we have it or the account |
848 * name if that's all we have | 851 * name if that's all we have |
878 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); | 881 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
879 | 882 |
880 purple_conversation_write(conv, NULL, message, | 883 purple_conversation_write(conv, NULL, message, |
881 PURPLE_MESSAGE_SEND, time(NULL)); | 884 PURPLE_MESSAGE_SEND, time(NULL)); |
882 | 885 |
883 serv_send_im(account->gc, (char *)pouncee, (char *)message, 0); | 886 serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0); |
884 } | 887 } |
885 } | 888 } |
886 | 889 |
887 if (purple_pounce_action_is_enabled(pounce, "execute-command")) | 890 if (purple_pounce_action_is_enabled(pounce, "execute-command")) |
888 { | 891 { |