Mercurial > pidgin
comparison src/main.c @ 5563:9eb5b13fd412
[gaim-migrate @ 5965]
Just a taste of what's coming.
Standard "This won't compile" thing. Plugin authors, you're going to hate
me, but that's okay, because I have friends too!
It's really late. My brain resembles that of fish swimming in jello pudding
with neon lights flying around chanting musicals. I'm not on drugs. I'm
just that tired.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 30 May 2003 09:38:29 +0000 |
parents | 7e4de9699da9 |
children | 5e7de337a053 |
comparison
equal
deleted
inserted
replaced
5562:3c8d34574601 | 5563:9eb5b13fd412 |
---|---|
48 #include <ctype.h> | 48 #include <ctype.h> |
49 #include "prpl.h" | 49 #include "prpl.h" |
50 #include "sound.h" | 50 #include "sound.h" |
51 #include "gaim.h" | 51 #include "gaim.h" |
52 #include "gaim-socket.h" | 52 #include "gaim-socket.h" |
53 #include "account.h" | |
53 #include "prefs.h" | 54 #include "prefs.h" |
54 #include "notify.h" | 55 #include "notify.h" |
56 #include "gtkaccount.h" | |
55 #include "gtkblist.h" | 57 #include "gtkblist.h" |
56 #include "gtkdebug.h" | 58 #include "gtkdebug.h" |
57 #include "gtknotify.h" | 59 #include "gtknotify.h" |
58 #include "gtkrequest.h" | 60 #include "gtkrequest.h" |
59 #if HAVE_SIGNAL_H | 61 #if HAVE_SIGNAL_H |
117 | 119 |
118 /* the self destruct sequence has been initiated */ | 120 /* the self destruct sequence has been initiated */ |
119 gaim_event_broadcast(event_quit); | 121 gaim_event_broadcast(event_quit); |
120 | 122 |
121 /* transmission ends */ | 123 /* transmission ends */ |
122 signoff_all(); | 124 gaim_connections_disconnect_all(); |
123 | 125 |
124 /* record what we have before we blow it away... */ | 126 /* record what we have before we blow it away... */ |
125 save_prefs(); | 127 save_prefs(); |
126 gaim_prefs_sync(); | 128 gaim_prefs_sync(); |
127 | 129 |
154 } | 156 } |
155 | 157 |
156 /* we need to do this for Oscar because serv_login only starts the login | 158 /* we need to do this for Oscar because serv_login only starts the login |
157 * process, it doesn't end there. gaim_setup will be called later from | 159 * process, it doesn't end there. gaim_setup will be called later from |
158 * oscar.c, after the buddy list is made and serv_finish_login is called */ | 160 * oscar.c, after the buddy list is made and serv_finish_login is called */ |
159 void gaim_setup(struct gaim_connection *gc) | 161 void gaim_setup(GaimConnection *gc) |
160 { | 162 { |
161 if (gaim_prefs_get_bool("/core/sound/login") && gaim_prefs_get_bool("/core/sound/silent_signon")) { | 163 if (gaim_prefs_get_bool("/core/sound/login") && gaim_prefs_get_bool("/core/sound/silent_signon")) { |
162 if(snd_tmout) { | 164 if(snd_tmout) { |
163 g_source_remove(snd_tmout); | 165 g_source_remove(snd_tmout); |
164 } | 166 } |
170 static gboolean domiddleclick(GtkWidget *w, GdkEventButton *event, gpointer null) | 172 static gboolean domiddleclick(GtkWidget *w, GdkEventButton *event, gpointer null) |
171 { | 173 { |
172 if (event->button != 2) | 174 if (event->button != 2) |
173 return FALSE; | 175 return FALSE; |
174 | 176 |
175 auto_login(); | 177 /* TODO auto_login(); */ |
178 | |
176 return TRUE; | 179 return TRUE; |
177 } | 180 } |
178 | 181 |
179 static void dologin(GtkWidget *widget, GtkWidget *w) | 182 static void dologin(GtkWidget *widget, GtkWidget *w) |
180 { | 183 { |
181 struct gaim_account *account; | 184 GaimAccount *account; |
182 const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); | 185 const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); |
183 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | 186 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); |
184 | 187 |
185 if (!strlen(username)) { | 188 if (!strlen(username)) { |
186 gaim_notify_error(NULL, NULL, _("Please enter your login."), NULL); | 189 gaim_notify_error(NULL, NULL, _("Please enter your login."), NULL); |
190 /* if there is more than one user of the same name, then fuck | 193 /* if there is more than one user of the same name, then fuck |
191 * them, they just have to use the account editor to sign in | 194 * them, they just have to use the account editor to sign in |
192 * the second one */ | 195 * the second one */ |
193 | 196 |
194 account = gaim_account_find(username, -1); | 197 account = gaim_account_find(username, -1); |
195 if (!account) | 198 if (!account) { |
196 account = gaim_account_new(username, GAIM_PROTO_DEFAULT, | 199 account = gaim_account_new(username, GAIM_PROTO_DEFAULT); |
197 OPT_ACCT_REM_PASS); | 200 |
198 | 201 gaim_account_set_remember_password(account, TRUE); |
199 g_snprintf(account->password, sizeof account->password, "%s", password); | 202 } |
200 save_prefs(); | 203 |
201 serv_login(account); | 204 gaim_account_set_password(account, password); |
205 | |
206 gaim_account_connect(account); | |
202 } | 207 } |
203 | 208 |
204 /* <name> is a comma-separated list of names, or NULL | 209 /* <name> is a comma-separated list of names, or NULL |
205 if NULL and there is at least one user defined in .gaimrc, try to login. | 210 if NULL and there is at least one user defined in .gaimrc, try to login. |
206 if not NULL, parse <name> into separate strings, look up each one in | 211 if not NULL, parse <name> into separate strings, look up each one in |
208 returns: 0 if successful | 213 returns: 0 if successful |
209 -1 if no user was found that had a saved password | 214 -1 if no user was found that had a saved password |
210 */ | 215 */ |
211 static int dologin_named(char *name) | 216 static int dologin_named(char *name) |
212 { | 217 { |
213 struct gaim_account *account; | 218 GaimAccount *account; |
214 char **names, **n; | 219 char **names, **n; |
215 int retval = -1; | 220 int retval = -1; |
216 | 221 |
217 if (name !=NULL) { /* list of names given */ | 222 if (name !=NULL) { /* list of names given */ |
218 names = g_strsplit(name, ",", 32); | 223 names = g_strsplit(name, ",", 32); |
219 for (n = names; *n != NULL; n++) { | 224 for (n = names; *n != NULL; n++) { |
220 account = gaim_account_find(*n, -1); | 225 account = gaim_account_find(*n, -1); |
221 if (account) { /* found a user */ | 226 if (account) { /* found a user */ |
222 if (account->options & OPT_ACCT_REM_PASS) { | 227 if (gaim_account_get_remember_password(account)) { |
223 retval = 0; | 228 retval = 0; |
224 serv_login(account); | 229 serv_login(account); |
225 } | 230 } |
226 } | 231 } |
227 } | 232 } |
228 g_strfreev(names); | 233 g_strfreev(names); |
229 } else { /* no name given, use default */ | 234 } else { /* no name given, use default */ |
230 account = (struct gaim_account *)gaim_accounts->data; | 235 account = (GaimAccount *)gaim_accounts->data; |
231 if (account->options & OPT_ACCT_REM_PASS) { | 236 |
237 if (gaim_account_get_remember_password(account)) { | |
232 retval = 0; | 238 retval = 0; |
233 serv_login(account); | 239 serv_login(account); |
234 } | 240 } |
235 } | 241 } |
236 | 242 |
251 | 257 |
252 | 258 |
253 static void combo_changed(GtkWidget *w, GtkWidget *combo) | 259 static void combo_changed(GtkWidget *w, GtkWidget *combo) |
254 { | 260 { |
255 const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); | 261 const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); |
256 struct gaim_account *account; | 262 GaimAccount *account; |
257 | 263 |
258 account = gaim_account_find(txt, -1); | 264 account = gaim_account_find(txt, -1); |
259 | 265 |
260 if (account && account->options & OPT_ACCT_REM_PASS) { | 266 if (account && gaim_account_get_remember_password(account)) { |
261 gtk_entry_set_text(GTK_ENTRY(pass), account->password); | 267 gtk_entry_set_text(GTK_ENTRY(pass), account->password); |
262 } else { | 268 } else { |
263 gtk_entry_set_text(GTK_ENTRY(pass), ""); | 269 gtk_entry_set_text(GTK_ENTRY(pass), ""); |
264 } | 270 } |
265 } | 271 } |
267 | 273 |
268 static GList *combo_user_names() | 274 static GList *combo_user_names() |
269 { | 275 { |
270 GSList *accts = gaim_accounts; | 276 GSList *accts = gaim_accounts; |
271 GList *tmp = NULL; | 277 GList *tmp = NULL; |
272 struct gaim_account *account; | 278 GaimAccount *account; |
273 | 279 |
274 if (!accts) | 280 if (!accts) |
275 return g_list_append(NULL, _("<New User>")); | 281 return g_list_append(NULL, _("<New User>")); |
276 | 282 |
277 while (accts) { | 283 while (accts) { |
278 account = (struct gaim_account *)accts->data; | 284 account = (GaimAccount *)accts->data; |
279 tmp = g_list_append(tmp, account->username); | 285 tmp = g_list_append(tmp, account->username); |
280 accts = accts->next; | 286 accts = accts->next; |
281 } | 287 } |
282 | 288 |
283 return tmp; | 289 return tmp; |
365 | 371 |
366 /* And now for the buttons */ | 372 /* And now for the buttons */ |
367 button = gaim_pixbuf_button_from_stock(_("Accounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL); | 373 button = gaim_pixbuf_button_from_stock(_("Accounts"), GAIM_STOCK_ACCOUNTS, GAIM_BUTTON_VERTICAL); |
368 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | 374 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
369 g_signal_connect(G_OBJECT(button), "clicked", | 375 g_signal_connect(G_OBJECT(button), "clicked", |
370 G_CALLBACK(account_editor), mainwindow); | 376 G_CALLBACK(gaim_gtk_account_dialog_show), mainwindow); |
371 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 377 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
372 | 378 |
373 #ifdef NO_MULTI | 379 #ifdef NO_MULTI |
374 gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); | 380 gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); |
375 #endif | 381 #endif |
387 g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL); | 393 g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(domiddleclick), NULL); |
388 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 394 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
389 | 395 |
390 /* Now grab the focus that we need */ | 396 /* Now grab the focus that we need */ |
391 if (gaim_accounts) { | 397 if (gaim_accounts) { |
392 struct gaim_account *account = gaim_accounts->data; | 398 GaimAccount *account = gaim_accounts->data; |
393 if (account->options & OPT_ACCT_REM_PASS) { | 399 |
400 if (gaim_account_get_remember_password(account)) { | |
394 combo_changed(NULL, name); | 401 combo_changed(NULL, name); |
395 gtk_widget_grab_focus(button); | 402 gtk_widget_grab_focus(button); |
396 } else { | 403 } else { |
397 gtk_widget_grab_focus(pass); | 404 gtk_widget_grab_focus(pass); |
398 } | 405 } |
410 { | 417 { |
411 switch (sig) { | 418 switch (sig) { |
412 case SIGHUP: | 419 case SIGHUP: |
413 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", | 420 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", |
414 "Caught signal %d\n", sig); | 421 "Caught signal %d\n", sig); |
415 signoff_all(NULL, NULL); | 422 gaim_connections_disconnect_all(); |
416 break; | 423 break; |
417 case SIGSEGV: | 424 case SIGSEGV: |
418 core_quit(); | 425 core_quit(); |
419 #ifndef DEBUG | 426 #ifndef DEBUG |
420 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" | 427 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" |
447 #endif | 454 #endif |
448 break; | 455 break; |
449 default: | 456 default: |
450 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", | 457 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", |
451 "Caught signal %d\n", sig); | 458 "Caught signal %d\n", sig); |
452 signoff_all(NULL, NULL); | 459 gaim_connections_disconnect_all(); |
453 | 460 |
454 gaim_plugins_unload_all(); | 461 gaim_plugins_unload_all(); |
455 | 462 |
456 if (gtk_main_level()) | 463 if (gtk_main_level()) |
457 gtk_main_quit(); | 464 gtk_main_quit(); |
576 return 0; | 583 return 0; |
577 } | 584 } |
578 | 585 |
579 static void set_first_user(char *name) | 586 static void set_first_user(char *name) |
580 { | 587 { |
581 struct gaim_account *account; | 588 GaimAccount *account; |
582 | 589 |
583 account = gaim_account_find(name, -1); | 590 account = gaim_account_find(name, -1); |
584 | 591 |
585 if (!account) { /* new user */ | 592 if (!account) { /* new user */ |
586 account = g_new0(struct gaim_account, 1); | 593 account = g_new0(GaimAccount, 1); |
587 g_snprintf(account->username, sizeof(account->username), "%s", name); | 594 g_snprintf(account->username, sizeof(account->username), "%s", name); |
588 account->protocol = GAIM_PROTO_DEFAULT; | 595 account->protocol = GAIM_PROTO_DEFAULT; |
589 gaim_accounts = g_slist_prepend(gaim_accounts, account); | 596 gaim_accounts = g_slist_prepend(gaim_accounts, account); |
590 } else { /* user already exists */ | 597 } else { /* user already exists */ |
591 gaim_accounts = g_slist_remove(gaim_accounts, account); | 598 gaim_accounts = g_slist_remove(gaim_accounts, account); |
937 opt_login_arg = NULL; | 944 opt_login_arg = NULL; |
938 } | 945 } |
939 } | 946 } |
940 | 947 |
941 if (!opt_acct && !opt_nologin && gaim_session == 0) | 948 if (!opt_acct && !opt_nologin && gaim_session == 0) |
942 auto_login(); | 949 ; /* TODO auto_login(); */ |
943 | 950 |
944 if (opt_acct) { | 951 if (opt_acct) { |
945 account_editor(NULL, NULL); | 952 gaim_gtk_account_dialog_show(); |
946 } else if ((dologin_ret == -1) && !connections) | 953 } else if ((dologin_ret == -1) && !gaim_connections_get_all()) |
947 show_login(); | 954 show_login(); |
948 | 955 |
949 gtk_main(); | 956 gtk_main(); |
950 core_quit(); | 957 core_quit(); |
951 gaim_sound_quit(); | 958 gaim_sound_quit(); |