aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/exchange-operations/ChangeLog26
-rw-r--r--plugins/exchange-operations/exchange-delegates-user.c195
-rw-r--r--plugins/exchange-operations/exchange-delegates-user.h5
-rw-r--r--plugins/exchange-operations/exchange-delegates.c32
-rw-r--r--plugins/exchange-operations/exchange-delegates.h1
-rw-r--r--plugins/exchange-operations/exchange-mail-send-options.c44
-rw-r--r--plugins/exchange-operations/exchange-send-options.c239
-rw-r--r--plugins/exchange-operations/exchange-send-options.glade82
-rw-r--r--plugins/exchange-operations/exchange-send-options.h7
-rw-r--r--plugins/exchange-operations/org-gnome-exchange-operations.error.xml9
10 files changed, 609 insertions, 31 deletions
diff --git a/plugins/exchange-operations/ChangeLog b/plugins/exchange-operations/ChangeLog
index b2583f6211..397c17e56e 100644
--- a/plugins/exchange-operations/ChangeLog
+++ b/plugins/exchange-operations/ChangeLog
@@ -1,3 +1,29 @@
+2007-07-09 Chenthill Palanisamy <pchenthill@novell.com>
+
+ reviewed by: Veerapuram Varadhan <vvaradhan@novell.com>
+
+ * exchange-delegates-user.c: (map_to_full_role_name),
+ (em_utils_delegates_done), (exchange_delegates_user_edit):
+ * exchange-delegates-user.h:
+ * exchange-delegates.c: (add_button_clicked_cb),
+ (edit_button_clicked_cb), (email_look_up), (table_click_cb):
+ * exchange-delegates.glade:
+ * exchange-delegates.h:
+ * exchange-mail-send-options.c: (append_to_header):
+ * exchange-send-options.c:
+ (exchange_send_options_get_widgets_data), (get_widgets),
+ (exchange_send_options_fill_widgets_with_data),
+ (exchange_send_options_cb), (delegate_option_toggled),
+ (addressbook_dialog_response), (addressbook_entry_changed),
+ (address_button_clicked), (exchange_sendoptions_dialog_run),
+ (exchange_sendoptions_dialog_init):
+ * exchange-send-options.glade:
+ * exchange-send-options.h:
+ * org-gnome-exchange-operations.error.xml: Added the exchange
+ delegation support.
+
+ Committing on behalf of Bharath Acharya <abharath@novell.com>
+
2007-07-03 Srinivasa Ragavan <sragavan@novell.com>
* exchange-account-setup.c: (owa_authenticate_user): Form the password
diff --git a/plugins/exchange-operations/exchange-delegates-user.c b/plugins/exchange-operations/exchange-delegates-user.c
index 0599190ebe..8964cfea44 100644
--- a/plugins/exchange-operations/exchange-delegates-user.c
+++ b/plugins/exchange-operations/exchange-delegates-user.c
@@ -23,8 +23,10 @@
#include <config.h>
#endif
+#include <mail/mail-ops.h>
+#include <mail/mail-component.h>
+#include <camel/camel-multipart.h>
#include "exchange-delegates-user.h"
-
#include <e2k-global-catalog.h>
#include <e2k-marshal.h>
#include <e2k-sid.h>
@@ -46,6 +48,7 @@
#include <string.h>
+
#define EXCHANGE_DELEGATES_USER_SEPARATOR -2
#define EXCHANGE_DELEGATES_USER_CUSTOM -3
/* Can't use E2K_PERMISSIONS_ROLE_CUSTOM, because it's -1, which
@@ -67,6 +70,11 @@ static const int exchange_perm_map[] = {
const char *exchange_delegates_user_folder_names[] = {
"calendar", "tasks", "inbox", "contacts"
};
+
+const char *folder_names_for_display[] = {
+ "Calendar", "Tasks ", "Inbox ", "Contacts"
+};
+
static const char *widget_names[] = {
"calendar_perms", "task_perms", "inbox_perms", "contact_perms",
};
@@ -157,6 +165,43 @@ parent_window_destroyed (gpointer dialog, GObject *where_parent_window_was)
gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
}
+/* Maps the role_nam parameter to their corresponding Full role name
+*/
+const char *
+map_to_full_role_name (E2kPermissionsRole role_nam)
+{
+ const char *role_name;
+
+ switch (role_nam)
+ {
+ case E2K_PERMISSIONS_ROLE_EDITOR: role_name = g_strdup (
+ _("Editor (read, create, edit)"));
+ break;
+
+ case E2K_PERMISSIONS_ROLE_AUTHOR: role_name = g_strdup (
+ _("Author (read, create)"));
+ break;
+
+ case E2K_PERMISSIONS_ROLE_REVIEWER: role_name = g_strdup (
+ _("Reviewer (read-only)"));
+ break;
+
+ default: role_name = g_strdup (_("None"));
+ break;
+ }
+
+ return role_name;
+}
+
+static void
+em_utils_delegates_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info,
+ int queued, const char *appended_uid, void *data)
+{
+ camel_message_info_free (info);
+ mail_send ();
+}
+
+
/**
* exchange_delegates_user_edit:
* @user: a delegate
@@ -168,11 +213,12 @@ parent_window_destroyed (gpointer dialog, GObject *where_parent_window_was)
* Return value: %TRUE for "OK", %FALSE for "Cancel".
**/
gboolean
-exchange_delegates_user_edit (ExchangeDelegatesUser *user,
- GtkWidget *parent_window)
-{
+exchange_delegates_user_edit (ExchangeAccount *account,
+ ExchangeDelegatesUser *user,
+ GtkWidget *parent_window)
+{
GladeXML *xml;
- GtkWidget *dialog, *table, *label, *menu, *check;
+ GtkWidget *dialog, *table, *label, *menu, *check, *check_delegate;
char *title;
int button, i;
E2kPermissionsRole role;
@@ -242,6 +288,141 @@ exchange_delegates_user_edit (ExchangeDelegatesUser *user,
modified = TRUE;
}
}
+
+
+ /* The following piece of code is used to construct a mail message to be sent to a Delegate
+ summarizing all the permissions set for him on the various user's folders.
+ */
+ check_delegate = glade_xml_get_widget (xml, "delegate_mail");
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_delegate)) == TRUE) {
+ if (button == GTK_RESPONSE_OK) {
+
+ EAccount *eaccount;
+ CamelMimeMessage *delegate_mail = camel_mime_message_new ();
+ CamelMultipart *body = camel_multipart_new ();
+ CamelMimePart *part;
+ CamelDataWrapper *delegate_mail_text, *delegate_mail_data;
+ CamelContentType *type;
+ CamelInternetAddress *addr;
+ CamelStream *stream;
+ CamelFolder *out_folder;
+ CamelMessageInfo *info;
+ char *self_address, *delegate_mail_subject;
+ char *role_name;
+ char *role_name_final = "";
+
+ const char *recipient_address;
+ const char *delegate_exchange_dn;
+
+
+ self_address = g_strdup (exchange_account_get_email_id (account));
+
+ /* Create toplevel container */
+ camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (body),
+ "multipart/alternative;");
+ camel_multipart_set_boundary (body, NULL);
+
+ /* Create textual receipt */
+ delegate_mail_text = camel_data_wrapper_new ();
+ type = camel_content_type_new ("text", "plain");
+ camel_content_type_set_param (type, "format", "flowed");
+ camel_data_wrapper_set_mime_type_field (delegate_mail_text, type);
+ camel_content_type_unref (type);
+ stream = camel_stream_mem_new ();
+
+ camel_stream_printf (stream,
+ _("This message was sent automatically by Evolution \
+ to inform you that you have been designated as a \
+ delegate. You can now send messages on my behalf.\
+ \n\nYou have been given the following permissions \
+ on my folders:\n"));
+ for (i = 0; i < EXCHANGE_DELEGATES_LAST; i++) {
+ menu = glade_xml_get_widget (xml, widget_names[i]);
+ role = e_dialog_option_menu_get (menu, exchange_perm_map);
+ role_name = g_strdup (map_to_full_role_name(role));
+ role_name_final = g_strconcat (role_name_final, "\t",
+ folder_names_for_display[i], ":", "\t",
+ role_name, "\n", NULL);
+ }
+
+ camel_stream_printf (stream, "%s", role_name_final);
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)) == TRUE) {
+ camel_stream_printf (stream, _("\nYou are also permitted \
+ to see my private items."));
+ }
+ else
+ camel_stream_printf (stream, _("\nHowever you are not permitted\
+ to see my private items."));
+ camel_data_wrapper_construct_from_stream (delegate_mail_text, stream);
+ g_free (role_name);
+ g_free (role_name_final);
+ camel_object_unref (stream);
+
+ part = camel_mime_part_new ();
+ camel_medium_set_content_object (CAMEL_MEDIUM (part), delegate_mail_text);
+ camel_object_unref (delegate_mail_text);
+ camel_multipart_add_part (body, part);
+ camel_object_unref (part);
+
+ /* Create the machine-readable receipt */
+ delegate_mail_data = camel_data_wrapper_new ();
+ type = camel_content_type_new ("message", "disposition-notification");
+ camel_data_wrapper_set_mime_type_field (delegate_mail_data, type);
+ camel_content_type_unref (type);
+ stream = camel_stream_mem_new ();
+ part = camel_mime_part_new ();
+
+ camel_data_wrapper_construct_from_stream (delegate_mail_data, stream);
+ camel_object_unref (stream);
+ camel_medium_set_content_object (CAMEL_MEDIUM (part), delegate_mail_data);
+ camel_object_unref (delegate_mail_data);
+ camel_multipart_add_part (body, part);
+ camel_object_unref (part);
+
+ /* Finish creating the message */
+ camel_medium_set_content_object (CAMEL_MEDIUM (delegate_mail), CAMEL_DATA_WRAPPER (body));
+ camel_object_unref (body);
+
+ delegate_mail_subject = g_strdup_printf (_("You have been designated \
+ as a delegate for %s"), exchange_account_get_username (account));
+ camel_mime_message_set_subject (delegate_mail, delegate_mail_subject);
+ g_free (delegate_mail_subject);
+
+ addr = camel_internet_address_new ();
+ camel_address_decode (CAMEL_ADDRESS (addr), self_address);
+ camel_mime_message_set_from (delegate_mail, addr);
+ g_free (self_address);
+ camel_object_unref (addr);
+
+ delegate_exchange_dn = e2k_entryid_to_dn (user->entryid);
+ recipient_address = email_look_up (delegate_exchange_dn,account);
+
+ addr = camel_internet_address_new ();
+ camel_address_decode (CAMEL_ADDRESS (addr), recipient_address);
+ camel_mime_message_set_recipients (delegate_mail, CAMEL_RECIPIENT_TYPE_TO, addr);
+ camel_object_unref (addr);
+
+ eaccount = exchange_account_fetch (account);
+ if(eaccount) {
+ camel_medium_set_header (CAMEL_MEDIUM (delegate_mail),
+ "X-Evolution-Account", eaccount->uid);
+ camel_medium_set_header (CAMEL_MEDIUM (delegate_mail),
+ "X-Evolution-Transport", eaccount->transport->url);
+ camel_medium_set_header (CAMEL_MEDIUM (delegate_mail),
+ "X-Evolution-Fcc", eaccount->sent_folder_uri);
+ }
+
+ /* Send the permissions summarizing mail */
+ out_folder = mail_component_get_folder (NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
+ info = camel_message_info_new (NULL);
+ camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ mail_append_mail (out_folder, delegate_mail, info, em_utils_delegates_done, 0);
+
+ }
+
+ }
+
check = glade_xml_get_widget (xml, "see_private_checkbox");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)) !=
user->see_private) {
@@ -297,8 +478,8 @@ exchange_delegates_user_new (const char *display_name)
**/
ExchangeDelegatesUser *
exchange_delegates_user_new_from_gc (E2kGlobalCatalog *gc,
- const char *email,
- GByteArray *creator_entryid)
+ const char *email,
+ GByteArray *creator_entryid)
{
E2kGlobalCatalogStatus status;
E2kGlobalCatalogEntry *entry;
diff --git a/plugins/exchange-operations/exchange-delegates-user.h b/plugins/exchange-operations/exchange-delegates-user.h
index 2b5b291e13..ee4d8db80e 100644
--- a/plugins/exchange-operations/exchange-delegates-user.h
+++ b/plugins/exchange-operations/exchange-delegates-user.h
@@ -59,8 +59,9 @@ ExchangeDelegatesUser *exchange_delegates_user_new_from_gc (E2kGlobalCatalog
const char *email,
GByteArray *creator_entryid);
-gboolean exchange_delegates_user_edit (ExchangeDelegatesUser *user,
- GtkWidget *parent_window);
+gboolean exchange_delegates_user_edit (ExchangeAccount *account, ExchangeDelegatesUser *user,
+ GtkWidget *parent_window);
+
#ifdef __cplusplus
diff --git a/plugins/exchange-operations/exchange-delegates.c b/plugins/exchange-operations/exchange-delegates.c
index fc1de553db..d940a188a0 100644
--- a/plugins/exchange-operations/exchange-delegates.c
+++ b/plugins/exchange-operations/exchange-delegates.c
@@ -453,12 +453,12 @@ add_button_clicked_cb (GtkWidget *widget, gpointer data)
e_error_run (GTK_WINDOW (parent_window), ERROR_DOMAIN ":delegate-existing",
user->display_name, NULL);
g_object_unref (user);
- exchange_delegates_user_edit (match, parent_window);
+ exchange_delegates_user_edit (delegates->account, match, parent_window);
return;
}
}
- if (!exchange_delegates_user_edit (user, parent_window)) {
+ if (!exchange_delegates_user_edit (delegates->account, user, parent_window)) {
g_object_unref (user);
return;
}
@@ -511,10 +511,34 @@ edit_button_clicked_cb (GtkWidget *widget, gpointer data)
g_return_if_fail (row >= 0 && row < delegates->users->len);
parent_window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
- exchange_delegates_user_edit (delegates->users->pdata[row],
+
+ exchange_delegates_user_edit (delegates->account, delegates->users->pdata[row],
parent_window);
}
+const char *
+email_look_up (const char *delegate_legacy, ExchangeAccount *account)
+{
+ E2kGlobalCatalog *gc;
+ E2kGlobalCatalogEntry *entry;
+ E2kGlobalCatalogStatus status;
+
+ const char *email_id;
+
+ gc = exchange_account_get_global_catalog (account);
+
+ if (!gc)
+ return;
+
+ status = e2k_global_catalog_lookup (
+ gc, NULL, E2K_GLOBAL_CATALOG_LOOKUP_BY_LEGACY_EXCHANGE_DN,
+ delegate_legacy, 0, &entry);
+
+ email_id = g_strdup (entry->email);
+ e2k_global_catalog_entry_free (gc, entry);
+ return email_id;
+}
+
static gboolean
table_click_cb (GtkWidget *widget, GdkEventButton *event, gpointer data)
{
@@ -534,7 +558,7 @@ table_click_cb (GtkWidget *widget, GdkEventButton *event, gpointer data)
return FALSE;
parent_window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
- exchange_delegates_user_edit (delegates->users->pdata[row],
+ exchange_delegates_user_edit (delegates->account, delegates->users->pdata[row],
parent_window);
return TRUE;
}
diff --git a/plugins/exchange-operations/exchange-delegates.h b/plugins/exchange-operations/exchange-delegates.h
index be8f4f89e3..3e87e06b38 100644
--- a/plugins/exchange-operations/exchange-delegates.h
+++ b/plugins/exchange-operations/exchange-delegates.h
@@ -13,6 +13,7 @@ extern "C" {
#endif /* __cplusplus */
void exchange_delegates (ExchangeAccount *account, GtkWidget *parent);
+const char *email_look_up (const char *delegate_legacy, ExchangeAccount *account);
#ifdef __cplusplus
}
diff --git a/plugins/exchange-operations/exchange-mail-send-options.c b/plugins/exchange-operations/exchange-mail-send-options.c
index 1a5f7f38f5..3fe9d7f4c1 100644
--- a/plugins/exchange-operations/exchange-mail-send-options.c
+++ b/plugins/exchange-operations/exchange-mail-send-options.c
@@ -26,9 +26,11 @@
#include <glib/gi18n.h>
#include <camel/camel-mime-message.h>
+#include <camel/camel-address.h>
#include "mail/em-event.h"
#include "composer/e-msg-composer.h"
+#include "composer/e-msg-composer-hdrs.h"
#include "libedataserver/e-account.h"
#include "exchange-send-options.h"
@@ -41,6 +43,10 @@ static void
append_to_header (ExchangeSendOptionsDialog *dialog, gint state, gpointer data)
{
EMsgComposer *composer;
+ EMsgComposerHdrs *hdrs;
+ CamelInternetAddress *sender_address;
+ const char *sender_id, *recipient_id;
+
composer = (EMsgComposer *)data;
if (state == GTK_RESPONSE_OK) {
if (dialog->options->importance) {
@@ -77,6 +83,44 @@ append_to_header (ExchangeSendOptionsDialog *dialog, gint state, gpointer data)
}
else
e_msg_composer_remove_header (composer, "Sensitivity");
+
+ hdrs = e_msg_composer_get_hdrs (composer);
+ sender_address = (CamelAddress *) e_msg_composer_hdrs_get_from (hdrs);
+ sender_id = (const char*) camel_address_encode (sender_address);
+
+ struct _camel_header_address *addr = camel_header_address_decode (
+ dialog->options->delegate_address, NULL);
+
+ struct _camel_header_address *sender_addr = camel_header_address_decode (
+ sender_id, NULL);
+
+ if(dialog->options->send_as_del_enabled &&
+ dialog->options->delegate_address &&
+ g_ascii_strcasecmp(addr->v.addr, sender_addr->v.addr)) {
+
+ e_msg_composer_modify_header (composer, "Sender" , sender_id);
+
+ /* This block handles the case wherein the address to be added
+ * in the "From" field has no name associated with it.
+ * So for cases where there is no name we append the address
+ * (only email) within angular braces.
+ */
+ if(!g_ascii_strcasecmp (addr->name, "")) {
+ recipient_id = g_strdup_printf ("<%s>",
+ dialog->options->delegate_address);
+ e_msg_composer_add_header (composer, "From", recipient_id);
+ }
+
+ else
+ e_msg_composer_add_header (composer, "From",
+ dialog->options->delegate_address);
+ }
+
+
+ else {
+ e_msg_composer_remove_header (composer, "Sender");
+ e_msg_composer_add_header (composer, "From", sender_id);
+ }
if (dialog->options->delivery_enabled) {
EMsgComposerHdrs *hdrs = e_msg_composer_get_hdrs(composer);
diff --git a/plugins/exchange-operations/exchange-send-options.c b/plugins/exchange-operations/exchange-send-options.c
index 68bfc89fce..e9dacc7d22 100644
--- a/plugins/exchange-operations/exchange-send-options.c
+++ b/plugins/exchange-operations/exchange-send-options.c
@@ -24,11 +24,15 @@
#include <string.h>
#include <glib.h>
+#include <libedataserverui/e-name-selector.h>
+#include <libedataserverui/e-contact-store.h>
+#include "exchange-operations.h"
+#include <e-util/e-error.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtk.h>
#include <libgnome/libgnome.h>
-#include <glib/gi18n.h>
+#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include "e-util/e-util-private.h"
@@ -42,6 +46,9 @@ struct _ExchangeSendOptionsDialogPrivate {
/*Widgets*/
GtkWidget *main;
+
+ /*name selector dialog*/
+ ENameSelector *proxy_name_selector;
/*Importance*/
GtkWidget *importance;
@@ -49,12 +56,18 @@ struct _ExchangeSendOptionsDialogPrivate {
/*Sensitivity*/
GtkWidget *sensitivity;
+ /*Send_as_delegate_enabled*/
+ GtkWidget *delegate_enabled;
+
/*Read Receipt*/
GtkWidget *read_receipt;
/*Delivery Receipt*/
GtkWidget *delivery_receipt;
-
+
+ /*User button*/
+ GtkWidget *button_user;
+
/*Label Widgets*/
GtkWidget *importance_label;
GtkWidget *sensitivity_label;
@@ -74,22 +87,88 @@ enum {
static guint signals[LAST_SIGNAL] = {0};
-
-static void
+/* exchange_send_options_get_widgets_data(ExchangeSendOptionsDialog *sod)
+ Return Value:This function returns a -1 if an error occurs. In case of error-free operation a 1 is returned.
+*/
+static int
exchange_send_options_get_widgets_data (ExchangeSendOptionsDialog *sod)
{
ExchangeSendOptionsDialogPrivate *priv;
ExchangeSendOptions *options;
+ const char *address, *email, *name;
+ guint count=0;
+ ENameSelectorEntry *name_selector_entry;
+ EDestinationStore *destination_store;
+ GList *destinations, *tmp;
+
priv = sod->priv;
options = sod->options;
+ /* This block helps us fetch the address of the delegator(s). If no delegator is selected or more
+ than one delegatee has been selected then an info dialog is popped up to help the user.
+ */
+ if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled))) {
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector, "Add User");
+ destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (name_selector_entry));
+ destinations = e_destination_store_list_destinations (destination_store);
+ tmp = destinations;
+
+ email = NULL;
+
+ /* The temporary variables address, email, and name are needed to fetch the list items.
+ Only the valid one is then copied into the storage variables. The "count" variable
+ helps us keep a count of the exact number of items in the list. The g_list_length(GList *)
+ produced ambiguous results. Hence count is used :)
+ */
+ for (; tmp != NULL; tmp = g_list_next (tmp)) {
+ address = g_strdup ((char *) e_destination_get_address (tmp->data));
+ email = g_strdup ((char *) e_destination_get_email (tmp->data));
+ name = g_strdup (e_destination_get_name (tmp->data));
+ if (g_str_equal (email, ""))
+ continue;
+ count++;
+
+ options->delegate_address = address;
+ options->delegate_name = name;
+ options->delegate_email = email;
+ }
+
+ if(count == 0) {
+ e_error_run ((GtkWindow *) priv->main,
+ "org-gnome-exchange-operations:no-delegate-selected", NULL, NULL);
+ gtk_widget_grab_focus ((GtkWidget *) name_selector_entry);
+ options->delegate_address = NULL;
+ options->delegate_name = NULL;
+ options->delegate_email = NULL;
+ return -1;
+ }
+
+ if(count > 1) {
+ e_error_run ((GtkWindow *)priv->main,
+ "org-gnome-exchange-operations:more-delegates-selected", NULL, NULL);
+ gtk_widget_grab_focus ((GtkWidget *) name_selector_entry);
+ options->delegate_address = NULL;
+ options->delegate_name = NULL;
+ options->delegate_email = NULL;
+ return -1;
+ }
+ }
+
options->importance = gtk_combo_box_get_active ((GtkComboBox *)priv->importance);
options->sensitivity = gtk_combo_box_get_active ((GtkComboBox *)priv->sensitivity);
- options->delivery_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delivery_receipt));
- options->read_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->read_receipt));
+ options->send_as_del_enabled = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->delegate_enabled));
+ options->delivery_enabled = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->delivery_receipt));
+
+ options->read_enabled = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (priv->read_receipt));
+
+ return 1;
}
static gboolean
@@ -107,6 +186,8 @@ get_widgets (ExchangeSendOptionsDialog *sod)
priv->importance = EXCHANGE ("imp_combo_box");
priv->sensitivity = EXCHANGE ("sensitivity_combo_box");
+ priv->button_user = EXCHANGE ("button-user");
+ priv->delegate_enabled = EXCHANGE ("del_enabled_check");
priv->read_receipt = EXCHANGE ("read_check_button");
priv->delivery_receipt = EXCHANGE ("delivery_check_button");
priv->importance_label = EXCHANGE ("Importance_label");
@@ -116,6 +197,8 @@ get_widgets (ExchangeSendOptionsDialog *sod)
return (priv->importance
&&priv->sensitivity
+ &&priv->button_user
+ &&priv->delegate_enabled
&&priv->read_receipt
&&priv->delivery_receipt
&&priv->importance_label
@@ -127,6 +210,8 @@ exchange_send_options_fill_widgets_with_data (ExchangeSendOptionsDialog *sod)
{
ExchangeSendOptionsDialogPrivate *priv;
ExchangeSendOptions *options;
+ ENameSelectorEntry *name_selector_entry;
+
priv = sod->priv;
options = sod->options;
@@ -137,11 +222,26 @@ exchange_send_options_fill_widgets_with_data (ExchangeSendOptionsDialog *sod)
gtk_combo_box_set_active ((GtkComboBox *) priv->importance, options->importance);
gtk_combo_box_set_active ((GtkComboBox *) priv->sensitivity, options->sensitivity);
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector, "Add User");
+
+ if(options->send_as_del_enabled) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled), TRUE);
+ gtk_widget_set_sensitive ((GtkWidget *)name_selector_entry, TRUE);
+ gtk_widget_set_sensitive ((GtkWidget *)priv->button_user, TRUE);
+ }
+
+ else {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled), FALSE);
+ gtk_widget_set_sensitive ((GtkWidget *)name_selector_entry, FALSE);
+ gtk_widget_set_sensitive ((GtkWidget *)priv->button_user, FALSE);
+ }
if (options->read_enabled)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->read_receipt), TRUE);
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->read_receipt), FALSE);
+
if (options->delivery_enabled)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivery_receipt), TRUE);
else
@@ -189,37 +289,104 @@ static void exchange_send_options_cb (GtkDialog *dialog, gint state, gpointer fu
sod = func_data;
priv = sod->priv;
- switch (state) {
+ switch (state) {
case GTK_RESPONSE_OK:
- exchange_send_options_get_widgets_data (sod);
+ if(exchange_send_options_get_widgets_data (sod) < 0)
+ return;
case GTK_RESPONSE_CANCEL:
- gtk_widget_hide (priv->main);
- gtk_widget_destroy (priv->main);
- g_object_unref (priv->xml);
- break;
+ gtk_widget_hide (priv->main);
+ gtk_widget_destroy (priv->main);
+ g_object_unref (priv->xml);
+ break;
case GTK_RESPONSE_HELP:
- gnome_help_display (
+ gnome_help_display (
"evolution.xml", priv->help_section, &error);
if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
}
- break;
+ break;
}
g_signal_emit (G_OBJECT (func_data), signals[SOD_RESPONSE], 0, state);
}
+
+/* This function acts as a listener for the toggling of "send_as_a_delegate" button. This is needed to
+ sensitize the name_selector_entry and the User Button
+*/
+static void
+delegate_option_toggled (GtkCheckButton *button, gpointer func_data)
+{
+ ExchangeSendOptionsDialogPrivate *priv;
+ ExchangeSendOptionsDialog *sod;
+ ENameSelectorEntry *name_selector_entry;
+ ExchangeSendOptions *options;
+
+ sod=func_data;
+ priv=sod->priv;
+ options=sod->options;
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector, "Add User");
+
+ if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delegate_enabled))) {
+ gtk_widget_set_sensitive ((GtkWidget *) name_selector_entry, TRUE);
+ gtk_widget_set_sensitive ((GtkWidget *) priv->button_user, TRUE);
+ }
+
+ else {
+ gtk_widget_set_sensitive ((GtkWidget *) name_selector_entry, FALSE);
+ gtk_widget_set_sensitive ((GtkWidget *) priv->button_user, FALSE);
+ }
+
+}
+
+static void
+addressbook_dialog_response (ENameSelectorDialog *name_selector_dialog, gint response, gpointer user_data)
+{
+ gtk_widget_hide (GTK_WIDGET (name_selector_dialog));
+}
+
+static void
+addressbook_entry_changed (GtkWidget *entry, gpointer user_data)
+{
+}
+
+/* This function invokes the name selector dialog
+*/
+static void
+address_button_clicked (GtkButton *button, gpointer func_data)
+{
+
+ ExchangeSendOptionsDialogPrivate *priv;
+ ExchangeSendOptionsDialog *sod;
+ ENameSelectorDialog *name_selector_dialog;
+
+ sod=func_data;
+ priv=sod->priv;
+
+ name_selector_dialog = e_name_selector_peek_dialog (priv->proxy_name_selector);
+ gtk_widget_show (GTK_WIDGET (name_selector_dialog));
+}
gboolean
exchange_sendoptions_dialog_run (ExchangeSendOptionsDialog *sod, GtkWidget *parent)
-{
+{
ExchangeSendOptionsDialogPrivate *priv;
+ ExchangeSendOptions *options;
+
GtkWidget *toplevel;
gchar *filename;
+ EDestinationStore *destination_store;
+ ENameSelectorDialog *name_selector_dialog;
+ ENameSelectorModel *name_selector_model;
+ ENameSelectorEntry *name_selector_entry;
+ EDestination *des;
+ GtkWidget *name_box;
g_return_val_if_fail (sod != NULL || EXCHANGE_IS_SENDOPTIONS_DIALOG (sod), FALSE);
priv = sod->priv;
+ options = sod->options;
filename = g_build_filename (EVOLUTION_GLADEDIR,
"exchange-send-options.glade",
@@ -243,11 +410,44 @@ exchange_sendoptions_dialog_run (ExchangeSendOptionsDialog *sod, GtkWidget *pare
gtk_window_set_transient_for (GTK_WINDOW (toplevel),
GTK_WINDOW (parent));
+ priv->proxy_name_selector = e_name_selector_new ();
+ name_selector_dialog = e_name_selector_peek_dialog (priv->proxy_name_selector);
+
+ name_selector_model = e_name_selector_peek_model (priv->proxy_name_selector);
+ e_name_selector_model_add_section (name_selector_model, "Add User", "Add User", NULL);
+
exchange_send_options_fill_widgets_with_data (sod);
+
+ if(options->delegate_address) {
+ e_name_selector_model_peek_section (name_selector_model, "Add User", NULL, &destination_store);
+ des = e_destination_new ();
+ e_destination_set_email (des, options->delegate_email);
+ e_destination_set_name (des, options->delegate_name);
+ e_destination_store_append_destination (destination_store, des);
+ g_object_unref (des);
+ }
+
+ g_signal_connect ((GtkButton *) priv->button_user, "clicked",
+ G_CALLBACK (address_button_clicked), sod);
+ g_signal_connect (name_selector_dialog, "response",
+ G_CALLBACK (addressbook_dialog_response), sod);
+ g_signal_connect (GTK_DIALOG (priv->main), "response",
+ G_CALLBACK(exchange_send_options_cb), sod);
+ g_signal_connect ((GtkCheckButton *) priv->delegate_enabled, "toggled",
+ G_CALLBACK(delegate_option_toggled), sod);
+
+ name_selector_entry = e_name_selector_peek_section_entry (priv->proxy_name_selector,
+ "Add User");
+ g_signal_connect (name_selector_entry, "changed", G_CALLBACK (addressbook_entry_changed), sod);
- g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(exchange_send_options_cb), sod);
-
- gtk_window_set_modal ((GtkWindow *)priv->main, TRUE);
+ /* The name box is just a container. The name_selector_entry is added to it. This Widget
+ is created dynamically*/
+ name_box = glade_xml_get_widget (priv->xml, "del_name_box");
+ gtk_container_add ((GtkContainer *) name_box, (GtkWidget *) name_selector_entry);
+ gtk_widget_show ((GtkWidget *) name_selector_entry);
+ gtk_widget_grab_focus ((GtkWidget *) name_selector_entry);
+
+ gtk_window_set_modal ((GtkWindow *) priv->main, TRUE);
gtk_widget_show (priv->main);
return TRUE;
@@ -291,6 +491,7 @@ exchange_sendoptions_dialog_init (GObject *object)
sod->priv = priv;
sod->options = new;
+ sod->options->send_as_del_enabled = FALSE;
sod->options->delivery_enabled = FALSE;
sod->options->read_enabled = FALSE;
sod->options->importance = E_IMP_NORMAL;
@@ -302,6 +503,8 @@ exchange_sendoptions_dialog_init (GObject *object)
priv->sensitivity = NULL;
priv->sensitivity_label = NULL;
priv->importance_label = NULL;
+ priv->button_user = NULL;
+ priv->proxy_name_selector = NULL;
priv->read_receipt = NULL;
priv->delivery_receipt = NULL;
diff --git a/plugins/exchange-operations/exchange-send-options.glade b/plugins/exchange-operations/exchange-send-options.glade
index 4ca75c1675..92a9dc2b75 100644
--- a/plugins/exchange-operations/exchange-send-options.glade
+++ b/plugins/exchange-operations/exchange-send-options.glade
@@ -236,6 +236,88 @@ Low</property>
</child>
<child>
+ <widget class="GtkCheckButton" id="del_enabled_check">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Send as Delegate</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="del_name_box">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button-user">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_User</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <accessibility>
+ <atkproperty name="AtkObject::accessible_name" translatable="yes">button-user</atkproperty>
+ </accessibility>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkVBox" id="track_option_vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
diff --git a/plugins/exchange-operations/exchange-send-options.h b/plugins/exchange-operations/exchange-send-options.h
index 8d4e2de55f..f09e189670 100644
--- a/plugins/exchange-operations/exchange-send-options.h
+++ b/plugins/exchange-operations/exchange-send-options.h
@@ -48,11 +48,18 @@ typedef enum {
E_SENSITIVITY_CONFIDENTIAL
} ExchangeSendOptionsSensitivity;
+/* We require the delegate_email and delegate_name to store the address of the delegator selected into
+ the destination store.
+*/
typedef struct {
ExchangeSendOptionsImp importance;
ExchangeSendOptionsSensitivity sensitivity;
+ gboolean send_as_del_enabled;
gboolean delivery_enabled;
gboolean read_enabled;
+ const char *delegate_name;
+ const char *delegate_email;
+ const char *delegate_address;
} ExchangeSendOptions ;
struct _ExchangeSendOptionsDialog {
diff --git a/plugins/exchange-operations/org-gnome-exchange-operations.error.xml b/plugins/exchange-operations/org-gnome-exchange-operations.error.xml
index 021ce67f87..0aa4b6fb79 100644
--- a/plugins/exchange-operations/org-gnome-exchange-operations.error.xml
+++ b/plugins/exchange-operations/org-gnome-exchange-operations.error.xml
@@ -183,6 +183,15 @@ username, and password, and try again.</_secondary>
<_secondary>{0}</_secondary>
</error>
+<error id="no-delegate-selected" type="info">
+ <_primary>Please enter a Delegate's ID or deselect the Send as a Delegate option.</_primary>
+ </error>
+
+<error id="more-delegates-selected" type="info">
+ <_primary>You are permitted to send a message on behalf of only one delegator at a time.</_primary>
+ </error>
+
+
<error id="select-user" type="info">
<_primary>Please select a user.</_primary>
</error>