aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJain Vivek <jvivek@src.gnome.org>2005-01-10 22:06:56 +0800
committerJain Vivek <jvivek@src.gnome.org>2005-01-10 22:06:56 +0800
commit9eba51db53e91fb748d096e0474e9df63234af53 (patch)
treeabbd39e4a713ca714345cae0be54793683309d4d /plugins
parent01c7f390e72140243c19477485fb4e88509f6365 (diff)
downloadgsoc2013-evolution-9eba51db53e91fb748d096e0474e9df63234af53.tar.gz
gsoc2013-evolution-9eba51db53e91fb748d096e0474e9df63234af53.tar.zst
gsoc2013-evolution-9eba51db53e91fb748d096e0474e9df63234af53.zip
2005-01-10 Vivek Jain <jvivek@novell.com> Included
* install-shared.c : opens up a wizard on reading a shared folder notification and installs shared folder at the recepient end. * share-folder-common.c : added (refresh_folder_tree) : to refresh the folder tree when a folder is shared or a shared folder is created so that different icons are displayed (get_cnc): to get a connection (get_container_id):to get the container id of the folder user selects * 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 svn path=/trunk/; revision=28320
Diffstat (limited to 'plugins')
-rw-r--r--plugins/shared-folder/ChangeLog2
-rw-r--r--plugins/shared-folder/Makefile.am4
-rw-r--r--plugins/shared-folder/org-gnome-shared-folder.eplug.in39
-rw-r--r--plugins/shared-folder/share-folder-common.c191
-rw-r--r--plugins/shared-folder/share-folder.c345
-rw-r--r--plugins/shared-folder/share-folder.h14
6 files changed, 349 insertions, 246 deletions
diff --git a/plugins/shared-folder/ChangeLog b/plugins/shared-folder/ChangeLog
index d5deb26d3a..b2c95845ba 100644
--- a/plugins/shared-folder/ChangeLog
+++ b/plugins/shared-folder/ChangeLog
@@ -10,6 +10,8 @@ a shared folder is created so that different icons are displayed
(get_container_id):to get the container id of the folder user selects
* 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
2004-12-15 Vivek Jain <jvivek@novell.com>
diff --git a/plugins/shared-folder/Makefile.am b/plugins/shared-folder/Makefile.am
index 58db34f810..539844fe2a 100644
--- a/plugins/shared-folder/Makefile.am
+++ b/plugins/shared-folder/Makefile.am
@@ -10,13 +10,13 @@ INCLUDES = \
plugin_DATA = org-gnome-shared-folder.eplug
plugin_LTLIBRARIES = liborg-gnome-shared-folder.la
-liborg_gnome_shared_folder_la_SOURCES = share-folder-common.c share-folder.c share-folder.h
+liborg_gnome_shared_folder_la_SOURCES = share-folder-common.c share-folder.c install-shared.c share-folder.h
liborg_gnome_shared_folder_la_LIBADD= $(prefix)/lib/libegroupwise-1.2.la
liborg_gnome_shared_folder_la_LDFLAGS = -module -avoid-version
- glade_DATA =properties.glade
+ glade_DATA =properties.glade
diff --git a/plugins/shared-folder/org-gnome-shared-folder.eplug.in b/plugins/shared-folder/org-gnome-shared-folder.eplug.in
index d16afdc5c2..b91ccf7b5a 100644
--- a/plugins/shared-folder/org-gnome-shared-folder.eplug.in
+++ b/plugins/shared-folder/org-gnome-shared-folder.eplug.in
@@ -1,48 +1,41 @@
<e-plugin-list>
<e-plugin id="org.gnome.evolution.mail_shared_folder" type="shlib" name="Shared folder" description="shared folder properties "
location="@PLUGINDIR@/liborg-gnome-shared-folder.so">
-
<hook class="org.gnome.evolution.mail.config:1.0">
<group
id="org.gnome.evolution.mail.folderConfig"
target="folder"
- check="shared_folder_validate"
+ check="shared_folder_check"
commit="shared_folder_commit"
abort="shared_folder_abort">
- <item type="page" path="10.shared" label="_Shared" factory="org_gnome_shared_folder_factory"/>
+ <item type="page" path="10.shared" label="Shared" factory="org_gnome_shared_folder_factory"/>
</group>
</hook>
</e-plugin>
-
- <e-plugin id="org.gnome.mail.folder.share_option"
- type="shlib" domain="evolution" name="SHARE Folders"
- location="@PLUGINDIR@/liborg-gnome-shared-folder.so">
- <description>Allows sharing folders in the folder tree context menu</description>
- <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.03" label="_Share"
- activate="org_gnome_shared_option"
- enable="delete" visible="delete"/>
- </menu>
- </hook>
- </e-plugin>
+ <e-plugin id="org.gnome.evolution.mail_view" type="shlib" name="mail view" description="viewing the mail"
+ location="@PLUGINDIR@/liborg-gnome-shared-folder.so">
+
+<hook class="org.gnome.evolution.mail.events:1.0">
+<event
+ target="message"
+ id="message.reading"
+ type="pass"
+ handle="org_gnome_popup_wizard"/>
+</hook>
+</e-plugin>
<e-plugin id="org.gnome.mail.folder.create_option"
type="shlib" domain="evolution" name="CREATE Folders"
location="@PLUGINDIR@/liborg-gnome-shared-folder.so">
- <description>Allows sharing folders in the folder tree context menu</description>
- <author name="Jeffrey Stedfast" email="fejj@novell.com"/>
+ <description>Allows creating shared folders in the folder tree context menu</description>
+ <author name="Vivek Jain" email="jvivek@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 Shared Folder"
+ <item type="item" path="20.emc.00" label="_New Shared Folder"
activate="org_gnome_create_option"
enable="delete" visible="delete"/>
</menu>
</hook>
</e-plugin>
-
-
-
</e-plugin-list>
diff --git a/plugins/shared-folder/share-folder-common.c b/plugins/shared-folder/share-folder-common.c
index 599b04ed2a..9f1c46ca31 100644
--- a/plugins/shared-folder/share-folder-common.c
+++ b/plugins/shared-folder/share-folder-common.c
@@ -22,17 +22,12 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-ui-component.h>
#include <camel/camel-store.h>
#include <camel/camel-vee-store.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <libgnome/gnome-i18n.h>
-#include <gconf/gconf-client.h>
#include <e-util/e-config.h>
#include <mail/em-config.h>
#include <mail/em-popup.h>
@@ -42,8 +37,8 @@
#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 <camel/camel-store.h>
+#include <camel/camel-folder.h>
#include <e-gw-container.h>
#include <e-gw-connection.h>
#include <glade/glade.h>
@@ -53,41 +48,59 @@
ShareFolder *common = NULL;
extern CamelSession *session;
-
struct ShareInfo {
GtkWidget *d;
ShareFolder *sf;
EMFolderTreeModel *model;
EMFolderSelector *emfs;
};
-
-void
-shared_folder_check (EPlugin *ep, EConfigTarget *target)
+
+static void
+refresh_folder_tree (EMFolderTreeModel *model, CamelStore *store)
{
- printf ("check **********\n");
-}
+ gchar *uri;
+ EAccount *account;
+ CamelException ex;
+ CamelProvider *provider;
+ uri = camel_url_to_string (((CamelService *) store)->url, CAMEL_URL_HIDE_ALL);
+ account = mail_config_get_account_by_source_url (uri);
+ uri = account->source->url;
+ em_folder_tree_model_remove_store (model, store);
+
+ camel_exception_init (&ex);
+ if (!(provider = camel_provider_get(uri, &ex))) {
+ camel_exception_clear (&ex);
+ return;
+ }
+ if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE))
+ return;
+ em_folder_tree_model_add_store (model, store, account->name);
+ //camel_object_unref (store);
+}
-
void
-shared_folder_commit (EPlugin *ep, EConfigTarget *target)
+shared_folder_commit (EPlugin *ep, EConfigTarget *tget)
{
+ EMConfigTargetFolder *target= (EMConfigTargetFolder *)tget->config->target;
+ CamelFolder *folder = target->folder;
+ CamelStore *store = folder->parent_store;
+ EMFolderTreeModel *model = mail_component_peek_tree_model (mail_component_peek ());
if (common) {
share_folder (common);
+ refresh_folder_tree (model, store);
g_object_run_dispose (common);
+ common = NULL;
}
- printf ("commit **********\n");
}
-
void
shared_folder_abort (EPlugin *ep, EConfigTarget *target)
{
if (common) {
- share_folder (common);
- g_object_run_dispose (common);
+ g_object_run_dispose ((GObject *)common);
+ common = NULL;
}
- printf ("aborttttttt**********\n");
}
struct _EMCreateFolder {
@@ -103,7 +116,7 @@ struct _EMCreateFolder {
CamelFolderInfo *fi;
/* callback data */
- void (* done) (CamelFolderInfo *fi, void *user_data);
+ void (* done) (struct _EMCreateFolder *m, void *user_data);
void *user_data;
};
@@ -133,20 +146,23 @@ create_folder__created (struct _mail_msg *mm)
{
struct _EMCreateFolder *m = (struct _EMCreateFolder *) mm;
struct ShareInfo *ssi = (struct ShareInfo *) m->user_data;
+ CamelStore *store = CAMEL_STORE (m->store) ;
+ EGwConnection *ccnc;
+
+ if (m->done) {
+ ccnc = get_cnc (store);
+ if(ccnc) {
+ (ssi->sf)->cnc = ccnc;
- CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (m->store) ;
- CamelGroupwiseStorePrivate *priv = gw_store->priv ;
+ (ssi->sf)->container_id = g_strdup (get_container_id ((ssi->sf)->cnc, m->name));
+ g_print("\n\n\name :%s\n\nid: %s", m->name, (ssi->sf)->container_id);
+ share_folder(ssi->sf);
+ }
- 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);
+ m->done (m, m->user_data);
}
-
}
-
+
static void
create_folder__free (struct _mail_msg *mm)
{
@@ -166,24 +182,22 @@ static struct _mail_msg_op create_folder_op = {
create_folder__free,
};
-
-
static void
-new_folder_created_cb (CamelFolderInfo *fi, void *user_data)
+new_folder_created_cb (struct _EMCreateFolder *m, 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);
+ if (m->fi){
+ refresh_folder_tree (ssi->model, m->store);
+ 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)
+create_folder (CamelStore *store, const char *full_name, void (* done) (struct _EMCreateFolder *m, void *user_data), void *user_data)
{
char *name, *namebuf = NULL;
struct _EMCreateFolder *m;
@@ -263,8 +277,6 @@ users_dialog_response(GtkWidget *dialog, int response, struct ShareInfo *ssi)
camel_object_unref (store);
}
-
-
static void
new_folder_response (EMFolderSelector *emfs, int response, EMFolderTreeModel *model)
{
@@ -297,7 +309,7 @@ new_folder_response (EMFolderSelector *emfs, int response, EMFolderTreeModel *mo
return ;
}
-GtkWidget *
+void
org_gnome_create_option(EPlugin *ep, EMPopupTargetFolder *target)
{
@@ -310,6 +322,7 @@ org_gnome_create_option(EPlugin *ep, EMPopupTargetFolder *target)
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);
+ g_print("\nselected uri:%s\n",uri);
em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
g_free(uri);
g_signal_connect (dialog, "response", G_CALLBACK (new_folder_response), model);
@@ -332,26 +345,26 @@ org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_d
folderuri = g_strdup(target->uri);
account = g_strrstr(folderuri, "groupwise");
-
- if(account){
- sub = g_strrstr(folderuri, "#");
+ sub = g_strrstr(folderuri, "#");
if(sub == NULL)
sub = g_strrstr(folderuri, "/");
sub++;
- 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) {
+ g_print ("\n\n%s\n\n", sub);
+
+ if ( !( strcmp (sub, "Mailbox") && strcmp (sub, "Calendar") && strcmp (sub, "Contacts") && strcmp (sub, "Documents") && strcmp (sub, "Authored") && strcmp (sub, "Default Library") && strcmp (sub, "Work In Progress") && strcmp (sub, "Cabinet") && strcmp (sub, "Sent Items") && strcmp (sub, "Trash") && strcmp (sub, "Checklist"))) {
+ g_free (folderuri);
+ return NULL;
+ }
+
+ if (account) {
+ CamelFolder *folder = target->folder;
+ CamelStore *store = folder->parent_store;
+ cnc = get_cnc (store);
+ if (E_IS_GW_CONNECTION (cnc))
+ id = get_container_id (cnc, sub);
+ else
+ g_warning("Could not Connnect\n");
- id = g_strdup (container_id_lookup(priv,sub));
- cnc = cnc_lookup (priv);
- } else {
- cnc = NULL;
- id = NULL;
- }
-
if (cnc && id)
sharing_tab = share_folder_new (cnc, id);
else
@@ -366,3 +379,63 @@ org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_d
return NULL;
}
+EGwConnection *
+get_cnc (CamelStore *store)
+{
+ EGwConnection *cnc;
+ char *uri, *property_value, *use_ssl, *server_name, *user, *port;
+ CamelService *service;
+ CamelURL *url;
+
+ service = CAMEL_SERVICE(store);
+ url = service->url;
+ server_name = g_strdup (url->host);
+ user = g_strdup (url->user);
+
+ g_print("\n\nserver : %s, user : %s\n\n", server_name, 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);
+ g_print("\n\nurl : %s, user : %s\n\n", uri, user);
+
+ cnc = e_gw_connection_new (uri, user, service->url->passwd);
+ return cnc;
+
+}
+
+gchar *
+get_container_id(EGwConnection *cnc, gchar *fname)
+{
+ GList *container_list = NULL;
+ gchar *id = NULL;
+ gchar *name;
+ /* get list of containers */
+ if (e_gw_connection_get_container_list (cnc, "folders", &(container_list)) == E_GW_CONNECTION_STATUS_OK) {
+ GList *container = NULL;
+
+ for (container = container_list; container != NULL; container = container->next) {
+ name = e_gw_container_get_name (container->data);
+ g_print ("\n\nchecking container for: %s\n\n", name);
+ /* if Null is passed as name then we return top lavel id*/
+ /*if (fname == NULL) {
+ id = g_strdup (e_gw_container_get_id (container->data));
+ break;
+ } else*/ if (!strcmp (name, fname)) {
+ id = g_strdup (e_gw_container_get_id (container->data));
+ break;
+ }
+ }
+ e_gw_connection_free_container_list (container_list);
+ }
+ return id;
+}
diff --git a/plugins/shared-folder/share-folder.c b/plugins/shared-folder/share-folder.c
index b29fd285c8..3e142cebc2 100644
--- a/plugins/shared-folder/share-folder.c
+++ b/plugins/shared-folder/share-folder.c
@@ -38,6 +38,7 @@
#include <libedataserverui/e-contact-store.h>
#include <libgnomeui/gnome-ui-init.h>
#include <libgnome/gnome-init.h>
+#include <widgets/misc/e-error.h>
#include <e-gw-container.h>
#include <e-gw-connection.h>
#define ROOTNODE "vboxSharing"
@@ -47,7 +48,6 @@ static void share_folder_class_init (ShareFolderClass *class);
static void share_folder_init (ShareFolder *sf);
static void share_folder_destroy (GtkObject *obj);
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);
@@ -95,7 +95,7 @@ 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;
@@ -158,7 +158,7 @@ find_node(GList *list, gchar *email)
for(i=0; tmp ; i++)
{
user= g_list_nth_data(tmp, 0);
- if(!strcmp(user->email, email)){
+ if(!g_ascii_strcasecmp(user->email, email)){
duplicate = i;
break;
}
@@ -173,22 +173,22 @@ static void
free_all(ShareFolder *sf)
{
if(sf->new_list){
- g_list_foreach (sf->new_list, free_node, NULL);
+ g_list_foreach (sf->new_list,(GFunc) free_node, NULL);
g_list_free (sf->new_list);
}
if(sf->update_list){
- g_list_foreach (sf->update_list, free_node, NULL);
+ g_list_foreach (sf->update_list, (GFunc) free_node, NULL);
g_list_free (sf->update_list);
}
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);
+ g_list_foreach (sf->new_list, (GFunc) free_node, NULL);
g_list_free (sf->new_list);
}
if (sf->remove_list) {
- g_list_foreach (sf->remove_list, free_node, NULL);
+ g_list_foreach (sf->remove_list, (GFunc) free_node, NULL);
g_list_free (sf->remove_list);
}
@@ -220,26 +220,26 @@ update_list_update (ShareFolder *sf)
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) {
- 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;
+ /* 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) {
+ 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;
- return ;
+ return ;
+ }
}
- }
if (user) {
if(user->rights != rights){
@@ -259,14 +259,18 @@ update_list_update (ShareFolder *sf)
static void
display_container (EGwContainer *container , ShareFolder *sf)
{
- gint i;
gchar **tail;
gchar *id_shared;
gchar *id_unshared;
gboolean byme = FALSE;
gboolean tome = FALSE;
+ gchar *email = NULL;
+ gchar *msg;
+ GList *user_list = NULL;
+ 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);
@@ -274,31 +278,37 @@ display_container (EGwContainer *container , ShareFolder *sf)
g_strfreev(tail);
}
- if((!strcmp(id_unshared, sf->container_id)) || (!strcmp(id_shared, sf->container_id)) ){
+ if((!g_ascii_strcasecmp(id_unshared, sf->container_id)) || (!g_ascii_strcasecmp(id_shared, sf->container_id)) ){
sf->gcontainer = container;
byme = e_gw_container_get_is_shared_by_me(container);
tome = e_gw_container_get_is_shared_to_me(container);
- if(byme | tome) {
-
- sf->users = e_gw_container_get_length (sf->gcontainer);
-
+ if(byme || tome) {
+ e_gw_container_get_user_list (sf->gcontainer, &user_list);
+ sf->users = g_list_length (user_list);
if(sf->users != 0) {
sf->is_shared = TRUE;
gtk_toggle_button_set_active((GtkToggleButton *) sf->shared, TRUE);
shared_clicked(sf->shared , sf);
- if(tome){
+ 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->table), TRUE);
+ 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));
+ gtk_list_store_set (GTK_LIST_STORE (sf->model), &(sf->iter), 0, msg, -1);
+ g_free (msg);
+ g_free (email);
- gchar *email= NULL;
- gchar *msg;
- for(i = 0; i < sf->users; i++) {
+ } else
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->table), TRUE);
- email = g_strdup (e_gw_container_get_email (sf->gcontainer, i));
+ while (user_list) {
+ user = user_list->data;
+ email = g_strdup (user->email);
msg = g_strdup_printf ("%s", email);
gtk_list_store_append (GTK_LIST_STORE (sf->model), &(sf->iter));
gtk_list_store_set (GTK_LIST_STORE (sf->model), &(sf->iter), 0, msg, -1);
@@ -306,7 +316,7 @@ display_container (EGwContainer *container , ShareFolder *sf)
g_free (email);
msg = NULL;
email = NULL;
- g_print("\n");
+ user_list = user_list->next;
}
/* i also need to display status*/
} else {
@@ -315,10 +325,7 @@ display_container (EGwContainer *container , ShareFolder *sf)
not_shared_clicked (sf->not_shared , sf);
}
}
-
-
}
-
}
static void
@@ -334,10 +341,9 @@ get_container_list (ShareFolder *sf)
display_container (E_GW_CONTAINER (container->data), sf);
}
- g_warning("Could not get the Container List");
-
+ else
+ g_warning("Could not get the Container List");
}
-
}
static void
@@ -349,7 +355,6 @@ user_selected(GtkTreeSelection *selection, ShareFolder *sf)
gchar *email = NULL;
int length=0;
-
/* This function should be called in the beginning of any probable subsequent event*/
update_list_update (sf);
@@ -358,7 +363,7 @@ user_selected(GtkTreeSelection *selection, ShareFolder *sf)
gtk_widget_set_sensitive (GTK_WIDGET (sf->frame), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (sf->remove), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( sf->add), 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);
gtk_tree_model_get (GTK_LIST_STORE (sf->model), &(sf->iter), 0, &email, -1);
@@ -400,18 +405,13 @@ user_selected(GtkTreeSelection *selection, ShareFolder *sf)
}
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);
gtk_widget_set_sensitive (GTK_WIDGET (sf->remove), FALSE);
-
}
-
}
static void
@@ -430,60 +430,74 @@ not_shared_clicked (GtkRadioButton *button, ShareFolder *sf)
} else {
sf->flag_for_ok = 2;
}
-
gtk_widget_set_sensitive (GTK_WIDGET (sf->table), FALSE);
}
static void
add_clicked(GtkButton *button, ShareFolder *sf)
{
- static gchar *email = NULL;
+ gchar *email = NULL;
EShUsers *user = NULL;
GList *list = NULL;
gint rights = 0;
gint length;
gchar *msg = NULL;
-
- email = gtk_entry_get_text (GTK_ENTRY (sf->name));
- if (strcmp (email, "" )) {
- update_list_update (sf);
- user = g_new0 (EShUsers, 1);
- user->email = g_strdup(email);
- } else {
- return;
-
- }
- /*check whether already exists*/
- if (sf->gcontainer)
- e_gw_container_get_user_list (sf->gcontainer, &list);
+ EDestinationStore *destination_store;
+ GList *destinations, *tmp;
+ ENameSelectorEntry *name_selector_entry;
+
+ name_selector_entry = e_name_selector_peek_section_entry (sf->name_selector, "Add User");
+ destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (
+ name_selector_entry));
+ destinations = e_destination_store_list_destinations (destination_store);
+ tmp = destinations;
+ for (; tmp != NULL; tmp = g_list_next (tmp)) {
+ email = e_destination_get_email (tmp->data);
+ if (g_strrstr (email, "@") == NULL)
+ 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, "" )) {
+ update_list_update (sf);
+ user = g_new0 (EShUsers, 1);
+ user->email = g_strdup(email);
+ } else {
+
+ return;
+ }
+ /*check whether already exists*/
+ if (sf->gcontainer)
+ e_gw_container_get_user_list (sf->gcontainer, &list);
- if (list && user->email){
+ if (list && user->email){
- sf->duplicate = find_node (list, user->email);
- if (sf->duplicate != -1) {
- sf->duplicate = -1;
- return ;
- }
- }
- if (sf->new_list && user->email){
+ sf->duplicate = find_node (list, user->email);
+ if (sf->duplicate != -1) {
+ sf->duplicate = -1;
+ return ;
+ }
+ }
+ if (sf->new_list && user->email){
- sf->duplicate = find_node (sf->new_list, user->email);
- if (sf->duplicate != -1) {
- sf->duplicate = -1;
- return ;
+ sf->duplicate = find_node (sf->new_list, user->email);
+ if (sf->duplicate != -1) {
+ sf->duplicate = -1;
+ return ;
+ }
+ }
+
+ user->rights = rights;
+ msg = g_strdup (user->email);
+ gtk_list_store_append (GTK_LIST_STORE (sf->model), &(sf->iter));
+ gtk_list_store_set (GTK_LIST_STORE (sf->model), &(sf->iter), 0, msg, -1);
+
+ g_free(msg);
+ sf->new_list = g_list_append (sf->new_list, user);
+ length = g_list_length (sf->new_list);
+ sf->flag_for_ok = 0;
}
}
+ gtk_entry_set_text (GTK_ENTRY(name_selector_entry), "");
- user->rights = rights;
- msg = g_strdup (user->email);
- gtk_list_store_append (GTK_LIST_STORE (sf->model), &(sf->iter));
- gtk_list_store_set (GTK_LIST_STORE (sf->model), &(sf->iter), 0, msg, -1);
-
- g_free(msg);
- sf->new_list = g_list_append (sf->new_list, user);
- length = g_list_length (sf->new_list);
- sf->flag_for_ok = 0;
- gtk_entry_set_text (sf->name, "");
}
static void
@@ -493,7 +507,7 @@ remove_clicked(GtkButton *button, ShareFolder *sf)
GList *list = NULL;
EShUsers *usr = NULL;
gchar *email;
-
+
/*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);
@@ -509,8 +523,6 @@ remove_clicked(GtkButton *button, ShareFolder *sf)
} else {
sf->remove_list = g_list_append (sf->remove_list, usr);
}
-
-
g_free (email);
gtk_list_store_remove (GTK_LIST_STORE (sf->model), &(sf->iter));
sf->flag_for_ok = 1;
@@ -519,57 +531,51 @@ remove_clicked(GtkButton *button, ShareFolder *sf)
void
share_folder (ShareFolder *sf)
{
-
update_list_update (sf);
-
if (E_IS_GW_CONNECTION (sf->cnc)) {
+ if(sf->flag_for_ok == 2){ /* you have to remove all the users*/
+ GList *list = NULL;
-
- if(sf->flag_for_ok == 2){ /* you have to remove all the users*/
- GList *list = NULL;
-
-
- if(sf->new_list){
- g_list_foreach (sf->new_list, free_node, NULL);
- g_list_free (sf->new_list);
- }
- if(sf->update_list){
- g_list_foreach (sf->update_list, free_node, NULL);
- g_list_free (sf->update_list);
- }
-
- sf->new_list = NULL;
- if(sf->remove_list){
- g_list_foreach (sf->remove_list, free_node, NULL);
- 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);
+ if(sf->new_list){
+ g_list_foreach (sf->new_list, (GFunc) free_node, NULL);
+ g_list_free (sf->new_list);
+ }
+ if(sf->update_list){
+ g_list_foreach (sf->update_list, (GFunc) free_node, NULL);
+ g_list_free (sf->update_list);
+ }
- } else {
- g_warning("Container is Null");
- }
-
+ sf->new_list = NULL;
+ if(sf->remove_list){
+ g_list_foreach (sf->remove_list,(GFunc) free_node, NULL);
+ 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);
} 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);
- }
+ g_warning("Container is Null");
+ }
- if (sf->update_list) {
- if (e_gw_connection_share_folder (sf->cnc, sf->container_id, sf->update_list, sf->sub, sf->mesg, 2) == E_GW_CONNECTION_STATUS_OK);
- }
- }
+ } 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);
+ }
- 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);
+ if (sf->update_list) {
+ sf->sub = "Shared Folder rights updated";
+ if (e_gw_connection_share_folder (sf->cnc, sf->container_id, sf->update_list, sf->sub, sf->mesg, 2) == E_GW_CONNECTION_STATUS_OK);
}
-
- }
+ }
+ if (sf->remove_list) {
+ sf->sub = "Shared Folder removed";
+ if (e_gw_connection_share_folder (sf->cnc, sf->container_id, sf->remove_list, sf->sub, sf->mesg, 1) == E_GW_CONNECTION_STATUS_OK);
+ }
+ }
}
static void
@@ -578,7 +584,7 @@ not_ok_clicked(GtkButton *button, ShareFolder *sf)
gchar *subj = NULL;
gchar *msg = NULL;
- GtkTextIter *start,*end;
+ GtkTextIter *start, *end;
GtkTextBuffer *buffer;
buffer=g_new0(GtkTextBuffer,1);
@@ -587,16 +593,12 @@ not_ok_clicked(GtkButton *button, ShareFolder *sf)
subj = g_strdup (gtk_entry_get_text (sf->subject));
if(subj)
sf->sub = subj;
-
-
buffer = gtk_text_view_get_buffer (sf->message);
gtk_text_buffer_get_start_iter (buffer, start);
gtk_text_buffer_get_end_iter (buffer, end);
-
msg = g_strdup(gtk_text_buffer_get_text (buffer, start, end, FALSE));
if(msg)
sf->mesg = msg;
-
gtk_widget_destroy (GTK_WIDGET (sf->window));
}
@@ -615,9 +617,9 @@ notification_clicked(GtkButton *button, ShareFolder *sf)
static GladeXML *xmln;
GtkButton *not_ok;
GtkButton *not_cancel;
-
+
xmln = glade_xml_new (EVOLUTION_GLADEDIR "/properties.glade" ,"window1", NULL);
- sf->window = GTK_WINDOW (glade_xml_get_widget (xmln, "window1"));
+ sf->window = GTK_WIDGET (glade_xml_get_widget (xmln, "window1"));
sf->subject = GTK_ENTRY (glade_xml_get_widget (xmln, "entry3"));
gtk_entry_set_text(GTK_ENTRY (sf->subject) , sf->sub);
@@ -628,33 +630,66 @@ notification_clicked(GtkButton *button, ShareFolder *sf)
g_signal_connect ((gpointer) not_cancel, "clicked", G_CALLBACK (not_cancel_clicked), sf->window);
}
+static void
+addressbook_dialog_response (ENameSelectorDialog *name_selector_dialog, gint response, gpointer user_data)
+{
+ gtk_widget_hide (GTK_WIDGET (name_selector_dialog));
+}
+
+static void
+addressbook_entry_changed (GtkWidget *entry, gpointer user_data)
+{
+
+}
+
+static void
+address_button_clicked_cb (GtkButton *button, gpointer data)
+{
+ ShareFolder *sf = data;
+ ENameSelectorDialog *name_selector_dialog;
+
+ name_selector_dialog = e_name_selector_peek_dialog (sf->name_selector);
+ gtk_widget_show (GTK_WIDGET (name_selector_dialog));
+}
static void
share_folder_construct (ShareFolder *sf)
{
-
GladeXML *xml;
+ ENameSelectorDialog *name_selector_dialog;
+ ENameSelectorModel *name_selector_model;
+ ENameSelectorEntry *name_selector_entry;
+
xml = glade_xml_new (EVOLUTION_GLADEDIR "/properties.glade", ROOTNODE, NULL);
sf->xml =xml;
- if(!sf->xml) {
- g_warning("could not get xml");
+ if (!sf->xml) {
+ g_warning ("could not get xml");
}
- sf->vbox = GTK_VBOX(glade_xml_get_widget(sf->xml, "vboxSharing"));
-
-
+ sf->vbox = GTK_VBOX (glade_xml_get_widget(sf->xml, "vboxSharing"));
sf->table = GTK_WIDGET (glade_xml_get_widget (sf->xml, "table26"));
gtk_widget_set_sensitive (GTK_WIDGET (sf->table), FALSE);
sf->shared = GTK_RADIO_BUTTON (glade_xml_get_widget (sf->xml, "radShared"));
- g_signal_connect ((gpointer) sf->shared, "clicked", G_CALLBACK (shared_clicked), sf);
+ g_signal_connect ((gpointer) sf->shared, "clicked", G_CALLBACK (shared_clicked), sf);
sf->not_shared = GTK_RADIO_BUTTON (glade_xml_get_widget (sf->xml, "radNotShared"));
g_signal_connect ((gpointer) sf->not_shared, "clicked", G_CALLBACK (not_shared_clicked), 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);*/
+ gtk_widget_set_sensitive (GTK_WIDGET (sf->add_book), TRUE);
+ g_signal_connect((GtkWidget *) sf->add_book, "clicked", G_CALLBACK (address_button_clicked_cb), sf);
+
+ sf->name_selector = e_name_selector_new ();
+ name_selector_dialog = e_name_selector_peek_dialog (sf->name_selector);
+ g_signal_connect (name_selector_dialog, "response",
+ G_CALLBACK (addressbook_dialog_response), sf);
+
+ name_selector_model = e_name_selector_peek_model (sf->name_selector);
+ e_name_selector_model_add_section (name_selector_model, "Add User", "Add User", NULL);
+
+ name_selector_entry = e_name_selector_peek_section_entry (sf->name_selector, "Add User");
+ g_signal_connect (name_selector_entry, "changed",
+ G_CALLBACK (addressbook_entry_changed), 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);
@@ -666,11 +701,11 @@ share_folder_construct (ShareFolder *sf)
sf->notification = GTK_BUTTON (glade_xml_get_widget (sf->xml, "Notification"));
g_signal_connect((GtkWidget *) sf->notification, "clicked", G_CALLBACK (notification_clicked), sf);
-
sf->name = GTK_ENTRY (glade_xml_get_widget (sf->xml, "entry2"));
/*TODO:connect name and label*/
- gtk_widget_show (GTK_WIDGET(sf->name));
-
+ gtk_widget_hide (GTK_WIDGET(sf->name));
+ gtk_table_attach ((GtkWidget *) sf->table, (GtkWidget *) name_selector_entry, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND, 8, 0);
+ gtk_widget_show ((GtkWidget *) name_selector_entry);
sf->frame = GTK_FRAME (glade_xml_get_widget(sf->xml, "frame1"));
gtk_widget_set_sensitive(GTK_WIDGET (sf->frame), FALSE);
@@ -683,27 +718,25 @@ share_folder_construct (ShareFolder *sf)
sf->user_rights = GTK_LABEL (glade_xml_get_widget (sf->xml,"label550"));
- sf->scrolledwindow = GTK_WIDGET (glade_xml_get_widget (sf->xml,"scrolledwindow1"));
+ sf->scrolled_window = GTK_WIDGET (glade_xml_get_widget (sf->xml,"scrolledwindow1"));
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sf->scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sf->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
sf->model = gtk_list_store_new (1, G_TYPE_STRING);
sf->user_list = gtk_tree_view_new ();
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sf->scrolledwindow), sf->user_list);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sf->scrolled_window), 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));
-
sf->cell = gtk_cell_renderer_text_new ();
sf->column = gtk_tree_view_column_new_with_attributes ("Users", sf->cell, "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (sf->user_list),
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)
+share_folder_new (EGwConnection *ccnc, gchar *id)
{
ShareFolder *new;
new = (ShareFolder *) g_object_new (share_folder_get_type (), NULL);
@@ -712,7 +745,7 @@ share_folder_new (gchar *ccnc, gchar *id)
new->container_id = id;
get_container_list(new);
- return (GtkWidget *) new;
+ return (ShareFolder *) new;
}
diff --git a/plugins/shared-folder/share-folder.h b/plugins/shared-folder/share-folder.h
index dd21401335..da692bc985 100644
--- a/plugins/shared-folder/share-folder.h
+++ b/plugins/shared-folder/share-folder.h
@@ -20,7 +20,6 @@
*
*/
-
#ifndef __SHARE_FOLDER_H__
#define __SHARE_FOLDER_H__
@@ -32,7 +31,9 @@ extern "C" {
#include <glib.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtk.h>
+#include <camel/camel-store.h>
#include <e-gw-connection.h>
+#include <libedataserverui/e-name-selector.h>
#define _SHARE_FOLDER_TYPE (share_folder_get_type ())
#define SHARE_FOLDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SHARE_FOLDER, ShareFolder))
@@ -81,7 +82,7 @@ struct _ShareFolder {
struct _GtkEntry *subject;
struct _GtkRadioButton *shared;
struct _GtkRadioButton *not_shared;
- struct _GtkWidget *scrolledwindow;
+ struct _GtkWidget *scrolled_window;
struct _GtkWidget *table;
struct _GtkListStore *model;
struct _GtkCellRenderer *cell;
@@ -107,19 +108,20 @@ struct _ShareFolder {
gchar *mesg;
GList *container_list;
GtkTreeIter iter;
+ ENameSelector *name_selector;
+
};
struct _ShareFolderClass {
GtkVBoxClass parent_class;
-
};
GType share_folderget_type (void);
-
-struct _ShareFolder * share_folder_new (gchar *ccnc, gchar *id);
-
+struct _ShareFolder * share_folder_new (EGwConnection *ccnc, gchar *id);
void share_folder(struct _ShareFolder *sf);
+gchar * get_container_id (EGwConnection *cnc, gchar *fname);
+EGwConnection * get_cnc (CamelStore *store);
#ifdef __cplusplus
}