Mercurial > pidgin.yaz
comparison pidgin/gtkmain.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 84b0f9b23ede |
children | 66dff3dfdea6 |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /* | 1 /* |
2 * gaim | 2 * purple |
3 * | 3 * |
4 * Gaim is the legal property of its developers, whose names are too numerous | 4 * Purple is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
6 * source distribution. | 6 * source distribution. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
109 #endif | 109 #endif |
110 | 110 |
111 static int | 111 static int |
112 dologin_named(const char *name) | 112 dologin_named(const char *name) |
113 { | 113 { |
114 GaimAccount *account; | 114 PurpleAccount *account; |
115 char **names; | 115 char **names; |
116 int i; | 116 int i; |
117 int ret = -1; | 117 int ret = -1; |
118 | 118 |
119 if (name != NULL) { /* list of names given */ | 119 if (name != NULL) { /* list of names given */ |
120 names = g_strsplit(name, ",", 64); | 120 names = g_strsplit(name, ",", 64); |
121 for (i = 0; names[i] != NULL; i++) { | 121 for (i = 0; names[i] != NULL; i++) { |
122 account = gaim_accounts_find(names[i], NULL); | 122 account = purple_accounts_find(names[i], NULL); |
123 if (account != NULL) { /* found a user */ | 123 if (account != NULL) { /* found a user */ |
124 ret = 0; | 124 ret = 0; |
125 gaim_account_connect(account); | 125 purple_account_connect(account); |
126 } | 126 } |
127 } | 127 } |
128 g_strfreev(names); | 128 g_strfreev(names); |
129 } else { /* no name given, use the first account */ | 129 } else { /* no name given, use the first account */ |
130 GList *accounts; | 130 GList *accounts; |
131 | 131 |
132 accounts = gaim_accounts_get_all(); | 132 accounts = purple_accounts_get_all(); |
133 if (accounts != NULL) | 133 if (accounts != NULL) |
134 { | 134 { |
135 account = (GaimAccount *)accounts->data; | 135 account = (PurpleAccount *)accounts->data; |
136 ret = 0; | 136 ret = 0; |
137 gaim_account_connect(account); | 137 purple_account_connect(account); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 return ret; | 141 return ret; |
142 } | 142 } |
143 | 143 |
144 #ifdef HAVE_SIGNAL_H | 144 #ifdef HAVE_SIGNAL_H |
145 static void sighandler(int sig); | 145 static void sighandler(int sig); |
146 | 146 |
147 /** | 147 /** |
148 * Reap all our dead children. Sometimes Gaim forks off a separate | 148 * Reap all our dead children. Sometimes Purple forks off a separate |
149 * process to do some stuff. When that process exits we are | 149 * process to do some stuff. When that process exits we are |
150 * informed about it so that we can call waitpid() and let it | 150 * informed about it so that we can call waitpid() and let it |
151 * stop being a zombie. | 151 * stop being a zombie. |
152 * | 152 * |
153 * We used to do this immediately when our signal handler was | 153 * We used to do this immediately when our signal handler was |
158 * | 158 * |
159 * Anyway, so then GStreamer waits for its child to die and then | 159 * Anyway, so then GStreamer waits for its child to die and then |
160 * it continues with the initialization process. This means that | 160 * it continues with the initialization process. This means that |
161 * we have a race condition where GStreamer is waitpid()ing for its | 161 * we have a race condition where GStreamer is waitpid()ing for its |
162 * child to die and we're catching the SIGCHLD signal. If GStreamer | 162 * child to die and we're catching the SIGCHLD signal. If GStreamer |
163 * is awarded the zombied process then everything is ok. But if Gaim | 163 * is awarded the zombied process then everything is ok. But if Purple |
164 * reaps the zombie process then the GStreamer initialization sequence | 164 * reaps the zombie process then the GStreamer initialization sequence |
165 * fails. | 165 * fails. |
166 * | 166 * |
167 * So the ugly solution is to wait a second to give GStreamer time to | 167 * So the ugly solution is to wait a second to give GStreamer time to |
168 * reap that bad boy. | 168 * reap that bad boy. |
202 static void | 202 static void |
203 sighandler(int sig) | 203 sighandler(int sig) |
204 { | 204 { |
205 switch (sig) { | 205 switch (sig) { |
206 case SIGHUP: | 206 case SIGHUP: |
207 gaim_debug_warning("sighandler", "Caught signal %d\n", sig); | 207 purple_debug_warning("sighandler", "Caught signal %d\n", sig); |
208 gaim_connections_disconnect_all(); | 208 purple_connections_disconnect_all(); |
209 break; | 209 break; |
210 case SIGSEGV: | 210 case SIGSEGV: |
211 fprintf(stderr, "%s", segfault_message); | 211 fprintf(stderr, "%s", segfault_message); |
212 abort(); | 212 abort(); |
213 break; | 213 break; |
218 break; | 218 break; |
219 case SIGALRM: | 219 case SIGALRM: |
220 clean_pid(); | 220 clean_pid(); |
221 break; | 221 break; |
222 default: | 222 default: |
223 gaim_debug_warning("sighandler", "Caught signal %d\n", sig); | 223 purple_debug_warning("sighandler", "Caught signal %d\n", sig); |
224 gaim_connections_disconnect_all(); | 224 purple_connections_disconnect_all(); |
225 | 225 |
226 gaim_plugins_unload_all(); | 226 purple_plugins_unload_all(); |
227 | 227 |
228 if (gtk_main_level()) | 228 if (gtk_main_level()) |
229 gtk_main_quit(); | 229 gtk_main_quit(); |
230 exit(0); | 230 exit(0); |
231 } | 231 } |
254 icons = g_list_append(icons,icon); | 254 icons = g_list_append(icons,icon); |
255 gtk_window_set_default_icon_list(icons); | 255 gtk_window_set_default_icon_list(icons); |
256 g_object_unref(G_OBJECT(icon)); | 256 g_object_unref(G_OBJECT(icon)); |
257 g_list_free(icons); | 257 g_list_free(icons); |
258 } else { | 258 } else { |
259 gaim_debug_error("ui_main", | 259 purple_debug_error("ui_main", |
260 "Failed to load the default window icon!\n"); | 260 "Failed to load the default window icon!\n"); |
261 } | 261 } |
262 #endif | 262 #endif |
263 | 263 |
264 return 0; | 264 return 0; |
265 } | 265 } |
266 | 266 |
267 static void | 267 static void |
268 debug_init(void) | 268 debug_init(void) |
269 { | 269 { |
270 gaim_debug_set_ui_ops(pidgin_debug_get_ui_ops()); | 270 purple_debug_set_ui_ops(pidgin_debug_get_ui_ops()); |
271 pidgin_debug_init(); | 271 pidgin_debug_init(); |
272 } | 272 } |
273 | 273 |
274 static void | 274 static void |
275 pidgin_ui_init(void) | 275 pidgin_ui_init(void) |
276 { | 276 { |
277 /* Set the UI operation structures. */ | 277 /* Set the UI operation structures. */ |
278 gaim_accounts_set_ui_ops(pidgin_accounts_get_ui_ops()); | 278 purple_accounts_set_ui_ops(pidgin_accounts_get_ui_ops()); |
279 gaim_xfers_set_ui_ops(pidgin_xfers_get_ui_ops()); | 279 purple_xfers_set_ui_ops(pidgin_xfers_get_ui_ops()); |
280 gaim_blist_set_ui_ops(pidgin_blist_get_ui_ops()); | 280 purple_blist_set_ui_ops(pidgin_blist_get_ui_ops()); |
281 gaim_notify_set_ui_ops(pidgin_notify_get_ui_ops()); | 281 purple_notify_set_ui_ops(pidgin_notify_get_ui_ops()); |
282 gaim_privacy_set_ui_ops(pidgin_privacy_get_ui_ops()); | 282 purple_privacy_set_ui_ops(pidgin_privacy_get_ui_ops()); |
283 gaim_request_set_ui_ops(pidgin_request_get_ui_ops()); | 283 purple_request_set_ui_ops(pidgin_request_get_ui_ops()); |
284 gaim_sound_set_ui_ops(pidgin_sound_get_ui_ops()); | 284 purple_sound_set_ui_ops(pidgin_sound_get_ui_ops()); |
285 gaim_connections_set_ui_ops(pidgin_connections_get_ui_ops()); | 285 purple_connections_set_ui_ops(pidgin_connections_get_ui_ops()); |
286 gaim_whiteboard_set_ui_ops(pidgin_whiteboard_get_ui_ops()); | 286 purple_whiteboard_set_ui_ops(pidgin_whiteboard_get_ui_ops()); |
287 #ifdef USE_SCREENSAVER | 287 #ifdef USE_SCREENSAVER |
288 gaim_idle_set_ui_ops(pidgin_idle_get_ui_ops()); | 288 purple_idle_set_ui_ops(pidgin_idle_get_ui_ops()); |
289 #endif | 289 #endif |
290 | 290 |
291 pidgin_stock_init(); | 291 pidgin_stock_init(); |
292 pidgin_account_init(); | 292 pidgin_account_init(); |
293 pidgin_connection_init(); | 293 pidgin_connection_init(); |
324 | 324 |
325 /* and end it all... */ | 325 /* and end it all... */ |
326 gtk_main_quit(); | 326 gtk_main_quit(); |
327 } | 327 } |
328 | 328 |
329 static GaimCoreUiOps core_ops = | 329 static PurpleCoreUiOps core_ops = |
330 { | 330 { |
331 pidgin_prefs_init, | 331 pidgin_prefs_init, |
332 debug_init, | 332 debug_init, |
333 pidgin_ui_init, | 333 pidgin_ui_init, |
334 pidgin_quit | 334 pidgin_quit |
335 }; | 335 }; |
336 | 336 |
337 static GaimCoreUiOps * | 337 static PurpleCoreUiOps * |
338 pidgin_core_get_ui_ops(void) | 338 pidgin_core_get_ui_ops(void) |
339 { | 339 { |
340 return &core_ops; | 340 return &core_ops; |
341 } | 341 } |
342 | 342 |
357 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" | 357 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" |
358 " account(s) to use, separated by commas)\n" | 358 " account(s) to use, separated by commas)\n" |
359 " -v, --version display the current version and exit\n"), VERSION, name); | 359 " -v, --version display the current version and exit\n"), VERSION, name); |
360 } | 360 } |
361 | 361 |
362 gaim_print_utf8_to_console(stdout, text); | 362 purple_print_utf8_to_console(stdout, text); |
363 g_free(text); | 363 g_free(text); |
364 } | 364 } |
365 | 365 |
366 #ifdef HAVE_STARTUP_NOTIFICATION | 366 #ifdef HAVE_STARTUP_NOTIFICATION |
367 static void | 367 static void |
506 debug_enabled = TRUE; | 506 debug_enabled = TRUE; |
507 #else | 507 #else |
508 debug_enabled = FALSE; | 508 debug_enabled = FALSE; |
509 #endif | 509 #endif |
510 | 510 |
511 #ifdef GAIM_FATAL_ASSERTS | 511 #ifdef PURPLE_FATAL_ASSERTS |
512 /* Make g_return_... functions fatal. */ | 512 /* Make g_return_... functions fatal. */ |
513 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); | 513 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); |
514 #endif | 514 #endif |
515 | 515 |
516 #ifndef _WIN32 | 516 #ifndef _WIN32 |
544 "%sgdb.php\n\n" | 544 "%sgdb.php\n\n" |
545 "If you need further assistance, please IM either SeanEgn or \n" | 545 "If you need further assistance, please IM either SeanEgn or \n" |
546 "LSchiere (via AIM). Contact information for Sean and Luke \n" | 546 "LSchiere (via AIM). Contact information for Sean and Luke \n" |
547 "on other protocols is at\n" | 547 "on other protocols is at\n" |
548 "%scontactinfo.php\n"), | 548 "%scontactinfo.php\n"), |
549 GAIM_WEBSITE, GAIM_WEBSITE, GAIM_WEBSITE | 549 PURPLE_WEBSITE, PURPLE_WEBSITE, PURPLE_WEBSITE |
550 ); | 550 ); |
551 | 551 |
552 /* we have to convert the message (UTF-8 to console | 552 /* we have to convert the message (UTF-8 to console |
553 charset) early because after a segmentation fault | 553 charset) early because after a segmentation fault |
554 it's not a good practice to allocate memory */ | 554 it's not a good practice to allocate memory */ |
665 return 0; | 665 return 0; |
666 } | 666 } |
667 | 667 |
668 /* set a user-specified config directory */ | 668 /* set a user-specified config directory */ |
669 if (opt_config_dir_arg != NULL) { | 669 if (opt_config_dir_arg != NULL) { |
670 gaim_util_set_user_dir(opt_config_dir_arg); | 670 purple_util_set_user_dir(opt_config_dir_arg); |
671 } | 671 } |
672 | 672 |
673 /* | 673 /* |
674 * We're done piddling around with command line arguments. | 674 * We're done piddling around with command line arguments. |
675 * Fire up this baby. | 675 * Fire up this baby. |
676 */ | 676 */ |
677 | 677 |
678 gaim_debug_set_enabled(debug_enabled); | 678 purple_debug_set_enabled(debug_enabled); |
679 | 679 |
680 | 680 |
681 search_path = g_build_filename(gaim_user_dir(), "gtkrc-2.0", NULL); | 681 search_path = g_build_filename(purple_user_dir(), "gtkrc-2.0", NULL); |
682 gtk_rc_add_default_file(search_path); | 682 gtk_rc_add_default_file(search_path); |
683 g_free(search_path); | 683 g_free(search_path); |
684 | 684 |
685 gui_check = gtk_init_check(&argc, &argv); | 685 gui_check = gtk_init_check(&argc, &argv); |
686 if (!gui_check) { | 686 if (!gui_check) { |
696 | 696 |
697 #ifdef _WIN32 | 697 #ifdef _WIN32 |
698 winpidgin_init(hint); | 698 winpidgin_init(hint); |
699 #endif | 699 #endif |
700 | 700 |
701 gaim_core_set_ui_ops(pidgin_core_get_ui_ops()); | 701 purple_core_set_ui_ops(pidgin_core_get_ui_ops()); |
702 gaim_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops()); | 702 purple_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops()); |
703 | 703 |
704 /* | 704 /* |
705 * Set plugin search directories. Give priority to the plugins | 705 * Set plugin search directories. Give priority to the plugins |
706 * in user's home directory. | 706 * in user's home directory. |
707 */ | 707 */ |
708 search_path = g_build_filename(gaim_user_dir(), "plugins", NULL); | 708 search_path = g_build_filename(purple_user_dir(), "plugins", NULL); |
709 gaim_plugins_add_search_path(search_path); | 709 purple_plugins_add_search_path(search_path); |
710 g_free(search_path); | 710 g_free(search_path); |
711 gaim_plugins_add_search_path(LIBDIR); | 711 purple_plugins_add_search_path(LIBDIR); |
712 | 712 |
713 if (!gaim_core_init(PIDGIN_UI)) { | 713 if (!purple_core_init(PIDGIN_UI)) { |
714 fprintf(stderr, | 714 fprintf(stderr, |
715 "Initialization of the " PIDGIN_NAME " core failed. Dumping core.\n" | 715 "Initialization of the " PIDGIN_NAME " core failed. Dumping core.\n" |
716 "Please report this!\n"); | 716 "Please report this!\n"); |
717 abort(); | 717 abort(); |
718 } | 718 } |
719 | 719 |
720 /* TODO: Move blist loading into gaim_blist_init() */ | 720 /* TODO: Move blist loading into purple_blist_init() */ |
721 gaim_set_blist(gaim_blist_new()); | 721 purple_set_blist(purple_blist_new()); |
722 gaim_blist_load(); | 722 purple_blist_load(); |
723 | 723 |
724 /* TODO: Move prefs loading into gaim_prefs_init() */ | 724 /* TODO: Move prefs loading into purple_prefs_init() */ |
725 gaim_prefs_load(); | 725 purple_prefs_load(); |
726 gaim_prefs_update_old(); | 726 purple_prefs_update_old(); |
727 pidgin_prefs_update_old(); | 727 pidgin_prefs_update_old(); |
728 | 728 |
729 /* load plugins we had when we quit */ | 729 /* load plugins we had when we quit */ |
730 gaim_plugins_load_saved("/gaim/gtk/plugins/loaded"); | 730 purple_plugins_load_saved("/purple/gtk/plugins/loaded"); |
731 pidgin_docklet_init(); | 731 pidgin_docklet_init(); |
732 | 732 |
733 /* TODO: Move pounces loading into gaim_pounces_init() */ | 733 /* TODO: Move pounces loading into purple_pounces_init() */ |
734 gaim_pounces_load(); | 734 purple_pounces_load(); |
735 | 735 |
736 | 736 |
737 /* HACK BY SEANEGAN: | 737 /* HACK BY SEANEGAN: |
738 * We've renamed prpl-oscar to prpl-aim and prpl-icq, accordingly. | 738 * We've renamed prpl-oscar to prpl-aim and prpl-icq, accordingly. |
739 * Let's do that change right here... after everything's loaded, but | 739 * Let's do that change right here... after everything's loaded, but |
740 * before anything has happened | 740 * before anything has happened |
741 */ | 741 */ |
742 for (accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { | 742 for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
743 GaimAccount *account = accounts->data; | 743 PurpleAccount *account = accounts->data; |
744 if (!strcmp(gaim_account_get_protocol_id(account), "prpl-oscar")) { | 744 if (!strcmp(purple_account_get_protocol_id(account), "prpl-oscar")) { |
745 if (isdigit(*gaim_account_get_username(account))) | 745 if (isdigit(*purple_account_get_username(account))) |
746 gaim_account_set_protocol_id(account, "prpl-icq"); | 746 purple_account_set_protocol_id(account, "prpl-icq"); |
747 else | 747 else |
748 gaim_account_set_protocol_id(account, "prpl-aim"); | 748 purple_account_set_protocol_id(account, "prpl-aim"); |
749 } | 749 } |
750 } | 750 } |
751 | 751 |
752 ui_main(); | 752 ui_main(); |
753 | 753 |
765 | 765 |
766 /* | 766 /* |
767 * We want to show the blist early in the init process so the | 767 * We want to show the blist early in the init process so the |
768 * user feels warm and fuzzy (not cold and prickley). | 768 * user feels warm and fuzzy (not cold and prickley). |
769 */ | 769 */ |
770 gaim_blist_show(); | 770 purple_blist_show(); |
771 | 771 |
772 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled")) | 772 if (purple_prefs_get_bool("/purple/gtk/debug/enabled")) |
773 pidgin_debug_window_show(); | 773 pidgin_debug_window_show(); |
774 | 774 |
775 if (opt_login) { | 775 if (opt_login) { |
776 dologin_ret = dologin_named(opt_login_arg); | 776 dologin_ret = dologin_named(opt_login_arg); |
777 if (opt_login_arg != NULL) { | 777 if (opt_login_arg != NULL) { |
781 } | 781 } |
782 | 782 |
783 if (opt_nologin) | 783 if (opt_nologin) |
784 { | 784 { |
785 /* Set all accounts to "offline" */ | 785 /* Set all accounts to "offline" */ |
786 GaimSavedStatus *saved_status; | 786 PurpleSavedStatus *saved_status; |
787 | 787 |
788 /* If we've used this type+message before, lookup the transient status */ | 788 /* If we've used this type+message before, lookup the transient status */ |
789 saved_status = gaim_savedstatus_find_transient_by_type_and_message( | 789 saved_status = purple_savedstatus_find_transient_by_type_and_message( |
790 GAIM_STATUS_OFFLINE, NULL); | 790 PURPLE_STATUS_OFFLINE, NULL); |
791 | 791 |
792 /* If this type+message is unique then create a new transient saved status */ | 792 /* If this type+message is unique then create a new transient saved status */ |
793 if (saved_status == NULL) | 793 if (saved_status == NULL) |
794 saved_status = gaim_savedstatus_new(NULL, GAIM_STATUS_OFFLINE); | 794 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); |
795 | 795 |
796 /* Set the status for each account */ | 796 /* Set the status for each account */ |
797 gaim_savedstatus_activate(saved_status); | 797 purple_savedstatus_activate(saved_status); |
798 } | 798 } |
799 else | 799 else |
800 { | 800 { |
801 /* Everything is good to go--sign on already */ | 801 /* Everything is good to go--sign on already */ |
802 if (!gaim_prefs_get_bool("/core/savedstatus/startup_current_status")) | 802 if (!purple_prefs_get_bool("/core/savedstatus/startup_current_status")) |
803 gaim_savedstatus_activate(gaim_savedstatus_get_startup()); | 803 purple_savedstatus_activate(purple_savedstatus_get_startup()); |
804 gaim_accounts_restore_current_statuses(); | 804 purple_accounts_restore_current_statuses(); |
805 } | 805 } |
806 | 806 |
807 if ((accounts = gaim_accounts_get_all_active()) == NULL) | 807 if ((accounts = purple_accounts_get_all_active()) == NULL) |
808 { | 808 { |
809 pidgin_accounts_window_show(); | 809 pidgin_accounts_window_show(); |
810 } | 810 } |
811 else | 811 else |
812 { | 812 { |