1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Authors: Parthasarathi Susarla <sparthasarathi@novell.com>
*
* 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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <glib/gi18n.h>
#include "send-options.h"
#include "mail/em-menu.h"
#include "mail/em-utils.h"
#include "composer/e-msg-composer.h"
#include "e-util/e-account.h"
#include "widgets/misc/e-send-options.h"
static ESendOptionsDialog * dialog = NULL ;
void org_gnome_compose_send_options (EPlugin *ep, EMMenuTargetWidget *t);
static time_t
add_day_to_time (time_t time, int days)
{
struct tm *tm;
tm = localtime (&time);
tm->tm_mday += days;
tm->tm_isdst = -1;
return mktime (tm);
}
static void
send_options_commit (EMsgComposer *comp, gpointer user_data)
{
if (!user_data && !E_IS_SENDOPTIONS_DIALOG (user_data))
return;
if (dialog) {
g_object_unref (dialog);
dialog = NULL;
}
}
void
org_gnome_compose_send_options (EPlugin *ep, EMMenuTargetWidget *t)
{
struct _EMenuTarget menu = t->target ;
EMsgComposer *comp = (struct _EMsgComposer *)menu.widget ;
EAccount *account = NULL;
char *temp = NULL;
char *url;
char value [100];
account = e_msg_composer_get_preferred_account (comp) ;
url = g_strdup (account->transport->url) ;
temp = strstr (url, "groupwise") ;
if (!temp) {
g_print ("Sorry send options only available for a groupwise account\n") ;
}
g_free (temp) ;
/*disply the send options dialog*/
if (!dialog) {
g_print ("New dialog\n\n") ;
dialog = e_sendoptions_dialog_new () ;
}
e_sendoptions_dialog_run (dialog, menu.widget, E_ITEM_MAIL) ;
if (dialog->data->gopts->reply_enabled) {
if (dialog->data->gopts->reply_convenient)
e_msg_composer_add_header (comp, X_REPLY_CONVENIENT ,"1" ) ;
else if (dialog->data->gopts->reply_within) {
time_t t;
t = add_day_to_time (time (NULL), dialog->data->gopts->reply_convenient);
strftime (value, 17, "%Y%m%dT%H%M%SZ", gmtime (&t));
e_msg_composer_add_header (comp, X_REPLY_WITHIN , value) ;
}
}
if (dialog->data->gopts->expiration_enabled) {
if (dialog->data->gopts->expire_after != 0) {
time_t t;
t = add_day_to_time (time (NULL), dialog->data->gopts->expire_after);
strftime (value, 17, "%Y%m%dT%H%M%SZ", gmtime (&t));
e_msg_composer_add_header (comp, X_EXPIRE_AFTER, value) ;
}
}
if (dialog->data->gopts->delay_enabled) {
strftime (value, 17, "%Y%m%dT%H%M%SZ", gmtime (&dialog->data->gopts->delay_until));
e_msg_composer_add_header (comp, X_DELAY_UNTIL, value) ;
}
/*Status Tracking Options*/
if (dialog->data->sopts->tracking_enabled) {
temp = g_strdup_printf ("%d",dialog->data->sopts->track_when) ;
e_msg_composer_add_header (comp, X_TRACK_WHEN, temp) ;
g_free (temp) ;
}
if (dialog->data->sopts->autodelete) {
e_msg_composer_add_header (comp, X_AUTODELETE, "1") ;
}
if (dialog->data->sopts->opened) {
temp = g_strdup_printf ("%d",dialog->data->sopts->opened) ;
e_msg_composer_add_header (comp, X_RETURN_NOTIFY_OPEN, temp) ;
g_free (temp) ;
}
if (dialog->data->sopts->declined) {
temp = g_strdup_printf ("%d",dialog->data->sopts->declined) ;
e_msg_composer_add_header (comp, X_RETURN_NOTIFY_DECLINE, temp) ;
g_free (temp) ;
}
g_signal_connect (GTK_WIDGET (comp), "destroy",
G_CALLBACK (send_options_commit), dialog);
}
|