Some patches.
- From: jwilliam cs iupui edu (Joe Williams)
- To: balsa-list gnome org
- Subject: Some patches.
- Date: Fri, 23 Apr 1999 01:23:59 -0500 (EST)
Here's some patches to make the mailbox configuration stuff abit more
"stable"(IE: Less likely to corrupt your .balsarc). All of the
changes are to mailbox-conf.c. I did the following:
1) Added checks at the end of a mailbox update/add(mailbox_conf_close
and mailbox_conf_add) to see if any fields where left blank(This would
cause a malformed .balsarc to be written to disk)
Note: At one point in the code the developer made a comment
/* TODO cleanup */ for a window(mailbox_conf_close in
the first if statement). I did a widget_destroy, g_free
and assigned mcw to NULL like the code did later on,
but I'm not 100% certain this is what he intended. It
*appears* to work though.
2) Fixed the update code for a local mailbox(it would seg-fault and cause
your .balsarc to be lost compeltetly). It appears there was a mis-cast
variable which caused the error.
Notes/Questions:
a) I'm relatively new at the GUI stuff so you guys might want to do
a once-over on the code to make sure I'm not doing anything stupid.
Everything appears to work fine to me though.
b) Whats the policy on granting write-access to the CVS repository?
Joe
Here's my diff:
Index: mailbox-conf.c
===================================================================
RCS file: /cvs/gnome/balsa/src/mailbox-conf.c,v
retrieving revision 1.44
diff -r1.44 mailbox-conf.c
389c389,498
< static void
---
> /* Returns 1 if everything was okey
> * Returns -2 if there was a blank field and the user wants to re-edit
> * Returns -1 if there was a blank field and the user wants to cancel
> */
>
> static int
> check_for_blank_fields(Mailbox *mailbox)
> {
> gchar *msg = NULL;
> GtkWidget *ask;
> gint clicked_button;
>
> switch(mailbox->type) {
> case MAILBOX_MH:
> case MAILBOX_MAILDIR:
> case MAILBOX_UNKNOWN:
> return 1;
> break;
> case MAILBOX_IMAP:
> if(!strcmp(gtk_entry_get_text(GTK_ENTRY(gnome_entry_gtk_entry(GNOME_ENTRY
> (mcw->imap_folderpath)))),"") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY(mcw->imap_server)), "") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->imap_username)), "") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->imap_password)), "") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->imap_port)), "")) {
>
> if(!strcmp(gtk_entry_get_text(GTK_ENTRY(gnome_entry_gtk_entry
> (GNOME_ENTRY
> (mcw->imap_folderpath)))),""))
> {
> msg = _("You need to fill in the folderpath field.");
> }
> else if(!strcmp(gtk_entry_get_text(GTK_ENTRY(mcw->imap_server)), ""))
> {
> msg = _("You need to fill in the IMAP Server field");
> }
> else if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->imap_username)), ""))
> {
> msg = _("You need to fill in the username field");
> }
> else if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->imap_password)), ""))
> {
> msg = _("You need to fill in the password field");
> }
> else if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->imap_port)), ""))
> {
> msg = _("You need to fill in the port field");
> }
> else
> msg = _("All of the fields must be filled in");
> }
>
> break;
>
> case MAILBOX_MBOX:
> if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->local_mailbox_name)), ""))
> msg = _("You need to fill in the Mailbox Name field.");
>
> break;
> case MAILBOX_POP3:
> if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_mailbox_name)), "") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_username)), "") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_password)), "") ||
> !strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_server)), "")) {
>
>
> if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_mailbox_name)),""))
> {
> msg = _("You need to fill in the Mailbox Name field.");
> }
> else if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_username)),""))
> {
> msg = _("You need to fill in the user field.");
> }
> else if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_password)),""))
> {
> msg = _("You need to fill in the password field.");
> }
> else if(!strcmp(gtk_entry_get_text (GTK_ENTRY (mcw->pop_server)), ""))
> {
> msg = _("You need to fill in the server field.");
> }
> else
> {
> msg = _("Some of the fields are blank.");
> }
> }
> break;
>
> }
>
> if(msg == NULL) /* msg == NULL only if no fields where blank */
> return 1;
>
> ask = gnome_message_box_new(msg, GNOME_MESSAGE_BOX_QUESTION,
> GNOME_STOCK_BUTTON_OK,
> GNOME_STOCK_BUTTON_CANCEL, NULL);
>
>
> gnome_dialog_set_default(GNOME_DIALOG(ask), 1);
> gtk_window_set_modal(GTK_WINDOW(ask), TRUE);
> clicked_button = gnome_dialog_run(GNOME_DIALOG(ask));
>
> if(clicked_button == 1)
> return -2; /* Was a blank, want to re-edit */
> else
> return -1; /* Was a blank, want to cancel */
> }
>
> static int
392,393c501
< if (!mailbox)
< return;
---
> int field_check;
394a503,505
> if (!mailbox)
> return 1;
>
401,402c512,521
< gchar *filename =
< gtk_entry_get_text (GTK_ENTRY (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (mcw->local_mailbox_path))));
---
> gchar *filename;
> field_check = check_for_blank_fields(mailbox);
>
> if(field_check == -1)
> return -1;
> else if(field_check == -2)
> return -2;
>
> filename =
> gtk_entry_get_text (GTK_ENTRY ((mcw->local_mailbox_path)));
412a532,537
> field_check = check_for_blank_fields(mailbox);
> if(field_check == -1)
> return -1;
> else if(field_check == -2)
> return 1;
>
428a554,559
> field_check = check_for_blank_fields(mailbox);
> if(field_check == -1)
> return -1;
> else if(field_check == -2)
> return 1;
>
455a587
> return 1;
466a599
> int field_check;
498a632,638
>
> field_check = check_for_blank_fields(mailbox);
> if(field_check == -2)
> break;
> else if(field_check == -1)
> return NULL;
>
511a652,658
>
> field_check = check_for_blank_fields(mailbox);
> if(field_check == -2)
> break;
> else if(field_check == -1)
> return NULL;
>
517a665
>
527c675,681
<
---
>
> field_check = check_for_blank_fields(mailbox);
> if(field_check == -2)
> break;
> else if(field_check == -1)
> return NULL;
>
563a718
> int return_value;
570c725
< conf_update_mailbox (mcw->mailbox, old_mbox_name);
---
> return_value = conf_update_mailbox (mcw->mailbox, old_mbox_name);
573c728,729
< if (mailbox->type == MAILBOX_POP3) /* redraw the pop3 server list */
---
> if (mailbox->type == MAILBOX_POP3 &&
> return_value != -1) /* redraw the pop3 server list */
574a731,732
> else /* redraw the main mailbox list */
> balsa_mblist_redraw (BALSA_MBLIST (balsa_app.mblist));
576,579c734,738
< else
< balsa_mblist_redraw (BALSA_MBLIST (balsa_app.mblist)); /* redraw the main mailbox list */
<
< /* TODO cleanup */
---
> if(return_value != -1) {
> gtk_widget_destroy (mcw->window);
> g_free (mcw);
> mcw = NULL;
> }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]