From db4eb8ad23b7601552cb73d88b4dbd04305b0006 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 24 Aug 2005 03:15:26 +0000 Subject: return the right type. (proxy_soap_login): fix pointer cast. 2005-08-23 Not Zed * 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 --- plugins/groupwise-features/ChangeLog | 27 +++++++ plugins/groupwise-features/install-shared.c | 90 ++++++++++++------------ plugins/groupwise-features/junk-mail-settings.c | 4 +- plugins/groupwise-features/junk-settings.c | 8 ++- plugins/groupwise-features/proxy-login.c | 17 +++-- plugins/groupwise-features/proxy-login.h | 2 +- plugins/groupwise-features/share-folder-common.c | 1 + plugins/groupwise-features/share-folder.c | 17 +++-- 8 files changed, 98 insertions(+), 68 deletions(-) diff --git a/plugins/groupwise-features/ChangeLog b/plugins/groupwise-features/ChangeLog index 659bb20a50..273370eee1 100644 --- a/plugins/groupwise-features/ChangeLog +++ b/plugins/groupwise-features/ChangeLog @@ -1,3 +1,30 @@ +2005-08-23 Not Zed + + * 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. + 2005-08-22 vivek jain ** see previous commit 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 #include -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); } } diff --git a/plugins/groupwise-features/junk-mail-settings.c b/plugins/groupwise-features/junk-mail-settings.c index 5a361fb573..c5d1dc1529 100644 --- a/plugins/groupwise-features/junk-mail-settings.c +++ b/plugins/groupwise-features/junk-mail-settings.c @@ -91,13 +91,13 @@ junk_mail_settings (EPopup *ep, EPopupItem *item, void *data) gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 6); junk_tab = junk_settings_new (cnc); - w = junk_tab->vbox; + w = (GtkWidget *)junk_tab->vbox; gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 6); /*We might have to add more options for settings i.e. more pages*/ while (page_count > 0 ){ notebook = gtk_notebook_new (); - gtk_notebook_append_page (notebook, box, NULL); + gtk_notebook_append_page ((GtkNotebook *)notebook, box, NULL); gtk_box_pack_start ((GtkBox *) ((GtkDialog *) dialog)->vbox, notebook, TRUE, TRUE, 0); } diff --git a/plugins/groupwise-features/junk-settings.c b/plugins/groupwise-features/junk-settings.c index daccf8c1c1..c2bba7ab1d 100644 --- a/plugins/groupwise-features/junk-settings.c +++ b/plugins/groupwise-features/junk-settings.c @@ -361,8 +361,10 @@ remove_clicked(GtkButton *button, JunkSettings *js) static void user_selected(GtkTreeSelection *selection, JunkSettings *js) { + GtkTreeModel *model; + gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); - if (gtk_tree_selection_get_selected (selection, &(js->model), &(js->iter))){ + if (gtk_tree_selection_get_selected (selection, &model, &(js->iter))){ gtk_widget_set_sensitive (GTK_WIDGET (js->remove), TRUE); } @@ -381,7 +383,7 @@ junk_settings_construct (JunkSettings *js) g_warning ("could not get xml"); } js->vbox = GTK_VBOX (glade_xml_get_widget(js->xml, "vboxSettings")); - js->table = GTK_WIDGET (glade_xml_get_widget (js->xml, "vbox194")); + js->table = GTK_VBOX (glade_xml_get_widget (js->xml, "vbox194")); gtk_widget_set_sensitive (GTK_WIDGET (js->table), FALSE); js->enable = GTK_RADIO_BUTTON (glade_xml_get_widget (js->xml, "radEnable")); @@ -407,7 +409,7 @@ junk_settings_construct (JunkSettings *js) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (js->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); js->model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); - js->entry_list = gtk_tree_view_new (); + js->entry_list = (GtkTreeView *)gtk_tree_view_new (); /*gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (js->scrolled_window), (GtkWidget *)js->entry_list);*/ gtk_container_add (GTK_CONTAINER (js->scrolled_window), (GtkWidget *)js->entry_list); gtk_tree_view_set_model (GTK_TREE_VIEW (js->entry_list), GTK_TREE_MODEL (js->model)); diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c index 57970ea171..079b618c1e 100644 --- a/plugins/groupwise-features/proxy-login.c +++ b/plugins/groupwise-features/proxy-login.c @@ -61,15 +61,13 @@ #include #include #include -#include +#include "proxy-login.h" #define GW(name) glade_xml_get_widget (priv->xml, name) #define ACCOUNT_PICTURE 0 #define ACCOUNT_NAME 1 -void org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, char *uri); - proxyLogin *pld = NULL; static GObjectClass *parent_class = NULL; @@ -198,11 +196,11 @@ proxy_get_password (EAccount *account, char **user_name, char **password) url = camel_url_new (account->source->url, NULL); if (url == NULL) - return NULL; + return 0; *user_name = g_strdup (url->user); poa_address = url->host; if (!poa_address || strlen (poa_address) ==0) - return NULL; + return 0; soap_port = camel_url_get_param (url, "soap_port"); if (!soap_port || strlen (soap_port) == 0) @@ -354,7 +352,7 @@ proxy_soap_login (char *email) e_account_list_add(accounts, dstAccount); e_account_list_change (accounts, srcAccount); e_account_list_save(accounts); - g_object_set_data ((GObject *)dstAccount, "permissions", permissions); + g_object_set_data ((GObject *)dstAccount, "permissions", GINT_TO_POINTER(permissions)); mail_get_store(e_account_get_string(dstAccount, E_ACCOUNT_SOURCE_URL), NULL, proxy_login_add_new_store, dstAccount); g_free (proxy_source_url); @@ -376,7 +374,7 @@ proxy_login_add_new_store (char *uri, CamelStore *store, void *user_data) { MailComponent *component = mail_component_peek (); EAccount *account = user_data; - int permissions = g_object_get_data ((GObject *)account, "permissions"); + int permissions = GPOINTER_TO_INT(g_object_get_data ((GObject *)account, "permissions")); if (store == NULL) return; @@ -427,7 +425,7 @@ proxy_login_setup_tree_view (void) gtk_tree_view_set_model (priv->tree, GTK_TREE_MODEL (priv->store)); selection = gtk_tree_view_get_selection (priv->tree); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); - g_signal_connect (G_OBJECT (selection), "changed", proxy_login_tree_view_changed_cb, NULL); + g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK(proxy_login_tree_view_changed_cb), NULL); } static void @@ -461,8 +459,9 @@ proxy_login_update_tree (void) } void -org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, char *uri) +org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, void *data) { + char *uri = data; proxyLoginPrivate *priv; pld = proxy_login_new(); diff --git a/plugins/groupwise-features/proxy-login.h b/plugins/groupwise-features/proxy-login.h index 2213124082..983a83fef5 100644 --- a/plugins/groupwise-features/proxy-login.h +++ b/plugins/groupwise-features/proxy-login.h @@ -54,7 +54,7 @@ proxyLogin * proxy_login_new (void); static void proxy_login_cb (GtkDialog *dialog, gint state); static void proxy_login_add_new_store (char *uri, CamelStore *store, void *user_data); static void proxy_login_setup_tree_view (void); -void org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, char *uri); +void org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, void *data); proxyLogin* proxy_dialog_new (void); static void proxy_soap_login (char *email); char *parse_email_for_name (char *email); diff --git a/plugins/groupwise-features/share-folder-common.c b/plugins/groupwise-features/share-folder-common.c index 5e29695f80..f98d0de494 100644 --- a/plugins/groupwise-features/share-folder-common.c +++ b/plugins/groupwise-features/share-folder-common.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/plugins/groupwise-features/share-folder.c b/plugins/groupwise-features/share-folder.c index b76ed73c2d..1886edbcff 100644 --- a/plugins/groupwise-features/share-folder.c +++ b/plugins/groupwise-features/share-folder.c @@ -521,10 +521,10 @@ notification_clicked(GtkButton *button, ShareFolder *sf) gtk_window_set_title (GTK_WINDOW (sf->window), "Custom Notification"); gtk_window_set_position (GTK_WINDOW (sf->window) , GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_default_size (GTK_WINDOW (sf->window), 100, 200); - gtk_widget_reparent (GTK_WINDOW (sf->window), GTK_DIALOG (sf->vbox)); - gtk_window_set_transient_for (sf->window, GTK_DIALOG(sf->vbox)); - gtk_window_set_modal (sf->window, TRUE); - gtk_window_present (sf->window); + gtk_widget_reparent (GTK_WIDGET (sf->window), GTK_WIDGET (sf->vbox)); + gtk_window_set_transient_for ((GtkWindow *)sf->window, GTK_WINDOW(sf->vbox)); + gtk_window_set_modal ((GtkWindow *)sf->window, TRUE); + gtk_window_present ((GtkWindow *)sf->window); gtk_widget_show_all (sf->window); } @@ -553,12 +553,11 @@ address_button_clicked_cb (GtkButton *button, gpointer data) static void user_selected(GtkTreeSelection *selection, ShareFolder *sf) { + GtkTreeModel *model; gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); - if (gtk_tree_selection_get_selected (selection, &(sf->model), &(sf->iter))){ + if (gtk_tree_selection_get_selected (selection, &model, &sf->iter)) gtk_widget_set_sensitive (GTK_WIDGET (sf->remove), TRUE); - - } } static void @@ -677,7 +676,7 @@ share_folder_construct (ShareFolder *sf) g_warning ("could not get xml"); } sf->vbox = GTK_VBOX (glade_xml_get_widget(sf->xml, "vboxSharing")); - sf->table = GTK_WIDGET (glade_xml_get_widget (sf->xml, "vbox194")); + sf->table = GTK_VBOX (glade_xml_get_widget (sf->xml, "vbox194")); gtk_widget_set_sensitive (GTK_WIDGET (sf->table), FALSE); sf->shared = GTK_RADIO_BUTTON (glade_xml_get_widget (sf->xml, "radShared")); @@ -724,7 +723,7 @@ share_folder_construct (ShareFolder *sf) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sf->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); sf->model = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); - sf->user_list = gtk_tree_view_new (); + sf->user_list = (GtkTreeView *)gtk_tree_view_new (); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sf->scrolled_window), (GtkWidget *)sf->user_list); gtk_tree_view_set_model (GTK_TREE_VIEW (sf->user_list), GTK_TREE_MODEL (sf->model)); gtk_widget_show (GTK_WIDGET (sf->user_list)); -- cgit v1.2.3