1 /* gpacontext.h - The GpaContext object. 2 * Copyright (C) 2003, Miguel Coca. 3 * 4 * This file is part of GPA 5 * 6 * GPA is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * GPA is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 19 */ 20 21 #ifndef GPA_CONTEXT_H 22 #define GPA_CONTEXT_H 23 24 #include <glib.h> 25 #include <glib-object.h> 26 #include <gpgme.h> 27 28 /* GObject stuff */ 29 #define GPA_CONTEXT_TYPE (gpa_context_get_type ()) 30 #define GPA_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_CONTEXT_TYPE, GpaContext)) 31 #define GPA_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPA_CONTEXT_TYPE, GpaContextClass)) 32 #define GPA_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_CONTEXT_TYPE)) 33 #define GPA_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_CONTEXT_TYPE)) 34 #define GPA_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GPA_CONTEXT_TYPE, GpaContextClass)) 35 36 typedef struct _GpaContext GpaContext; 37 typedef struct _GpaContextClass GpaContextClass; 38 39 struct _GpaContext { 40 GObject parent; 41 42 /* public: */ 43 44 /* The real gpgme_ctx_t */ 45 gpgme_ctx_t ctx; 46 /* Whether there is an operation currently in course */ 47 gboolean busy; 48 49 /* private: */ 50 51 /* Queued I/O callbacks */ 52 GList *cbs; 53 /* The IO callback structure */ 54 struct gpgme_io_cbs *io_cbs; 55 /* Hack to block certain events. */ 56 int inhibit_gpgme_events; 57 }; 58 59 struct _GpaContextClass { 60 GObjectClass parent_class; 61 62 /* Signal handlers */ 63 void (*start) (GpaContext *context); 64 void (*done) (GpaContext *context, gpg_error_t err); 65 void (*next_key) (GpaContext *context, gpgme_key_t key); 66 void (*next_trust_item) (GpaContext *context, gpgme_trust_item_t item); 67 void (*progress) (GpaContext *context, int current, int total); 68 }; 69 70 GType gpa_context_get_type (void) G_GNUC_CONST; 71 72 /* API */ 73 74 /* Create a new GpaContext object. 75 */ 76 GpaContext *gpa_context_new (void); 77 78 /* TRUE if an operation is in progress. 79 */ 80 gboolean gpa_context_busy (GpaContext *context); 81 82 /* Return a string with the diagnostics from gpgme. */ 83 char *gpa_context_get_diag (GpaContext *context); 84 85 #endif /*GPA_CONTEXT_H*/ 86