*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/*
#include "addrbook.h"
#include "addrindex.h"
#include "manage_window.h"
+#include "ldapserver.h"
+#include "ldapupdate.h"
+#include "alertpanel.h"
typedef struct {
AddressBookFile *book;
static struct _AddressAdd_dlg {
GtkWidget *window;
+ GtkWidget *picture;
GtkWidget *entry_name;
GtkWidget *label_address;
GtkWidget *entry_remarks;
static void addressadd_create( void ) {
GtkWidget *window;
- GtkWidget *vbox;
+ GtkWidget *vbox, *hbox;
GtkWidget *table;
GtkWidget *label;
+ GtkWidget *picture;
GtkWidget *entry_name;
GtkWidget *label_addr;
GtkWidget *entry_rems;
g_signal_connect(G_OBJECT(window), "size_allocate",
G_CALLBACK(addressadd_size_allocate_cb), NULL);
+ hbox = gtk_hbox_new(FALSE, 6);
vbox = gtk_vbox_new(FALSE, 8);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_container_set_border_width( GTK_CONTAINER(vbox), 8 );
+ picture = gtk_image_new();
+ gtk_box_pack_start(GTK_BOX(hbox), picture, FALSE, FALSE, 0);
+
table = gtk_table_new(3, 2, FALSE);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
gtk_table_set_row_spacings(GTK_TABLE(table), 8);
gtk_table_set_col_spacings(GTK_TABLE(table), 8);
gtk_widget_show_all(vbox);
addressadd_dlg.window = window;
+ addressadd_dlg.picture = picture;
addressadd_dlg.entry_name = entry_name;
addressadd_dlg.label_address = label_addr;
addressadd_dlg.entry_remarks = entry_rems;
list = addrindex_get_interface_list( addrIndex );
while( list ) {
AddressInterface *interface = list->data;
- if( interface->type == ADDR_IF_BOOK ) {
+ if( interface->type == ADDR_IF_BOOK ||
+ interface->type == ADDR_IF_LDAP ) {
nodeDS = interface->listSource;
while( nodeDS ) {
ds = nodeDS->data;
}
}
-gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const gchar *address, const gchar *remarks ) {
+gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name,
+ const gchar *address, const gchar *remarks, GdkPixbuf *picture ) {
gboolean retVal = FALSE;
ItemPerson *person = NULL;
FolderInfo *fi = NULL;
addressadd_cancelled = FALSE;
+
if( ! addressadd_dlg.window ) addressadd_create();
gtk_widget_grab_focus(addressadd_dlg.ok_btn);
gtk_widget_show(addressadd_dlg.window);
gtk_label_set_text( GTK_LABEL(addressadd_dlg.label_address ), address );
if( remarks )
gtk_entry_set_text( GTK_ENTRY(addressadd_dlg.entry_remarks ), remarks );
-
+ if( picture ) {
+ gtk_image_set_from_pixbuf(GTK_IMAGE(addressadd_dlg.picture), picture);
+ gtk_widget_show(GTK_WIDGET(addressadd_dlg.picture));
+ } else {
+ gtk_widget_hide(GTK_WIDGET(addressadd_dlg.picture));
+ }
gtk_main();
gtk_widget_hide( addressadd_dlg.window );
returned_name,
address,
returned_remarks);
+ person->status = ADD_ENTRY;
+
+ if (picture) {
+ GError *error = NULL;
+ gchar *name = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S,
+ ADDRITEM_ID(person), ".png", NULL );
+ gdk_pixbuf_save(picture, name, "png", &error, NULL);
+ if (error) {
+ g_warning(_("Failed to save image: \n%s"),
+ error->message);
+ g_error_free(error);
+ }
+ addritem_person_set_picture( person, ADDRITEM_ID(person) ) ;
+ g_free( name );
+ }
+#ifdef USE_LDAP
+ if (fi->book->type == ADBOOKTYPE_LDAP) {
+ LdapServer *server = (LdapServer *) fi->book;
+ ldapsvr_set_modified(server, TRUE);
+ ldapsvr_update_book(server, person);
+ if (server->retVal != LDAPRC_SUCCESS) {
+ alertpanel( _("Add address(es)"),
+ _("Can't add the specified address"),
+ GTK_STOCK_CLOSE, NULL, NULL );
+ return server->retVal;
+ }
+ }
+#endif
g_free(returned_name);
g_free(returned_remarks);
if( person ) retVal = TRUE;