if( _clipBoard_ != NULL ) {
addrclip_free( _clipBoard_ );
}
- addrcompl_teardown();
if( _addressIndex_ != NULL ) {
addrindex_free_index( _addressIndex_ );
}
}
if( address ) {
if( name && name[0] != '\0' ) {
- if( strchr_with_skip_quote( name, '"', ',' ) )
+ if( name[0] != '"' && strpbrk( name, ",.[]<>" ) != NULL )
buf = g_strdup_printf( "\"%s\" <%s>", name, address );
else
buf = g_strdup_printf( "%s <%s>", name, address );
person = ( ItemPerson * ) ADDRITEM_PARENT(email);
if( addressbook_edit_person( abf, NULL, person, TRUE ) == NULL ) return;
addressbook_folder_refresh_one_person( clist, person );
+ invalidate_address_completion();
return;
}
}
/* Edit person - basic page */
ItemPerson *person = ( ItemPerson * ) obj;
if( addressbook_edit_person( abf, NULL, person, FALSE ) == NULL ) return;
+ invalidate_address_completion();
addressbook_folder_refresh_one_person( clist, person );
return;
}
}
}
-static void addressbook_folder_load_one_person( GtkCTree *clist, ItemPerson *person,
- AddressTypeControlItem *atci, AddressTypeControlItem *atciMail) {
-
+static void addressbook_folder_load_one_person(
+ GtkCTree *clist, ItemPerson *person,
+ AddressTypeControlItem *atci,
+ AddressTypeControlItem *atciMail )
+{
GtkCTreeNode *nodePerson = NULL;
GtkCTreeNode *nodeEMail = NULL;
gchar *text[N_COLS];
addrbook.listSelected = NULL;
gtk_ctree_remove_node( clist, node );
addressbook_menubar_set_sensitive( FALSE );
- addressbook_menuitem_set_sensitive( gtk_ctree_node_get_row_data(
- GTK_CTREE(clist), addrbook.treeSelected ), addrbook.treeSelected );
+ addressbook_menuitem_set_sensitive(
+ gtk_ctree_node_get_row_data(
+ GTK_CTREE(clist), addrbook.treeSelected ),
+ addrbook.treeSelected );
}
static void addressbook_folder_refresh_one_person( GtkCTree *clist, ItemPerson *person ) {
/* Load root folder */
ItemFolder *rootFolder = NULL;
rootFolder = addrindex_ds_get_root_folder( ds );
- addressbook_folder_load_person( ctreelist, addrindex_ds_get_root_folder( ds ) );
- addressbook_folder_load_group( ctreelist, addrindex_ds_get_root_folder( ds ) );
+ addressbook_folder_load_person(
+ ctreelist, addrindex_ds_get_root_folder( ds ) );
+ addressbook_folder_load_group(
+ ctreelist, addrindex_ds_get_root_folder( ds ) );
}
}
else {
}
void addressbook_ads_set_name( AdapterDSource *adapter, gchar *value ) {
- ADDRESS_OBJECT_NAME(adapter) = mgu_replace_string( ADDRESS_OBJECT_NAME(adapter), value );
+ ADDRESS_OBJECT_NAME(adapter) =
+ mgu_replace_string( ADDRESS_OBJECT_NAME(adapter), value );
}
/*
ds = nodeDS->data;
newNode = NULL;
name = addrindex_ds_get_name( ds );
- ads = addressbook_create_ds_adapter( ds, atci->objectType, name );
- newNode = addressbook_add_object( node, ADDRESS_OBJECT(ads) );
+ ads = addressbook_create_ds_adapter(
+ ds, atci->objectType, name );
+ newNode = addressbook_add_object(
+ node, ADDRESS_OBJECT(ads) );
nodeDS = g_list_next( nodeDS );
}
gtk_ctree_expand( ctree, node );
}
addrIndex = addrindex_create_index();
- addrcompl_initialize();
/* Use new address book index. */
addrindex_set_file_path( addrIndex, get_rc_dir() );
newNode = gtk_ctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm, atci->iconXpm, atci->maskXpm,
atci->treeLeaf, atci->treeExpand );
- if( newNode )
- gtk_ctree_node_set_row_data_full( ctree, newNode, adapter,
- addressbook_free_treenode );
+ gtk_ctree_node_set_row_data_full( ctree, newNode, adapter,
+ addressbook_free_treenode );
}
listItems = itemFolder->listFolder;
if( _addressIndex_->retVal != MGU_SUCCESS ) {
addrindex_print_index( _addressIndex_, stdout );
}
+
+ /* Notify address completion of new data */
+ invalidate_address_completion();
}
}
*/
static void addressbook_lup_clicked( GtkButton *button, gpointer data ) {
GtkCTree *ctree = GTK_CTREE(addrbook.ctree);
- AddressObject *pobj;
AddressObject *obj;
AdapterDSource *ads = NULL;
gchar *sLookup;
- GtkCTreeNode *node = NULL, *parentNode = NULL;
if( ! addrbook.treeSelected ) return;
if( GTK_CTREE_ROW( addrbook.treeSelected )->level == 1 ) return;
sLookup = gtk_editable_get_chars( GTK_EDITABLE(addrbook.entry), 0, -1 );
g_strchomp( sLookup );
- /* printf( "addressbook_lup_clicked/Lookup: '%s'\n", sLookup ); */
if( obj->type == ADDR_DATASOURCE ) {
- /* printf( "I am a datasource\n" ); */
ads = ADAPTER_DSOURCE(obj);
- }
- else {
- /* printf( "Test my parent\n" ); */
- parentNode = GTK_CTREE_ROW(addrbook.treeSelected)->parent;
- obj = gtk_ctree_node_get_row_data( ctree, parentNode );
- if( obj->type == ADDR_DATASOURCE ) {
- ads = ADAPTER_DSOURCE(obj);
- }
- }
#ifdef USE_LDAP
- if( ads && ads->subType == ADDR_LDAP ) {
- addressbook_ldap_lookup( ads, sLookup );
+ if( ads->subType == ADDR_LDAP ) {
+ addressbook_ldap_lookup( ads, sLookup );
+ }
+#endif /* USE_LDAP */
}
-#endif
+
g_free( sLookup );
}
return TRUE;
}
+/* **********************************************************************
+* Address completion support.
+* ***********************************************************************
+*/
+
+/*
+* This function is used by the address completion function to load
+* addresses.
+* Enter: callBackFunc Function to be called when an address is
+* to be loaded.
+* Return: TRUE if data loaded, FALSE if address index not loaded.
+*/
+gboolean addressbook_load_completion( gint (*callBackFunc) ( const gchar *, const gchar *, const gchar * ) ) {
+ AddressDataSource *ds;
+ GList *nodeIf, *nodeDS;
+ GList *listP, *nodeP;
+ GList *nodeM;
+ gchar *sName, *sAddress, *sAlias, *sFriendly;
+
+ debug_print( "addressbook_load_completion\n" );
+
+ if( _addressIndex_ == NULL ) return FALSE;
+
+ nodeIf = addrindex_get_interface_list( _addressIndex_ );
+ while( nodeIf ) {
+ AddressInterface *interface = nodeIf->data;
+ nodeDS = interface->listSource;
+ while( nodeDS ) {
+ ds = nodeDS->data;
+
+ /* Read address book */
+ if( addrindex_ds_get_modify_flag( ds ) ) {
+ addrindex_ds_read_data( ds );
+ }
+
+ if( ! addrindex_ds_get_read_flag( ds ) ) {
+ addrindex_ds_read_data( ds );
+ }
+
+ /* Get all persons */
+ listP = addrindex_ds_get_all_persons( ds );
+ nodeP = listP;
+ while( nodeP ) {
+ ItemPerson *person = nodeP->data;
+ nodeM = person->listEMail;
+
+ /* Figure out name to use */
+ sName = person->nickName;
+ if( sName == NULL || *sName == '\0' ) {
+ sName = ADDRITEM_NAME(person);
+ }
+
+ /* Process each E-Mail address */
+ while( nodeM ) {
+ ItemEMail *email = nodeM->data;
+ /* Have mail */
+ sFriendly = sName;
+ sAddress = email->address;
+ if( sAddress || *sAddress != '\0' ) {
+ sAlias = ADDRITEM_NAME(email);
+ if( sAlias && *sAlias != '\0' ) {
+ sFriendly = sAlias;
+ }
+ ( callBackFunc ) ( sFriendly, sAddress, sName );
+ }
+
+ nodeM = g_list_next( nodeM );
+ }
+ nodeP = g_list_next( nodeP );
+ }
+ /* Free up the list */
+ g_list_free( listP );
+
+ nodeDS = g_list_next( nodeDS );
+ }
+ nodeIf = g_list_next( nodeIf );
+ }
+ debug_print( "addressbook_load_completion... done\n" );
+
+ return TRUE;
+}
+
/* **********************************************************************
* Address Import.
* ***********************************************************************
newNode );
addrbook.treeSelected = newNode;
}
+
+ /* Notify address completion */
+ invalidate_address_completion();
}
}
}
newNode );
addrbook.treeSelected = newNode;
}
+
+ /* Notify address completion */
+ invalidate_address_completion();
}
}
}
newNode );
addrbook.treeSelected = newNode;
}
+
+ /* Notify address completion */
+ invalidate_address_completion();
}
}
}
ADDRESS_OBJECT(ads) );
}
}
+
+ /* Notify address completion */
+ invalidate_address_completion();
}
}
/*
* End of Source.
*/
-/* **********************************************************************
-* Address completion and search support.
-* ***********************************************************************
-*/
-
-/**
- * Setup search for specified search string.
- * \param searchTerm Search string.
- * \param target Target data.
- * \param callBack Call back function.
- * \return ID allotcated to this query, or 0 if none.
- */
-gint addressbook_setup_search(
- const gchar *searchTerm, const gpointer target,
- AddrSearchCallbackFunc callback )
-{
- if( _addressIndex_ == NULL ) {
- printf( "address index not loaded\n" );
- return 0;
- }
- return addrindex_setup_search( _addressIndex_, searchTerm, target, callback );
-}
-
-/**
- * Perform the previously registered search.
- * \param queryID ID of search query to be executed.
- * \return <i>TRUE</i> if search started successfully, or <i>FALSE</i> if
- * failed.
- */
-gboolean addressbook_start_search( const gint queryID ) {
- if( _addressIndex_ == NULL ) {
- printf( "address index not loaded\n" );
- return FALSE;
- }
- return addrindex_start_search( _addressIndex_, queryID );
-}
-
-/**
- * Stop the previously registered search.
- * \param queryID ID of search query to stop.
- */
-void addressbook_stop_search( const gint queryID ){
- if( _addressIndex_ == NULL ) {
- /* printf( "address index not loaded\n" ); */
- return;
- }
- addrindex_stop_search( _addressIndex_, queryID );
-}
-
-/**
- * Read all address interfaces and data sources.
- */
-void addressbook_read_all( void ) {
- if( _addressIndex_ == NULL ) {
- /* Load index file */
- /* printf( "address index not loaded\n" ); */
- /* addressbook_read_file(); */
- }
-
- if( ! addrindex_get_loaded( _addressIndex_ ) ) {
- /* Read all address books */
- addrindex_read_all( _addressIndex_ );
- }
- /*
- else {
- printf( "Address data already loaded!!!!!!!!!!!!!!!\n" );
- }
- */
-}
-
-/**
- * Perform a simple search of all non-query type data sources for specified
- * search term. If several entries are found, only the first item is
- * returned. Interfaces that require a time-consuming "query" are ignored for
- * this search.
- *
- * \param searchTerm Search term to find. Typically an email address.
- * \return Reference to a single E-Mail object that was found in the address
- * book, or <i>NULL</i> if nothing found. This should *NOT* be freed
- * when done.
- */
-ItemEMail *addressbook_quick_search_single( const gchar *searchTerm ) {
- if( _addressIndex_ == NULL ) {
- /* printf( "address index not loaded\n" ); */
- return NULL;
- }
- return addrindex_quick_search_single( _addressIndex_, searchTerm );
-}
-
-/**
- * Perform a simple search of all non-query type data sources for specified
- * search term. If several entries are found, only the first item is
- * returned. Interfaces that require a time-consuming "query" are ignored for
- * this search.
- *
- * \param addrIndex Address index object.
- * \param searchTerm Search term to find. Typically an email address.
- * \return List of references to zero or mail E-Mail object that was found in
- * the address books, or <i>NULL</i> if nothing found. This list
- * *SHOULD* be freed when done.
- */
-GList *addressbook_quick_search_list( const gchar *searchTerm )
-{
- if( _addressIndex_ == NULL ) {
- printf( "address index not loaded\n" );
- return NULL;
- }
- return addrindex_quick_search_list( _addressIndex_, searchTerm );
-}
-/*
-* End of Source.
-*/