seahorse-key-source.h 8.35 KB
Newer Older
1 2 3
/*
 * Seahorse
 *
4
 * Copyright (C) 2004,2005 Nate Nielsen
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * 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.
 */
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 
/**
 * SeahorseKeySource: Base class for other key sources. 
 * 
 * - A generic interface for accessing key sources.
 * - Eventually more functionality will be merged from seahorse-op.* into 
 *   this class and derived classes. 
 * - Each SeahorseKey has a weak pointer to the SeahorseKeySource that 
 *   created it.
 * 
 * Properties base classes must implement:
 *  ktype: (GQuark) The ktype (ie: SKEY_PGP) of keys originating from this 
 *         key source.
 *  location: (SeahorseKeyLoc) The location of keys that come from this 
 *         source. (ie: SKEY_LOC_LOCAL, SKEY_LOC_REMOTE)
 *  uri: (gchar*) Only for remote key sources. The full URI of the keyserver 
 *         being used.
 */

40 41 42 43 44 45 46 47

#ifndef __SEAHORSE_KEY_SOURCE_H__
#define __SEAHORSE_KEY_SOURCE_H__

#include <gnome.h>
#include <gpgme.h>

#include "seahorse-key.h"
48
#include "seahorse-operation.h"
49 50 51 52 53 54 55 56 57

#define SEAHORSE_TYPE_KEY_SOURCE            (seahorse_key_source_get_type ())
#define SEAHORSE_KEY_SOURCE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_KEY_SOURCE, SeahorseKeySource))
#define SEAHORSE_KEY_SOURCE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_KEY_SOURCE, SeahorseKeySourceClass))
#define SEAHORSE_IS_KEY_SOURCE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_KEY_SOURCE))
#define SEAHORSE_IS_KEY_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_KEY_SOURCE))
#define SEAHORSE_KEY_SOURCE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_KEY_SOURCE, SeahorseKeySourceClass))

typedef struct _SeahorseKeySource {
58
    GObject             parent;   
59 60 61
} SeahorseKeySource;

/* Flags for the get_state method below */
62 63 64 65 66 67 68 69 70 71 72 73
typedef enum {
    SKSRC_REMOTE = 0x00000001,
    SKSRC_LOADING = 0x00000010
} SeahorseKeySourceFlags;

/* Operation for the load method below */
typedef enum {
    SKSRC_LOAD_NEW,
    SKSRC_LOAD_ALL,
    SKSRC_LOAD_KEY,
    SKSRC_LOAD_SEARCH
} SeahorseKeySourceLoad;
74

