aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/shared-folder/share-folder-common.c
blob: bdb036c8211ff4fb2353e2478ef279dbc3b7ca61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 *  Author: Vivek Jain <jvivek@novell.com>
 *
 *  Copyright 2004 Novell, Inc.
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of version 2 of the GNU General Public
 *  License as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 *
 */

#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 <libebook/e-destination.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>
#include <mail/em-folder-properties.h>
#include <mail/em-folder-tree.h>
#include <mail/em-folder-selector.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 "share-folder.h"
#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION

typedef CORBA_Object GNOME_Evolution_Addressbook_SelectNames;
ShareFolder *common = NULL;



void 
shared_folder_check (EPlugin *ep, EConfigTarget *target)
{
    printf ("check **********\n");
}


    
void 
shared_folder_commit (EPlugin *ep, EConfigTarget *target)
{

    if(common)
        share_folder (common);
    g_object_run_dispose(common);

    printf ("commit **********\n");
}


void 
shared_folder_abort (EPlugin *ep, EConfigTarget *target)
{
    printf ("aborttttttt**********\n");
}





GtkWidget *
org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
{

    gchar *folderuri = NULL;
    gchar *account = NULL;
    gchar *id = NULL;
    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);
    account = g_strrstr(folderuri, "groupwise");
    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 ;
        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));
            cnc = cnc_lookup (priv);
        } else {
            cnc = NULL;
            id = NULL;
        }
        
        g_free (folderuri);
        
        if (cnc && id)
            sharing_tab = share_folder_new (cnc, id);
        else 
            return NULL;

        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;
        

}