From 7aecd03e9465610ddc6d8cb16615e9cf3d4af356 Mon Sep 17 00:00:00 2001 From: Veerapuram Varadhan Date: Mon, 22 Jan 2007 18:59:12 +0000 Subject: Adding files corresponding to the implementation. svn path=/trunk/; revision=33138 --- .../exchange-mail-send-options.c | 143 +++++++++ .../exchange-operations/exchange-send-options.c | 348 +++++++++++++++++++++ .../exchange-send-options.glade | 326 +++++++++++++++++++ .../exchange-operations/exchange-send-options.h | 76 +++++ 4 files changed, 893 insertions(+) create mode 100644 plugins/exchange-operations/exchange-mail-send-options.c create mode 100644 plugins/exchange-operations/exchange-send-options.c create mode 100644 plugins/exchange-operations/exchange-send-options.glade create mode 100644 plugins/exchange-operations/exchange-send-options.h (limited to 'plugins') diff --git a/plugins/exchange-operations/exchange-mail-send-options.c b/plugins/exchange-operations/exchange-mail-send-options.c new file mode 100644 index 0000000000..65533d8ed2 --- /dev/null +++ b/plugins/exchange-operations/exchange-mail-send-options.c @@ -0,0 +1,143 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Authors: R.Raghavendran + * + * Copyright 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include + +#include +#include + +#include +#include "mail/em-event.h" + +#include "composer/e-msg-composer.h" +#include "libedataserver/e-account.h" + +#include "exchange-send-options.h" + +void org_gnome_exchange_send_options (EPlugin *ep, EMEventTargetComposer *t); + +static ExchangeSendOptionsDialog *dialog=NULL; + +static void +append_to_header (ExchangeSendOptionsDialog *dialog, gint state, gpointer data) +{ + EMsgComposer *composer; + composer = (EMsgComposer *)data; + if (state == GTK_RESPONSE_OK) { + if (dialog->options->importance) { + switch (dialog->options->importance) { + case E_IMP_HIGH : + e_msg_composer_modify_header (composer, "Importance", "high"); + break; + case E_IMP_LOW : + e_msg_composer_modify_header (composer, "Importance", "low"); + break; + default : + g_print ("\nNo importance set"); + break; + } + } + else + e_msg_composer_remove_header (composer, "Importance"); + + if (dialog->options->sensitivity) { + switch (dialog->options->sensitivity) { + case E_SENSITIVITY_CONFIDENTIAL : + e_msg_composer_modify_header (composer, "Sensitivity", "Company-Confidential"); + break; + case E_SENSITIVITY_PERSONAL : + e_msg_composer_modify_header (composer, "Sensitivity", "Personal"); + break; + case E_SENSITIVITY_PRIVATE : + e_msg_composer_modify_header (composer, "Sensitivity", "Private"); + break; + default : + g_print ("\nNo importance set"); + break; + } + } + else + e_msg_composer_remove_header (composer, "Sensitivity"); + + if (dialog->options->delivery_enabled) { + EMsgComposerHdrs *hdrs = e_msg_composer_get_hdrs(composer); + + char *mdn_address = hdrs->account->id->reply_to; + if (!mdn_address || !*mdn_address) + mdn_address = hdrs->account->id->address; + e_msg_composer_modify_header (composer, "Return-Receipt-To", mdn_address); + } + else + e_msg_composer_remove_header (composer, "Return-Receipt-To"); + + if (dialog->options->read_enabled) { + EMsgComposerHdrs *hdrs = e_msg_composer_get_hdrs(composer); + + char *mdn_address = hdrs->account->id->reply_to; + if (!mdn_address || !*mdn_address) + mdn_address = hdrs->account->id->address; + + e_msg_composer_modify_header (composer, "Disposition-Notification-To", mdn_address); + } + else + e_msg_composer_remove_header (composer, "Disposition-Notification-To"); + } +} + +static void +send_options_commit (EMsgComposer *comp, gpointer user_data) +{ + if (!user_data && !EXCHANGE_IS_SENDOPTIONS_DIALOG (user_data)) + return; + + if (dialog) { + g_print ("\nDialog getting unreferenced "); + g_object_unref (dialog); + dialog = NULL; + } +} + +void +org_gnome_exchange_send_options (EPlugin *ep, EMEventTargetComposer *target) +{ + EMsgComposer *composer = target->composer; + EAccount *account = NULL; + char *temp = NULL; + + account = e_msg_composer_get_preferred_account (composer) ; + temp = strstr (account->transport->url, "exchange") ; + if (!temp) { + return; + } + e_msg_composer_set_send_options (composer, TRUE); + /*disply the send options dialog*/ + if (!dialog) { + g_print ("New dialog\n\n") ; + dialog = exchange_sendoptions_dialog_new () ; + } + exchange_sendoptions_dialog_run (dialog, composer) ; + g_signal_connect (dialog, "sod_response", G_CALLBACK (append_to_header), composer); + + g_signal_connect (GTK_WIDGET (composer), "destroy", + G_CALLBACK (send_options_commit), dialog); + +} diff --git a/plugins/exchange-operations/exchange-send-options.c b/plugins/exchange-operations/exchange-send-options.c new file mode 100644 index 0000000000..9215c42e8c --- /dev/null +++ b/plugins/exchange-operations/exchange-send-options.c @@ -0,0 +1,348 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Authors: R.Raghavendran + * + * Copyright (C) 2004 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Bangalore, MA 02111-1307, India. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "e-util/e-util-private.h" + +#include "exchange-send-options.h" + +struct _ExchangeSendOptionsDialogPrivate { + /* Glade XML data */ + GladeXML *xml; + + /*Widgets*/ + + GtkWidget *main; + + /*Importance*/ + GtkWidget *importance; + + /*Sensitivity*/ + GtkWidget *sensitivity; + + /*Read Receipt*/ + GtkWidget *read_receipt; + + /*Delivery Receipt*/ + GtkWidget *delivery_receipt; + + /*Label Widgets*/ + GtkWidget *importance_label; + GtkWidget *sensitivity_label; + char *help_section; +}; + +static void exchange_sendoptions_dialog_class_init (GObjectClass *object_class); +static void exchange_sendoptions_dialog_finalize (GObject *object); +static void exchange_sendoptions_dialog_init (GObject *object); +static void exchange_sendoptions_dialog_dispose (GObject *object); + +static GObjectClass *parent_class = NULL; +enum { + SOD_RESPONSE, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; + + +static void +exchange_send_options_get_widgets_data (ExchangeSendOptionsDialog *sod) +{ + ExchangeSendOptionsDialogPrivate *priv; + ExchangeSendOptions *options; + + priv = sod->priv; + options = sod->options; + + 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)); + +} + +static gboolean +get_widgets (ExchangeSendOptionsDialog *sod) +{ + ExchangeSendOptionsDialogPrivate *priv; + + priv = sod->priv; + +#define EXCHANGE(name) glade_xml_get_widget (priv->xml, name) + + priv->main = EXCHANGE ("send_options"); + if (!priv->main) + return FALSE; + + priv->importance = EXCHANGE ("imp_combo_box"); + priv->sensitivity = EXCHANGE ("sensitivity_combo_box"); + priv->read_receipt = EXCHANGE ("read_check_button"); + priv->delivery_receipt = EXCHANGE ("delivery_check_button"); + priv->importance_label = EXCHANGE ("Importance_label"); + priv->sensitivity_label = EXCHANGE ("Sensitivity_label"); + +#undef EXCHANGE + + return (priv->importance + &&priv->sensitivity + &&priv->read_receipt + &&priv->delivery_receipt + &&priv->importance_label + &&priv->sensitivity_label); +} + +static void +exchange_send_options_fill_widgets_with_data (ExchangeSendOptionsDialog *sod) +{ + ExchangeSendOptionsDialogPrivate *priv; + ExchangeSendOptions *options; + priv = sod->priv; + options = sod->options; + + priv->help_section = g_strdup ("usage-mail"); + + gtk_label_set_mnemonic_widget (GTK_LABEL (priv->importance_label), priv->importance); + gtk_label_set_mnemonic_widget (GTK_LABEL (priv->sensitivity_label), priv->sensitivity); + + gtk_combo_box_set_active ((GtkComboBox *) priv->importance, options->importance); + gtk_combo_box_set_active ((GtkComboBox *) priv->sensitivity, options->sensitivity); + + 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 + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivery_receipt), FALSE); +} + +ExchangeSendOptionsDialog * +exchange_sendoptions_dialog_new (void) { + ExchangeSendOptionsDialog *sod; + + sod = g_object_new (EXCHANGE_TYPE_SENDOPTIONS_DIALOG, NULL); + + return sod; +} + +GType exchange_sendoptions_dialog_get_type (void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (ExchangeSendOptionsDialogClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) exchange_sendoptions_dialog_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (ExchangeSendOptionsDialog), + 0, /* n_preallocs */ + (GInstanceInitFunc) exchange_sendoptions_dialog_init, + NULL /* instance_init */ + }; + type = g_type_register_static (G_TYPE_OBJECT, + "ExchangeSendOptionsDialogType", + &info, 0); + } + return type; +} + +static void exchange_send_options_cb (GtkDialog *dialog, gint state, gpointer func_data) +{ + ExchangeSendOptionsDialogPrivate *priv; + ExchangeSendOptionsDialog *sod; + GError *error = NULL; + + sod = func_data; + priv = sod->priv; + + switch (state) { + case GTK_RESPONSE_OK: + exchange_send_options_get_widgets_data (sod); + case GTK_RESPONSE_CANCEL: + gtk_widget_hide (priv->main); + gtk_widget_destroy (priv->main); + g_object_unref (priv->xml); + break; + case GTK_RESPONSE_HELP: + gnome_help_display_desktop (NULL, + "evolution-" BASE_VERSION, + "evolution-" BASE_VERSION ".xml", + priv->help_section, + &error); + if (error != NULL) + g_warning ("%s", error->message); + break; + } + g_signal_emit (G_OBJECT (func_data), signals[SOD_RESPONSE], 0, state); + +} + +gboolean +exchange_sendoptions_dialog_run (ExchangeSendOptionsDialog *sod, GtkWidget *parent) +{ + ExchangeSendOptionsDialogPrivate *priv; + GtkWidget *toplevel; + gchar *filename; + + g_return_val_if_fail (sod != NULL || EXCHANGE_IS_SENDOPTIONS_DIALOG (sod), FALSE); + + priv = sod->priv; + + filename = g_build_filename (EVOLUTION_GLADEDIR, + "exchange-send-options.glade", + NULL); + priv->xml = glade_xml_new (filename, NULL, NULL); + g_free (filename); + + if (!priv->xml) { + g_message ( G_STRLOC ": Could not load the Glade XML file "); + return FALSE; + } + + if (!get_widgets(sod)) { + g_object_unref (priv->xml); + g_message (G_STRLOC ": Could not get the Widgets \n"); + return FALSE; + } + + toplevel = gtk_widget_get_toplevel (priv->main); + if (parent) + gtk_window_set_transient_for (GTK_WINDOW (toplevel), + GTK_WINDOW (parent)); + + exchange_send_options_fill_widgets_with_data (sod); + + g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(exchange_send_options_cb), sod); + + gtk_window_set_modal ((GtkWindow *)priv->main, TRUE); + gtk_widget_show (priv->main); + + return TRUE; +} + +static void +exchange_sendoptions_dialog_class_init (GObjectClass *object) +{ + ExchangeSendOptionsDialogClass *klass; + GObjectClass *object_class; + + klass = EXCHANGE_SENDOPTIONS_DIALOG_CLASS (object); + parent_class = g_type_class_peek_parent (klass); + object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = exchange_sendoptions_dialog_finalize; + object_class->dispose = exchange_sendoptions_dialog_dispose; + signals[SOD_RESPONSE] = g_signal_new ("sod_response", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (ExchangeSendOptionsDialogClass, esod_response), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); + +} + +static void +exchange_sendoptions_dialog_init (GObject *object) +{ + + ExchangeSendOptionsDialog *sod; + ExchangeSendOptionsDialogPrivate *priv; + ExchangeSendOptions *new; + + sod = EXCHANGE_SENDOPTIONS_DIALOG (object); + new = g_new0 (ExchangeSendOptions, 1); + + priv = g_new0 (ExchangeSendOptionsDialogPrivate, 1); + + sod->priv = priv; + sod->options = new; + sod->options->delivery_enabled = FALSE; + sod->options->read_enabled = FALSE; + sod->options->importance = E_IMP_NORMAL; + sod->options->sensitivity = E_SENSITIVITY_NORMAL; + + priv->xml = NULL; + priv->main = NULL; + priv->importance = NULL; + priv->sensitivity = NULL; + priv->sensitivity_label = NULL; + priv->importance_label = NULL; + priv->read_receipt = NULL; + priv->delivery_receipt = NULL; + +} + +static void +exchange_sendoptions_dialog_finalize (GObject *object) +{ + ExchangeSendOptionsDialog *sod = (ExchangeSendOptionsDialog *)object; + ExchangeSendOptionsDialogPrivate *priv; + + g_return_if_fail (EXCHANGE_IS_SENDOPTIONS_DIALOG (sod)); + priv = sod->priv; + + g_free (priv->help_section); + + if (sod->options) { + g_free (sod->options); + sod->options = NULL; + } + + if (sod->priv) { + g_free (sod->priv); + sod->priv = NULL; + } + + if (parent_class->finalize) + (* parent_class->finalize) (object); + +} + +static void +exchange_sendoptions_dialog_dispose (GObject *object) +{ + ExchangeSendOptionsDialog *sod = (ExchangeSendOptionsDialog *) object; + + g_return_if_fail (EXCHANGE_IS_SENDOPTIONS_DIALOG (sod)); + + if (parent_class->dispose) + (* parent_class->dispose) (object); + +} + diff --git a/plugins/exchange-operations/exchange-send-options.glade b/plugins/exchange-operations/exchange-send-options.glade new file mode 100644 index 0000000000..4ca75c1675 --- /dev/null +++ b/plugins/exchange-operations/exchange-send-options.glade @@ -0,0 +1,326 @@ + + + + + + + + True + Exchange - Send Options + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + True + -11 + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + <b>Message Settings</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.490000009537 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + 6 + True + 2 + 2 + False + 6 + 0 + + + + True + I_mportance: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.490000009537 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Sensitivity: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Normal +Personal +Private +Confidential + False + True + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + Normal +High +Low + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 0 + + + + True + <b>Tracking Options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 6 + False + False + + + + + + 6 + True + True + Request a _delivery receipt for this message + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + 6 + True + True + Request a _read receipt for this message + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + diff --git a/plugins/exchange-operations/exchange-send-options.h b/plugins/exchange-operations/exchange-send-options.h new file mode 100644 index 0000000000..8d4e2de55f --- /dev/null +++ b/plugins/exchange-operations/exchange-send-options.h @@ -0,0 +1,76 @@ + /* Evolution exchange send options + * Copyright (C) 2004 Novell, Inc. + * + * Authors: Raghavendran R + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Bangalore, MA 02111-1307, India. + */ + +#ifndef __EXCHANGE_SENDOPTIONS_DIALOG_H__ +#define __EXCHANGE_SENDOPTIONS_DIALOG_H__ + +#include +#include + + + +#define EXCHANGE_TYPE_SENDOPTIONS_DIALOG (exchange_sendoptions_dialog_get_type ()) +#define EXCHANGE_SENDOPTIONS_DIALOG(obj) (GTK_CHECK_CAST ((obj), EXCHANGE_TYPE_SENDOPTIONS_DIALOG, ExchangeSendOptionsDialog)) +#define EXCHANGE_SENDOPTIONS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EXCHANGE_TYPE_SENDOPTIONS_DIALOG, ExchangeSendOptionsDialogClass)) +#define EXCHANGE_IS_SENDOPTIONS_DIALOG(obj) (GTK_CHECK_TYPE ((obj), EXCHANGE_TYPE_SENDOPTIONS_DIALOG)) +#define EXCHANGE_IS_SENDOPTIONS_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EXCHANGE_TYPE_SENDOPTIONS_DIALOG)) + +typedef struct _ExchangeSendOptionsDialog ExchangeSendOptionsDialog; +typedef struct _ExchangeSendOptionsDialogClass ExchangeSendOptionsDialogClass; +typedef struct _ExchangeSendOptionsDialogPrivate ExchangeSendOptionsDialogPrivate; + +typedef enum { + E_IMP_NORMAL, + E_IMP_HIGH, + E_IMP_LOW +} ExchangeSendOptionsImp; + +typedef enum { + E_SENSITIVITY_NORMAL, + E_SENSITIVITY_PERSONAL, + E_SENSITIVITY_PRIVATE, + E_SENSITIVITY_CONFIDENTIAL +} ExchangeSendOptionsSensitivity; + +typedef struct { + ExchangeSendOptionsImp importance; + ExchangeSendOptionsSensitivity sensitivity; + gboolean delivery_enabled; + gboolean read_enabled; +} ExchangeSendOptions ; + +struct _ExchangeSendOptionsDialog { + GObject object; + + ExchangeSendOptions *options; + /* Private data */ + ExchangeSendOptionsDialogPrivate *priv; +}; + + +struct _ExchangeSendOptionsDialogClass { + GObjectClass parent_class; + void (* esod_response) (ExchangeSendOptionsDialog *esd, gint status); +}; + +GType exchange_sendoptions_dialog_get_type (void); +ExchangeSendOptionsDialog *exchange_sendoptions_dialog_new (void); +gboolean exchange_sendoptions_dialog_run (ExchangeSendOptionsDialog *sod, GtkWidget *parent); +#endif + -- cgit v1.2.3