LDAP static search.
[claws.git] / src / addressbook.c
index a76ca489c5a58cd44f47adc0584998093e1d2745..6daf690400b23cea8561f065e2526b091d7c92ab 100644 (file)
@@ -135,6 +135,8 @@ static GdkPixmap *categoryxpm;
 static GdkBitmap *categoryxpmmask;
 static GdkPixmap *ldapxpm;
 static GdkBitmap *ldapxpmmask;
+static GdkPixmap *addrsearchxpm;
+static GdkPixmap *addrsearchxpmmask;
 
 /* Message buffer */
 static gchar addressbook_msgbuf[ ADDRESSBOOK_MSGBUF_SIZE ];
@@ -862,6 +864,7 @@ static void addressbook_create(void)
        addrbook.listSelected = NULL;
        address_completion_start(window);
        gtk_widget_show_all(window);
+       gtk_widget_set_sensitive(addrbook.lup_btn, FALSE);
 
 }
 
@@ -938,7 +941,6 @@ static void addressbook_button_set_sensitive(void)
                        bcc_sens = TRUE;
        }
 
-       gtk_widget_set_sensitive(addrbook.lup_btn, FALSE);
        gtk_widget_set_sensitive(addrbook.to_btn, to_sens);
        gtk_widget_set_sensitive(addrbook.cc_btn, cc_sens);
        gtk_widget_set_sensitive(addrbook.bcc_btn, bcc_sens);
@@ -1277,6 +1279,15 @@ static void addressbook_menuitem_set_sensitive( AddressObject *obj, GtkCTreeNode
        menu_set_sensitive( addrbook.menu_factory, "/Tools/Export LDIF...", canExport );
 }
 
+/**
+ * Address book tree callback function that responds to selection of tree
+ * items.
+ *
+ * \param ctree  Tree widget.
+ * \param node   Node that was selected.
+ * \param column Column number where selected occurred.
+ * \param data   Pointer to user data.
+ */
 static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
                                      gint column, gpointer data)
 {
@@ -1284,6 +1295,7 @@ static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
        AdapterDSource *ads = NULL;
        AddressDataSource *ds = NULL;
        ItemFolder *rootFolder = NULL;
+       AddressObjectType aot;
 
        addrbook.treeSelected = node;
        addrbook.listSelected = NULL;
@@ -1323,11 +1335,15 @@ static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
                        /* Load folders into the tree */
                        rootFolder = addrindex_ds_get_root_folder( ds );
                        if( ds->type == ADDR_IF_JPILOT ) {
-                               addressbook_node_add_folder( node, ds, rootFolder, ADDR_CATEGORY );
+                               aot = ADDR_CATEGORY;
+                       }
+                       else if( ds->type == ADDR_IF_LDAP ) {
+                               aot = ADDR_LDAP_QUERY;
                        }
                        else {
-                               addressbook_node_add_folder( node, ds, rootFolder, ADDR_ITEM_FOLDER );
+                               aot = ADDR_ITEM_FOLDER;
                        }
+                       addressbook_node_add_folder( node, ds, rootFolder, aot );
                        addrindex_ds_set_access_flag( ds, &tVal );
                        gtk_ctree_expand( ctree, node );
                }
