[evolution-patches] F/B Publishing Patch
- From: Gary Ekker <gekker novell com>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] F/B Publishing Patch
- Date: Thu, 08 Apr 2004 17:37:36 -0600
Hopefully this will be the last patch needed for this code for a while.
Thanks to fejj for fixing the instant apply for me, as that was an item
on my list.
The patch adds support for the e-password stuff, I am embarrassed to
have discoverd my mistake only after I submitted the bounty. It fixes
some logic problems in the publishing part, and a crash for NULL
ESources. The crash only occurs if you had publishing urls and then did
a --force-migrate, thereby leaving behind invalid calendar UIDs.
Perhaps we need the migration code to remove these publishing sources
from gconf?
-Gary
? fb.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2242
diff -u -r1.2242 ChangeLog
--- ChangeLog 7 Apr 2004 20:36:48 -0000 1.2242
+++ ChangeLog 8 Apr 2004 23:24:28 -0000
@@ -1,3 +1,17 @@
+2004-04-08 Gary Ekker <gekker novell com>
+
+ * gui/dialogs/url-editor-dialog.c: Fixed to use e-passwords.
+
+ * gui/dialogs/cal-prefs-dialog.c: Fixed crash and bugs created by
+ changes made for instant apply.
+
+ * gui/itip-utils.c: Fixed to use e-passwords.
+
+ * gui/e-pub-utils.c: Fixed to use e-passwords.
+ (just_published): Fixed error in logic.
+ (e_pub_publish): Fixed crash if ESource is NULL.
+
+
2004-04-07 Jeffrey Stedfast <fejj ximian com>
* gui/dialogs/cal-prefs-dialog.c: Fixed to be instant-apply.
Index: gui/e-pub-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-pub-utils.c,v
retrieving revision 1.2
diff -u -r1.2 e-pub-utils.c
--- gui/e-pub-utils.c 16 Mar 2004 23:18:00 -0000 1.2
+++ gui/e-pub-utils.c 8 Apr 2004 23:24:28 -0000
@@ -27,6 +27,8 @@
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
#include <libecal/e-cal-time-util.h>
+#include <libgnome/gnome-i18n.h>
+#include "e-util/e-passwords.h"
#include "calendar-config.h"
#include "common/authentication.h"
#include "itip-utils.h"
@@ -38,7 +40,7 @@
xmlDocPtr doc;
xmlNodePtr root, p;
xmlChar *location, *enabled, *frequency;
- xmlChar *username, *password, *publish_time;
+ xmlChar *username, *publish_time;
GSList *l = NULL;
uri->location = NULL;
@@ -56,7 +58,6 @@
enabled = xmlGetProp (root, "enabled");
frequency = xmlGetProp (root, "frequency");
username = xmlGetProp (root, "username");
- password = xmlGetProp (root, "password");
publish_time = xmlGetProp (root, "publish_time");
if (location != NULL)
@@ -67,11 +68,11 @@
uri->publish_freq = atoi (frequency);
if (username != NULL)
uri->username = g_strdup (username);
- if (password != NULL)
- uri->password = g_strdup (password);
if (publish_time != NULL)
uri->last_pub_time = g_strdup (publish_time);
+ uri->password = g_strdup ("");
+
for (p = root->children; p != NULL; p = p->next) {
xmlChar *uid = xmlGetProp (p, "uid");
@@ -108,7 +109,6 @@
xmlSetProp (root, "enabled", enabled);
xmlSetProp (root, "frequency", frequency);
xmlSetProp (root, "username", uri->username);
- xmlSetProp (root, "password", uri->password);
xmlSetProp (root, "publish_time", uri->last_pub_time);
for (cals = uri->calendars; cals != NULL; cals = cals->next) {
@@ -176,19 +176,21 @@
static gboolean
just_published (gchar *last_pub_time) {
icaltimezone *utc;
- struct icaltimetype pubtime_itt, adjust_itt;
+ struct icaltimetype current_itt, adjust_itt;
if (strlen (last_pub_time) != 0) {
utc = icaltimezone_get_utc_timezone ();
- pubtime_itt = icaltime_from_string (last_pub_time);
- adjust_itt = icaltime_current_time_with_zone (utc);
+ adjust_itt = icaltime_from_string (last_pub_time);
+ current_itt = icaltime_current_time_with_zone (utc);
icaltime_adjust (&adjust_itt, 0, 0, 0, 3);
- if (icaltime_compare_date_only (pubtime_itt, adjust_itt) < 0)
+ if (icaltime_compare (adjust_itt, current_itt) < 0)
return TRUE;
+ else
+ return FALSE;
}
- return FALSE;
+ return TRUE;
}
void
@@ -215,13 +217,17 @@
ECalComponent *clone = NULL;
gboolean cloned = FALSE;
ECal *client = NULL;
- gchar *xml = (gchar *)uri_config_list->data;
+ char *prompt;
+ gboolean remember = FALSE;
+ gchar *password;
+
+ gchar *xml = (gchar *)l->data;
uri = g_new0 (EPublishUri, 1);
e_pub_uri_from_xml (uri, xml);
/* kludge to safeguard against loop from gconf update */
- if (just_published (uri->last_pub_time))
+ if (!just_published (uri->last_pub_time))
return;
/* TODO: make sure we're online */
@@ -256,8 +262,8 @@
source_uid = g_strdup (p->data);
source = e_source_list_peek_source_by_uid (source_list, source_uid);
-
- client = auth_new_cal_from_uri (e_source_get_uri (source), E_CAL_SOURCE_TYPE_EVENT);
+ if (source)
+ client = auth_new_cal_from_uri (e_source_get_uri (source), E_CAL_SOURCE_TYPE_EVENT);
if (!client) {
g_warning (G_STRLOC ": Could not publish Free/Busy: Calendar backend no longer exists");
@@ -285,12 +291,32 @@
g_free (source_uid);
}
+
+ /* add password to the uri */
+ password = e_passwords_get_password ("Calendar",
+ (gchar *)uri->location);
+ if (!password) {
+ prompt = g_strdup_printf (_("Enter the password for %s"), (gchar *)uri->location);
+ password = e_passwords_ask_password (_("Enter password"),
+ "Calendar", (gchar *)uri->location,
+ prompt, TRUE,
+ E_PASSWORDS_REMEMBER_FOREVER,
+ &remember, NULL);
+
+ g_free (prompt);
+
+ if (!password) {
+ g_slist_free (p);
+ continue;
+ }
+ }
+
if (cloned && clone)
published = itip_publish_comp ((ECal *) client,
uri->location,
uri->username,
- uri->password, &clone);
+ password, &clone);
g_slist_free (p);
}
Index: gui/itip-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/itip-utils.c,v
retrieving revision 1.88
diff -u -r1.88 itip-utils.c
--- gui/itip-utils.c 1 Mar 2004 21:38:36 -0000 1.88
+++ gui/itip-utils.c 8 Apr 2004 23:24:28 -0000
@@ -1152,18 +1152,6 @@
/* Publish the component */
session = soup_session_async_new ();
- /* add username and password to the uri */
- if (strlen (password) == 0) {
- prompt = g_strdup_printf (_("Enter the password for %s"), uri);
- password = e_passwords_ask_password (_("Enter password"),
- "Calendar", NULL,
- prompt, TRUE,
- E_PASSWORDS_DO_NOT_REMEMBER,
- &remember, NULL);
-
- g_free (prompt);
- }
-
real_uri = soup_uri_new (uri);
if (!real_uri) {
g_warning (G_STRLOC ": Invalid URL: %s", uri);
Index: gui/dialogs/cal-prefs-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/cal-prefs-dialog.c,v
retrieving revision 1.35
diff -u -r1.35 cal-prefs-dialog.c
--- gui/dialogs/cal-prefs-dialog.c 7 Apr 2004 20:36:48 -0000 1.35
+++ gui/dialogs/cal-prefs-dialog.c 8 Apr 2004 23:24:28 -0000
@@ -641,6 +641,7 @@
-1);
url_list_changed (dialog_data);
+ show_fb_config (dialog_data);
if (!GTK_WIDGET_SENSITIVE ((GtkWidget *) dialog_data->url_remove)) {
selection = gtk_tree_view_get_selection ((GtkTreeView *) dialog_data->url_list);
@@ -686,6 +687,7 @@
-1);
url_list_changed (dialog_data);
+ show_fb_config (dialog_data);
if (!GTK_WIDGET_SENSITIVE ((GtkWidget *) dialog_data->url_remove)) {
selection = gtk_tree_view_get_selection ((GtkTreeView *) dialog_data->url_list);
@@ -757,8 +759,8 @@
gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_enable), FALSE);
}
g_free (url);
-
url_list_changed (dialog_data);
+ show_fb_config (dialog_data);
}
}
@@ -776,6 +778,9 @@
URL_LIST_FREE_BUSY_URL_COLUMN, &url,
-1);
url->enabled = !url->enabled;
+
+ gtk_tree_selection_select_iter (selection, &iter);
+
gtk_list_store_set ((GtkListStore *) model, &iter,
URL_LIST_ENABLED_COLUMN, url->enabled,
-1);
@@ -784,6 +789,7 @@
url->enabled ? _("Disable") : _("Enable"));
url_list_changed (dialog_data);
+ show_fb_config (dialog_data);
}
}
@@ -817,6 +823,7 @@
url->enabled ? _("Disable") : _("Enable"));
url_list_changed (dialog_data);
+ show_fb_config (dialog_data);
}
gtk_tree_path_free (path);
@@ -863,7 +870,7 @@
static void
show_fb_config (DialogData *dialog_data)
{
- GSList *url_config_list;
+ GSList *url_config_list = NULL;
GtkListStore *model;
GtkTreeIter iter;
@@ -872,6 +879,27 @@
/* restore urls from gconf */
url_config_list = calendar_config_get_free_busy();
+
+ if (!url_config_list) {
+ /* list is empty-disable edit, remove, and enable buttons */
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_edit),
+ FALSE);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_remove),
+ FALSE);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_enable),
+ FALSE);
+ } else {
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_edit),
+ TRUE);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_remove),
+ TRUE);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_enable),
+ TRUE);
+ }
while (url_config_list) {
gchar *xml = (gchar *)url_config_list->data;
@@ -896,17 +924,6 @@
g_slist_foreach (url_config_list, (GFunc) g_free, NULL);
g_slist_free (url_config_list);
- if (!gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter)) {
- /* list is empty-disable edit, remove, and enable buttons */
- gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_edit),
- FALSE);
-
- gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_remove),
- FALSE);
-
- gtk_widget_set_sensitive (GTK_WIDGET (dialog_data->url_enable),
- FALSE);
- }
}
/* Shows the current task list settings in the dialog */
Index: gui/dialogs/url-editor-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/url-editor-dialog.c,v
retrieving revision 1.1
diff -u -r1.1 url-editor-dialog.c
--- gui/dialogs/url-editor-dialog.c 13 Jan 2004 01:59:28 -0000 1.1
+++ gui/dialogs/url-editor-dialog.c 8 Apr 2004 23:24:28 -0000
@@ -34,6 +34,7 @@
#include "cal-prefs-dialog.h"
#include "url-editor-dialog.h"
+#include "e-util/e-passwords.h"
#include <gtk/gtk.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkoptionmenu.h>
@@ -82,7 +83,8 @@
url_dlg_data->url_data = uri;
init_widgets (url_dlg_data);
- if (uri->location && uri->username && uri->password) {
+
+ if (uri->location && uri->username) {
if (strlen(uri->location) != 0) {
gtk_entry_set_text (url_dlg_data->url_entry,
uri->location);
@@ -91,6 +93,11 @@
gtk_entry_set_text (url_dlg_data->username_entry,
uri->username);
}
+ }
+
+ uri->password = e_passwords_get_password ("Calendar", url_dlg_data->url_data->location);
+
+ if (uri->password) {
if (strlen(uri->password) != 0) {
gtk_entry_set_text (url_dlg_data->password_entry,
uri->password);
@@ -99,25 +106,26 @@
} else {
e_dialog_toggle_set (url_dlg_data->remember_pw, FALSE);
}
-
- switch (uri->publish_freq) {
- case URI_PUBLISH_DAILY:
- e_dialog_radio_set (url_dlg_data->daily,
- URI_PUBLISH_DAILY,
- pub_frequency_type_map);
- break;
- case URI_PUBLISH_WEEKLY:
- e_dialog_radio_set (url_dlg_data->daily,
- URI_PUBLISH_WEEKLY,
- pub_frequency_type_map);
- break;
- case URI_PUBLISH_USER:
- default:
- e_dialog_radio_set (url_dlg_data->daily,
- URI_PUBLISH_USER,
- pub_frequency_type_map);
- }
}
+
+ switch (uri->publish_freq) {
+ case URI_PUBLISH_DAILY:
+ e_dialog_radio_set (url_dlg_data->daily,
+ URI_PUBLISH_DAILY,
+ pub_frequency_type_map);
+ break;
+ case URI_PUBLISH_WEEKLY:
+ e_dialog_radio_set (url_dlg_data->daily,
+ URI_PUBLISH_WEEKLY,
+ pub_frequency_type_map);
+ break;
+ case URI_PUBLISH_USER:
+ default:
+ e_dialog_radio_set (url_dlg_data->daily,
+ URI_PUBLISH_USER,
+ pub_frequency_type_map);
+ }
+
dialog_data->url_editor=TRUE;
dialog_data->url_editor_dlg = (GtkWidget *) url_dlg_data;
gtk_widget_set_sensitive ((GtkWidget *) url_dlg_data->ok, FALSE);
@@ -128,8 +136,13 @@
if ((GtkEntry *) url_dlg_data->url_entry) {
url_editor_dialog_fb_url_activated (url_dlg_data->url_entry, url_dlg_data);
url_dlg_data->url_data->username = g_strdup (gtk_entry_get_text ((GtkEntry *) url_dlg_data->username_entry));
- if (e_dialog_toggle_get (url_dlg_data->remember_pw))
- url_dlg_data->url_data->password = g_strdup (gtk_entry_get_text ((GtkEntry *) url_dlg_data->password_entry));
+ url_dlg_data->url_data->password = g_strdup (gtk_entry_get_text ((GtkEntry *) url_dlg_data->password_entry));
+ if (e_dialog_toggle_get (url_dlg_data->remember_pw)) {
+ e_passwords_add_password (url_dlg_data->url_data->location, url_dlg_data->url_data->password);
+ e_passwords_remember_password ("Calendar", url_dlg_data->url_data->location);
+ } else {
+ e_passwords_forget_password ("Calendar", url_dlg_data->url_data->location);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]