addrquery.h (3150B)
1 /* 2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client 3 * Copyright (C) 2003-2012 Match Grun and the Claws Mail team 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 /* 21 * Functions to define an address query (a request). 22 */ 23 24 #ifndef __ADDRQUERY_H__ 25 #define __ADDRQUERY_H__ 26 27 #include <glib.h> 28 #include <stdio.h> 29 #include <sys/time.h> 30 #include "addritem.h" 31 32 /* Query types */ 33 #define ADDRQUERY_NONE 0 34 35 /* Search type */ 36 typedef enum { 37 ADDRSEARCH_NONE, 38 ADDRSEARCH_DYNAMIC, 39 ADDRSEARCH_EXPLICIT, 40 ADDRSEARCH_LOCATE 41 } AddrSearchType; 42 43 /* Data structures */ 44 typedef struct { 45 gint queryID; 46 AddrSearchType searchType; 47 gchar *searchTerm; 48 time_t timeStart; 49 void ( *callBackEnd ) ( void * ); 50 void ( *callBackEntry ) ( void * ); 51 GList *queryList; 52 } 53 QueryRequest; 54 55 /* Some macros */ 56 #define ADDRQUERY_OBJECT(obj) ((AddrQueryObject *)obj) 57 #define ADDRQUERY_TYPE(obj) (ADDRQUERY_OBJECT(obj)->queryType) 58 #define ADDRQUERY_ID(obj) (ADDRQUERY_OBJECT(obj)->queryID) 59 #define ADDRQUERY_SEARCHTYPE(obj) (ADDRQUERY_OBJECT(obj)->searchType) 60 #define ADDRQUERY_NAME(obj) (ADDRQUERY_OBJECT(obj)->queryName) 61 #define ADDRQUERY_RETVAL(obj) (ADDRQUERY_OBJECT(obj)->retVal) 62 #define ADDRQUERY_FOLDER(obj) (ADDRQUERY_OBJECT(obj)->folder) 63 #define ADDRQUERY_SEARCHVALUE(obj) (ADDRQUERY_OBJECT(obj)->searchValue) 64 65 /* Generic address query (base class) */ 66 typedef struct _AddrQueryObject AddrQueryObject; 67 struct _AddrQueryObject { 68 gint queryType; 69 gint queryID; 70 AddrSearchType searchType; 71 gchar *queryName; 72 gint retVal; 73 ItemFolder *folder; /* Reference to folder in cache */ 74 gchar *searchValue; 75 }; 76 77 /* Address search call back functions */ 78 typedef gint ( AddrSearchCallbackEntry ) ( gpointer sender, 79 gint queryID, 80 GList *listEMail, 81 gpointer data ); 82 83 typedef void ( AddrSearchCallbackEnd ) ( gpointer sender, 84 gint queryID, 85 gint status, 86 gpointer data ); 87 88 /* Function prototypes */ 89 QueryRequest *qryreq_create ( void ); 90 void qryreq_set_search_type ( QueryRequest *req, const AddrSearchType value ); 91 void qryreq_add_query ( QueryRequest *req, AddrQueryObject *aqo ); 92 93 void qrymgr_initialize ( void ); 94 void qrymgr_teardown ( void ); 95 QueryRequest *qrymgr_add_request( const gchar *searchTerm, 96 void *callBackEnd, 97 void *callBackEntry ); 98 99 QueryRequest *qrymgr_find_request( const gint queryID ); 100 void qrymgr_delete_request ( const gint queryID ); 101 102 #endif /* __ADDRQUERY_H__ */