@@ -1819,6 +1835,7 @@ static void addressbook_tree_button_pressed(GtkWidget *ctree,
        gboolean canTreeCut = FALSE;
        gboolean canTreeCopy = FALSE;
        gboolean canTreePaste = FALSE;
+       gboolean canLookup = FALSE;
 
        if( ! event ) return;
        addressbook_menubar_set_sensitive( FALSE );
@@ -1830,6 +1847,7 @@ static void addressbook_tree_button_pressed(GtkWidget *ctree,
        }
 
        menu_set_insensitive_all(GTK_MENU_SHELL(addrbook.tree_popup));
+       gtk_widget_set_sensitive( addrbook.lup_btn, FALSE );
 
        if( obj == NULL ) return;
 
@@ -1852,6 +1870,7 @@ static void addressbook_tree_button_pressed(GtkWidget *ctree,
                        gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
                }
                canTreeCopy = TRUE;
+               if( iface->externalQuery ) canLookup = TRUE;
        }
        else if (obj->type == ADDR_ITEM_FOLDER) {
                ds = addressbook_find_datasource( addrbook.treeSelected );
@@ -1868,6 +1887,8 @@ static void addressbook_tree_button_pressed(GtkWidget *ctree,
                        gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
                }
                canTreeCopy = TRUE;
+               iface = ds->interface;
+               if( iface->externalQuery ) canLookup = TRUE;
        }
        else if (obj->type == ADDR_ITEM_GROUP) {
                ds = addressbook_find_datasource( addrbook.treeSelected );
@@ -1902,6 +1923,8 @@ static void addressbook_tree_button_pressed(GtkWidget *ctree,
        menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste",         canPaste );
        menu_set_sensitive( addrbook.menu_factory, "/Edit/Paste Address", canPaste );
 
+       gtk_widget_set_sensitive( addrbook.lup_btn, canLookup );
+
        if( event->button == 3 ) {
                gtk_menu_popup(GTK_MENU(addrbook.tree_popup), NULL, NULL, NULL, NULL,
                               event->button, event->time);
@@ -3091,7 +3114,10 @@ static GtkCTreeNode *addressbook_add_object(GtkCTreeNode *node,
 *        itemGroup Group to add.
 * Return: Inserted node.
 */
-static GtkCTreeNode *addressbook_node_add_group( GtkCTreeNode *node, AddressDataSource *ds, ItemGroup *itemGroup ) {
+static GtkCTreeNode *addressbook_node_add_group(
+               GtkCTreeNode *node, AddressDataSource *ds,
+               ItemGroup *itemGroup )
+{
        GtkCTree *ctree = GTK_CTREE(addrbook.ctree);
        GtkCTreeNode *newNode;
        AdapterGroup *adapter;
@@ -3119,13 +3145,16 @@ static GtkCTreeNode *addressbook_node_add_group( GtkCTreeNode *node, AddressData
        return newNode;
 }
 
-/*
-* Add folder into the address index tree.
-* Enter: node      Parent node.
-*        ds         Data source.
-*        itemFolder Folder to add.
-*        otype      Object type to display.
-* Return: Inserted node.
+/**
+ * Add folder into the address index tree. Only visible folders are loaded into
+ * the address index tree. Note that the root folder is not inserted into the
+ * tree.
+ *
+ * \param  node              Parent node.
+ * \param  ds         Data source.
+ * \param  itemFolder Folder to add.
+ * \param  otype      Object type to display.
+ * \return Inserted node for the folder.
 */
 static GtkCTreeNode *addressbook_node_add_folder(
                GtkCTreeNode *node, AddressDataSource *ds,
@@ -3136,9 +3165,12 @@ static GtkCTreeNode *addressbook_node_add_folder(
        AdapterFolder *adapter;
        AddressTypeControlItem *atci = NULL;
        GList *listItems = NULL;
-       gchar **name;
+       gchar *name;
        ItemFolder *rootFolder;
 
+       /* Only visible folders */
+       if( itemFolder->isHidden ) return NULL;
+
        if( ds == NULL ) return NULL;
        if( node == NULL || itemFolder == NULL ) return NULL;
 
@@ -3151,14 +3183,13 @@ static GtkCTreeNode *addressbook_node_add_folder(
                newNode = node;
        }
        else {
-               name = &itemFolder->obj.name;
-
                adapter = g_new0( AdapterFolder, 1 );
                ADDRESS_OBJECT_TYPE(adapter) = ADDR_ITEM_FOLDER;
                ADDRESS_OBJECT_NAME(adapter) = g_strdup( ADDRITEM_NAME(itemFolder) );
                adapter->itemFolder = itemFolder;
 
-               newNode = gtk_ctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
+               name = ADDRITEM_NAME(itemFolder);
+               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 ) {
@@ -3331,147 +3362,193 @@ static void addressbook_new_ldap_cb( gpointer data, guint action, GtkWidget *wid
                }
        }
 }
+#endif
 
-static void addressbook_ldap_show_message( LdapServer *svr ) {
-       gchar *name;
-       gchar *desc;
+/**
+ * Display address search status message.
+ * \param queryType Query type.
+ * \param status    Status/Error code.
+ */
+static void addressbook_search_message( AddrQueryType queryType, gint sts ) {
+       gchar *desc = NULL;
        *addressbook_msgbuf = '\0';
-       if( svr ) {
-               name = ldapsvr_get_name( svr );
-               if( svr->retVal == MGU_SUCCESS ) {
-                       g_snprintf( addressbook_msgbuf,
-                                   sizeof(addressbook_msgbuf), "%s",
-                                   name );
+
+       if( sts != MGU_SUCCESS ) {
+               if( queryType == ADDRQUERY_LDAP ) {
+#ifdef USE_LDAP                        
+                       desc = addressbook_err2string( _lutErrorsLDAP_, sts );
+#endif
                }
                else {
-                       desc = addressbook_err2string(
-                                       _lutErrorsLDAP_, svr->retVal );
-                       g_snprintf( addressbook_msgbuf,
-                                   sizeof(addressbook_msgbuf),
-                                   "%s: %s", name, desc );
+                       desc = NULL;
                }
+               g_snprintf( addressbook_msgbuf,
+                       sizeof(addressbook_msgbuf), "%s", desc );
        }
        addressbook_status_show( addressbook_msgbuf );
 }
 
-static void addressbook_ldap_show_results( LdapServer *server ) {
-       GtkCTree *ctree = GTK_CTREE(addrbook.ctree);
+/**
+ * Refresh addressbook by forcing refresh of current selected object in
+ * tree.
+ */
+static void addressbook_refresh_current( void ) {
        AddressObject *obj;
-       AdapterDSource *ads = NULL;
-       AddressDataSource *ds = NULL;
-       AddressInterface *iface = NULL;
-
-       if( server == NULL ) return;
-       if( ! addrbook.treeSelected ) return;
-       if( GTK_CTREE_ROW( addrbook.treeSelected )->level == 1 ) return;
+       GtkCTree *ctree;
 
+       ctree = GTK_CTREE(addrbook.ctree);
        obj = gtk_ctree_node_get_row_data( ctree, addrbook.treeSelected );
        if( obj == NULL ) return;
-       if( obj->type == ADDR_DATASOURCE ) {
-               ads = ADAPTER_DSOURCE(obj);
-               if( ads->subType == ADDR_LDAP ) {
-                       LdapServer *ldapSvr;
-
-                       ds = ads->dataSource;
-                       if( ds == NULL ) return;
-                       iface = ds->interface;
-                       if( ! iface->haveLibrary ) return;
-                       server = ds->rawDataSource;
-                       if( ldapSvr == server ) {
-                               /* Read from cache */
-                               gtk_widget_show_all(addrbook.window);
-                               addressbook_set_clist( obj );
-                               addressbook_ldap_show_message( server );
-                               gtk_widget_show_all(addrbook.window);
-                               gtk_entry_set_text( GTK_ENTRY(addrbook.entry), "" );
-                       }
-               }
-       }
+       addressbook_set_clist( obj );
 }
 
-static gint _idleID_ = 0;
-static gchar *_tempMessage_ = N_("Busy searching LDAP...");
+static gchar *_tempMessage_ = N_("Busy searching...");
 
-/*
- * LDAP idle function. This function is called during UI idle time while
- * an LDAP search is in progress.
- * Enter: data Reference to LDAP server object.
+/**
+ * Address search idle function. This function is called during UI idle time
+ * while a search is in progress.
+ *
+ * \param data Idler data.
  */
-static void addressbook_ldap_idle( gpointer data ) {
+static void addressbook_search_idle( gpointer data ) {
+       /*
+       gint queryID;
+
+       queryID = GPOINTER_TO_INT( data );
+       printf( "addressbook_ldap_idle... queryID=%d\n", queryID );
+       */
 }
 
-/*
- * LDAP search completion function.
+/**
+ * Search completion function. This removes the query from the idle list.
+ *
+ * \param queryID   Query to be removed.
+ * \param queryType Query type being removed.
+ * \param status    Search status.
  */
-static void addressbook_ldap_idle_end( void ) {
-       /* Server has completed search - remove from idle list */
-       printf( "addressbook_ldap_idle_end... completed" );
-       if( _idleID_ != 0 ) {
-               gtk_idle_remove( _idleID_ );
+static void addressbook_search_idle_end(
+               gint queryID, AddrQueryType queryType, gint status )
+{
+       gpointer data;
+
+       data = GINT_TO_POINTER( queryID );
+       if( data ) {
+               gtk_idle_remove_by_data( data );
        }
-       _idleID_ = 0;
+       addressbook_refresh_current();
+       addressbook_search_message( queryType, status );
 }
 
-/*
- * Perform lookup for LDAP search.
- * Enter: ads     Adapter for data source.
- *        sLookup Lookup string.
+/**
+ * Perform search.
+ *
+ * \param ds         Data source to search.
+ * \param searchTerm String to lookup.
+ * \param pNode      Parent data source node.
  */
-static void addressbook_ldap_lookup( AdapterDSource *ads, gchar *sLookup ) {
-       AddressDataSource *ds = NULL;
-       AddressInterface *iface = NULL;
-       LdapServer *server;
+static void addressbook_perform_search(
+               AddressDataSource *ds, gchar *searchTerm,
+               GtkCTreeNode *pNode )
+{
+       AddressBookFile *abf;
+       ItemFolder *folder;
+       GtkCTree *ctree;
+       GtkCTreeNode *nNode;
+       gchar *name;
+       gint queryID;
+       guint idleID;
+       AddressObjectType aoType;
+
+       if( ds->type == ADDR_IF_LDAP ) {
+#ifdef USE_LDAP
+               aoType = ADDR_LDAP_QUERY;
+#endif
+       }
+       else {
+               return;
+       }
+       abf = ds->rawDataSource;
+
+       /* Setup a query */
+       if( *searchTerm == '\0' || strlen( searchTerm ) < 1 ) return;
 
-       printf( "addressbook_ldap_lookup/Searching for '%s'\n", sLookup );
-       ds = ads->dataSource;
-       if( ds == NULL ) return;
-       iface = ds->interface;
-       if( ! iface->haveLibrary ) return;
-       server = ds->rawDataSource;
-       if( server ) {
-               printf( "addressbook_ldap_lookup/Starting.../1\n" );
-               if( *sLookup == '\0' || strlen( sLookup ) < 1 ) return;
 
-               /* Setup a query */
-               printf( "addressbook_ldap_lookup/Starting.../2\n" );
+       /* Create a folder for the search results */
+       folder = addrbook_add_new_folder( abf, NULL );
+       name = g_strdup_printf( "Search '%s'", searchTerm );
+       addritem_folder_set_name( folder, name );
+       addritem_folder_set_remarks( folder, "" );
+       g_free( name );
 
-               /* Sit back and wait for something to happen */
-               _idleID_ = gtk_idle_add(
-                       ( GtkFunction ) addressbook_ldap_idle, NULL );
-               addrindex_search_ldap_noid( server, sLookup, addressbook_ldap_idle_end  );
-               addressbook_status_show( _tempMessage_ );
+       /* Now let's see the folder */
+       ctree = GTK_CTREE(addrbook.ctree);
+       nNode = addressbook_node_add_folder( pNode, ds, folder, aoType );
+       gtk_ctree_expand( ctree, pNode );
+       if( nNode ) {
+               gtk_ctree_select( ctree, nNode );
+               addrbook.treeSelected = nNode;
        }
+
+       /* Setup the search */
+       queryID = addrindex_setup_static_search(
+                       ds, searchTerm, folder, addressbook_search_idle_end );
+       if( queryID == 0 ) return;
+
+       /* Set up idler function */
+       idleID = gtk_idle_add(
+                       ( GtkFunction ) addressbook_search_idle,
+                       GINT_TO_POINTER( queryID ) );
+
+       /* Start search, sit back and wait for something to happen */
+       addrindex_start_static_search( queryID, idleID );
+
+       addressbook_status_show( _tempMessage_ );
 }
-#endif /* USE_LDAP */
 
-/*
- * Lookup button handler.
+/**
+ * Lookup button handler. Address search is only performed against
+ * address interfaces for external queries.
+ *
+ * \param button Lookup button widget.
+ * \param data   Data object.
  */
 static void addressbook_lup_clicked( GtkButton *button, gpointer data ) {
-       GtkCTree *ctree = GTK_CTREE(addrbook.ctree);
+       GtkCTree *ctree;
        AddressObject *obj;
-       AdapterDSource *ads = NULL;
-       gchar *sLookup;
+       AddressDataSource *ds;
+       AddressInterface *iface;
+       gchar *searchTerm;
+       GtkCTreeNode *node, *parentNode;
 
-       if( ! addrbook.treeSelected ) return;
-       if( GTK_CTREE_ROW( addrbook.treeSelected )->level == 1 ) return;
+       node = addrbook.treeSelected;
+       if( ! node ) return;
+       if( GTK_CTREE_ROW(node)->level == 1 ) return;
 
-       obj = gtk_ctree_node_get_row_data( ctree, addrbook.treeSelected );
+       ctree = GTK_CTREE(addrbook.ctree);
+       obj = gtk_ctree_node_get_row_data( ctree, node );
        if( obj == NULL ) return;
 
-       sLookup = gtk_editable_get_chars( GTK_EDITABLE(addrbook.entry), 0, -1 );
-       g_strchomp( sLookup );
+       ds = addressbook_find_datasource( node );
+       if( ds == NULL ) return;
 
-       if( obj->type == ADDR_DATASOURCE ) {
-               ads = ADAPTER_DSOURCE(obj);
-#ifdef USE_LDAP
-               if( ads->subType == ADDR_LDAP ) {
-                       addressbook_ldap_lookup( ads, sLookup );
-               }
-#endif /* USE_LDAP */
+       /* We must have a datasource that is an external interface */
+       iface = ds->interface;
+       if( ! iface->haveLibrary ) return;
+       if( ! iface->externalQuery ) return;
+
+       searchTerm =
+               gtk_editable_get_chars( GTK_EDITABLE(addrbook.entry), 0, -1 );
+       g_strchomp( searchTerm );
+
+       if( obj->type == ADDR_ITEM_FOLDER ) {
+               parentNode = GTK_CTREE_ROW(node)->parent;
+       }
+       else {
+               parentNode = node;
        }
+       addressbook_perform_search( ds, searchTerm, parentNode );
 
-       g_free( sLookup );
+       g_free( searchTerm );
 }
 
 /* **********************************************************************
@@ -3514,6 +3591,7 @@ void addrbookctl_build_map( GtkWidget *window ) {
        stock_pixmap_gdk(window, STOCK_PIXMAP_JPILOT, &jpilotxpm, &jpilotxpmmask);
        stock_pixmap_gdk(window, STOCK_PIXMAP_CATEGORY, &categoryxpm, &categoryxpmmask);
        stock_pixmap_gdk(window, STOCK_PIXMAP_LDAP, &ldapxpm, &ldapxpmmask);
+       stock_pixmap_gdk(window, STOCK_PIXMAP_ADDRESS_SEARCH, &addrsearchxpm, &addrsearchxpmmask);
 
        _addressBookTypeHash_ = g_hash_table_new( g_int_hash, g_int_equal );
        _addressBookTypeList_ = NULL;
@@ -3668,7 +3746,7 @@ void addrbookctl_build_map( GtkWidget *window ) {
        atci->interfaceType = ADDR_IF_LDAP;
        atci->showInTree = TRUE;
        atci->treeExpand = TRUE;
-       atci->treeLeaf = TRUE;
+       atci->treeLeaf = FALSE;
        atci->displayName = _( "LDAP Server" );
        atci->iconXpm = ldapxpm;
        atci->maskXpm = ldapxpmmask;
@@ -3678,6 +3756,22 @@ void addrbookctl_build_map( GtkWidget *window ) {
        g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
        _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
 
+       /* LDAP Query  */
+       atci = g_new0( AddressTypeControlItem, 1 );
+       atci->objectType = ADDR_LDAP_QUERY;
+       atci->interfaceType = ADDR_IF_LDAP;
+       atci->showInTree = TRUE;
+       atci->treeExpand = FALSE;
+       atci->treeLeaf = TRUE;
+       atci->displayName = _( "LDAP Query" );
+       atci->iconXpm = addrsearchxpm;
+       atci->maskXpm = addrsearchxpmmask;
+       atci->iconXpmOpen = addrsearchxpm;
+       atci->maskXpmOpen = addrsearchxpmmask;
+       atci->menuCommand = NULL;
+       g_hash_table_insert( _addressBookTypeHash_, &atci->objectType, atci );
+       _addressBookTypeList_ = g_list_append( _addressBookTypeList_, atci );
+
 }
 
 /*
@@ -3809,7 +3903,6 @@ void addrbookctl_build_ifselect() {
        gchar *endptr = NULL;
        gboolean enabled;
        AdapterInterface *adapter;
-       /* GList *node; */
 
        selectStr = g_strdup( ADDRESSBOOK_IFACE_SELECTION );
 
@@ -3844,7 +3937,6 @@ void addrbookctl_build_ifselect() {
        g_list_free( _addressIFaceSelection_ );
        _addressIFaceSelection_ = newList;
        newList = NULL;
-
 }
 
 /* **********************************************************************
@@ -3876,74 +3968,11 @@ gboolean addressbook_add_contact( const gchar *name, const gchar *address, const
 *                     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;
-
+gboolean addressbook_load_completion(
+               gint (*callBackFunc) ( const gchar *, const gchar *, const gchar * ) )
+{
        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;
+       return addrindex_load_completion( _addressIndex_, callBackFunc );
 }
 
 /* **********************************************************************