aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Jain <jvivek@novell.com>2005-01-13 19:32:17 +0800
committerJain Vivek <jvivek@src.gnome.org>2005-01-13 19:32:17 +0800
commit30bab8c491c75223386c71a7e1c265791d6b7c9c (patch)
tree2d86ea4ddeea2171e29e85c8a06d1fb610316086
parentb52ceae69038cf629b93b8d3e403a8a7ebec886d (diff)
downloadgsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.tar
gsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.tar.gz
gsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.tar.bz2
gsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.tar.lz
gsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.tar.xz
gsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.tar.zst
gsoc2013-evolution-30bab8c491c75223386c71a7e1c265791d6b7c9c.zip
changed the function find_node to return user node corresponding to the
2005-01-13 Vivek Jain <jvivek@novell.com> * share-folder.c :changed the function find_node to return user node corresponding to the mail address given. (add_clicked): added a condition so that user can't share folder to himself. (user_selected): modified to display proper rights when owner is selected. * share-folder-common.c : calling share_folder with a cnc in it. svn path=/trunk/; revision=28390
-rw-r--r--plugins/shared-folder/ChangeLog35
-rw-r--r--plugins/shared-folder/install-shared.c2
-rw-r--r--plugins/shared-folder/share-folder-common.c17
-rw-r--r--plugins/shared-folder/share-folder.c139
-rw-r--r--plugins/shared-folder/share-folder.h1
5 files changed, 108 insertions, 86 deletions
diff --git a/plugins/shared-folder/ChangeLog b/plugins/shared-folder/ChangeLog
index 5d411b0214..2782a217d0 100644
--- a/plugins/shared-folder/ChangeLog
+++ b/plugins/shared-folder/ChangeLog
@@ -1,3 +1,10 @@
+2005-01-13 Vivek Jain <jvivek@novell.com>
+ * share-folder.c :changed the function find_node to return user node
+ corresponding to the mail address given.
+ (add_clicked): added a condition so that user can't share folder to itself.
+ (user_selected): modified to display proper rights when owner is selected.
+ * share-folder-common.c : calling share_folder with a cnc in it.
+
2005-01-11 Vivek Jain <jvivek@novell.com>
killed compile time warnings by including suitable definitions
and type casting widgets
@@ -14,7 +21,7 @@ a shared folder is created so that different icons are displayed
* share-folder.c : minor changes to fix the crash
* Makefile.am : including install-shared.c in sources
* org-gnome-shared-folder.eplug.in : added a plugin to the e-plugin list for
- the message-read event
+the message-read event
2004-12-15 Vivek Jain <jvivek@novell.com>
@@ -25,19 +32,19 @@ Added (Create a shared folder) functionality in the plugin
2004-12-15 Vivek Jain <jvivek@novell.com>
* shared-folder-common.c : (org_gnome_shared_folder_factory)
-* shared-folder.c : some whitespace changes, typecasting widgets,
-in (on_add_clicked) removed assigning the rights portion
-
-2004-12-08 Vivek Jain <jvivek@novell.com>
-
-The following files are added as an initial check in for the plugin that
-implements shared-folder functionality in the groupwise folders
-* share-folder.c
-* share-folder.h
-* share-folder-common.c
-* properties.glade
-* Makefile.am
-* org-gnome-shared-folder.eplug.in
+ * shared-folder.c : some whitespace changes, typecasting widgets,
+ in (on_add_clicked) removed assigning the rights portion
+
+ 2004-12-08 Vivek Jain <jvivek@novell.com>
+
+ The following files are added as an initial check in for the plugin that
+ implements shared-folder functionality in the groupwise folders
+ * share-folder.c
+ * share-folder.h
+ * share-folder-common.c
+ * properties.glade
+ * Makefile.am
+ * org-gnome-shared-folder.eplug.in
diff --git a/plugins/shared-folder/install-shared.c b/plugins/shared-folder/install-shared.c
index 7eb1191e95..6b7e7b8f78 100644
--- a/plugins/shared-folder/install-shared.c
+++ b/plugins/shared-folder/install-shared.c
@@ -192,6 +192,7 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
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) ;
+/* buffer = camel_mime_message_build_mbox_from ( (CamelMimeMessage *)target->message) ;*/
from_addr = camel_mime_message_get_from ((CamelMimeMessage *)target->message);
if (camel_internet_address_get (from_addr,0, &name, &email))
subject = camel_mime_message_get_subject (target->message) ;
@@ -203,6 +204,7 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target)
finish_page = GNOME_DRUID_PAGE_EDGE (gnome_druid_page_edge_new_with_vals(GNOME_EDGE_FINISH, TRUE, "finished Install the shared folder", "said", NULL,NULL, NULL));
wizard = GNOME_DRUID (gnome_druid_new_with_window ("Shared Folder Installation", NULL, TRUE, (GtkWidget**)(&window)));
gnome_druid_append_page(wizard, GNOME_DRUID_PAGE(title_page));
+ gtk_window_set_position (GTK_WINDOW (window) , GTK_WIN_POS_CENTER_ALWAYS);
gtk_widget_show_all (GTK_WIDGET (title_page));
gnome_druid_append_page(wizard, GNOME_DRUID_PAGE(middle_page));
gtk_widget_show_all (GTK_WIDGET (middle_page));
diff --git a/plugins/shared-folder/share-folder-common.c b/plugins/shared-folder/share-folder-common.c
index fa1f36eab7..dd79b6f43c 100644
--- a/plugins/shared-folder/share-folder-common.c
+++ b/plugins/shared-folder/share-folder-common.c
@@ -292,6 +292,10 @@ new_folder_response (EMFolderSelector *emfs, int response, EMFolderTreeModel *mo
GtkWidget *users_dialog;
GtkWidget *w;
struct ShareInfo *ssi;
+ const char *uri, *path;
+ EGwConnection *cnc;
+ CamelException ex;
+ CamelStore *store;
ssi = g_new0(struct ShareInfo, 1);
if (response != GTK_RESPONSE_OK) {
@@ -299,12 +303,21 @@ new_folder_response (EMFolderSelector *emfs, int response, EMFolderTreeModel *mo
return;
}
+ /* i want store at this point to get cnc not sure proper or not*/
+ uri = em_folder_selector_get_selected_uri (emfs);
+ camel_exception_init (&ex);
+ if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ cnc = get_cnc (store);
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 = share_folder_new (cnc, NULL);
((ssi->sf)->table)->parent = NULL;
gtk_widget_set_sensitive (GTK_WIDGET ((ssi->sf)->table), TRUE);
ssi->model = model;
@@ -315,7 +328,9 @@ new_folder_response (EMFolderSelector *emfs, int response, EMFolderTreeModel *mo
gtk_widget_show(users_dialog);
g_signal_connect (users_dialog, "response", G_CALLBACK (users_dialog_response), ssi);
+ camel_object_unref (store);
return ;
+
}
void
diff --git a/plugins/shared-folder/share-folder.c b/plugins/shared-folder/share-folder.c
index 2ed4b41cec..6d8f140d9a 100644
--- a/plugins/shared-folder/share-folder.c
+++ b/plugins/shared-folder/share-folder.c
@@ -52,7 +52,7 @@ static void share_folder_finalise (GObject *obj);
static void free_node(EShUsers *user);
static void free_all(ShareFolder *sf);
static void update_list_update (ShareFolder *sf);
-static int find_node(GList *list, gchar *email);
+static EShUsers * find_node(GList *list, gchar *email);
static void free_all(ShareFolder *sf);
static void get_container_list (ShareFolder *sf);
static void user_selected(GtkTreeSelection *selection, ShareFolder *sf);
@@ -125,7 +125,6 @@ share_folder_init (ShareFolder *sf)
{
sf->gcontainer = NULL;
sf->users = 0;
- sf->duplicate = -1;
sf->flag_for_ok = 0;
sf->shared = FALSE;
sf->container_list = NULL;
@@ -146,28 +145,25 @@ free_node(EShUsers *user)
return ;
}
-static int
+static EShUsers *
find_node(GList *list, gchar *email)
{
-
EShUsers *user = NULL;
GList *tmp;
gint i ;
- gint duplicate = -1;
+
if(list){
- tmp = g_list_first(list);
+ tmp = g_list_first(list);
for(i=0; tmp ; i++)
{
- user= g_list_nth_data(tmp, 0);
+ user= tmp->data;
if(!g_ascii_strcasecmp(user->email, email)){
- duplicate = i;
- break;
+ return user; /*if found, it returns that user*/
}
tmp= g_list_next(tmp);
}
-
}
- return duplicate;
+ return NULL;
}
static void
@@ -208,6 +204,7 @@ update_list_update (ShareFolder *sf)
gboolean delete = FALSE;
GList *tmp = NULL;
EShUsers *user = NULL;
+ EShUsers *usr = NULL;
int rights = 0;
add = gtk_toggle_button_get_active(sf->add);
edit = gtk_toggle_button_get_active(sf->edit);
@@ -224,24 +221,22 @@ update_list_update (ShareFolder *sf)
if(sf->update_list){
tmp = g_list_last(sf->update_list);
- user = g_list_nth_data(tmp, 0);
+ user = tmp->data;
/* 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) {
+ usr = find_node (sf->new_list, user->email);
+ if (usr) {
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;
- user = g_list_nth_data (sf->new_list, sf->duplicate);
- sf->duplicate = -1;
- if(user->rights != rights)
- user->rights= rights;
-
+ /* and update the rights in the new list*/
+ if(usr->rights != rights)
+ usr->rights= rights;
return ;
}
}
-
+ /* if not in the new list then update the rights, if no change then remove it from the update list*/
if (user) {
if(user->rights != rights){
user->rights= rights;
@@ -271,7 +266,6 @@ display_container (EGwContainer *container , ShareFolder *sf)
EShUsers *user = NULL;
id_shared = g_strdup(e_gw_container_get_id(container));
- g_print ("folder id: %s ours is %s\n",id_shared, sf->container_id);
/* 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);
@@ -291,12 +285,11 @@ display_container (EGwContainer *container , ShareFolder *sf)
gtk_toggle_button_set_active((GtkToggleButton *) sf->shared, TRUE);
shared_clicked(sf->shared , sf);
if (tome) {
- gtk_widget_set_sensitive (GTK_WIDGET (sf->table), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (sf->shared), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (sf->not_shared), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (sf->scrolled_window), TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (sf->user_list), TRUE);
-
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->add_button), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->remove), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->add_book), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->notification), FALSE);
email = g_strdup (e_gw_container_get_owner (sf->gcontainer));
msg = g_strconcat (email, " (Owner)", NULL);
gtk_list_store_append (GTK_LIST_STORE (sf->model), &(sf->iter));
@@ -351,10 +344,11 @@ static void
user_selected(GtkTreeSelection *selection, ShareFolder *sf)
{
EShUsers *user = NULL;
- gint index = -1;
+ EShUsers *usr = NULL;
+ GList *list = NULL;
+ gint index = -1;
int rights = 0;
gchar *email = NULL;
- int length=0;
/* This function should be called in the beginning of any probable subsequent event*/
update_list_update (sf);
@@ -363,7 +357,9 @@ user_selected(GtkTreeSelection *selection, ShareFolder *sf)
if (gtk_tree_selection_get_selected (selection, &(sf->model), &(sf->iter))){
gtk_widget_set_sensitive (GTK_WIDGET (sf->frame), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (sf->remove), TRUE);
-
+ if(sf->gcontainer)
+ if (e_gw_container_get_is_shared_to_me (sf->gcontainer))
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->remove), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->add), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->del), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->edit), FALSE);
@@ -372,42 +368,44 @@ user_selected(GtkTreeSelection *selection, ShareFolder *sf)
gtk_label_set_text (GTK_LABEL (sf->user_rights), email);
- sf->duplicate = find_node(sf->update_list, email);
- if( sf->duplicate == -1) {
- if (sf->shared && index < sf->users) {
- rights = e_gw_container_get_rights (sf->gcontainer, email);
- } else {
- user = g_list_nth_data (sf->new_list, index - sf->users);
- rights = user->rights;
+ usr = find_node(sf->update_list, email);
+ if(! usr) { /* not in the update list..check whether an existing user*/
+ if (sf->gcontainer)
+ e_gw_container_get_user_list (sf->gcontainer, &list);
+ if (list && email){
+ usr = find_node (list, email);
+ if (usr)
+ rights = usr->rights;
+ }
+ if (sf->new_list && email){
+ usr = find_node (sf->new_list, email);
+ if (usr)
+ rights = usr->rights;
}
- } else {
- user = g_list_nth_data (sf->update_list, sf->duplicate);
- rights = user->rights;
- sf->duplicate = -1;
+
+ } else {
+ rights = usr->rights;
+ sf->update_list = g_list_remove (sf->update_list, usr); /*i want to keep it on the top*/
+ free_node (usr);
}
+ /* till here fight was to get the rights of the selected user now display them*/
if (rights & 0x1)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->add), TRUE);
if (rights & 0x2)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->edit), TRUE);
if (rights & 0x4)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->del), TRUE);
-
+ if(g_strrstr (email, "Owner")) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->add), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->edit), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->del), TRUE);
+ }
user = g_new0(EShUsers, 1);
user->email = g_strdup (email);
user->rights = rights;
- if (sf->duplicate != -1) {
- EShUsers *usr = NULL;
- usr = g_list_nth_data (sf->update_list, sf->duplicate);
- if (usr) {
- sf->update_list = g_list_remove (sf->update_list, usr);
- free_node (usr);
- }
- sf->duplicate = -1;
- }
sf->update_list = g_list_append (sf->update_list, user);
- length = g_list_length (sf->update_list);
}
else {
gtk_widget_set_sensitive (GTK_WIDGET (sf->frame), FALSE);
@@ -439,7 +437,9 @@ static void
add_clicked(GtkButton *button, ShareFolder *sf)
{
const char *email = NULL;
+ const char *self_email = NULL;
EShUsers *user = NULL;
+ EShUsers *usr = NULL;
GList *list = NULL;
gint rights = 0;
gint length;
@@ -453,9 +453,11 @@ add_clicked(GtkButton *button, ShareFolder *sf)
name_selector_entry));
destinations = e_destination_store_list_destinations (destination_store);
tmp = destinations;
+ self_email = g_strdup (e_gw_connection_get_user_email (sf->cnc));
for (; tmp != NULL; tmp = g_list_next (tmp)) {
email = e_destination_get_email (tmp->data);
- if (g_strrstr (email, "@") == NULL)
+ /* You can't share a folder with yourself*/
+ if (g_strrstr (email, "@") == NULL || (!g_ascii_strcasecmp (email , self_email)))
e_error_run ((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) sf->table), "mail:shared-folder-invalid-user-error", email, NULL);
else {
if (g_ascii_strcasecmp (email, "" )) {
@@ -471,20 +473,17 @@ add_clicked(GtkButton *button, ShareFolder *sf)
e_gw_container_get_user_list (sf->gcontainer, &list);
if (list && user->email){
-
- sf->duplicate = find_node (list, user->email);
- if (sf->duplicate != -1) {
- sf->duplicate = -1;
+ usr = find_node (list, user->email);
+ if (usr)
return ;
- }
+
}
if (sf->new_list && user->email){
- sf->duplicate = find_node (sf->new_list, user->email);
- if (sf->duplicate != -1) {
- sf->duplicate = -1;
+ usr = find_node (sf->new_list, user->email);
+ if (usr)
return ;
- }
+
}
user->rights = rights;
@@ -508,22 +507,21 @@ remove_clicked(GtkButton *button, ShareFolder *sf)
GList *list = NULL;
EShUsers *usr = NULL;
+ EShUsers *user = NULL;
gchar *email;
/*check whether this is required*/
gtk_tree_model_get ((GtkTreeModel *) 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);
- sf->update_list = g_list_remove (sf->update_list, usr);
- if (sf->duplicate != -1) {
- free_node (usr);
- usr = g_list_nth_data (sf->new_list, sf->duplicate);
+ user = list->data;
+ sf->update_list = g_list_remove (sf->update_list, user);
+ /* if in the newlist remove from there*/
+ usr = find_node (sf->new_list, user->email);
+ if (usr) {
sf->new_list = g_list_remove (sf->new_list, usr);
free_node(usr);
- sf->duplicate = -1;
} else {
- sf->remove_list = g_list_append (sf->remove_list, usr);
+ sf->remove_list = g_list_append (sf->remove_list, user);
}
g_free (email);
gtk_list_store_remove (GTK_LIST_STORE (sf->model), &(sf->iter));
@@ -570,7 +568,6 @@ share_folder (ShareFolder *sf)
if (sf->update_list) {
sf->sub = "Shared Folder rights updated";
- printf ("\n\nthe message is :%s\n\n", sf->mesg);
if (e_gw_connection_share_folder (sf->cnc, sf->container_id, sf->update_list, sf->sub, sf->mesg, 2) == E_GW_CONNECTION_STATUS_OK);
}
}
@@ -634,6 +631,7 @@ notification_clicked(GtkButton *button, ShareFolder *sf)
g_signal_connect ((gpointer) not_ok, "clicked", G_CALLBACK (not_ok_clicked), sf);
not_cancel = GTK_BUTTON (glade_xml_get_widget (xmln, "nCancel"));
g_signal_connect ((gpointer) not_cancel, "clicked", G_CALLBACK (not_cancel_clicked), sf->window);
+ gtk_window_set_title (GTK_WINDOW (sf->window), "Custom Notification");
gtk_window_set_position (GTK_WINDOW (sf->window) , GTK_WIN_POS_CENTER_ALWAYS);
gtk_widget_show_all (sf->window);
}
@@ -751,6 +749,7 @@ share_folder_new (EGwConnection *ccnc, gchar *id)
share_folder_construct (new);
new->cnc = ccnc;
new->container_id = id;
+ if (ccnc && id)
get_container_list(new);
return (ShareFolder *) new;
diff --git a/plugins/shared-folder/share-folder.h b/plugins/shared-folder/share-folder.h
index da692bc985..9d4aeff51e 100644
--- a/plugins/shared-folder/share-folder.h
+++ b/plugins/shared-folder/share-folder.h
@@ -98,7 +98,6 @@ struct _ShareFolder {
gint users;
gboolean byme;
gboolean tome;
- gint duplicate;
gint flag_for_ok;
gchar *email;
gboolean is_shared;