aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-features/install-shared.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-08-24 11:15:26 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-08-24 11:15:26 +0800
commitdb4eb8ad23b7601552cb73d88b4dbd04305b0006 (patch)
treee4eb8b41014e449b99a584e45f1ef35e3e448146 /plugins/groupwise-features/install-shared.c
parentba263d1aceb348eb6a28bb6a07d3f2e9abc351a8 (diff)
downloadgsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.tar
gsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.tar.gz
gsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.tar.bz2
gsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.tar.lz
gsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.tar.xz
gsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.tar.zst
gsoc2013-evolution-db4eb8ad23b7601552cb73d88b4dbd04305b0006.zip
return the right type. (proxy_soap_login): fix pointer cast.
2005-08-23 Not Zed <NotZed@Ximian.com> * proxy-login.c (proxy_get_password): return the right type. (proxy_soap_login): fix pointer cast. (proxy_login_add_new_store): fix pointer cast. (proxy_login_setup_tree_view): fix callback cast. (org_gnome_proxy_account_login): fix prototype to match use. * junk-settings.c (user_selected): fix calling. (junk_settings_construct): more stupid casts. * junk-mail-settings.c (junk_mail_settings): casts. * install-shared.c (install_folder_response): constify item_id. (install_folder_response): remove unused. (org_gnome_popup_wizard): fixed numerous problems with this, over-copying data around, not referencing information properly, freeing potentially unset variables, etc etc. (accept_free): add a free function. * share-folder.c (notification_clicked): fix a multitude of busted casts. (user_selected): fix broken calling conventions, busted style. (share_folder_construct): fix more busted/missing casts. * share-folder-common.c: add missing header. svn path=/trunk/; revision=30232
Diffstat (limited to 'plugins/groupwise-features/install-shared.c')
-rw-r--r--plugins/groupwise-features/install-shared.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/plugins/groupwise-features/install-shared.c b/plugins/groupwise-features/install-shared.c
index 79f3edfe19..1f0bd303de 100644
--- a/plugins/groupwise-features/install-shared.c
+++ b/plugins/groupwise-features/install-shared.c
@@ -48,13 +48,11 @@
#include <e-gw-connection.h>
#include <share-folder.h>
-CamelSession *session;
struct AcceptData {
- const char *item_id;
+ CamelMimeMessage *msg;
EMFolderTreeModel *model;
};
-
void org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target);
static void
@@ -67,11 +65,11 @@ install_folder_response (EMFolderSelector *emfs, int response, gpointer *data)
gchar **names;
gchar *folder_name;
gchar *parent_name;
- gchar *container_id,*item_id;
+ gchar *container_id;
+ const char *item_id;
CamelException ex;
CamelStore *store;
CamelFolder *folder;
- CamelFolderChangeInfo *changes;
EAccount *account;
CamelProvider *provider;
EGwConnection *cnc;
@@ -80,7 +78,7 @@ install_folder_response (EMFolderSelector *emfs, int response, gpointer *data)
gtk_widget_destroy (GTK_WIDGET (emfs));
} else {
model = accept_data->model;
- item_id = accept_data->item_id;
+ item_id = camel_mime_message_get_message_id (accept_data->msg);
uri = em_folder_selector_get_selected_uri (emfs);
path = em_folder_selector_get_selected_path (emfs);
names = g_strsplit (path, "/", -1);
@@ -97,7 +95,7 @@ install_folder_response (EMFolderSelector *emfs, int response, gpointer *data)
parent_name = NULL;
}
camel_exception_init (&ex);
- if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
+ if (!(store = (CamelStore *) camel_session_get_service (mail_component_peek_session(NULL), uri, CAMEL_PROVIDER_STORE, &ex))) {
camel_exception_clear (&ex);
return;
}
@@ -106,7 +104,7 @@ install_folder_response (EMFolderSelector *emfs, int response, gpointer *data)
if(E_IS_GW_CONNECTION (cnc)) {
container_id = get_container_id (cnc, parent_name);
- if(e_gw_connection_accept_shared_folder (cnc, folder_name, container_id, item_id, NULL) == E_GW_CONNECTION_STATUS_OK) {
+ if(e_gw_connection_accept_shared_folder (cnc, folder_name, container_id, (char *)item_id, NULL) == E_GW_CONNECTION_STATUS_OK) {
folder = camel_store_get_folder (store, "Mailbox", 0, NULL);
@@ -142,24 +140,36 @@ install_folder_response (EMFolderSelector *emfs, int response, gpointer *data)
}
+static void
+accept_free(void *data)
+{
+ struct AcceptData *accept_data = data;
+
+ camel_object_unref(accept_data->msg);
+ g_free(accept_data);
+}
+
static void
-accept_clicked(GnomeDruidPage *page, GtkWidget *druid, const char *id)
+accept_clicked(GnomeDruidPage *page, GtkWidget *druid, CamelMimeMessage *msg)
{
EMFolderTreeModel *model;
EMFolderTree *folder_tree;
GtkWidget *dialog ;
struct AcceptData *accept_data;
char *uri;
+
accept_data = g_new0(struct AcceptData, 1);
- model = mail_component_peek_tree_model (mail_component_peek ());
+ model = mail_component_peek_tree_model (NULL);
folder_tree = (EMFolderTree *) em_folder_tree_new_with_model (model);
dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
uri = em_folder_tree_get_selected_uri(folder_tree);
em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
g_free(uri);
- accept_data->item_id = id;
+ accept_data->msg = msg;
+ camel_object_ref(msg);
accept_data->model = model;
- g_signal_connect (dialog, "response", G_CALLBACK (install_folder_response), accept_data);
+ g_object_set_data_full((GObject *)dialog, "accept-data", accept_data, accept_free);
+! g_signal_connect (dialog, "response", G_CALLBACK (install_folder_response), accept_data);
gtk_window_set_title (GTK_WINDOW (dialog), "Install Shared Folder");
gtk_widget_destroy (druid);
gtk_widget_show (dialog);
@@ -170,19 +180,17 @@ void
org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
{
const CamelInternetAddress *from_addr = NULL;
- const char *name, *item_id;
+ const char *name;
const char *email;
GtkWidget *window;
GnomeDruid *wizard;
GnomeDruidPageEdge *title_page;
CamelMimeMessage *msg = (CamelMimeMessage *) target->message ;
CamelStreamMem *content ;
- CamelDataWrapper *dw ;
+ CamelDataWrapper *dw;
CamelMimePart *mime_part ;
- CamelMultipart *mp ;
char *notification;
char *start_message;
- char *buffer = NULL;
/* XXX:Remove this when server has a fix to show mails in shared-folder*/
if (!getenv("GROUPWISE_SHARED_FOLDER"))
@@ -192,46 +200,40 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
return ;
mime_part = CAMEL_MIME_PART(msg) ;
- notification = (char *)camel_medium_get_header (CAMEL_MEDIUM(msg),"X-notification") ;
- if (!notification) {
- return ;
-
+ if ((notification = (char *)camel_medium_get_header (CAMEL_MEDIUM(msg),"X-notification")) == NULL
+ || (from_addr = camel_mime_message_get_from ((CamelMimeMessage *)target->message)) == NULL
+ || !camel_internet_address_get(from_addr, 0, &name, &email)
+ || (dw = camel_medium_get_content_object (CAMEL_MEDIUM (msg))) == NULL) {
+ return;
} else {
- mp = (CamelMultipart *) camel_medium_get_content_object (CAMEL_MEDIUM (msg)) ;
- dw = camel_data_wrapper_new () ;
- content = (CamelStreamMem *)camel_stream_mem_new();
- if (!mp)
- return ;
-
- if (CAMEL_IS_MULTIPART (mp)) {
- mime_part = camel_multipart_get_part (mp, 0) ;
- dw = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part)) ;
- camel_data_wrapper_write_to_stream(dw, (CamelStream *)content) ;
- buffer = g_malloc0 (content->buffer->len+1) ;
- buffer = memcpy (buffer, content->buffer->data, content->buffer->len) ;
-
- } else {
- dw = camel_medium_get_content_object (CAMEL_MEDIUM (msg)) ;
- camel_data_wrapper_write_to_stream(dw, (CamelStream *)content) ;
- buffer = g_malloc0 (content->buffer->len+1) ;
- buffer = memcpy (buffer, content->buffer->data, content->buffer->len) ;
+ if (CAMEL_IS_MULTIPART (dw)) {
+ dw = camel_medium_get_content_object((CamelMedium *)camel_multipart_get_part((CamelMultipart *)dw, 0));
+ if (dw == NULL)
+ return;
}
+ content = (CamelStreamMem *)camel_stream_mem_new();
+ camel_data_wrapper_write_to_stream(dw, (CamelStream *)content) ;
+ camel_stream_write((CamelStream *)content, "", 1);
+
from_addr = camel_mime_message_get_from ((CamelMimeMessage *)target->message);
- if (camel_internet_address_get (from_addr,0, &name, &email)) {
- start_message = g_strconcat (" The User ", "'", name, "'" ," has shared a folder with you\n\n", " Message from ", "'" , name, "'\n\n\n", buffer, "\n\n\n", "Click 'Forward' to install the shared folder\n\n",NULL);
+ if (from_addr && camel_internet_address_get(from_addr, 0, &name, &email)) {
+ /* FIXME: this needs translating ... */
+ start_message = g_strconcat (" The User ", "'", name, "'" ," has shared a folder with you\n\n",
+ " Message from ", "'" , name, "'\n\n\n", content->buffer->data, "\n\n\n", "Click 'Forward' to install the shared folder\n\n",NULL);
title_page = GNOME_DRUID_PAGE_EDGE (gnome_druid_page_edge_new_with_vals(GNOME_EDGE_START, TRUE, "Install the shared folder", start_message, NULL, NULL, NULL));
+ g_free(start_message);
wizard = GNOME_DRUID (gnome_druid_new_with_window ("Shared Folder Installation", NULL, TRUE, (GtkWidget**)(&window)));
gtk_window_set_position (GTK_WINDOW (window) , GTK_WIN_POS_CENTER_ALWAYS);
gnome_druid_append_page(wizard, GNOME_DRUID_PAGE(title_page));
gtk_widget_show_all (GTK_WIDGET (title_page));
- item_id = camel_mime_message_get_message_id (msg);
- g_signal_connect (title_page, "next", G_CALLBACK(accept_clicked), item_id);
+ camel_object_ref(msg);
+ g_object_set_data_full((GObject *)title_page, "msg", msg, camel_object_unref);
+ g_signal_connect (title_page, "next", G_CALLBACK(accept_clicked), msg);
} else
g_warning ("Could not get the sender name");
- g_free (buffer) ;
- g_free (start_message) ;
+ camel_object_unref(content);
}
}