src/gtknotify.c

changeset 12477
9328971aff14
parent 12257
bc979ba39363
child 12600
7ecd4441fdc7
equal deleted inserted replaced
12476:c4e21f4ab5a7 12477:9328971aff14
719 719
720 static void * 720 static void *
721 gaim_gtk_notify_uri(const char *uri) 721 gaim_gtk_notify_uri(const char *uri)
722 { 722 {
723 #ifndef _WIN32 723 #ifndef _WIN32
724 char *escaped = g_shell_quote(uri);
724 char *command = NULL; 725 char *command = NULL;
725 char *remote_command = NULL; 726 char *remote_command = NULL;
726 const char *web_browser; 727 const char *web_browser;
727 int place; 728 int place;
728 729
730 place = gaim_prefs_get_int("/gaim/gtk/browsers/place"); 731 place = gaim_prefs_get_int("/gaim/gtk/browsers/place");
731 732
732 /* if they are running gnome, use the gnome web browser */ 733 /* if they are running gnome, use the gnome web browser */
733 if (gaim_running_gnome() == TRUE) 734 if (gaim_running_gnome() == TRUE)
734 { 735 {
735 command = g_strdup_printf("gnome-open \"%s\"", uri); 736 command = g_strdup_printf("gnome-open %s", escaped);
736 } 737 }
737 else if (!strcmp(web_browser, "epiphany") || 738 else if (!strcmp(web_browser, "epiphany") ||
738 !strcmp(web_browser, "galeon")) 739 !strcmp(web_browser, "galeon"))
739 { 740 {
740 if (place == GAIM_BROWSER_NEW_WINDOW) 741 if (place == GAIM_BROWSER_NEW_WINDOW)
741 command = g_strdup_printf("%s -w \"%s\"", web_browser, uri); 742 command = g_strdup_printf("%s -w %s", web_browser, escaped);
742 else if (place == GAIM_BROWSER_NEW_TAB) 743 else if (place == GAIM_BROWSER_NEW_TAB)
743 command = g_strdup_printf("%s -n \"%s\"", web_browser, uri); 744 command = g_strdup_printf("%s -n %s", web_browser, escaped);
744 else 745 else
745 command = g_strdup_printf("%s \"%s\"", web_browser, uri); 746 command = g_strdup_printf("%s %s", web_browser, escaped);
746 } 747 }
747 else if (!strcmp(web_browser, "gnome-open")) 748 else if (!strcmp(web_browser, "gnome-open"))
748 { 749 {
749 command = g_strdup_printf("gnome-open \"%s\"", uri); 750 command = g_strdup_printf("gnome-open %s", escaped);
750 } 751 }
751 else if (!strcmp(web_browser, "kfmclient")) 752 else if (!strcmp(web_browser, "kfmclient"))
752 { 753 {
753 command = g_strdup_printf("kfmclient openURL \"%s\"", uri); 754 command = g_strdup_printf("kfmclient openURL %s", escaped);
754 /* 755 /*
755 * Does Konqueror have options to open in new tab 756 * Does Konqueror have options to open in new tab
756 * and/or current window? 757 * and/or current window?
757 */ 758 */
758 } 759 }
760 !strcmp(web_browser, "mozilla-firebird") || 761 !strcmp(web_browser, "mozilla-firebird") ||
761 !strcmp(web_browser, "firefox")) 762 !strcmp(web_browser, "firefox"))
762 { 763 {
763 char *args = ""; 764 char *args = "";
764 765
765 command = g_strdup_printf("%s \"%s\"", web_browser, uri); 766 command = g_strdup_printf("%s %s", web_browser, escaped);
766 767
767 /* 768 /*
768 * Firefox 0.9 and higher require a "-a firefox" option when 769 * Firefox 0.9 and higher require a "-a firefox" option when
769 * using -remote commands. This breaks older versions of 770 * using -remote commands. This breaks older versions of
770 * mozilla. So we include this other handly little string 771 * mozilla. So we include this other handly little string
776 if (!strcmp(web_browser, "firefox")) 777 if (!strcmp(web_browser, "firefox"))
777 args = "-a firefox"; 778 args = "-a firefox";
778 779
779 if (place == GAIM_BROWSER_NEW_WINDOW) 780 if (place == GAIM_BROWSER_NEW_WINDOW)
780 remote_command = g_strdup_printf("%s %s -remote " 781 remote_command = g_strdup_printf("%s %s -remote "
781 "\"openURL(%s,new-window)\"", 782 "openURL(%s,new-window)",
782 web_browser, args, uri); 783 web_browser, args, escaped);
783 else if (place == GAIM_BROWSER_NEW_TAB) 784 else if (place == GAIM_BROWSER_NEW_TAB)
784 remote_command = g_strdup_printf("%s %s -remote " 785 remote_command = g_strdup_printf("%s %s -remote "
785 "\"openURL(%s,new-tab)\"", 786 "openURL(%s,new-tab)",
786 web_browser, args, uri); 787 web_browser, args, escaped);
787 else if (place == GAIM_BROWSER_CURRENT) 788 else if (place == GAIM_BROWSER_CURRENT)
788 remote_command = g_strdup_printf("%s %s -remote " 789 remote_command = g_strdup_printf("%s %s -remote "
789 "\"openURL(%s)\"", 790 "openURL(%s)",
790 web_browser, args, uri); 791 web_browser, args, escaped);
791 } 792 }
792 else if (!strcmp(web_browser, "netscape")) 793 else if (!strcmp(web_browser, "netscape"))
793 { 794 {
794 command = g_strdup_printf("netscape \"%s\"", uri); 795 command = g_strdup_printf("netscape %s", escaped);
795 796
796 if (place == GAIM_BROWSER_NEW_WINDOW) 797 if (place == GAIM_BROWSER_NEW_WINDOW)
797 { 798 {
798 remote_command = g_strdup_printf("netscape -remote " 799 remote_command = g_strdup_printf("netscape -remote "
799 "\"openURL(%s,new-window)\"", 800 "openURL(%s,new-window)",
800 uri); 801 escaped);
801 } 802 }
802 else if (place == GAIM_BROWSER_CURRENT) 803 else if (place == GAIM_BROWSER_CURRENT)
803 { 804 {
804 remote_command = g_strdup_printf("netscape -remote " 805 remote_command = g_strdup_printf("netscape -remote "
805 "\"openURL(%s)\"", uri); 806 "openURL(%s)", escaped);
806 } 807 }
807 } 808 }
808 else if (!strcmp(web_browser, "opera")) 809 else if (!strcmp(web_browser, "opera"))
809 { 810 {
810 if (place == GAIM_BROWSER_NEW_WINDOW) 811 if (place == GAIM_BROWSER_NEW_WINDOW)
811 command = g_strdup_printf("opera -newwindow \"%s\"", uri); 812 command = g_strdup_printf("opera -newwindow %s", escaped);
812 else if (place == GAIM_BROWSER_NEW_TAB) 813 else if (place == GAIM_BROWSER_NEW_TAB)
813 command = g_strdup_printf("opera -newpage \"%s\"", uri); 814 command = g_strdup_printf("opera -newpage %s", escaped);
814 else if (place == GAIM_BROWSER_CURRENT) 815 else if (place == GAIM_BROWSER_CURRENT)
815 { 816 {
816 remote_command = g_strdup_printf("opera -remote " 817 remote_command = g_strdup_printf("opera -remote "
817 "\"openURL(%s)\"", uri); 818 "openURL(%s)", escaped);
818 command = g_strdup_printf("opera \"%s\"", uri); 819 command = g_strdup_printf("opera %s", escaped);
819 } 820 }
820 else 821 else
821 command = g_strdup_printf("opera \"%s\"", uri); 822 command = g_strdup_printf("opera %s", escaped);
822 823
823 } 824 }
824 else if (!strcmp(web_browser, "custom")) 825 else if (!strcmp(web_browser, "custom"))
825 { 826 {
826 const char *web_command; 827 const char *web_command;
834 "chosen, but no command has been set.")); 835 "chosen, but no command has been set."));
835 return NULL; 836 return NULL;
836 } 837 }
837 838
838 if (strstr(web_command, "%s")) 839 if (strstr(web_command, "%s"))
839 command = gaim_strreplace(web_command, "%s", uri); 840 command = gaim_strreplace(web_command, "%s", escaped);
840 else 841 else
841 { 842 {
842 /* 843 /*
843 * There is no "%s" in the browser command. Assume the user 844 * There is no "%s" in the browser command. Assume the user
844 * wanted the URL tacked on to the end of the command. 845 * wanted the URL tacked on to the end of the command.
845 */ 846 */
846 command = g_strdup_printf("%s %s", web_command, uri); 847 command = g_strdup_printf("%s %s", web_command, escaped);
847 } 848 }
848 } 849 }
850
851 g_free(escaped);
849 852
850 if (remote_command != NULL) 853 if (remote_command != NULL)
851 { 854 {
852 /* try the remote command first */ 855 /* try the remote command first */
853 if (uri_command(remote_command, TRUE) != 0) 856 if (uri_command(remote_command, TRUE) != 0)

mercurial