aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/shared-folder/org-gnome-shared-folder.eplug.in2
-rw-r--r--plugins/shared-folder/share-folder-common.c273
-rw-r--r--plugins/shared-folder/share-folder.c100
3 files changed, 282 insertions, 93 deletions
diff --git a/plugins/shared-folder/org-gnome-shared-folder.eplug.in b/plugins/shared-folder/org-gnome-shared-folder.eplug.in
index 2f0d9519ea..d16afdc5c2 100644
--- a/plugins/shared-folder/org-gnome-shared-folder.eplug.in
+++ b/plugins/shared-folder/org-gnome-shared-folder.eplug.in
@@ -35,7 +35,7 @@
<author name="Jeffrey Stedfast" email="fejj@novell.com"/>
<hook class="org.gnome.evolution.mail.popup:1.0">
<menu id="org.gnome.evolution.mail.foldertree.popup" target="folder">
- <item type="item" path="20.emc.00" label="_Create New"
+ <item type="item" path="20.emc.00" label="_Create Shared Folder"
activate="org_gnome_create_option"
enable="delete" visible="delete"/>
</menu>
diff --git a/plugins/shared-folder/share-folder-common.c b/plugins/shared-folder/share-folder-common.c
index bdb036c821..1d2dd633f8 100644
--- a/plugins/shared-folder/share-folder-common.c
+++ b/plugins/shared-folder/share-folder-common.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Author: Vivek Jain <jvivek@novell.com>
+ * Authors: Vivek Jain <jvivek@novell.com>
*
* Copyright 2004 Novell, Inc.
*
@@ -26,8 +26,8 @@
#include <bonobo/bonobo-widget.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-ui-component.h>
-#include <libebook/e-destination.h>
-
+#include <camel/camel-store.h>
+#include <camel/camel-vee-store.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
@@ -39,19 +39,27 @@
#include <mail/em-folder-properties.h>
#include <mail/em-folder-tree.h>
#include <mail/em-folder-selector.h>
-
+#include <mail/mail-mt.h>
+#include <mail/em-vfolder-rule.h>
+#include <filter/filter-rule.h>
#include <camel/providers/groupwise/camel-groupwise-store.h>
#include <camel/providers/groupwise/camel-groupwise-folder.h>
#include <e-gw-container.h>
#include <e-gw-connection.h>
#include <glade/glade.h>
+#include <libgnomeui/libgnomeui.h>
#include "share-folder.h"
-#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION
+#define d(x)
-typedef CORBA_Object GNOME_Evolution_Addressbook_SelectNames;
ShareFolder *common = NULL;
+extern CamelSession *session;
-
+struct ShareInfo {
+ GtkWidget *d;
+ ShareFolder *sf;
+ EMFolderTreeModel *model;
+ EMFolderSelector *emfs;
+};
void
shared_folder_check (EPlugin *ep, EConfigTarget *target)
@@ -64,11 +72,10 @@ shared_folder_check (EPlugin *ep, EConfigTarget *target)
void
shared_folder_commit (EPlugin *ep, EConfigTarget *target)
{
-
- if(common)
+ if (common) {
share_folder (common);
- g_object_run_dispose(common);
-
+ g_object_run_dispose (common);
+ }
printf ("commit **********\n");
}
@@ -79,9 +86,233 @@ shared_folder_abort (EPlugin *ep, EConfigTarget *target)
printf ("aborttttttt**********\n");
}
+struct _EMCreateFolder {
+ struct _mail_msg msg;
+
+ /* input data */
+ CamelStore *store;
+ char *full_name;
+ char *parent;
+ char *name;
+
+ /* output data */
+ CamelFolderInfo *fi;
+
+ /* callback data */
+ void (* done) (CamelFolderInfo *fi, void *user_data);
+ void *user_data;
+};
+
+static char *
+create_folder__desc (struct _mail_msg *mm, int done)
+{
+ struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
+
+ return g_strdup_printf (_("Creating folder `%s'"), m->full_name);
+}
+static void
+create_folder__create (struct _mail_msg *mm)
+{
+ struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
+
+ d(printf ("creating folder parent='%s' name='%s' full_name='%s'\n", m->parent, m->name, m->full_name));
+
+ if ((m->fi = camel_store_create_folder (m->store, m->parent, m->name, &mm->ex))) {
+ if (camel_store_supports_subscriptions (m->store))
+ camel_store_subscribe_folder (m->store, m->full_name, &mm->ex);
+ }
+}
+static void
+create_folder__created (struct _mail_msg *mm)
+{
+ struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
+ struct ShareInfo *ssi = (struct ShareInfo *) m->user_data;
+ CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (m->store) ;
+ CamelGroupwiseStorePrivate *priv = gw_store->priv ;
+
+ if (m->done) {
+ (ssi->sf)->container_id = g_strdup (container_id_lookup (priv, m->name));
+ (ssi->sf)->cnc = cnc_lookup (priv);
+ g_print("\n\n\name :%s\n\nid: %s", m->name, (ssi->sf)->container_id);
+ share_folder(ssi->sf);
+ m->done (m->fi, m->user_data);
+ }
+
+}
+
+static void
+create_folder__free (struct _mail_msg *mm)
+{
+ struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
+
+ camel_store_free_folder_info (m->store, m->fi);
+ camel_object_unref (m->store);
+ g_free (m->full_name);
+ g_free (m->parent);
+ g_free (m->name);
+}
+
+static struct _mail_msg_op create_folder_op = {
+ create_folder__desc,
+ create_folder__create,
+ create_folder__created,
+ create_folder__free,
+};
+
+
+
+static void
+new_folder_created_cb (CamelFolderInfo *fi, void *user_data)
+{
+ struct ShareInfo *ssi = (struct ShareInfo *) user_data;
+ EMFolderSelector *emfs = ssi->emfs;
+
+ if (fi) {
+ gtk_widget_destroy ((GtkWidget *) emfs);
+ gtk_widget_destroy ((GtkWidget *) ssi->d);
+ }
+
+ g_object_unref (emfs);
+}
+
+static int
+create_folder (CamelStore *store, const char *full_name, void (* done) (CamelFolderInfo *fi, void *user_data), void *user_data)
+{
+ char *name, *namebuf = NULL;
+ struct _EMCreateFolder *m;
+ const char *parent;
+ int id;
+
+ namebuf = g_strdup (full_name);
+ if (!(name = strrchr (namebuf, '/'))) {
+ name = namebuf;
+ parent = "";
+ } else {
+ *name++ = '\0';
+ parent = namebuf;
+ }
+
+ m = mail_msg_new (&create_folder_op, NULL, sizeof (struct _EMCreateFolder));
+ camel_object_ref (store);
+ m->store = store;
+ m->full_name = g_strdup (full_name);
+ m->parent = g_strdup (parent);
+ m->name = g_strdup (name);
+ m->user_data = (struct ShareInfo *) user_data;
+ m->done = done;
+ g_free (namebuf);
+ id = m->msg.seq;
+ e_thread_put (mail_thread_new, (EMsg *) m);
+
+ return id;
+}
+
+static void
+users_dialog_response(GtkWidget *dialog, int response, struct ShareInfo *ssi)
+{
+ struct _EMFolderTreeModelStoreInfo *si;
+ EMFolderSelector *emfs = ssi->emfs;
+ const char *uri, *path;
+ CamelException ex;
+ CamelStore *store;
+
+ if (response != GTK_RESPONSE_OK) {
+ gtk_widget_destroy ((GtkWidget *) emfs);
+ gtk_widget_destroy(dialog);
+ return;
+ }
+
+ uri = em_folder_selector_get_selected_uri (emfs);
+ path = em_folder_selector_get_selected_path (emfs);
+
+ d(printf ("Creating new folder: %s (%s)\n", path, uri));
+
+ camel_exception_init (&ex);
+ if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ if (!(si = g_hash_table_lookup ((ssi->model)->store_hash, store))) {
+ g_assert_not_reached ();
+ camel_object_unref (store);
+ return;
+ }
+
+ /* HACK: we need to create vfolders using the vfolder editor */
+ if (CAMEL_IS_VEE_STORE(store)) {
+ EMVFolderRule *rule;
+
+ rule = em_vfolder_rule_new();
+ filter_rule_set_name((FilterRule *)rule, path);
+ vfolder_gui_add_rule(rule);
+ gtk_widget_destroy((GtkWidget *)emfs);
+ } else {
+ g_object_ref (emfs);
+ ssi->d = dialog;
+ create_folder (si->store, path, new_folder_created_cb, ssi);
+
+ }
+ camel_object_unref (store);
+}
+
+
+
+static void
+new_folder_response (EMFolderSelector *emfs, int response, EMFolderTreeModel *model)
+{
+ GtkWidget *users_dialog;
+ GtkWidget *w;
+ struct ShareInfo *ssi;
+
+ ssi = g_new0(struct ShareInfo, 1);
+ if (response != GTK_RESPONSE_OK) {
+ gtk_widget_destroy ((GtkWidget *) emfs);
+ return;
+ }
+
+ users_dialog = gtk_dialog_new_with_buttons (
+ _("Users"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+ w = gtk_label_new_with_mnemonic (_("Enter the users and set permissions"));
+ gtk_widget_show(w);
+ gtk_box_pack_start(GTK_BOX (GTK_DIALOG (users_dialog)->vbox), (GtkWidget *) w, TRUE, TRUE, 6);
+ ssi->sf = share_folder_new (NULL, NULL);
+ ((ssi->sf)->table)->parent = NULL;
+ gtk_widget_set_sensitive (GTK_WIDGET ((ssi->sf)->table), TRUE);
+ ssi->model = model;
+ ssi->emfs = emfs;
+ gtk_box_pack_end(GTK_BOX (GTK_DIALOG (users_dialog)->vbox), (GtkWidget *) (ssi->sf)->table, TRUE, TRUE, 6);
+ gtk_widget_hide((GtkWidget*) emfs);
+ gtk_window_resize (GTK_WINDOW (users_dialog), 350, 300);
+ gtk_widget_show(users_dialog);
+ g_signal_connect (users_dialog, "response", G_CALLBACK (users_dialog_response), ssi);
+
+ return ;
+}
+
+GtkWidget *
+org_gnome_create_option(EPlugin *ep, EMPopupTargetFolder *target)
+{
+
+ EMFolderTreeModel *model;
+ EMFolderTree *folder_tree;
+ GtkWidget *dialog ;
+ char *uri;
+
+ model = mail_component_peek_tree_model (mail_component_peek ());
+ 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);
+ g_signal_connect (dialog, "response", G_CALLBACK (new_folder_response), model);
+ gtk_window_set_title (GTK_WINDOW (dialog), "New Shared Folder" );
+ gtk_widget_show(dialog);
+
+}
GtkWidget *
org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
@@ -93,22 +324,21 @@ org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_d
gchar *sub = NULL;
EGwConnection *cnc;
ShareFolder *sharing_tab;
- EMConfigTargetPrefs *target1 = (EMConfigTargetPrefs *) hook_data->config->target;
- EMConfigTargetFolder *target2= (EMConfigTargetFolder *)hook_data->config->target;
- folderuri=g_strdup(target2->uri);
+ EMConfigTargetFolder *target= (EMConfigTargetFolder *)hook_data->config->target;
+
+ folderuri = g_strdup(target->uri);
account = g_strrstr(folderuri, "groupwise");
- if(account)
- {
+
+ if(account){
sub = g_strrstr(folderuri, "#");
if(sub == NULL)
sub = g_strrstr(folderuri, "/");
sub++;
- g_print("\n\nTHE URI OF THE FOLDER%s\n\n %s\n\n",target2->uri,sub);
- CamelFolder *folder = target2->folder ;
+ CamelFolder *folder = target->folder ;
CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER(folder) ;
CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store) ;
CamelGroupwiseStorePrivate *priv = gw_store->priv ;
-
+
if (priv && sub) {
id = g_strdup (container_id_lookup(priv,sub));
@@ -125,15 +355,12 @@ org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_d
else
return NULL;
+ g_free (folderuri);
gtk_notebook_append_page((GtkNotebook *) hook_data->parent, sharing_tab->vbox, gtk_label_new_with_mnemonic N_("Sharing"));
-
common = sharing_tab;
-
return sharing_tab;
} else
return NULL;
-
-
}
diff --git a/plugins/shared-folder/share-folder.c b/plugins/shared-folder/share-folder.c
index cd83ad22d8..b29fd285c8 100644
--- a/plugins/shared-folder/share-folder.c
+++ b/plugins/shared-folder/share-folder.c
@@ -35,15 +35,12 @@
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkcellrenderertoggle.h>
#include <gtk/gtkcellrenderertext.h>
-
+#include <libedataserverui/e-contact-store.h>
+#include <libgnomeui/gnome-ui-init.h>
#include <libgnome/gnome-init.h>
#include <e-gw-container.h>
#include <e-gw-connection.h>
-
#define ROOTNODE "vboxSharing"
-
-
-
#define d(x)
static void share_folder_class_init (ShareFolderClass *class);
@@ -98,9 +95,8 @@ share_folder_class_init (ShareFolderClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
-
+
parent_class = g_type_class_ref (gtk_vbox_get_type ());
-
object_class->destroy = share_folder_destroy;
gobject_class->finalize = share_folder_finalise;
}
@@ -119,7 +115,7 @@ share_folder_destroy (GtkObject *obj)
{
ShareFolder *sf = (ShareFolder *) obj;
- free_all(sf);
+ free_all (sf);
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
}
@@ -137,10 +133,8 @@ share_folder_init (ShareFolder *sf)
sf->remove_list = NULL;
sf->sub = "Shared Folder notification";
sf->message = NULL;
-
}
-
static void
free_node(EShUsers *user)
{
@@ -149,10 +143,8 @@ free_node(EShUsers *user)
user->email = NULL;
}
return ;
-
}
-
static int
find_node(GList *list, gchar *email)
{
@@ -190,8 +182,6 @@ free_all(ShareFolder *sf)
}
sf->new_list = NULL;
-
-
e_gw_container_get_user_list (sf->gcontainer, &(sf->new_list));
if (sf->new_list) {
g_list_foreach (sf->new_list, free_node, NULL);
@@ -206,7 +196,6 @@ free_all(ShareFolder *sf)
sf->update_list = NULL;
sf->remove_list = NULL;
e_gw_connection_free_container_list (sf->container_list);
-
}
/* updates the rights in case changed in the prev selection*/
@@ -222,20 +211,20 @@ update_list_update (ShareFolder *sf)
add = gtk_toggle_button_get_active(sf->add);
edit = gtk_toggle_button_get_active(sf->edit);
delete = gtk_toggle_button_get_active(sf->del);
- if(add){
- rights = rights|0x1;
+ if (add) {
+ rights = rights | 0x1;
}
- if(edit){
- rights = rights|0x2;
+ if (edit) {
+ rights = rights | 0x2;
}
- if(delete){
- rights = rights|0x4;
+ if (delete) {
+ rights = rights | 0x4;
}
if(sf->update_list){
tmp = g_list_last(sf->update_list);
user = g_list_nth_data(tmp, 0);
-
+/* if the user is still in the new list then remove from update list*/
if (sf->new_list && user->email){
sf->duplicate = find_node (sf->new_list, user->email);
if (sf->duplicate != -1) {
@@ -252,15 +241,14 @@ update_list_update (ShareFolder *sf)
}
}
- if(user){
+ if (user) {
if(user->rights != rights){
user->rights= rights;
- }
- else{
- sf->update_list = g_list_remove(sf->update_list, user);
- free_node(user);
- if(g_list_length(sf->update_list) == 0)
+ } else {
+ sf->update_list = g_list_remove (sf->update_list, user);
+ free_node (user);
+ if (g_list_length (sf->update_list) == 0)
sf->update_list = NULL;
}
}
@@ -268,7 +256,6 @@ update_list_update (ShareFolder *sf)
}
-
static void
display_container (EGwContainer *container , ShareFolder *sf)
{
@@ -280,6 +267,7 @@ display_container (EGwContainer *container , ShareFolder *sf)
gboolean tome = FALSE;
id_shared = g_strdup(e_gw_container_get_id(container));
+ /* this has to be done since id changes after the folder is shared*/
if( g_str_has_suffix (id_shared, "35")){
tail = g_strsplit(id_shared, "@", 2);
id_unshared = g_strconcat(tail[0], "@", "13", NULL);
@@ -333,7 +321,6 @@ display_container (EGwContainer *container , ShareFolder *sf)
}
-
static void
get_container_list (ShareFolder *sf)
{
@@ -353,8 +340,6 @@ get_container_list (ShareFolder *sf)
}
-
-
static void
user_selected(GtkTreeSelection *selection, ShareFolder *sf)
{
@@ -429,19 +414,12 @@ user_selected(GtkTreeSelection *selection, ShareFolder *sf)
}
-
-
-
-
-
-
static void
shared_clicked (GtkRadioButton *button, ShareFolder *sf)
{
gtk_widget_set_sensitive (GTK_WIDGET (sf->table) ,TRUE);
sf->flag_for_ok = 0;
-
}
static void
@@ -454,10 +432,8 @@ not_shared_clicked (GtkRadioButton *button, ShareFolder *sf)
}
gtk_widget_set_sensitive (GTK_WIDGET (sf->table), FALSE);
-
}
-
static void
add_clicked(GtkButton *button, ShareFolder *sf)
{
@@ -467,8 +443,7 @@ add_clicked(GtkButton *button, ShareFolder *sf)
gint rights = 0;
gint length;
gchar *msg = NULL;
- gboolean add,edit, delete;
-
+
email = gtk_entry_get_text (GTK_ENTRY (sf->name));
if (strcmp (email, "" )) {
update_list_update (sf);
@@ -479,6 +454,7 @@ add_clicked(GtkButton *button, ShareFolder *sf)
}
/*check whether already exists*/
+ if (sf->gcontainer)
e_gw_container_get_user_list (sf->gcontainer, &list);
if (list && user->email){
@@ -506,13 +482,10 @@ add_clicked(GtkButton *button, ShareFolder *sf)
g_free(msg);
sf->new_list = g_list_append (sf->new_list, user);
length = g_list_length (sf->new_list);
- g_print("\nlist length: %d\n\n\n",length);
-
sf->flag_for_ok = 0;
gtk_entry_set_text (sf->name, "");
}
-
static void
remove_clicked(GtkButton *button, ShareFolder *sf)
{
@@ -520,11 +493,9 @@ remove_clicked(GtkButton *button, ShareFolder *sf)
GList *list = NULL;
EShUsers *usr = NULL;
gchar *email;
- gchar *removed_addr;
-
+
/*check whether this is required*/
gtk_tree_model_get (GTK_LIST_STORE(sf->model), &(sf->iter), 0, &email, -1);
-
list = g_list_last (sf->update_list);
usr = g_list_nth_data (list, 0);
sf->duplicate = find_node (sf->new_list, usr->email);
@@ -553,8 +524,7 @@ share_folder (ShareFolder *sf)
if (E_IS_GW_CONNECTION (sf->cnc)) {
- if(sf->gcontainer){
-
+
if(sf->flag_for_ok == 2){ /* you have to remove all the users*/
GList *list = NULL;
@@ -574,14 +544,16 @@ share_folder (ShareFolder *sf)
g_list_free (sf->remove_list);
}
sf->remove_list = NULL;
+ if (sf->gcontainer) {
+ e_gw_container_get_user_list (sf->gcontainer, &list);
+ sf->remove_list = g_list_copy (list);
- e_gw_container_get_user_list (sf->gcontainer, &list);
- sf->remove_list = g_list_copy (list);
-
+ } else {
+ g_warning("Container is Null");
+ }
+
} else {
-
-
if (sf->new_list) {
if (e_gw_connection_share_folder (sf->cnc, sf->container_id, sf->new_list, sf->sub, sf->mesg, 0) == E_GW_CONNECTION_STATUS_OK);
}
@@ -595,16 +567,11 @@ share_folder (ShareFolder *sf)
if (sf->remove_list) {
if (e_gw_connection_share_folder (sf->cnc, sf->container_id, sf->remove_list, sf->sub, sf->mesg, 1) == E_GW_CONNECTION_STATUS_OK);
}
- }
- else
- g_warning("Container is Null");
-
+
}
}
-
-
static void
not_ok_clicked(GtkButton *button, ShareFolder *sf)
{
@@ -632,7 +599,6 @@ not_ok_clicked(GtkButton *button, ShareFolder *sf)
gtk_widget_destroy (GTK_WIDGET (sf->window));
-
}
static void
@@ -673,7 +639,6 @@ share_folder_construct (ShareFolder *sf)
if(!sf->xml) {
g_warning("could not get xml");
}
- /*checck abt this Parent?*/
sf->vbox = GTK_VBOX(glade_xml_get_widget(sf->xml, "vboxSharing"));
@@ -689,6 +654,7 @@ share_folder_construct (ShareFolder *sf)
sf->add_book = GTK_BUTTON (glade_xml_get_widget (sf->xml, "Address"));
gtk_widget_set_sensitive (GTK_WIDGET (sf->add_book), FALSE);
+ /*g_signal_connect((GtkWidget *) sf->add_book, "clicked", G_CALLBACK (add_book_clicked), sf);*/
sf->add_button = GTK_BUTTON (glade_xml_get_widget(sf->xml, "Add"));
g_signal_connect((GtkWidget *) sf->add_button, "clicked", G_CALLBACK (add_clicked), sf);
@@ -734,12 +700,8 @@ share_folder_construct (ShareFolder *sf)
GTK_TREE_VIEW_COLUMN (sf->column));
g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW (sf->user_list)), "changed", G_CALLBACK (user_selected), sf);
-
-
}
-
-
ShareFolder *
share_folder_new (gchar *ccnc, gchar *id)
{
@@ -749,8 +711,8 @@ share_folder_new (gchar *ccnc, gchar *id)
new->cnc = ccnc;
new->container_id = id;
get_container_list(new);
- return (GtkWidget *) new;
+ return (GtkWidget *) new;
}