| 106 SIGPIPE, |
106 SIGPIPE, |
| 107 -1 |
107 -1 |
| 108 }; |
108 }; |
| 109 #endif |
109 #endif |
| 110 |
110 |
| 111 static int |
111 static void |
| 112 dologin_named(const char *name) |
112 dologin_named(const char *name) |
| 113 { |
113 { |
| 114 PurpleAccount *account; |
114 PurpleAccount *account; |
| 115 char **names; |
115 char **names; |
| 116 int i; |
116 int i; |
| 117 int ret = -1; |
|
| 118 |
117 |
| 119 if (name != NULL) { /* list of names given */ |
118 if (name != NULL) { /* list of names given */ |
| 120 names = g_strsplit(name, ",", 64); |
119 names = g_strsplit(name, ",", 64); |
| 121 for (i = 0; names[i] != NULL; i++) { |
120 for (i = 0; names[i] != NULL; i++) { |
| 122 account = purple_accounts_find(names[i], NULL); |
121 account = purple_accounts_find(names[i], NULL); |
| 123 if (account != NULL) { /* found a user */ |
122 if (account != NULL) { /* found a user */ |
| 124 ret = 0; |
123 purple_account_set_enabled(account, PIDGIN_UI, TRUE); |
| 125 purple_account_connect(account); |
|
| 126 } |
124 } |
| 127 } |
125 } |
| 128 g_strfreev(names); |
126 g_strfreev(names); |
| 129 } else { /* no name given, use the first account */ |
127 } else { /* no name given, use the first account */ |
| 130 GList *accounts; |
128 GList *accounts; |
| 131 |
129 |
| 132 accounts = purple_accounts_get_all(); |
130 accounts = purple_accounts_get_all(); |
| 133 if (accounts != NULL) |
131 if (accounts != NULL) |
| 134 { |
132 { |
| 135 account = (PurpleAccount *)accounts->data; |
133 account = (PurpleAccount *)accounts->data; |
| 136 ret = 0; |
134 purple_account_set_enabled(account, PIDGIN_UI, TRUE); |
| 137 purple_account_connect(account); |
135 } |
| 138 } |
136 } |
| 139 } |
|
| 140 |
|
| 141 return ret; |
|
| 142 } |
137 } |
| 143 |
138 |
| 144 #ifdef HAVE_SIGNAL_H |
139 #ifdef HAVE_SIGNAL_H |
| 145 static void sighandler(int sig); |
140 static void sighandler(int sig); |
| 146 |
141 |
| 437 gboolean opt_nologin = FALSE; |
432 gboolean opt_nologin = FALSE; |
| 438 gboolean opt_version = FALSE; |
433 gboolean opt_version = FALSE; |
| 439 char *opt_config_dir_arg = NULL; |
434 char *opt_config_dir_arg = NULL; |
| 440 char *opt_login_arg = NULL; |
435 char *opt_login_arg = NULL; |
| 441 char *opt_session_arg = NULL; |
436 char *opt_session_arg = NULL; |
| 442 int dologin_ret = -1; |
|
| 443 char *search_path; |
437 char *search_path; |
| 444 GList *accounts; |
438 GList *accounts; |
| 445 #ifdef HAVE_SIGNAL_H |
439 #ifdef HAVE_SIGNAL_H |
| 446 int sig_indx; /* for setting up signal catching */ |
440 int sig_indx; /* for setting up signal catching */ |
| 447 sigset_t sigset; |
441 sigset_t sigset; |
| 796 |
790 |
| 797 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled")) |
791 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled")) |
| 798 pidgin_debug_window_show(); |
792 pidgin_debug_window_show(); |
| 799 |
793 |
| 800 if (opt_login) { |
794 if (opt_login) { |
| 801 dologin_ret = dologin_named(opt_login_arg); |
795 /* disable all accounts */ |
| |
796 for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
| |
797 PurpleAccount *account = accounts->data; |
| |
798 purple_account_set_enabled(account, PIDGIN_UI, FALSE); |
| |
799 } |
| |
800 /* honor the startup status preference */ |
| |
801 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) |
| |
802 purple_savedstatus_activate(purple_savedstatus_get_startup()); |
| |
803 /* now enable the requested ones */ |
| |
804 dologin_named(opt_login_arg); |
| 802 if (opt_login_arg != NULL) { |
805 if (opt_login_arg != NULL) { |
| 803 g_free(opt_login_arg); |
806 g_free(opt_login_arg); |
| 804 opt_login_arg = NULL; |
807 opt_login_arg = NULL; |
| 805 } |
808 } |
| 806 } |
809 } |
| 807 |
810 |
| 808 if (opt_nologin) |
811 if (opt_nologin && !opt_login) |
| 809 { |
812 { |
| 810 /* Set all accounts to "offline" */ |
813 /* Set all accounts to "offline" */ |
| 811 PurpleSavedStatus *saved_status; |
814 PurpleSavedStatus *saved_status; |
| 812 |
815 |
| 813 /* If we've used this type+message before, lookup the transient status */ |
816 /* If we've used this type+message before, lookup the transient status */ |
| 819 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); |
822 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); |
| 820 |
823 |
| 821 /* Set the status for each account */ |
824 /* Set the status for each account */ |
| 822 purple_savedstatus_activate(saved_status); |
825 purple_savedstatus_activate(saved_status); |
| 823 } |
826 } |
| 824 else |
827 else if (!opt_login) |
| 825 { |
828 { |
| 826 /* Everything is good to go--sign on already */ |
829 /* Everything is good to go--sign on already */ |
| 827 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) |
830 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) |
| 828 purple_savedstatus_activate(purple_savedstatus_get_startup()); |
831 purple_savedstatus_activate(purple_savedstatus_get_startup()); |
| 829 purple_accounts_restore_current_statuses(); |
832 purple_accounts_restore_current_statuses(); |