#include <gtk/gtkitemfactory.h>
#include <string.h>
#include <setjmp.h>
+#include <sys/types.h>
+#include <dirent.h>
#include "main.h"
#include "addressbook.h"
#include "addrbook.h"
#include "addrindex.h"
#include "addressadd.h"
+#include "addrduplicates.h"
#include "addressbook_foldersel.h"
#include "vcard.h"
#include "editvcard.h"
#include "exphtmldlg.h"
#include "expldifdlg.h"
#include "browseldap.h"
+#include "addrcustomattr.h"
typedef enum
{
static void addressbook_list_select_remove ( AddrItemObject *aio );
static void addressbook_import_ldif_cb ( void );
+static void addressbook_find_duplicates_cb ( void );
+static void addressbook_edit_custom_attr_cb ( void );
static void addressbook_import_mutt_cb ( void );
static void addressbook_import_pine_cb ( void );
static void addressbook_export_html_cb ( void );
static GtkItemFactoryEntry addressbook_entries[] =
{
- {N_("/_Book"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Book/New _Book"), "<control>B", addressbook_new_book_cb, 0, NULL},
- {N_("/_Book/New _Folder"), "<control>R", addressbook_new_folder_cb, 0, NULL},
- {N_("/_Book/New _vCard"), "<control><shift>D", addressbook_new_vcard_cb, 0, NULL},
+ {N_("/_Book"), NULL, NULL, 0, "<Branch>", NULL},
+ {N_("/_Book/New _Book"), "<control>B", addressbook_new_book_cb, 0, NULL, NULL},
+ {N_("/_Book/New _Folder"), "<control>R", addressbook_new_folder_cb, 0, NULL, NULL},
+ {N_("/_Book/New _vCard"), "<control><shift>D", addressbook_new_vcard_cb, 0, NULL, NULL},
#ifdef USE_JPILOT
- {N_("/_Book/New _JPilot"), "<control>J", addressbook_new_jpilot_cb, 0, NULL},
+ {N_("/_Book/New _JPilot"), "<control>J", addressbook_new_jpilot_cb, 0, NULL, NULL},
#endif
#ifdef USE_LDAP
- {N_("/_Book/New LDAP _Server"), "<control><shift>S", addressbook_new_ldap_cb, 0, NULL},
+ {N_("/_Book/New LDAP _Server"), "<control><shift>S", addressbook_new_ldap_cb, 0, NULL, NULL},
#endif
- {N_("/_Book/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Book/_Edit book"), NULL, addressbook_treenode_edit_cb, 0, NULL},
- {N_("/_Book/_Delete book"), NULL, addressbook_treenode_delete_cb, 0, NULL},
- {N_("/_Book/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Book/_Save"), "<control>S", addressbook_file_save_cb, 0, NULL},
- {N_("/_Book/_Close"), "<control>W", close_cb, 0, NULL},
- {N_("/_Address"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Address/_Select all"), "<control>A", addressbook_select_all_cb, 0, NULL},
- {N_("/_Address/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Address/C_ut"), "<control>X", addressbook_clip_cut_cb, 0, NULL},
- {N_("/_Address/_Copy"), "<control>C", addressbook_clip_copy_cb, 0, NULL},
- {N_("/_Address/_Paste"), "<control>V", addressbook_clip_paste_cb, 0, NULL},
- {N_("/_Address/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Address/_Edit"), "<control>Return",addressbook_edit_address_cb, 0, NULL},
- {N_("/_Address/_Delete"), "<control>D", addressbook_delete_address_cb, 0, NULL},
- {N_("/_Address/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Address/New _Address"), "<control>N", addressbook_new_address_cb, 0, NULL},
- {N_("/_Address/New _Group"), "<control>G", addressbook_new_group_cb, 0, NULL},
- {N_("/_Address/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Address/_Mail To"), NULL, addressbook_mail_to_cb, 0, NULL},
- {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Tools/Import _LDIF file..."), NULL, addressbook_import_ldif_cb, 0, NULL},
- {N_("/_Tools/Import M_utt file..."), NULL, addressbook_import_mutt_cb, 0, NULL},
- {N_("/_Tools/Import _Pine file..."), NULL, addressbook_import_pine_cb, 0, NULL},
- {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Tools/Export _HTML..."), NULL, addressbook_export_html_cb, 0, NULL},
- {N_("/_Tools/Export LDI_F..."), NULL, addressbook_export_ldif_cb, 0, NULL},
- {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
- {N_("/_Help/_About"), NULL, about_show, 0, NULL}
+ {N_("/_Book/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Book/_Edit book"), NULL, addressbook_treenode_edit_cb, 0, NULL, NULL},
+ {N_("/_Book/_Delete book"), NULL, addressbook_treenode_delete_cb, 0, NULL, NULL},
+ {N_("/_Book/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Book/_Save"), "<control>S", addressbook_file_save_cb, 0, NULL, NULL},
+ {N_("/_Book/_Close"), "<control>W", close_cb, 0, NULL, NULL},
+ {N_("/_Address"), NULL, NULL, 0, "<Branch>", NULL},
+ {N_("/_Address/_Select all"), "<control>A", addressbook_select_all_cb, 0, NULL, NULL},
+ {N_("/_Address/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Address/C_ut"), "<control>X", addressbook_clip_cut_cb, 0, NULL, NULL},
+ {N_("/_Address/_Copy"), "<control>C", addressbook_clip_copy_cb, 0, NULL, NULL},
+ {N_("/_Address/_Paste"), "<control>V", addressbook_clip_paste_cb, 0, NULL, NULL},
+ {N_("/_Address/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Address/_Edit"), "<control>Return",addressbook_edit_address_cb, 0, NULL, NULL},
+ {N_("/_Address/_Delete"), "<control>D", addressbook_delete_address_cb, 0, NULL, NULL},
+ {N_("/_Address/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Address/New _Address"), "<control>N", addressbook_new_address_cb, 0, NULL, NULL},
+ {N_("/_Address/New _Group"), "<control>G", addressbook_new_group_cb, 0, NULL, NULL},
+ {N_("/_Address/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Address/_Mail To"), NULL, addressbook_mail_to_cb, 0, NULL, NULL},
+ {N_("/_Tools"), NULL, NULL, 0, "<Branch>", NULL},
+ {N_("/_Tools/Import _LDIF file..."), NULL, addressbook_import_ldif_cb, 0, NULL, NULL},
+ {N_("/_Tools/Import M_utt file..."), NULL, addressbook_import_mutt_cb, 0, NULL, NULL},
+ {N_("/_Tools/Import _Pine file..."), NULL, addressbook_import_pine_cb, 0, NULL, NULL},
+ {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Tools/Export _HTML..."), NULL, addressbook_export_html_cb, 0, NULL, NULL},
+ {N_("/_Tools/Export LDI_F..."), NULL, addressbook_export_ldif_cb, 0, NULL, NULL},
+ {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Tools/Find duplicates..."), NULL, addressbook_find_duplicates_cb, 0, NULL, NULL},
+ {N_("/_Tools/Edit custom attributes..."), NULL, addressbook_edit_custom_attr_cb, 0, NULL, NULL},
+ {N_("/_Help"), NULL, NULL, 0, "<Branch>", NULL},
+ {N_("/_Help/_About"), NULL, about_show, 0, NULL, NULL}
};
static GtkItemFactoryEntry addressbook_tree_popup_entries[] =
{
- {N_("/_Edit"), NULL, addressbook_treenode_edit_cb, 0, NULL},
- {N_("/_Delete"), NULL, addressbook_treenode_delete_cb, 0, NULL},
- {"/---", NULL, NULL, 0, "<Separator>"},
- {N_("/New _Book"), NULL, addressbook_new_book_cb, 0, NULL},
- {N_("/New _Folder"), NULL, addressbook_new_folder_cb, 0, NULL},
- {N_("/New _Group"), NULL, addressbook_new_group_cb, 0, NULL},
- {"/---", NULL, NULL, 0, "<Separator>"},
- {N_("/C_ut"), NULL, addressbook_treenode_cut_cb, 0, NULL},
- {N_("/_Copy"), NULL, addressbook_treenode_copy_cb, 0, NULL},
- {N_("/_Paste"), NULL, addressbook_treenode_paste_cb, 0, NULL}
+ {N_("/_Edit"), NULL, addressbook_treenode_edit_cb, 0, NULL, NULL},
+ {N_("/_Delete"), NULL, addressbook_treenode_delete_cb, 0, NULL, NULL},
+ {"/---", NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/New _Book"), NULL, addressbook_new_book_cb, 0, NULL, NULL},
+ {N_("/New _Folder"), NULL, addressbook_new_folder_cb, 0, NULL, NULL},
+ {N_("/New _Group"), NULL, addressbook_new_group_cb, 0, NULL, NULL},
+ {"/---", NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/C_ut"), NULL, addressbook_treenode_cut_cb, 0, NULL, NULL},
+ {N_("/_Copy"), NULL, addressbook_treenode_copy_cb, 0, NULL, NULL},
+ {N_("/_Paste"), NULL, addressbook_treenode_paste_cb, 0, NULL, NULL}
};
static GtkItemFactoryEntry addressbook_list_popup_entries[] =
{
- {N_("/_Select all"), NULL, addressbook_select_all_cb, 0, NULL},
- {"/---", NULL, NULL, 0, "<Separator>"},
- {N_("/_Edit"), NULL, addressbook_edit_address_cb, 0, NULL},
- {N_("/_Delete"), NULL, addressbook_delete_address_cb, 0, NULL},
- {"/---", NULL, NULL, 0, "<Separator>"},
- {N_("/New _Address"), NULL, addressbook_new_address_cb, 0, NULL},
- {N_("/New _Group"), NULL, addressbook_new_group_cb, 0, NULL},
- {"/---", NULL, NULL, 0, "<Separator>"},
- {N_("/C_ut"), NULL, addressbook_clip_cut_cb, 0, NULL},
- {N_("/_Copy"), NULL, addressbook_clip_copy_cb, 0, NULL},
- {N_("/_Paste"), NULL, addressbook_clip_paste_cb, 0, NULL},
- {"/---", NULL, NULL, 0, "<Separator>"},
-/* {N_("/Pa_ste Address"), NULL, addressbook_clip_paste_address_cb, 0, NULL},*/
- {N_("/_Mail To"), NULL, addressbook_mail_to_cb, 0, NULL},
+ {N_("/_Select all"), NULL, addressbook_select_all_cb, 0, NULL, NULL},
+ {"/---", NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/_Edit"), NULL, addressbook_edit_address_cb, 0, NULL, NULL},
+ {N_("/_Delete"), NULL, addressbook_delete_address_cb, 0, NULL, NULL},
+ {"/---", NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/New _Address"), NULL, addressbook_new_address_cb, 0, NULL, NULL},
+ {N_("/New _Group"), NULL, addressbook_new_group_cb, 0, NULL, NULL},
+ {"/---", NULL, NULL, 0, "<Separator>", NULL},
+ {N_("/C_ut"), NULL, addressbook_clip_cut_cb, 0, NULL, NULL},
+ {N_("/_Copy"), NULL, addressbook_clip_copy_cb, 0, NULL, NULL},
+ {N_("/_Paste"), NULL, addressbook_clip_paste_cb, 0, NULL, NULL},
+ {"/---", NULL, NULL, 0, "<Separator>", NULL},
+/* {N_("/Pa_ste Address"), NULL, addressbook_clip_paste_address_cb, 0, NULL, NULL},*/
+ {N_("/_Mail To"), NULL, addressbook_mail_to_cb, 0, NULL, NULL},
#ifdef USE_LDAP
- {N_("/_Browse Entry"), NULL, addressbook_browse_entry_cb, 0, NULL},
+ {N_("/_Browse Entry"), NULL, addressbook_browse_entry_cb, 0, NULL, NULL},
#endif
};
{ LDAPRC_NOENTRIES, N_("No LDAP entries found for search criteria") },
{ LDAPRC_STOP_FLAG, N_("LDAP search terminated on request") },
{ LDAPRC_TLS, N_("Error starting TLS connection") },
- { LDAPRC_NODN, N_("Distinguised Name (dn) is missing") },
+ { LDAPRC_NODN, N_("Distinguished Name (dn) is missing") },
{ LDAPRC_NAMING_VIOLATION, N_("Missing required information") },
{ LDAPRC_ALREADY_EXIST, N_("Another contact exists with that key") },
{ LDAPRC_STRONG_AUTH, N_("Strong(er) authentication required") },
/**
* Refresh addressbook and save to file(s).
*/
-static void addressbook_refresh( void )
+void addressbook_refresh( void )
{
if (addrbook.window) {
if (addrbook.treeSelected) {
name2 = GTK_CELL_TEXT (row2->cell[sort_column_number])->text;
if( ! name1 ) return ( name2 != NULL );
if( ! name2 ) return -1;
- return strcasecmp( name1, name2 );
+ return g_utf8_collate( name1, name2 );
} else {
/* Order groups before person */
if( aio1->type == ITEMTYPE_GROUP ) {
}
}
-static void addressbook_ds_status_message( AddressDataSource *ds, gchar *msg ) {
- *addressbook_msgbuf = '\0';
- if( ds ) {
- gchar *name;
-
- name = addrindex_ds_get_name( ds );
- g_snprintf( addressbook_msgbuf, sizeof(addressbook_msgbuf),
- "%s: %s", name, msg );
- }
- else {
- g_snprintf( addressbook_msgbuf, sizeof(addressbook_msgbuf),
- "%s", msg );
- }
- addressbook_status_show( addressbook_msgbuf );
-}
-
static void addressbook_ds_show_message( AddressDataSource *ds ) {
gint retVal;
gchar *name;
item = node->data;
node = g_list_next( node );
aio = ( AddrItemObject * ) item->addressItem;
+ if (!aio)
+ continue;
if( aio->type == ADDR_ITEM_GROUP ) {
ItemGroup *item = ( ItemGroup * ) aio;
GtkCTreeNode *nd = NULL;
}
#endif
if( item ) {
+ gchar *filename = addritem_person_get_picture(item);
+ if (filename && is_file_exist(filename))
+ g_unlink(filename);
+ g_free(filename);
addritem_free_item_person( item );
}
}
}
}
- if( addrbook.listSelected == NULL ) canEdit = FALSE;
+ if( addrbook.listSelected == NULL )
+ canEdit = FALSE;
/* Enable add */
menu_set_sensitive( addrbook.menu_factory, "/Address/New Address", editAddress );
menu_set_sensitive( addrbook.menu_factory, "/Tools/Export LDIF...", canExport );
}
-static void addressbook_list_menu_setup( void );
-
/**
* Address book tree callback function that responds to selection of tree
* items.
/* Setup main menu selections */
addressbook_menubar_set_sensitive( FALSE );
- addressbook_list_menu_setup();
addressbook_menuitem_set_sensitive( obj, node );
-
addressbook_list_select_clear();
addressbook_list_menu_setup();
return;
/* Parent object is a data source */
ads = ADAPTER_DSOURCE(pobj);
ds = ads->dataSource;
+ if (!ds)
+ return;
iface = ds->interface;
+ if (!iface)
+ return;
if( ! iface->readOnly ) {
menu_set_sensitive( addrbook.list_factory, "/New Address", TRUE );
if (iface->type != ADDR_IF_LDAP)
menu_set_sensitive( addrbook.list_factory, "/New Group", TRUE );
gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
- if( ! addrclip_is_empty( _clipBoard_ ) ) canPaste = TRUE;
- if( ! addrselect_test_empty( _addressSelect_ ) ) canCut = TRUE;
- if( obj ) canEdit = TRUE;
+ if( obj )
+ canEdit = TRUE;
+ canDelete = canEdit;
}
- canDelete = canEdit;
}
else if( pobj->type != ADDR_INTERFACE ) {
/* Parent object is not an interface */
if (!ds)
return;
iface = ds->interface;
+ if (!iface)
+ return;
if( ! iface->readOnly ) {
/* Folder or group */
if( pobj->type == ADDR_ITEM_FOLDER || pobj->type == ADDR_ITEM_GROUP ) {
menu_set_sensitive( addrbook.list_factory, "/New Group", TRUE );
if( obj ) canEdit = TRUE;
}
- if( ! addrclip_is_empty( _clipBoard_ ) ) canPaste = TRUE;
- if( ! addrselect_test_empty( _addressSelect_ ) ) canCut = TRUE;
canDelete = canEdit;
}
- if( iface && iface->type == ADDR_IF_LDAP ) {
+ if( iface->type == ADDR_IF_LDAP ) {
if( obj ) canBrowse = TRUE;
canEdit = TRUE;
canDelete = TRUE;
}
}
- if( ! addrselect_test_empty( _addressSelect_ ) ) canCopy = TRUE;
+
+ if( iface ) {
+ /* Enable cut and paste */
+ if( ! addrclip_is_empty( _clipBoard_ ) )
+ canPaste = TRUE;
+ if( ! addrselect_test_empty( _addressSelect_ ) )
+ canCut = TRUE;
+ /* Enable copy if something is selected */
+ if( ! addrselect_test_empty( _addressSelect_ ) )
+ canCopy = TRUE;
+ }
/* Disable edit or browse if more than one row selected */
if( GTK_CLIST(clist)->selection && GTK_CLIST(clist)->selection->next ) {
canBrowse = FALSE;
}
+ /* Forbid write changes when read-only */
+ if( iface && iface->readOnly ) {
+ canCut = FALSE;
+ canDelete = FALSE;
+ canPaste = FALSE;
+ }
+
/* Now go finalize menu items */
menu_set_sensitive( addrbook.list_factory, "/Edit", canEdit );
menu_set_sensitive( addrbook.list_factory, "/Delete", canDelete );
menu_set_sensitive( addrbook.list_factory, "/Cut", canCut );
menu_set_sensitive( addrbook.list_factory, "/Copy", canCopy );
menu_set_sensitive( addrbook.list_factory, "/Paste", canPaste );
-/* menu_set_sensitive( addrbook.list_factory, "/Paste Address", canPaste );*/
menu_set_sensitive( addrbook.list_factory, "/Mail To", canCopy );
menu_set_sensitive( addrbook.menu_factory, "/Address/Cut", canCut );
menu_set_sensitive( addrbook.menu_factory, "/Address/Copy", canCopy );
menu_set_sensitive( addrbook.menu_factory, "/Address/Paste", canPaste );
-/* menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );*/
-
- menu_set_sensitive( addrbook.tree_factory, "/Cut", canCut );
- menu_set_sensitive( addrbook.tree_factory, "/Copy", canCopy );
- menu_set_sensitive( addrbook.tree_factory, "/Paste", canPaste );
menu_set_sensitive( addrbook.menu_factory, "/Address/Edit", canEdit );
menu_set_sensitive( addrbook.menu_factory, "/Address/Delete", canDelete );
ds = addressbook_find_datasource( GTK_CTREE_NODE(addrbook.treeSelected) );
if( ds == NULL ) return;
if( addrindex_ds_get_readonly( ds ) ) {
- addressbook_ds_status_message(
- ds, _( "Cannot paste. Target address book is readonly." ) );
+ alertpanel_error( _("Cannot paste. Target address book is readonly.") );
return;
}
folder = ADAPTER_FOLDER(pobj)->itemFolder;
}
else if( pobj->type == ADDR_ITEM_GROUP ) {
- addressbook_ds_status_message(
- ds, _( "Cannot paste into an address group." ) );
+ alertpanel_error( _("Cannot paste into an address group.") );
return;
}
}
addressbook_list_menu_setup();
- if (!addrbook.target_compose && !prefs_common.addressbook_use_editaddress_dialog)
- addressbook_edit_address(NULL, 0, NULL, FALSE);
+ if (!addrbook.target_compose && !prefs_common.addressbook_use_editaddress_dialog) {
+ AddressObject *obj = gtk_ctree_node_get_row_data( clist, addrbook.listSelected );
+
+ if (obj && obj->type != ADDR_ITEM_GROUP)
+ addressbook_edit_address(NULL, 0, NULL, FALSE);
+ }
}
static void addressbook_list_row_unselected( GtkCTree *ctree,
addressbook_to_clicked(NULL, GINT_TO_POINTER(COMPOSE_TO));
else
if (prefs_common.addressbook_use_editaddress_dialog)
- addressbook_edit_address_cb(NULL, 0, NULL);
+ addressbook_edit_address_cb(NULL, 0, NULL);
+ else {
+ GtkCTree *clist = GTK_CTREE(addrbook.clist);
+ AddressObject *obj = gtk_ctree_node_get_row_data( clist, addrbook.listSelected );
+ if( obj && obj->type == ADDR_ITEM_GROUP )
+ addressbook_edit_address_cb(NULL, 0, NULL);
+ }
lasttime = 0;
} else
if( ! addrclip_is_empty( _clipBoard_ ) ) {
canTreePaste = TRUE;
}
-
if (obj->type == ADDR_INTERFACE) {
AdapterInterface *adapter = ADAPTER_INTERFACE(obj);
+ if( !adapter )
+ goto just_set_sens;
iface = adapter->interface;
- canEdit = FALSE;
- canDelete = FALSE;
- canTreeCopy = FALSE;
- if( iface->readOnly ) {
- canTreePaste = FALSE;
- }
- else {
+ if( !iface )
+ goto just_set_sens;
+ if( !iface->readOnly ) {
menu_set_sensitive( addrbook.tree_factory, "/New Book", TRUE );
gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
}
if (obj->type == ADDR_DATASOURCE) {
ads = ADAPTER_DSOURCE(obj);
ds = ads->dataSource;
- if (!ds)
+ if( !ds )
goto just_set_sens;
iface = ds->interface;
- if (!iface)
+ if( !iface )
goto just_set_sens;
- canEdit = TRUE;
- canDelete = TRUE;
- if( iface->readOnly ) {
- canTreePaste = FALSE;
- }
- else {
+ if( !iface->readOnly ) {
+ canDelete = TRUE;
menu_set_sensitive( addrbook.tree_factory, "/New Folder", TRUE );
menu_set_sensitive( addrbook.tree_factory, "/New Group", TRUE );
gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
}
+ canEdit = TRUE;
canTreeCopy = TRUE;
if( iface->externalQuery ) canLookup = TRUE;
}
else if (obj->type == ADDR_ITEM_FOLDER) {
ds = addressbook_find_datasource( node );
- if (!ds) {
+ if( !ds )
goto just_set_sens;
- }
iface = ds->interface;
- if (!iface)
+ if( !iface )
goto just_set_sens;
- if( iface->readOnly ) {
- canTreePaste = FALSE;
- }
- else {
+ if( !iface->readOnly ) {
canEdit = TRUE;
canDelete = TRUE;
canTreeCut = TRUE;
}
else if (obj->type == ADDR_ITEM_GROUP) {
ds = addressbook_find_datasource( node );
- if (!ds)
+ if( !ds )
goto just_set_sens;
iface = ds->interface;
- if (!iface)
+ if( !iface )
goto just_set_sens;
if( ! iface->readOnly ) {
canEdit = TRUE;
gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
}
}
- else if (obj->type == ADDR_INTERFACE) {
- canTreePaste = FALSE;
- }
if( canEdit ) {
- if( ! addrselect_test_empty( _addressSelect_ ) ) canCut = TRUE;
+ if( ! addrselect_test_empty( _addressSelect_ ) )
+ canCut = TRUE;
+ }
+ if( ! addrselect_test_empty( _addressSelect_ ) )
+ canCopy = TRUE;
+ if( ! addrclip_is_empty( _clipBoard_ ) )
+ canPaste = TRUE;
+
+ /* Forbid write changes when read-only */
+ if( iface && iface->readOnly ) {
+ canTreeCut = FALSE;
+ canTreePaste = FALSE;
+ canCut = FALSE;
+ canDelete = FALSE;
+ canPaste = FALSE;
}
- if( ! addrselect_test_empty( _addressSelect_ ) ) canCopy = TRUE;
- if( ! addrclip_is_empty( _clipBoard_ ) ) canPaste = TRUE;
just_set_sens:
/* Enable edit */
menu_set_sensitive( addrbook.menu_factory, "/Address/Cut", canCut );
menu_set_sensitive( addrbook.menu_factory, "/Address/Copy", canCopy );
menu_set_sensitive( addrbook.menu_factory, "/Address/Paste", canPaste );
-/* menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );*/
- addressbook_show_buttons(addrbook.target_compose == NULL, canLookup, addrbook.target_compose != NULL);
+ addressbook_show_buttons(addrbook.target_compose == NULL, canLookup,
+ addrbook.target_compose != NULL);
+
if( event->button == 3 ) {
gtk_menu_popup(GTK_MENU(addrbook.tree_popup), NULL, NULL, NULL, NULL,
event->button, event->time);
static void addressbook_edit_address_post_cb( ItemPerson *person )
{
if( person ) {
-
+#ifdef USE_LDAP
+ if (strcmp2(person->nickName, ADDRITEM_NAME(person)))
+ addritem_person_set_nick_name( person, ADDRITEM_NAME(person));
+#endif
addressbook_folder_refresh_one_person( GTK_CTREE(addrbook.clist), person );
invalidate_address_completion();
}
menu_set_sensitive( addrbook.menu_factory, "/Address/Cut", FALSE );
menu_set_sensitive( addrbook.menu_factory, "/Address/Copy", FALSE );
menu_set_sensitive( addrbook.menu_factory, "/Address/Paste", FALSE );
-
- /* we're already editing contact's detail here */
- menu_set_sensitive( addrbook.menu_factory, "/Address/Edit", FALSE );
- gtk_widget_set_sensitive( addrbook.edit_btn, FALSE );
}
static void addressbook_edit_address_cb( gpointer data, guint action, GtkWidget *widget ) {
person = ( ItemPerson * ) ADDRITEM_PARENT(email);
str = addressbook_format_item_clist( person, email );
if( str ) {
- text[COL_NAME] = str;
+ text[COL_NAME] = addressbook_set_col_name_guard(str);
}
else {
- text[COL_NAME] = ADDRITEM_NAME(person);
+ text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
}
text[COL_ADDRESS] = email->address;
text[COL_REMARKS] = email->remarks;
}
}
+gchar *addressbook_set_col_name_guard(gchar *value)
+{
+ gchar *ret = "<not set>";
+ gchar *tmp = g_strdup(value);
+ g_strstrip(tmp);
+ if (tmp !=NULL && *tmp != '\0')
+ ret = value;
+ g_free(tmp);
+ return ret;
+}
+
static void addressbook_folder_load_one_person(
GtkCTree *clist, ItemPerson *person,
AddressTypeControlItem *atci,
gchar *text[N_LIST_COLS];
gboolean flgFirst = TRUE, haveAddr = FALSE;
GList *node;
+#ifdef USE_LDAP
AddressBookFile *abf = addressbook_get_book_file();
+#endif
if( person == NULL ) return;
/* First email belongs with person */
gchar *str = addressbook_format_item_clist( person, email );
if( str ) {
- text[COL_NAME] = str;
+ text[COL_NAME] = addressbook_set_col_name_guard(str);
}
#ifdef USE_LDAP
else if( abf && abf->type == ADDR_IF_LDAP &&
person && person->nickName ) {
if (person->nickName) {
if (strcmp(person->nickName, "") != 0) {
- text[COL_NAME] = person->nickName;
+ text[COL_NAME] = addressbook_set_col_name_guard(person->nickName);
}
else {
- text[COL_NAME] = ADDRITEM_NAME(person);
+ text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
}
}
}
#endif
else {
- text[COL_NAME] = ADDRITEM_NAME(person);
+ text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
}
nodePerson = gtk_sctree_insert_node(
clist, NULL, NULL,
}
if( ! haveAddr ) {
/* Have name without EMail */
- text[COL_NAME] = ADDRITEM_NAME(person);
+ text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
text[COL_ADDRESS] = "";
text[COL_REMARKS] = "";
nodePerson = gtk_sctree_insert_node(
return retVal;
}
+static gboolean migrate_addrbook(const gchar *origdir, const gchar *destdir)
+{
+ DIR *dp;
+ struct dirent *d;
+ gboolean failed = FALSE;
+
+ if( ( dp = opendir( origdir ) ) == NULL ) {
+ return FALSE;
+ }
+
+ while( ( d = readdir( dp ) ) != NULL ) {
+ if (strncmp(d->d_name, "addrbook-", strlen("addrbook-")))
+ continue;
+ else {
+ gchar *orig_file = g_strconcat(origdir, G_DIR_SEPARATOR_S,
+ d->d_name, NULL);
+ gchar *dest_file = g_strconcat(destdir, G_DIR_SEPARATOR_S,
+ d->d_name, NULL);
+ if (copy_file(orig_file, dest_file, FALSE) < 0) {
+ failed = TRUE;
+ }
+ g_free(orig_file);
+ g_free(dest_file);
+ if (failed) {
+ break;
+ }
+ }
+ }
+
+ closedir( dp );
+ if (!failed) {
+ /* all copies succeeded, we can remove source files */
+ if( ( dp = opendir( origdir ) ) == NULL ) {
+ return FALSE;
+ }
+ while( ( d = readdir( dp ) ) != NULL ) {
+ if (strncmp(d->d_name, "addrbook-", strlen("addrbook-")))
+ continue;
+ else {
+ gchar *orig_file = g_strconcat(origdir, G_DIR_SEPARATOR_S,
+ d->d_name, NULL);
+ g_unlink(orig_file);
+ g_free(orig_file);
+ }
+ }
+ closedir( dp );
+ }
+
+ return !failed;
+}
+
void addressbook_read_file( void ) {
AddressIndex *addrIndex = NULL;
-
+ gchar *indexdir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, NULL);
+
debug_print( "Reading address index...\n" );
if( _addressIndex_ ) {
debug_print( "address book already read!!!\n" );
addrindex_initialize();
/* Use new address book index. */
- addrindex_set_file_path( addrIndex, get_rc_dir() );
+
+ if ( !is_dir_exist(indexdir) ) {
+ if ( make_dir(indexdir) < 0 ) {
+ addrindex_set_file_path( addrIndex, get_rc_dir() );
+ g_warning( "couldn't create dir %s\n", indexdir);
+ } else {
+ if (!migrate_addrbook(get_rc_dir(), indexdir)) {
+ remove_dir_recursive(indexdir);
+ addrindex_set_file_path( addrIndex, get_rc_dir() );
+ g_error("couldn't migrate dir %s", indexdir);
+ } else {
+ addrindex_set_file_path( addrIndex, indexdir);
+ }
+ }
+ } else {
+ addrindex_set_file_path( addrIndex, indexdir);
+ }
+ g_free(indexdir);
addrindex_set_file_name( addrIndex, ADDRESSBOOK_INDEX_FILE );
addrindex_read_data( addrIndex );
if( addrIndex->retVal == MGU_NO_FILE ) {
atci->showInTree = FALSE;
atci->treeExpand = FALSE;
atci->treeLeaf = TRUE;
- atci->displayName = _( "EMail Address" );
+ atci->displayName = _( "Email Address" );
atci->iconXpm = addressxpm;
atci->maskXpm = addressxpmmask;
atci->iconXpmOpen = addressxpm;
* This function is used by the Add sender to address book function.
*/
gboolean addressbook_add_contact(
- const gchar *name, const gchar *address, const gchar *remarks )
+ const gchar *name, const gchar *address, const gchar *remarks,
+ GdkPixbuf *picture )
{
debug_print( "addressbook_add_contact: name/address: %s - %s\n", name, address );
- if( addressadd_selection( _addressIndex_, name, address, remarks ) ) {
+ if( addressadd_selection( _addressIndex_, name, address, remarks, picture ) ) {
debug_print( "addressbook_add_contact - added\n" );
addressbook_refresh();
}
addressbook_exp_ldif( cache );
}
+static void addressbook_find_duplicates_cb(void)
+{
+ addrduplicates_find(GTK_WINDOW(addrbook.window));
+}
+
+static void addressbook_edit_custom_attr_cb(void)
+{
+ addressbook_custom_attr_edit();
+}
+
static void addressbook_start_drag(GtkWidget *widget, gint button,
GdkEvent *event,
void *data)
if( ds && ds->interface && ds->interface->readOnly)
gtk_selection_data_set(selection_data,
selection_data->target, 8,
- "Dummy_addr_copy", 15);
+ (const guchar *)"Dummy_addr_copy", 15);
else
gtk_selection_data_set(selection_data,
selection_data->target, 8,
- "Dummy_addr_move", 15);
+ (const guchar *)"Dummy_addr_move", 15);
}
}
if (gtk_clist_get_selection_info
(GTK_CLIST(widget), x - 24, y - 24, &row, &column)) {
- if (y > height - 24 && height + vpos < total_height)
+ if (y > height - 24 && height + vpos < total_height) {
gtk_adjustment_set_value(pos, (vpos+5 > height ? height : vpos+5));
-
- if (y < 24 && y > 0)
+ gtk_adjustment_changed(pos);
+ }
+ if (y < 24 && y > 0) {
gtk_adjustment_set_value(pos, (vpos-5 < 0 ? 0 : vpos-5));
-
+ gtk_adjustment_changed(pos);
+ }
node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
if (node != NULL) {
} else {
gdk_drag_status(context, 0, time);
}
-
return acceptable;
}
/*
* End of Source.
*/
-