75 76 77 78 79
typedef struct _SeahorseKeySourceClass {
    GtkObjectClass parent_class;

    /* virtual methods ------------------------------------------------- */

80 81 82 83 84 85 86 87 88 89
    /**
     * load
     * @sksrc: The #SeahorseKeySource.
     * @op: The type of load todo. See SeahorseKeySourceLoad.
     * @match: Match text (valid for SKSRC_LOAD_KEY and SKSRC_LOAD_SEARCH ops).
     * 
     * Loads the requested keys, and add the keys to SeahorseContext. 
     * 
     * Returns: The load operation.
     */
90 91
    SeahorseOperation* (*load) (SeahorseKeySource *sksrc, SeahorseKeySourceLoad op,
                                const gchar *match);
92
    
93 94 95 96 97 98
    /**
     * stop
     * @sksrc: The #SeahorseKeySource.
     * 
     * Stops any operations in progress. (ie: load, import, export etc...)
     */
99 100 101 102 103
    void (*stop) (SeahorseKeySource *sksrc);
    
    /* Get the flags for this key source */
    guint (*get_state) (SeahorseKeySource *sksrc);
    
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
    /**
     * import
     * @sksrc: The #SeahorseKeySource to import into.
     * @data: The data to import (not freed).
     *
     * Import keys into the key source. When operation is 'done' a GList of 
     * updated keys may be found as the operation result. 
     * 
     * Returns: The import operation
     */
    SeahorseOperation* (*import) (SeahorseKeySource *sksrc, gpgme_data_t data);

    /**
     * export
     * @sksrc: The #SeahorseKeySource to export from.
     * @keys: A list of keys to export.
120
     * @complete: Whether to export the secret key too.
121 122 123 124 125 126 127 128
     * @data: Optional data object to export to (not freed).
     *
     * Import keys into the key source. When operation is 'done' the result
     * of the operation will be a gpgme_data_t 
     * 
     * Returns: The export operation
     */    
    SeahorseOperation* (*export) (SeahorseKeySource *sksrc, GList *keys, 
129
                                  gboolean complete, gpgme_data_t data);
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144

    /**
     * export_raw
     * @sksrc: The #SeahorseKeySource to export from.
     * @keys: A list of key ids to export.
     * @data: Optional data object to export to (not freed).
     *
     * Import keys into the key source. When operation is 'done' the result
     * of the operation will be a gpgme_data_t 
     * 
     * Returns: The export operation
     */    
    SeahorseOperation* (*export_raw) (SeahorseKeySource *sksrc, GSList *keyids, 
                                      gpgme_data_t data);

145 146 147 148 149 150 151 152 153 154 155 156 157
    /**
     * remove
     * @sksrc: The #SeahorseKeySource to delete the key from.
     * @key: A key to delete.
     * @name: UID/name to delete, or 0 for main key.
     * @error: Error code when not successful.
     * 
     * Delete the keys from the key source. 
     *
     * Returns: Whether successful or not.
     */
    gboolean (*remove) (SeahorseKeySource *sksrc, SeahorseKey *skey,  
                        guint name, GError **error);
158
    
159 160 161 162 163 164 165
} SeahorseKeySourceClass;

GType       seahorse_key_source_get_type      (void);

/* Method helper functions ------------------------------------------- */


166
guint               seahorse_key_source_get_state        (SeahorseKeySource *sksrc);
167

168 169 170
SeahorseOperation*  seahorse_key_source_load             (SeahorseKeySource *sksrc,
                                                          SeahorseKeySourceLoad load,
                                                          const gchar *match);
171
                                                          
172 173 174
void                seahorse_key_source_load_sync        (SeahorseKeySource *sksrc,
                                                          SeahorseKeySourceLoad load,
                                                          const gchar *match);                                                          
175

176 177
void                seahorse_key_source_load_async       (SeahorseKeySource *sksrc,
                                                          SeahorseKeySourceLoad load,
178
                                                          const gchar *key);                                                          
179

180 181
SeahorseOperation*  seahorse_key_source_import           (SeahorseKeySource *sksrc,
                                                          gpgme_data_t data);
182 183 184 185
                                                          
gboolean            seahorse_key_source_import_sync      (SeahorseKeySource *sksrc,
                                                          gpgme_data_t data,
                                                          GError **err);
186

187 188
SeahorseOperation*  seahorse_key_source_export           (SeahorseKeySource *sksrc,
                                                          GList *keys,
189
                                                          gboolean complete,
190
                                                          gpgme_data_t data);                        
191

192 193 194 195
SeahorseOperation*  seahorse_key_source_export_raw       (SeahorseKeySource *sksrc, 
                                                          GSList *keyids, 
                                                          gpgme_data_t data);

196 197
void                seahorse_key_source_stop             (SeahorseKeySource *sksrc);

198 199 200 201 202
gboolean            seahorse_key_source_remove           (SeahorseKeySource *sksrc,
                                                          SeahorseKey *skey,
                                                          guint name,
                                                          GError **error);

203 204 205 206
GQuark              seahorse_key_source_get_ktype        (SeahorseKeySource *sksrc);

SeahorseKeyLoc      seahorse_key_source_get_location     (SeahorseKeySource *sksrc);

207 208 209
gchar*              seahorse_key_source_cannonical_keyid (GQuark ktype, 
                                                          const gchar *keyid);

210
#endif /* __SEAHORSE_KEY_SOURCE_H__ */