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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Authors: Chenthill Palanisamy (pchenthill@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.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <gtk/gtk.h>
#include "mail/em-account-editor.h"
#include "mail/em-config.h"
#include "e-util/e-account.h"
#include <widgets/misc/e-send-options.h>
#include <mail/em-config.h>
#include <e-gw-connection.h>
#include <camel/camel-url.h>
#include "e-util/e-passwords.h"
ESendOptionsDialog *sod = NULL;
GtkWidget *parent;
EGwConnection *n_cnc;
EGwSendOptions *opts = NULL;
void org_gnome_send_options (EPlugin *epl, EConfigHookItemFactoryData *data);
void send_options_commit (EPlugin *epl, EConfigHookItemFactoryData *data);
void send_options_changed (EPlugin *epl, EConfigHookItemFactoryData *data);
void send_options_abort (EPlugin *epl, EConfigHookItemFactoryData *data);
static EGwConnection *
get_cnc (EAccount *account)
{
EGwConnection *cnc;
char *uri, *use_ssl, *property_value, *server_name, *user, *port, *pass = NULL;
CamelURL *url;
const char *poa_address;
gboolean remember;
url = camel_url_new (account->source->url, NULL);
if (url == NULL) {
return NULL;
}
poa_address = camel_url_get_param (url, "poa");
if (!poa_address || strlen (poa_address) ==0)
return NULL;
server_name = g_strdup (url->host);
user = g_strdup (url->user);
property_value = camel_url_get_param (url, "soap_port");
use_ssl = g_strdup (camel_url_get_param (url, "soap_ssl"));
if(property_value == NULL)
port = g_strdup ("7181");
else if (strlen(property_value) == 0)
port = g_strdup ("7181");
else
port = g_strdup (property_value);
if (use_ssl)
uri = g_strconcat ("https://", server_name, ":", port, "/soap", NULL);
else
uri = g_strconcat ("http://", server_name, ":", port, "/soap", NULL);
pass = e_passwords_get_password ("Groupwise", uri);
if (!pass) {
char *prompt;
prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"),
"", poa_address, url->user);
pass = e_passwords_ask_password (prompt, "Groupwise", uri, prompt,
E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET, &remember,
NULL);
g_free (prompt);
}
cnc = e_gw_connection_new (uri, user, pass);
camel_url_free (url);
return cnc;
}
static void
e_send_options_load_general_opts (ESendOptionsGeneral *gopts, EGwSendOptionsGeneral *ggopts)
{
gopts->priority = ggopts->priority;
gopts->reply_enabled = ggopts->reply_enabled;
gopts->reply_convenient = ggopts->reply_convenient;
gopts->expiration_enabled = ggopts->expiration_enabled;
gopts->expire_after = ggopts->expire_after;
if (!gopts->expire_after)
gopts->expiration_enabled = FALSE;
gopts->delay_enabled = ggopts->delay_enabled;
/* TODO convert int to timet comparing the current day */
if (ggopts->delay_until) {
} else
gopts->delay_until = 0;
}
static void
e_send_options_load_status_options (ESendOptionsStatusTracking *sopts, EGwSendOptionsStatusTracking *gsopts)
{
sopts->tracking_enabled = gsopts->tracking_enabled;
sopts->track_when = gsopts->track_when;
sopts->autodelete = gsopts->autodelete;
sopts->opened = gsopts->opened;
sopts->accepted = gsopts->accepted;
sopts->declined = gsopts->declined;
sopts->completed = gsopts->completed;
}
static void
e_send_options_load_default_data (EGwSendOptions *opts, ESendOptionsDialog *sod)
{
EGwSendOptionsGeneral *ggopts;
EGwSendOptionsStatusTracking *gmopts;
EGwSendOptionsStatusTracking *gcopts;
EGwSendOptionsStatusTracking *gtopts;
ggopts = e_gw_sendoptions_get_general_options (opts);
gmopts = e_gw_sendoptions_get_status_tracking_options (opts, "mail");
gcopts = e_gw_sendoptions_get_status_tracking_options (opts, "calendar");
gtopts = e_gw_sendoptions_get_status_tracking_options (opts, "task");
e_send_options_load_general_opts (sod->data->gopts, ggopts);
e_send_options_load_status_options (sod->data->mopts, gmopts);
e_send_options_load_status_options (sod->data->copts, gcopts);
e_send_options_load_status_options (sod->data->topts, gtopts);
}
static void
e_sendoptions_clicked_cb (GtkWidget *button, gpointer data)
{
EAccount *account;
account = (EAccount *) data;
if (!sod) {
sod = e_sendoptions_dialog_new ();
e_sendoptions_set_global (sod, TRUE);
if (!n_cnc)
n_cnc = get_cnc (account);
if (!n_cnc) {
g_warning ("Send Options: Could not get the connection to the server \n");
return;
}
e_gw_connection_get_settings (n_cnc, &opts);
e_send_options_load_default_data (opts, sod);
}
if (n_cnc)
e_sendoptions_dialog_run (sod, parent ? parent : NULL, E_ITEM_NONE);
else
return;
}
void
org_gnome_send_options (EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
GtkWidget *frame, *button, *label;
EAccount *account;
target_account = (EMConfigTargetAccount *)data->config->target;
account = target_account->account;
if(!g_strrstr (account->source->url, "groupwise://"))
return;
frame = gtk_frame_new ("");
label = gtk_frame_get_label_widget (GTK_FRAME (frame));
gtk_label_set_markup (GTK_LABEL (label), "<b>Send Options</b>");
button = gtk_button_new_with_label ("Advanced send options");
gtk_widget_show (button);
g_signal_connect(button, "clicked",
G_CALLBACK (e_sendoptions_clicked_cb), account);
parent = gtk_widget_get_toplevel (GTK_WIDGET (data->parent));
if (!GTK_WIDGET_TOPLEVEL (parent))
parent = NULL;
gtk_widget_set_size_request (button, -1, -1);
gtk_container_add (GTK_CONTAINER (frame), button);
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
gtk_widget_show (frame);
gtk_box_set_spacing (GTK_BOX (data->parent), 12);
gtk_box_pack_start (GTK_BOX (data->parent), frame, FALSE, FALSE, 0);
}
static void
send_options_finalize ()
{
if (n_cnc) {
g_object_unref (n_cnc);
n_cnc = NULL;
}
if (sod) {
g_object_unref (sod);
sod = NULL;
}
if (opts) {
g_object_unref (opts);
opts = NULL;
}
}
void
send_options_commit (EPlugin *epl, EConfigHookItemFactoryData *data)
{
send_options_finalize ();
}
void
send_options_changed (EPlugin *epl, EConfigHookItemFactoryData *data)
{
}
void
send_options_abort (EPlugin *epl, EConfigHookItemFactoryData *data)
{
send_options_finalize ();
}
|