f100cf894f
Cherrypick from master 2003-12-30 08:59:01 UTC twb 'redesign, move, fix icon theme selector': doc/.cvsignore doc/Makefile.am doc/src/ChangeLog.claws-pre0.8.0 po/zh_CN.po src/addrdefs.h src/browseldap.c src/browseldap.h src/gtk/progressdialog.c src/gtk/progressdialog.h src/ldaplocate.c src/ldaplocate.h src/localfolder.c src/localfolder.h src/pgpmime.h src/pixmaps/check_spelling.xpm src/pixmaps/mime_message.xpm src/pixmaps/offline.xpm src/pixmaps/online.xpm src/pixmaps/privacy_expired.xpm src/pixmaps/privacy_failed.xpm src/pixmaps/privacy_passed.xpm src/pixmaps/privacy_signed.xpm src/pixmaps/privacy_unknown.xpm src/pixmaps/privacy_warn.xpm src/prefs_themes.h src/privacy.c src/privacy.h src/remotefolder.c src/remotefolder.h src/sgpgme.c src/sgpgme.h
150 lines
3.7 KiB
C
150 lines
3.7 KiB
C
/*
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
|
* Copyright (C) 2003 Match Grun
|
|
*
|
|
* 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
|
|
* (at your option) any later version.
|
|
*
|
|
* 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 Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/*
|
|
* Functions to perform searches for LDAP entries.
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
|
|
#ifdef USE_LDAP
|
|
|
|
#include <glib.h>
|
|
#include "addrquery.h"
|
|
#include "ldapserver.h"
|
|
#include "ldapquery.h"
|
|
|
|
/**
|
|
* Setup the search that will be performed and registered with the query
|
|
* manager.
|
|
*
|
|
* \param server LDAP server object.
|
|
* \param searchTerm Search term to locate.
|
|
* \param callBackEntry Function to call when each attribute is returned.
|
|
* \param callBackEnd Function to call when search is complete.
|
|
* \return Query ID allocated to query that will be executed.
|
|
*/
|
|
gint ldaplocate_search_setup(
|
|
LdapServer *server, const gchar *searchTerm, void *callBackEntry,
|
|
void *callBackEnd )
|
|
{
|
|
QueryRequest *req;
|
|
LdapQuery *qry;
|
|
gint queryID;
|
|
gchar *name;
|
|
|
|
/* Name the query */
|
|
name = g_strdup_printf( "Locate '%s'", searchTerm );
|
|
|
|
/* Set up a generic address query */
|
|
req = qrymgr_add_request( searchTerm, callBackEnd, callBackEntry );
|
|
qryreq_set_search_type( req, ADDRSEARCH_LOCATE );
|
|
queryID = req->queryID;
|
|
|
|
/* Construct a query */
|
|
qry = ldapqry_create();
|
|
ldapqry_set_query_id( qry, queryID );
|
|
ldapqry_set_name( qry, name );
|
|
ldapqry_set_search_value( qry, searchTerm );
|
|
ldapqry_set_search_type( qry, ADDRSEARCH_LOCATE );
|
|
ldapqry_set_callback_end( qry, callBackEnd );
|
|
ldapqry_set_callback_entry( qry, callBackEntry );
|
|
|
|
/* Setup server */
|
|
ldapsvr_add_query( server, qry );
|
|
|
|
/* Set up query request */
|
|
qryreq_add_query( req, ADDRQUERY_OBJECT(qry) );
|
|
|
|
g_free( name );
|
|
|
|
return queryID;
|
|
}
|
|
|
|
/**
|
|
* 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 ldaplocate_search_start( const gint queryID ) {
|
|
gboolean retVal;
|
|
LdapServer *server;
|
|
LdapQuery *qry;
|
|
QueryRequest *req;
|
|
AddrQueryObject *aqo;
|
|
|
|
retVal = FALSE;
|
|
req = qrymgr_find_request( queryID );
|
|
if( req == NULL ) {
|
|
return retVal;
|
|
}
|
|
|
|
/* Note: there should only be one query in the list */
|
|
aqo = req->queryList->data;
|
|
if( aqo->queryType == ADDRQUERY_LDAP ) {
|
|
qry = ( LdapQuery * ) aqo;
|
|
server = qry->server;
|
|
|
|
/* Retire any aged queries */
|
|
ldapsvr_retire_query( server );
|
|
|
|
/* Start the search */
|
|
retVal = TRUE;
|
|
ldapsvr_execute_query( server, qry );
|
|
}
|
|
return retVal;
|
|
}
|
|
|
|
/**
|
|
* Notify search to stop execution.
|
|
* \param queryID Query to terminate.
|
|
*/
|
|
void ldaplocate_search_stop( const gint queryID ) {
|
|
QueryRequest *req;
|
|
AddrQueryObject *aqo;
|
|
LdapQuery *qry;
|
|
gint queryType;
|
|
|
|
req = qrymgr_find_request( queryID );
|
|
if( req == NULL ) {
|
|
return;
|
|
}
|
|
|
|
aqo = req->queryList->data;
|
|
if( aqo->queryType == ADDRQUERY_LDAP ) {
|
|
/* Notify query to stop */
|
|
qry = ( LdapQuery * ) aqo;
|
|
ldapqry_set_stop_flag( qry, TRUE );
|
|
}
|
|
req->queryList->data = NULL;
|
|
|
|
/* Delete query */
|
|
qrymgr_delete_request( queryID );
|
|
}
|
|
|
|
#endif /* USE_LDAP */
|
|
|
|
/*
|
|
* End of Source.
|
|
*/
|
|
|
|
|