Page MenuHome GnuPG

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/src/ChangeLog b/src/ChangeLog
index f20f769..6537ccd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5406 +1,5445 @@
+2008-04-25 Marcus Brinkmann <marcus@g10code.de>
+
+ * Makefile.am (EXTRA_DIST): Add gpa-marshal.list.
+ (BUILT_SOURCES): Add gpa-marshal.h and gpa-marshal.c.
+ (MOSTLYCLEANFILES): Add gpa-marshal.h and gpa-marshal.c.
+ (gpa_SOURCES): Add gpa-marshal.h and gpa-marshal.c.
+ * gpa-marshal.list: New file.
+ * gpaoperation.h (struct _GpaOperationClass): Add argument ERR to
+ member COMPLETED. Add member STATUS.
+ (gpa_operation_server_finish): Remove prototype.
+ * gpaoperation.c: Remove SERVER_CTX property.
+ (gpa_operation_class_init): Change type of
+ completed signal to VOID__INT.
+ (gpa_operation_server_finish): Remove function.
+ (gpa_operation_class_init): Install STATUS signal.
+ * server.c: Include "gpastreamsignop.h".
+ (gpa_run_server_continuation): Rename to ...
+ (run_server_continuation): ... this, and make it static.
+ (cmd_encrypt, cmd_prep_encrypt, cmd_sign): Connect "completed"
+ signal to run_server_continuation. Connect "status" signal to
+ assuan_write_status.
+ * gpabackup.c, gpaexportop.c, gpafiledecryptop.c,
+ gpafileencryptop.c, gpafilesignop.c, gpafileverifyop.c,
+ gpagenkeyadvop.c, gpagenkeysimpleop.c, gpaimportop.c,
+ gpakeydeleteop.c, gpakeyexpireop.c, gpakeypasswdop.c,
+ gpakeysignop.c, gpakeytrustop.c, gpastreamencryptop.c: Do not call
+ gpa_operation_server_finish, but pass error code to "completed"
+ signal.
+ * gpastreamencryptop.h (gpa_stream_encrypt_operation_new): Remove
+ server_ctx argument.
+ * gpastreamencryptop.c (gpa_stream_encrypt_operation_new): Likewise.
+ * gpastreamsignop.h (gpa_stream_sign_operation_new): Remove
+ server_ctx argument.
+ * gpastreamsignop.c (gpa_stream_sign_operation_new): Likewise.
+
2008-04-24 Marcus Brinkmann <marcus@g10code.de>
+ * Makefile.am (gpa_SOURCES): Remove gpawizard.h and gpawizard.c.
+ * gpawizard.h, gpawizard.c: Remove files.
+ * keygenwizard.c: Rewritten to use GtkAssistant.
+
* settingsdlg.c (keyserver_selected_cb): Add missing event
argument.
(selected_from_list_cb): Also to caller.
2008-04-21 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (gpa_SOURCES): Add gpaprogressbar.h, gpaprogressbar.c.
* gpaprogressbar.h, gpaprogressbar.c: New files.
* gpaprogressdlg.h, gpaprogressdlg.c: Use GpaProgressBar.
2008-04-09 Marcus Brinkmann <marcus@g10code.de>
* keylist.c (setup_columns): Change attribute of
GPA_KEYLIST_COLUMN_IMAGE from "pixbuf" to "stock-id".
(get_key_pixbuf): Change return type to const gchar * and return
stock item IDs.
(gpa_keylist_constructor): Set type of first column to
G_TYPE_STRING.
(setup_columns): Set stock-size property of RENDERER, and use the
stock-id property for that tree view column renderer.
* icons.c (xpms): Use stock IDs for secret and public key.
(register_stock_icons): Set fixed sizes for the secret and public
key icons.
* icons.h (GPA_STOCK_PUBLIC_KEY, GPA_STOCK_SECRET_KEY): New.
2008-04-03 Marcus Brinkmann <marcus@g10code.de>
* gpa.h (gpa_windows_menu_action_entries): Use stock items for
file manager and clipboard windows.
* icons.c (register_stock_icons): Add fake stock icons for file
manager and clipboard windows.
(xpms): Use stock item macros.
(gpa_register_stock_items): Add stock items for clipboard and
fileman.
* confdialog.c (update_option): Use gtk_editable_set_editable
instead of gtk_entry_set_editable.
* gpawizard.c: Use g_object_set_data and g_object_get_data instead
of gtk_object_set_data and gtk_object_get_data.
(gpa_wizard_new): Use gtk_box_set_spacing instead of
gtk_button_box_set_spacing.
* keygenwizard.c: Use GtkImage instead of GtkPixmap.
* keyring.c: Use combo box instead of option menu for signature
user names.
(keyring_details_page_fill_num_keys): Use
gtk_notebook_set_current_page instead of gtk_notebook_set_page.
(keyring_update_details_notebook): Use g_idle_add instead of
gtk_idle_add.
(keyring_editor_new): Use g_object_set_data_full instead of
gtk_object_set_data_full.
* gpawidgets.c (gpa_expiry_frame_new): Likewise.
(gpa_expiry_frame_get_expiration, gpa_expiry_frame_validate): Use
g_object_get_data instead of gtk_object_get_data.
* icons.c (gpa_create_icon_widget): Remove obsolete function.
(xpms): Change name of "keyring" icon to "gpa-keyring".
* icons.h (gpa_create_icon_widget): Remove prototype.
(GPA_STOCK_KEYRING_EDITOR): New macro.
* keyring.c (keyring_editor_new): Use custom stock icon instead of
gpa_create_icon_widget.
* gtktools.c (gpa_window_show_centered): Remove obsolete function.
* gtktools.h (gpa_window_show_centered): Remove prototype.
* expirydlg.c (gpa_expiry_dialog_run): Change type of EXPIRY_DATE
to time_t. Use g_date_set_time_t instead of g_date_set_time.
* gpapastrings.c (gpa_expiry_date_string): Use g_date_set_time_t
instead of g_date_set_time.
(gpa_creation_date_string): Likewise.
* keygenwizard.c (free_keygen_wizard): Use g_object_unref instead
of gdk_pixmap_unref.
(gpa_keygen_wizard_new): Use gtk_window_set_transient_for and
gtk_window_set_position instead of gpa_window_show_centered.
(gpa_keygen_wizard_password_page): Use g_object_set_data instead
of gtk_object_set_data.
* keyimpseldlg.c (gpa_key_import_selection_dialog_run): Likewise.
* gpagenkeysimpleop.c (gpa_gen_key_simple_operation_constructor):
Show keygen wizard.
* gpa.c, gpawidgets.c, encryptdlg.c, gpawizard.c, keyeditdlg.c,
keyring.c, keyimpseldlg.c, keygenwizard.c, keygendlg.c: Use
g_signal_connect instead of gtk_signal_connect.
* gtktools.c (gpa_window_show_centered): Use gdk_drawable_get_size
instead of gdk_window_get_size.
* gtktools.h (gpa_connect_by_accelerator): Remove prototype.
* gtktools.c (gpa_connect_by_accelerator): Remove obsolete interface.
* selectkeydlg.c (select_key_dlg_constructor): Remove accel_group.
* keyring.c (keyring_editor_new): Likewise.
* keyimpseldlg.c (gpa_key_import_selection_dialog_run): Likewise.
* encryptdlg.c (gpa_file_encrypt_dialog_constructor): Remove
accelGroup variable. Use gtk_label_set_mnemonic_widget instead of
gpa_connect_by_accelerator.
* filesigndlg.c (gpa_file_sign_dialog_constructor): Likewise.
* gparecvkeydlg.c (gpa_receive_key_dialog_init): Likewise.
* recipientdlg.c (recipient_dlg_constructor): Likewise.
* keyimpseldlg.c (gpa_key_import_selection_dialog_run): Likewise.
* keygendlg.c (gpa_key_gen_run_dialog): Likewise.
Also clean up use of combo boxes and ESC key handling.
(struct _GPAKeyGenDialog): New member comboKeysize.
(response_cb): Check keysize parameter.
* settingsdlg.c (keyserver_selected_cb): Adjust to new combo box method.
(selected_from_list_cb): Likewise.
(append_to_combo): New function.
(default_keyserver_frame): Use new combo box interface.
2008-04-02 Marcus Brinkmann <marcus@g10code.de>
* gpafileverifyop.c (gpa_file_verify_operation_done_cb): Emit
file_created signal for direct input case.
2008-03-28 Marcus Brinkmann <marcus@g10code.de>
* keyring.c, fileman.c, clipboard.c: Many, many changes to use the
current Gtk interfaces for menubar and toolbar construction,
namely GtkUIManager and GtkAction, instead of the deprecated
GtkItemFactory. Also use the new GPA stock items consistently.
Change the sensitive widget code to use GtkAction instead of GtkWidget.
* gpa.h: Include "icons.h".
(gpa_open_keyring_editor, gpa_open_clipboard)
(gpa_open_filemanager, gpa_open_settings_dialog)
(gpa_open_backend_config_dialog): Add callback arguments to
prototypes.
(gpa_windows_menu_action_entries)
(gpa_preferences_menu_action_entries): New data.
* gpa.c: Include "icons.h".
(gpa_open_keyring_editor, gpa_open_clipboard)
(gpa_open_filemanager, gpa_open_settings_dialog)
(gpa_open_backend_config_dialog): Add callback arguments. Also to
caller.
(main): Invoke gpa_register_stock_items.
* icons.h (gpa_register_stock_items): New prototype.
(GPA_STOCK_SIGN, GPA_STOCK_VERIFY, GPA_STOCK_ENCRYPT)
(GPA_STOCK_DECRYPT, GPA_STOCK_KEYRING, GPA_STOCK_FILEMAN)
(GPA_STOCK_CLIPBOARD, GPA_STOCK_BRIEF, GPA_STOCK_DETAILED)
(GPA_STOCK_EDIT, GPA_STOCK_IMPORT, GPA_STOCK_EXPORT)
(GPA_STOCK_BACKUP): New macros.
* icons.c (gpa_register_stock_items): New function.
(xpms): Remove some obsolete entries (and don't include those xpm
files).
* helpmenu.h: Include <gtk/gtk.h>.
(gpa_help_about): New prototype.
(gpa_help_menu_add_to_factory): Removed prototype.
(gpa_help_menu_action_entries): New data.
* helpmenu.c (help_about): Rename to ...
(gpa_help_about): ... this. Make non-static.
(gpa_help_menu_add_to_factory): Removed function.
(help_help): Likewise.
* gtktools.h (gpa_toolbar_set_homogeneous): New prototype.
* gtktools.c (set_homogeneous, gpa_toolbar_set_homogeneous): New
functions.
2008-03-27 Marcus Brinkmann <marcus@g10code.de>
* gtktools.h (gpa_window_destroy, gpa_buttonCancel_new)
(gpa_button_set_text, gpa_check_button_new, gpa_radio_button_new)
(gpa_button_new, gpa_toggle_button_new, gpa_space_new)
(gpa_widget_hjustified_new, gpa_radio_button_new_from_widget):
(gpa_xpm_label_box, gpa_button_cancel_new): Removed prototype.
* gtktools.c (gpa_window_destroy, gpa_buttonCancel_new)
(gpa_button_set_text, gpa_check_button_new, gpa_radio_button_new)
(gpa_button_new, gpa_toggle_button_new, gpa_space_new)
(gpa_widget_hjustified_new, gpa_radio_button_new_from_widget)
(gpa_xpm_label_box, gpa_button_cancel_new): Removed function.
* keyimpseldlg.c (gpa_key_import_selection_dialog_run): Replace
gpa_button_new and gpa_button_cancel_new by stock button.
* keyeditdlg.c (gpa_key_edit_dialog_constructor): Use
gtk_button_new_with_mnemonic instead of gpa_button_new. Remove
accelerator group.
* gpawizard.c (gpa_wizard_new): Use stock buttons.
* encryptdlg.c (gpa_file_encrypt_dialog_constructor): Use
gtk_check_button_new_with_mnemonic instead of
gpa_check_button_new.
* filesigndlg.c (gpa_file_sign_dialog_constructor): Likewise.
* keysigndlg.c (gpa_key_sign_run_dialog): Likewise. Remove accelerator group.
* gpawidgets.h (gpa_expiry_frame_new): Remove argument accelGroup from prototype.
* keygendlg.c (gpa_key_gen_run_dialog): Change caller of gpa_expiry_frame_new.
* filesigndlg.c (gpa_file_sign_dialog_constructor): Use
gtk_radio_button_new_with_mnemonic instead of gpa_radio_button_new
and gtk_radio_button_new_with_mnemonic_from_widget instead fo
gpa_radio_button_new_from_widget.
* expirydlg.c (gpa_expiry_dialog_run): Likewise.
* gpawidgets.c (gpa_expiry_frame_new): Likewise. Remove argument
accelGroup.
* encryptdlg.c (gpa_file_encrypt_dialog_constructor): Set shadow around keylist.
* filesigndlg.c (gpa_file_sign_dialog_constructor): Set shadow
type around keylist.
* Makefile.am (tip_files): Removed variable.
(pkgdata_DATA): Remove $(tip_files).
(EXTRA_DIST): Remove $(tip_files).
* gpa_tips.de, gpa_tips.en: Removed file.
* helpmenu.c: Convert file encoding to UTF-8.
(help_about): Rewritten to use stock gtk about dialog.
(about_dialog, scroll_text, SCROLLING, DIM, shuffle_array)
(do_scrolling, scroll_state, scroll_offset, scroll_text_widths)
(scroll_area, scroll_pixmap, cur_scroll_text, cur_scroll_index)
(timer, help_license, about_dialog_unmap, about_dialog_destroy)
(about_dialog_button, about_dialog_timer, help_license_destroy):
Removed.
(gpa_help_menu_add_to_factory): Remove the Help->License entry.
2008-03-26 Werner Koch <wk@g10code.com>
* gpa.c: Change option --server to --daemon.
2008-03-25 Werner Koch <wk@g10code.com>
* keyserver.c (keyserver_read_list): Replace subkeys.pgp.net by
keys.gnupg.net.
2008-03-19 Marcus Brinkmann <marcus@g10code.de>
* fileman.c (get_load_file_name): Set default response.
* clipboard.c (get_save_file_name, get_load_file_name): Set
default response.
* gpabackupop.c (gpa_backup_operation_dialog_run): Remember last
dialog window settings. Set default response.
(gpa_backup_operation_do_backup): Remove overwrite check (done by
caller).
Reenable default key and keyserver handling:
* options.c (gpa_options_update_default_key): Remove work-around.
* gpgmetools.c (gpa_gpgme_new): Remove work-around
* gpa.c (main): Remove work-around.
* fileman.c (open_file): Support opening more than one file.
(get_load_file_name): Likewise.
(add_file): Convert filenames to UTF-8 before comparison, fix tree
iteration.
* fileman.c (dnd_data_received_handler): Silence gcc warning.
* gpaexportfileop.c (gpa_export_file_operation_get_destination):
Use save button instead load button.
* gpabackupop.c (export_browse): Removed.
(gpa_backup_operation_dialog_run): Rewritten.
* fileman.c (get_load_file_name): New function.
(open_file): Use it.
(gpa_file_manager_constructor): Don't pack ALIGN twice.
* clipboard.c (get_load_file_name): New function.
(file_open): Use it.
(get_save_file_name): New function.
(file_save_as): Use it.
* gtktools.h (gpa_get_save_file_name, gpa_get_load_file_name):
Removed prototypes.
* gtktools.c (gpa_get_save_file_name, gpa_get_load_file_name):
Removed.
* clipboard.c (gpa_clipboard_constructor): Create text_frame
early.
(gpa_clipboard_constructor): Don't pack ALIGN twice.
(has_selection): Remove superfluous cast.
* gtktools.c (struct _GPASaveFileNameDialog): Removed.
(GPASaveFileNameDialog): Removed.
(file_dialog_ok, file_dialog_cancel, file_dialog_destroy):
Removed.
(gpa_get_save_file_name, gpa_get_load_file_name): Reimplemented.
2008-03-18 Marcus Brinkmann <marcus@g10code.de>
* gpgmetools.h (gpa_open_output_direct): New prototype.
* gpgmetools.c (gpa_open_output_direct): New function.
* gpaimportfileop.c (gpa_import_file_operation_get_source): Use
the GtkFileChooserDialog widget instead of GtkFileSelection. Fix
loop logic.
* gpaexportfileop.c (gpa_export_file_operation_get_destination):
Likewise. Use gpa_open_output_direct instead of
gpa_open_output.
* gpawidgets.c (gpa_expiry_frame_new): Replace editable GtkCombo
by uneditable GtkComboBox.
(gpa_expiry_frame_dont): Don't change the "after" widgets, just
make them desensitive.
(gpa_expiry_frame_at): Likewise.
(gpa_expiry_frame_after): Likewise (except make them sensitive).
* gpawidgets.c (gpa_expiry_frame_new): Use
gtk_entry_set_width_chars instead of gtk_widget_set_size_request.
2008-03-12 Werner Koch <wk@g10code.com>
* gpastreamsignop.c, gpastreamsignop.h: New.
* gpafileencryptop.c (set_recipients): Free RSET before malloc.
(set_recipients): Set the protocol to use.
* keytable.c (reload_cache): Reset FIRST_HALF_DONE.
* gpacontext.c (gpa_context_init): Do not set the passphrse
callback in CMS mode.
* gpgmeedit.c (gpa_gpgme_edit_passwd_parms_release)
(gpa_gpgme_edit_passwd_start): Ditto.
* gpgmetools.c (gpa_gpgme_new): Ditto.
* gpafilesignop.c (set_signers): Set protocol from the keys.
(destination_filename): Add arg protocol and pass it from the caller.
* gpa.c (option_entries): Add option --clipboard. Fix spelling of
file manager.
(gpa_args_t): Add field START_CLIPBOARD.
(main): Implement option.
(args): Remove explicit initialization to put it into BSS.
* gpa_license.c, gpa_license.h: Remove.
* gpl-text.c, gpl-text.h: New.
* helpmenu.c (help_license): Use the new get_gpl_text.
(scroll_text): Add all names from AUTHORS.
2008-03-12 Marcus Brinkmann <marcus@g10code.de>
* clipboard.c (dos_to_unix): Removed.
* gpgmetools.h (dos_to_unix): New prototype.
* gpgmetools.c (dos_to_unix): Add comment.
2008-03-11 Marcus Brinkmann <marcus@g10code.de>
* gpgmetools.c (dos_to_unix) [G_OS_WIN32]: New function.
(dump_data_to_clipboard) [G_OS_WIN32]: Convert newlines.
2008-03-11 Werner Koch <wk@g10code.com>
* selectkeydlg.c (select_key_dlg_constructor): List only encrypt keys.
* keylist.h (KEY_USAGE_SIGN): Add key usage flags.
(_GpaKeyList): Add field REQUESTED_USAGE.
* keylist.c (gpa_keylist_new_with_keys): Add arg REQUESTED_USAGE.
(PROP_REQUESTED_USAGE): New.
(gpa_keylist_get_property, gpa_keylist_set_property)
(gpa_keylist_class_init): Install property.
(gpa_keylist_next): Filetr on usage and account.
* recipientdlg.c (parse_one_recipient): List only keys with
encrypt capability.
* keylist.c (gpa_keylist_constructor): Add a new column.
(GpaKeyListColumn): Add GPA_KEYLIST_COLUMN_KEYTYPE.
(gpa_keylist_next, setup_columns): Fill this column.
* gpgmetools.c (gpa_key_ownertrust_string): No ownertrust for X.509.
* keyring.c (keyring_editor_selection_changed): Set the protocol
before doing a key list.
(keyring_editor_has_single_selection_OpenPGP): New.
(keyring_editor_menubar_new): Use it for ownertrust.
(keyring_editor_popup_menu_new): Ditto.
2008-03-11 Marcus Brinkmann <marcus@g10code.de>
* settingsdlg.c: Include settingsdlg.h. Beautify code.
[! HAVE_CONFIG_H]: Don't include config.h.
(default_key_frame): Do not use a border with frames, but make the
label bold. Give the scrolled window a shadow.
(default_keyserver_frame): Do not use a border with frames, but
make the label bold.
(user_interface_mode_frame): Likewise.
2008-03-07 Werner Koch <wk@g10code.com>
* keytable.h (_GpaKeyTable): Add new fields FPR, DID_FIRST_HALF
and FIRST_HALF_ERR.
* keytable.c (first_half_done_cb): New.
(gpa_keytable_init): Connect "done" to that.
(reload_cache): Save the fingerprint.
(done_cb): Show error from both halfs.
* gpa.c: Include signal.h. Enable --cms with --server.
(main) [!G_OS_WIN32]: Ignore SIGPIPE.
* recipientdlg.c (set_column_title, add_tooltip): Remove and
factor code out to ..
* gtktools.c (gpa_add_tooltip, gpa_set_column_title): .. New.
* keylist.c (add_tooltip, set_column_title): Replace be new functions.
* gpa.c (main) [GLIB < 2.12]: Do not use the new g_context stuff.
* selectkeydlg.c (select_key_dlg_new_with_keys): New.
* keylist.c (gpa_keylist_new_public_only): Rename to ...
(gpa_keylist_new_with_keys): .. this and add more parameters.
(gpa_keylist_class_init): Add properties PROP_PROTOCOL,
PROP_INITIAL_KEYS, PROP_INITIAL_PATTERN.
(gpa_keylist_finalize): Release initial_keys.
(gpa_keylist_constructor): Fill the list with provided keys.
* gpgmetools.c (gpa_gpgme_copy_keyarray)
(gpa_gpgme_release_keyarray): New.
* gpastreamencryptop.c (release_keys, copy_keys): Remove and
replace all callers by the new functions.
2008-03-06 Werner Koch <wk@g10code.com>
* keylist.c: Change license to GPLv3+. Cosmetic changes.
(gpa_keylist_get_selected_key): New.
(gpa_keylist_elgamal_dialog): Remove.
(gpa_keylist_next): Remove detection of Elgamal signatures. It is
pointless as gpg has no more support for those keys.
(gpa_keylist_new_public_only): New.
(gpa_keylist_class_init, gpa_keylist_get_property)
(gpa_keylist_set_property): Add property.
(gpa_keylist_set_brief, gpa_keylist_set_detailed)
(gpa_keylist_next): Do not display the image in public_only mode.
(gpa_keylist_has_single_secret_selection, gpa_keylist_next):
Implement public_only.
(gpa_keylist_init): Make a dummy fucntion and move all stuff to ..
(gpa_keylist_constructor): .. New.
(gpa_keylist_class_init): Register constructor.
(gpa_keylist_set_detailed, gpa_keylist_set_brief): Merged into ..
(setup_columns): .. new. Add toolstips.
(add_tooltip, set_column_title): New.
* keylist.h (_GpaKeyList): Add field public_only.
* selectkeydlg.h, selectkeydlg.c: New.
* gpa.c: Move variables definitions to the top.
(quit_if_no_window): Do not quit if only the server has been
started.
(dummy_log_func): Use only for G_OS_WIN32.
* server.c (gpa_stop_server): New.
(connection_startup, connection_finish): Add shutdown logic.
2008-03-06 Marcus Brinkmann <marcus@g10code.de>
* settingsdlg.c (default_keyserver_frame): Invoke
keyserver_selected_cb on focus-out-event rather than activated.
2008-03-05 Werner Koch <wk@g10code.com>
* server.c (struct conn_ctrl_s): Add field GPA_OP.
* gpastreamencryptop.c: Major rewrite.
* recipientdlg.c, recipientdlg.h: Add more stuff.
2008-03-04 Marcus Brinkmann <marcus@g10code.de>
* gpafileverifyop.c (gpa_file_verify_operation_done_cb): Use
filename_in, not filename_out.
* keyring.c: Remove most forward declarations.
(keyring_editor_export): Do not chicken out if there are more keys
selected than one.
(keyring_editor_copy): Likewise.
(toolbar_export_key): Rename to ...
(toolbar_export_keys): ... this.
(keyring_toolbar_new): Use new name here.
(keyring_editor_edit): Make sure a single private key is selected.
(keyring_editor_backup): Likewise.
(keyring_editor_trust): Check for single selection.
(keyring_editor_menubar_new): Make "Send keys..." sensitive only
if there is a single selection.
(keyring_editor_send): Check for single selection.
(keyring_editor_can_sign): Access editor->current_key directly.
Protect against it being NULL.
* keyring.c: Beautify source code.
(keyring_details_notebook): Add border around details
page. Shrink border around signature and subkeys page.
(keyring_editor_add_subkeys_page): Set shadow type.
(struct _GPAKeyringEditor): Rename signatures_label to
signatures_hbox.
(keyring_details_notebook): Initialize signatures_hbox instead
signatures_label.
(keyring_signatures_page_fill_key): Show/hide signatures_hbox
instead of signatures_label and signatures_uids.
* clipboard.c (file_open): Use long long for size format.
2008-03-03 Marcus Brinkmann <marcus@g10code.de>
* clipboard.c (file_open): Add note for translators.
2008-02-29 Werner Koch <wk@g10code.com>
* keyserver.c [GLIB >= 2.6]: Include gstdio.h.
(read_list) [GLIB < 2.6]: Use fopen.
2008-02-28 Marcus Brinkmann <marcus@g10code.de>
* clipboard.c (gpa_clipboard_constructor): Call
update_selection_sensitive_widgets.
2008-02-28 Werner Koch <wk@g10code.com>
* server.c (struct conn_ctrl_s): Add fields is_unfinished and
client_died.
(not_finished): New. Use that instead of GPG_ERR_UNFINISHED.
(gpa_run_server_continuation, receive_cb): Handle dead client with
pending continuation.
* gpastreamencryptop.c: Add recipients property.
* recipientdlg.c, recipientdlg.h: New.
2008-02-20 Werner Koch <wk@g10code.com>
* server.c (cmd_start_keymanager): New.
(register_commands): Register it.
2008-02-15 Marcus Brinkmann <marcus@g10code.de>
* options.c: Include <glib/gstdio.h>.
(gpa_options_save_settings): Use g_fopen instead of open.
(gpa_options_read_settings): Likewise.
* keyserver.c: Include <glib/gstdio.h>.
(read_list): Use g_fopen instead of fopen. Change argument type
to gchar.
(keyserver_read_list): Change argument type to gchar.
* keyserver.h: Likewise in prototype.
* gpgmetools.c: Include <glib/gstdio.h>.
(gpa_fopen): Use g_fopen instead of fopen.
(gpa_backup_key): Likewise.
(gpa_open_output): Use g_open instead of open.
(gpa_open_input): Likewise.
* gpafileencryptop.c: Include <glib/gstdio.h>.
(gpa_file_encrypt_operation_done_cb): Use g_unlink instead of unlink.
* gpafiledecryptop.c: Include <glib/gstdio.h>.
(gpa_file_decrypt_operation_done_cb): Use g_unlink instead of unlink.
* gpafilesignop.c: Include <glib/gstdio.h>.
(gpa_file_sign_operation_done_cb): Use g_unlink instead of unlink.
* keygendlg.c (struct _GPAKeyGenDialog): New member entryUserID.
(gpa_key_gen_run_dialog): Initialize it.
(response_cb): Complain if there is no user ID.
2008-02-12 Marcus Brinkmann <marcus@g10code.de>
* encryptdlg.c (gpa_file_encrypt_dialog_constructor): Use
"documents" instead of "files" in windows title.
* gpafileencryptop.c (ignore_key_trust): Likewise.
* verifydlg.c (gpa_file_verify_dialog_constructor): Likewise.
* filesigndlg.c (gpa_file_sign_dialog_constructor): Likewise.
(gpa_file_sign_dialog_constructor): Say "detached signature"
instead of "Sign in separate file".
2008-02-07 Marcus Brinkmann <marcus@g10code.de>
* clipboard.c (dos_to_unix) [G_OS_WIN32]: New function.
(file_created_cb) [G_OS_WIN32]: Use it.
(file_open) [G_OS_WIN32]: Use it.
* clipboard.c (file_created_cb): Convert \r\n to \n.
* clipboard.c (GTK_STOCK_SELECT_ALL) [!GTK_CHECK_VERSION(2,10,0):
New macro.
(clipboard_text_new): Fix last change.
2008-02-06 Marcus Brinkmann <marcus@g10code.de>
* clipboard.c (clipboard_toolbar_new): Replace "file" by "text" in
several tooltips.
* fileman.c (gpa_file_manager_constructor): Add alignment.
* clipboard.c (clipboard_toolbar_new): Adjust spelling in tooltips.
* keyring.c (keyring_toolbar_new): Likewise.
* fileman.c (fileman_toolbar_new): Likewise.
* clipboard.c (gpa_clipboard_constructor): Add a fancy label after
the toolbar.
* fileman.c (gpa_file_manager_constructor): Add a fancy label
after the toolbar.
(file_list_new): Put a shadow around the scrollerFile.
* confdialog.c (create_dialog_tabs_2) [!GTK_CHECK_VERSION(2,12,0)]:
Do not add tooltips.
* clipboard.c (gtk_text_buffer_get_has_selection)
(gdk_atom_intern_static_string)
(MY_GTK_TEXT_BUFFER_NO_HAS_SELECTION) [!GTK_CHECK_VERSION(2,10,0)]:
New macros.
(clipboard_text_new) [MY_GTK_TEXT_BUFFER_NO_HAS_SELECTION]:
Connect to signals mark-set and changed of text buffer.
2008-02-04 Marcus Brinkmann <marcus@g10code.de>
* clipboard.c (file_verify): Remove debug output.
* gpawindowkeeper.c (gpa_windowKeeper_add_param): Store result of
g_list_append.
* Makefile.am (gpa_SOURCES): Add clipboard.h and clipboard.c.
* clipboard.h, clipboard.c: New files.
* gpa.h (gpa_open_clipboard): New prototype.
* gpa.c: Include "clipboard.h".
(quit_if_no_window): Also check for clipboard window).
(gpa_open_clipboard): New window.
* keyring.c (win_menu): Add clipboard window.
(keyring_toolbar_new): Add clipboard window.
* fileman.c (get_selected_files): Use file_item.
(file_created_cb): Change type of second argument to gpa_file_item_t.
(sign_files): Add new argument to gpa_file_sign_operation_new.
(encrypt_files): Add new argument to gpa_file_encrypt_operation_new.
(windows_menu): Add clipboard window.
(fileman_toolbar_new): Add clipboard window.
(gpa_file_manager_constructor): Use gtk_window_set_default_size
rather than gtk_widget_set_usize.
* encryptdlg.h (struct _GpaFileEncryptDialog): New members
scroller_who and force_armor.
(gpa_file_encrypt_dialog_new): Add new argument force_armor to
prototype.
* encryptdlg.c: Add property PROP_FORCE_ARMOR to property enum.
(gpa_file_encrypt_dialog_get_property)
(gpa_file_encrypt_dialog_set_property): Support it.
(gpa_file_encrypt_dialog_init): Move bunch of it to ...
(gpa_file_encrypt_dialog_constructor): ... this new function. Use
gtk_window_set_default_size rather than gtk_widget_set_usize.
Support force_armor. Desensitize scrolled window instead of
keylisting to fix a bug.
(changed_select_row_cb): Likewise.
(gpa_file_encrypt_dialog_class_init): Install new property.
(gpa_file_encrypt_dialog_new): New argument force_armor, use it.
* filesigndlg.h (struct _GpaFileSignDialog): New members
scroller_who and force_armor.
(gpa_file_sign_dialog_new): Add new argument force_armor to
prototype.
* filesigndlg.c: Add property PROP_FORCE_ARMOR to property enum.
(gpa_file_sign_dialog_get_property)
(gpa_file_sign_dialog_set_property): Support it.
(gpa_file_sign_dialog_constructor): Use gtk_window_set_default_size
rather than gtk_widget_set_usize. Support force_armor.
(gpa_file_sign_dialog_class_init): Install new property.
(gpa_file_sign_dialog_new): New argument force_armor, use it.
* gpafileop.h (struct gpa_file_item_s): New structure.
(gpa_file_item_t): New type.
* gpafileop.c (free_file_item): New function
(gpa_file_operation_finalize): Use it instead of g_free.
(gpa_file_operation_class_init): Change argument type of callback
to pointer.
(gpa_file_operation_current_file): Use file_item.
* gpafileverifyop.c (gpa_file_verify_operation_start): Change
second argument to type file_item. Use it to support direct memory.
(gpa_file_verify_operation_done_cb): Use file_item.
(gpa_file_verify_operation_done_error_cb): Use file_item.
* gpafiledecryptop.h (_GpaFileDecryptOperation): Remove member
plain_filename.
* gpafiledecryptop.c (gpa_file_decrypt_operation_init): Do not
reset OP->plain_filename.
(gpa_file_decrypt_operation_start): Change second argument to type
file_item. Use it to support direct mode.
(gpa_file_decrypt_operation_done_cb): Use file_item.
(gpa_file_decrypt_operation_done_error_cb): Use file_item.
* gpafilesignop.h (_GpaFileSignOperation): Add member force_armor.
(gpa_file_sign_operation_new): Add new argument force_armor to
prototype.
* gpafilesignop.c: New properties enum.
(gpa_file_sign_operation_get_property)
(gpa_file_sign_operation_set_property): New functions.
(gpa_file_sign_operation_init): Initialize OP->force_armor.
(gpa_file_sign_operation_new): Add new argument force_armor, use it.
(gpa_file_sign_operation_constructor): Add new argument to
gpa_file_sign_dialog_new invocation.
(gpa_file_sign_operation_class_init): Set class properties.
(gpa_file_sign_operation_start): Change second argument to type
gpa_file_item_t. Support direct memory use.
(gpa_file_sign_operation_done_cb): Use file_item.
(gpa_file_sign_operation_done_error_cb): Use file_item.
* gpafileencryptop.h (_GpaFileEncryptOperation): Add member force_armor,
and remove member cipher_filename.
(gpa_file_encrypt_operation_new): Add new argument force_armor to
prototype.
* gpafileencryptop.c: New properties enum.
(gpa_file_encrypt_operation_get_property)
(gpa_file_encrypt_operation_set_property): New functions.
(gpa_file_encrypt_operation_init): Initialize OP->force_armor, do
not initialize OP->cipher_filename.
(gpa_file_encrypt_operation_new): Add new argument force_armor, use it.
(gpa_file_encrypt_operation_constructor): Add new argument to
gpa_file_encrypt_dialog_new invocation.
(gpa_file_encrypt_operation_class_init): Set class properties.
(gpa_file_encrypt_operation_start): Change second argument to type
gpa_file_item_t. Support direct memory use.
(gpa_file_encrypt_operation_done_cb): Use file_item.
(gpa_file_encrypt_operation_done_error_cb): Use file_item.
* gpastreamencryptop.c (gpa_stream_encrypt_operation_constructor):
Add new argument to gpa_file_encrypt_dialog_new.
* keyimpseldlg.c (gpa_key_import_selection_dialog_run): Use
gtk_widget_set_size_request instead of gtk_widget_set_usize.
* gpawidgets.c (gpa_expiry_frame_new): Likewise.
* helpmenu.c (help_license): Likewise.
* helpmenu.c (gpa_help_menu_add_to_factory): Use stock item for
about menu.
* settingsdlg.c (default_key_frame): Likewise.
* confdialog.c (dialog_level): New global variable.
(comp_has_options, group_has_options): New functions.
(create_dialog_tabs_2): Skip groups with no displayable options.
Honor expert level.
(dialog_level_chooser_cb): New function.
(create_dialog): Add some padding, a label and combo box for
choosing the current expert level.
2008-01-31 Marcus Brinkmann <marcus@g10code.de>
* gpa.c (gpa_open_keyring_editor): Use gtk_window_present instead
of gdk_window_raise.
(gpa_open_filemanager, gpa_open_settings_dialog,
(gpa_open_backend_config_dialog): Likewise.
2008-01-29 Marcus Brinkmann <marcus@g10code.de>
* keyring.c (keyring_toolbar_new): Use stock icon for file manager
button in toolbar.
2008-01-27 Marcus Brinkmann <marcus@g10code.de>
* confdialog.c (create_dialog_tabs_2): Set expansion policy to
TRUE/TRUE for the entry widget.
2008-01-25 Marcus Brinkmann <marcus@g10code.de>
* fileman.c (file_list_new): Put a shadow around the scrolled
window.
(file_list_new): Use FILE_N_COLUMNS instead of hard-coded constant.
2008-01-24 Marcus Brinkmann <marcus@g10code.de>
* keyring.h: Add comment.
* keyring.c (keyring_editor_new): Put a shadow around the scrolled
window.
(struct _GPAKeyringEditor): Add status_label.
(keyring_statusbar_new): Set expand to false for all, and add 5
pixel padding around key ID, which is moved before the user
string. Initialize status_label to empty string here.
(keyring_update_status_bar): Set status_label.
(toolbar_preferences): Bring back to life.
(keyring_toolbar_new): Reenable preferences.
* fileman.c (toolbar_preferences): Bring back to life.
(fileman_toolbar_new): Reenable preferences. Add keyring to
toolbar.
* icons.c: Include keyringeditor.xpm.
(xpms): Add keyringeditor.
* gpa.h (gpa_get_keyring_editor, gpa_get_settings_dialog): Removed.
* gpa.c: Do not include gpapastrings.h, gpawindowkeeper.h,
gtktools.h, helpmenu.h, keytable.h, icons.h, errno.h, assert.h or
getopt.h.
(main): Create gnupg home dir if it doesn't exist even if option
file argument is given.
(gpa_get_keyring_editor, gpa_get_settings_dialog): Removed.
(GpaCommandLineArgs): Renamed to gpa_args_t. Also changed user.
(copyright): Made static.
2008-01-23 Marcus Brinkmann <marcus@g10code.de>
* gpa.h (cms_hack): Changed type in prototype to gboolean.
* gpa.c (main): Move i18n_init() invocation before rewritten
option parsing. Move variable args file scope.
(usage, longopts, option_desc, parse_command_line): Removed.
(print_copyright): Renamed to ...
(print_version): ... this and exit.
(longopts): Removed
(cms_hack): Changed type to gboolean.
2008-01-18 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (gpa_SOURCES): Add get-path.h and get-path.c. Move
w32reg.h and w32reg.c to ...
(gpa_w32_sources): ... here.
* get-path.h, get-path.c: New files.
* w32reg.h, w32reg.c: Beautify. Use g_malloc instead of malloc.
* gpa.c: Don't include <time.h> or "w32reg.h". Include
<glib/gstdio.h> and "get-path.h". Move the home dir stuff to
get-path.c. Beautify a bit.
(gpa_exec_dir): Remove global variable.
(copyright): Add g10 Code GmbH.
(main): Don't initialize gpa_exec_dir. Use g_mkdir instead of
mkdir. Move call to srand to ...
* helpmenu.c (help_about): ... here. Include <time.h>.
2008-01-17 Marcus Brinkmann <marcus@g10code.de>
* gpa.c (create_dialog): Switch "apply" and "reset" button.
* Makefile.am (noinst_PROGRAMS): Remove confdialog.
(confdialog_SOURCES): Remove variable.
(gpa_SOURCES): Add confdialog.h and confdialog.c.
* confdialog.h: New file.
* confdialog.c: Rewritten.
* gpa.h (gpa_open_backend_config_dialog): New prototype.
(gpa_show_backend_config): Prototype removed.
* gpa.c: Include "confdialog.h".
(backend_config_dialog): New variable.
(gpa_open_backend_config_dialog): New function.
* fileman.c (fileman_menu_new): Add entry for backend config.
* keyring.c (keyring_editor_menubar_new): Likewise.
2007-11-13 Werner Koch <wk@g10code.com>
* server.c (cmd_sender, cont_sign, cmd_sign): New.
(register_commands): Register SENDER and SIGN.
2007-11-12 Werner Koch <wk@g10code.com>
* server.c (cmd_prep_encrypt, cont_prep_encrypt): New.
(register_commands): Register PREP_ENCRYPT command.
(copy_recipients): Take a copy of each string.
* gpaoperation.c (gpa_operation_write_status): New.
* gpastreamencryptop.c (gpa_stream_encrypt_operation_new): Add arg
SILENT and change all callers.
(parse_recipients): Write a status line.
2007-10-02 Werner Koch <wk@g10code.com>
* utils.c (translate_sys2libc_fd): New.
2007-10-01 Werner Koch <wk@g10code.com>
* utils.c: New to implement xmalloc and xcalloc.
2007-09-28 Werner Koch <wk@g10code.com>
* gpakeyselector.c (gpa_key_selector_next_key): Don't segv is not
a default key is missing.
2007-09-27 Werner Koch <wk@g10code.com>
* server.c: New.
* w32-afunix.h, w32-afunix.c: New. Taken from GnuPG.
* gpa.c (main): Start the server. New option --server.
* gpa.h (gnupg_homedir): Declare it. Add a bunch of convenience
macros.
* gpafileencryptop.c (gpa_file_encrypt_operation_new_for_server):
New.
(gpa_file_encrypt_operation_next)
(gpa_file_encrypt_operation_done_cb)
(gpa_file_encrypt_operation_response_cb): Call server finish.
* gpaoperation.c (PROP_SERVER_CTX): New property.
(gpa_operation_set_property, gpa_operation_get_property): Set it.
(gpa_operation_class_init): Define property.
(gpa_operation_server_finish): New.
* Makefile.am (AM_CFLAGS): Add assuan and gpg-error flags.
(LDADD): Add assuan, gpg-error libs and NETLIBS
Make sure that all file include config.h as the first header.
2007-05-24 Werner Koch <wk@g10code.com>
* Makefile.am (.rc.o): Replace gmake style pattern rule.
2007-05-18 Werner Koch <wk@g10code.com>
* fileman.h (_GpaFileManager, _GpaFileManagerClass): Move
definitions to ..
* fileman.c: .. implementation file. Documentaion cleanups and
moved some functions for clarity.
(dnd_drop_handler, dnd_data_received_handler): New.
(gpa_file_manager_constructor): Connect DnD handler.
2007-05-16 Werner Koch <wk@g10code.com>
* helpmenu.c (help_about) [W32]: Point user to www.gpg4win.org.
(help_license): Capitalize a proper name.
2007-05-02 Werner Koch <wk@g10code.com>
* gpgmetools.c (string_to_utf8): Rewritten.
2007-04-25 Werner Koch <wk@g10code.com>
* keyring.c (keyring_details_page_fill_num_keys): Use ngettext.
Suggested by Maxim Britov.
* i18n.h (ngettext): New.
2007-02-12 Werner Koch <wk@g10code.com>
* gpaimportop.c (gpa_import_operation_class_init): New signal
imported_secret_keys.
(gpa_import_operation_done_cb): Emit new signal if a secret key
has been imported.
* keyring.c (gpa_keyring_editor_changed_wot_secret_cb): New.
(register_import_operation): Connect new signal.
* keylist.c (gpa_keylist_imported_secret_key): New.
2007-02-07 Werner Koch <wk@g10code.com>
* gpakeyselector.c (gpa_key_selector_get_selected_keys): Avoid
endless loop when seleting more than one key.
* gpafileencryptop.c (gpa_file_encrypt_operation_done_cb): Do not
free RSET here ..
(gpa_file_encrypt_operation_finalize): .. but here.
2007-01-29 Werner Koch <wk@g10code.com>
* gpgmeedit.c (struct edit_parms_s): New field
need_status_passphrase_sym.
(edit_fnc): Take care of it.
(PasswdState): New state PASSWD_ENTERNEW.
(struct passwd_parms_s): Remove REQUEST_COUNTER.
(edit_passwd_fnc_action): Handle PASSWD_ENTERNEW.
(edit_passwd_fnc_transit): Test for NEED_PASSPHRASE_SYM.
(passwd_passphrase_cb): Rewritten to take action directly on the
current state.
(gpa_gpgme_edit_passwd_start): Pass the edit parms and not the old
REQUEST_COUNTER.
* gpgmetools.c (passphrase_question_label): Take care of a missing
user-id hint.
* gpakeyexpireop.c (gpa_key_expire_operation_done_error_cb): Give
a more specific error message.
* gpgmeedit.c (edit_expire_fnc_transit): Return a more suitable
error code for invalid dates.
(gpa_gpgme_edit_expire_parms_new): Do not use %F for strftime as
this is C99 and not supported on all systems (i.e. Windows).
2007-01-10 Werner Koch <wk@g10code.com>
* Makefile.am (INCLUDES): Removed.
(AM_CFLAGS, AM_CPPFLAGS): New.
(LDADD): Add GPGME and GTK libs.
2006-07-26 Werner Koch <wk@g10code.com>
* passwddlg.c (gpa_change_passphrase_dialog_run): Release PASSWD
in case the dialog is repeated. Reported by Timo Schulz.
2006-07-15 Marcus Brinkmann <marcus@g10code.de>
* gpa.rc: Move to ...
* gpa-resource.rc: ... here. Update.
* Makefile.am (gpa_SOURCES): Remove gpa.rc.
(EXTRA_DIST): Add gpa-resource.rc.
(gpa_LDFLAGS, gpa_DEPENDENCIES): New variables.
2006-07-03 Werner Koch <wk@g10code.com>
* gpa.ico: New. Converted from ../gpa.png by wwp.
2006-05-27 Marcus Brinkmann <marcus@g10code.de>
* gpgmetools.c (gpa_backup_key): Close FILE on error.
* gpabackupop.c (gpa_backup_operation_do_backup): Add an error
message if creating the backup fails.
2006-03-20 Werner Koch <wk@g10code.com>
* hidewnd.c (enum_parent_windows): Updated test for newer
Windows versions.
2006-03-13 Werner Koch <wk@g10code.com>
* keygenwizard.c (gpa_keygen_wizard_generate_action): Init PARAMS
to avoid garbage in the comment field.
2006-03-03 Marcus Brinkmann <marcus@g10code.de>
* keyserver.c (keyserver_read_list): Fix typo in keyserver list.
2006-03-03 Marcus Brinkmann <marcus@g10code.de>
* gpafileverifyop.c: Revert last change, it broke verification of
non-encrypted files. Instead, the decryption operation has to
show the signatures, but that is a bigger change.
2006-02-28 Marcus Brinkmann <marcus@g10code.de>
* gpafileverifyop.c (gpa_file_verify_operation_start): Use
gpgme_op_decrypt_verify_start for non-detached signatures, so
decrypted and signed files can be verified.
* keygenwizard.c: Remove comment_page.
(gpa_keygen_wizard_comment_page): Function removed.
(gpa_keygen_wizard_generate_action): Do not free params.comment.
(gpa_keygen_wizard_new): Do not add comment page.
* gpa.c (main): Create default config directory if it doesn't
exist.
2006-02-14 Marcus Brinkmann <marcus@g10code.de>
* gpgmetools.c (O_BINARY): Define if it isn't defined by system
headers.
(gpa_open_output): Use open() instead of creat() and set binary
mode.
(gpa_open_input): Set binary mode.
2006-01-17 Werner Koch <wk@g10code.com>
Replaced all stock buttons with plain texts for uniform
translations.
2006-01-13 Werner Koch <wk@g10code.com>
* gpgmeedit.c (edit_fnc): Do not call write for empty strings.
Add support for debugging.
(edit_sign_fnc_transit) <SIGN_UID>: Detect sign_uid.okay.
2006-01-12 Werner Koch <wk@g10code.com>
* server_access.c (helper_path): Add special version for W32.
(do_spawn) [W32]: Don't pass ERROR by value.
* gpa.c (get_locale_dir): Fixed.
2006-01-11 Werner Koch <wk@g10code.com>
* gpawizard.c (gpa_wizard_new): Replace stock button labels by our
own for consistent labeling between gpg4win installer and GPA.
2006-01-05 Werner Koch <wk@g10code.com>
* gpgmetools.c (gpa_passphrase_cb): Use passphrase_len also for
non-W32.
* gpa.c (get_locale_dir): New.
(i18n_init): Use new function. This is required for W32.
2006-01-04 Werner Koch <wk@g10code.com>
* gpgmetools.c [W32]: Include windows.h.
2005-12-31 Marcus Brinkmann <marcus@g10code.de>
* gpgmetools.c (gpa_passphrase_cb) [G_OS_WIN32]: Use WriteFile
instead of write.
2005-11-29 Werner Koch <wk@g10code.com>
* gpa.c (longopts): Made --keymanager an alias for --keyring.
2005-11-16 Werner Koch <wk@g10code.com>
* gpgmetools.c (gpa_key_validity_string): Handle case of missing UID.
(gpa_gpgme_key_get_userid): Ditto.
* keyring.c (keyring_details_page_fill_key): Ditto.
* keylist.c (gpa_keylist_next): Check for zero fingerprints.
(is_zero_fpr): New.
* gpacontext.c (gpa_context_register_cb) [W32]: Translate file
descriptor.
(gpa_context_passphrase_cb) [W32]: Ditto.
2005-11-15 Werner Koch <wk@g10code.com>
* Makefile.am (gpa_SOURCES): Removed simple-gettext.c
* w32reg.c: Updated from GnuPG 1.4.
* gpa.c (default_homedir): New.
(main): Setup the homedir using the new function. This matches
gnupg's way.
(search_config_file): Removed. This complicated lookup of the
configuration file is a maintenance nightmare. We create the
filenames now directly using the standard gnupg hoemdirectory.
* helpmenu.c: Print revision number.
2005-11-10 Marcus Brinkmann <marcus@g10code.de>
* gpa.c [G_OS_WIN32]: Include <windows.h>.
(CSIDL_APPDATA, CSIDL_LOCAL_APPDATA, CSIDL_FLAG_CREATE)
[G_OS_WIN32]: Define.
(w32_strerror, dlopen, dlsym, dlerror, dlclose,
w32_shgetfolderpath) [G_OS_WIN32]: Define.
(search_config_file) [G_OS_WIN32]: Check for shared application
local data folder, and in there for gnupg's home directory.
* helpmenu.c [G_OS_WIN32]: Disable broken scroll text.
* simple-gettext.c: Unused file removed.
2005-11-08 Marcus Brinkmann <marcus@g10code.de>
* server_access.c (write_command): New argument scheme.
(server_send_keys): Also to invocation.
(server_get_key): Likewise.
(check_errors): Don't look for errors if the exit status looks OK.
* keyserver.c (keyserver_read_list): Use HKP server as default,
drop LDAP surfnet server (seems to be down).
* gpgmeedit.c (edit_sign_fnc_transit): Handle early
"sign_uid.okay".
* keysigndlg.c (gpa_key_sign_run_dialog): Fix last change.
2005-11-07 Marcus Brinkmann <marcus@g10code.de>
* gpabackupop.c (export_browse): Pass ENTRY as parent to
gpa_get_save_file_name.
* keyring.c (keyring_details_page_fill_key): Use
gpa_gpgme_key_format_fingerprint.
* keysigndlg.c (gpa_key_sign_run_dialog): Likewise.
* gpgmetools.c (dump_data_to_file): Use gpgme_data_seek instead
gpgme_data_rewind.
(dump_data_to_clipboard): Likewise.
(get_gpg_path): Rewritten.
(gpa_gpgme_key_sig_get_level): Use sig_class, not class.
(gpa_key_ownertrust_string): Use key->owner_trust.
(gpa_key_validity_string): Use key->uids->validity and the various
key->subkeys flags.
(gpa_gpgme_key_get_fingerprint): Renamed to ...
(gpa_gpgme_key_format_fingerprint): ... this. Accept only a
string as argument.
* gpgmetools.h (gpa_gpgme_key_get_fingerprint): Replace with ...
(gpa_gpgme_key_format_fingerprint): ... this.
(gpa_gpgme_key_get_short_keyid): Remove IDX argument from prototype.
* gpabackupop.c (gpa_backup_operation_set_property): Adjust caller
of gpa_gpgme_key_get_short_keyid.
* gpakeyselector.c (gpa_key_selector_next_key): Likewise.
* gpawidgets.c (gpa_key_info_new): Likewise.
* keylist.c (gpa_keylist_next): Likewise.
* keyring.c (keyring_details_page_fill_key): Likewise.
(keyring_update_status_bar): Likewise.
* verifydlg.c (add_signature_to_model): Likewise.
2005-10-28 Marcus Brinkmann <marcus@g10code.de>
* gpgmetools.c (gpa_gpgme_key_get_userid): Work directly on
gpgme_user_id_t objects.
* gpgmetools.h (gpa_gpgme_key_get_userid): Work directly on
gpgme_user_id_t objects.
* gpawidgets.c (gpa_key_info_new): Rework using above changes..
* verifydlg.c [!HAVE_CONFIG_H]: Don't include config.h.
(add_signature_to_model): Invoke gpa_gpgme_key_get_userid with
right argument.
* keyring.c [!HAVE_CONFIG_H]: Do not include config.h.
(keyring_details_page_fill_key, keyring_signatures_page_fill_key)
(keyring_update_status_bar): Fix callers of gpa_gpgme_key_get_userid.
* keysigndlg.c [!HAVE_CONFIG_H]: Do not include config.h.
(gpa_key_sign_run_dialog): Fix caller of gpa_gpgme_key_get_userid.
* keylist.c [HAVE_CONFIG_H]: Include config.h.
(gpa_keylist_next): Fix caller of gpa_gpgme_key_get_userid.
* gpakeyselector.c [HAVE_CONFIG_H]: Include config.h.
(gpa_key_selector_next_key): Fix caller of
gpa_gpgme_key_get_userid.
* gpa.c [!HAVE_CONFIG_H]: Don't include config.h.
(main) [!USE_SIMPLE_GETTEXT && ENABLE_NLS]: Invoke
gpgme_set_locale.
* options.h: Remove const qualifier from return type.
* options.c (gpa_options_get_default_key): Likewise.
* keytable.h (gpa_keytable_lookup_key): Likewise.
* keytable.c (gpa_keytable_lookup_key): Likewise.
* gpawidgets.c (gpa_expiry_frame_get_expiration): Make day, month
and year of type guint.
* expirydlg.c (expiry_ok): Likewise.
* qdchkpwd.c (qdchkpwd): Cast char pointer to unsigned char
pointer for compress.
* server_access.c (do_spawn): Make length of type gsize.
2005-10-06 Marcus Brinkmann <marcus@g10code.de>
* w32reg.c: Don't include util.h.
* gpa.c (search_config_file): Check existance of G_OS_WIN32, not
value.
2004-08-21 Miguel Coca <mcoca@gnu.org>
* gpaexportop.c (gpa_export_operation_idle_cb): Armor by default.
* gpaexportfileop.c (gpa_export_file_operation_get_destination): Use
the provided armor value as default.
2003-12-15 Miguel Coca <mcoca@gnu.org>
* keylist.c (gpa_keylist_next, gpa_keylist_init): Change the sorting
value for revoked and expired keys. This requires supporting negative
values in the sorting column.
2003-11-27 Miguel Coca <mcoca@gnu.org>
* keylist.c (gpa_keylist_elgamal_dialog): New.
(gpa_keylist_next): Check for secret ElGamal signing keys, and
warn the user.
2003-11-25 Miguel Coca <mcoca@gnu.org>
* gpa.c (main): Fix previous change.
2003-11-25 Miguel Coca <mcoca@gnu.org>
* gpa.c (main): Add a default icon for the application windows.
2003-11-24 Ling Li <ling@caltech.edu>
* keyring.c (keyring_editor_can_sign):
Disable the key sign button when there's no default key.
2003-11-23 Miguel Coca <mcoca@gnu.org>
* keytable.c (gpa_keytable_init, done_cb)
(gpa_keytable_lookup_key): Use initialized to test whether the
keytable has been filled from gpgme. This is needed because an empty
but initialized list is NULL, just as an unitialized one.
* keytable.h: Add "initialized" field to GpaKeyTable.
2003-11-21 Miguel Coca <mcoca@gnu.org>
* filesigndlg.c (gpa_file_sign_dialog_constructor): Use the name
"cleartext signature" even when in advanced mode. This is the same
nomenclature gpg uses.
2003-10-29 Miguel Coca <mcoca@gnu.org>
* qdchkpwd.c (qdchkpwd): Fix crash with long passphrases. Reported by
Graeme Hewson <graeme.hewson@oracle.com>.
2003-10-27 Miguel Coca <mcoca@gnu.org>
* keyring.c (keyring_editor_refresh, toolbar_refresh): New.
(keyring_toolbar_new): Add refresh toolbar icon.
(keyring_editor_menubar_new): Add refresh command.
2003-10-27 Miguel Coca <mcoca@gnu.org>
* gpafileverifyop.c (ask_use_detached_sig): New.
(is_detached_sig): Given a file, try to find a detached signature
in another file.
(gpa_file_verify_operation_init)
(gpa_file_verify_operation_done_cb): Save and use the filename of
the signature.
* verifydlg.h, verifydlg.c (gpa_file_verify_dialog_add_file)
(verify_file_page): Display the detached signature filename too.
* gpgmetools.c (gpa_generate_key_start): Remove fix for GPGME 0.4.3.
2003-10-22 Miguel Coca <mcoca@gnu.org>
* keyring.c (gpa_keyring_editor_new_key_cb): Update the default key
after generation.
* options.c (gpa_options_update_default_key)
(gpa_options_set_default_key): Catch a NULL key. Fixes crash at
startup for new users.
2003-10-18 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_generate_key_start): Introduce memory leak to
work around a GPGME 0.4.3 bug. To be removed after the release.
* gpaprogressdlg.c (gpa_progress_dialog_init): Disable cancel, as it
doesn't work yet.
2003-10-17 Miguel Coca <mcoca@gnu.org>
* gpakeytrustop.c (gpa_key_trust_operation_finalize): Remove unused
variable.
* gpafileencryptop.c (set_recipients): Remove deprecated gpgme calls.
* ownertrustdlg.c (gpa_ownertrust_run_dialog): Likewise.
* expirydlg.c (gpa_expiry_dialog_run): Likewise.
* keyring.c (disable_selection_sensitive_widgets): New.
(keyring_editor_selection_changed): Use it.
(keyring_editor_edit): Don't proceed without a valid key.
2003-10-13 Miguel Coca <mcoca@gnu.org>
* keyring.c: Delete stale include.
2003-10-12 Miguel Coca <mcoca@gnu.org>
* gpasubkeylist.c (gpa_subkey_list_new, gpa_subkey_list_set_key): Add
a "can authenticate" flag.
2003-10-12 Miguel Coca <mcoca@gnu.org>
* keyring.c (gpa_keyring_editor_new_key_cb)
(register_generate_operation): New.
(keyring_editor_generate_key_advanced)
(keyring_editor_generate_key_simple): Use operation objects.
* keylist.c (gpa_keylist_init):
(gpa_keylist_start_reload): Display the trustdb dialog.
(gpa_keylist_new_key): New.
(display_dialog, remove_trustdb_dialog): New.
(add_trustdb_dialog): New. Set a timeout before displaying the
"rebuilding trustdb" dialog.
(gpa_keylist_next): Remove the dialog here.
(gpa_keylist_end): Likewise. Make sure the dialog is always removed.
* keylist.h (gpa_keylist_new_key): New.
* keytable.c (gpa_keytable_init): Add new_key field.
(reload_cache): Receive a pattern, too.
(done_cb): Act differently when in "new key" mode.
(gpa_keytable_list_keys, gpa_keytable_force_reload)
(gpa_keytable_lookup_key): Change call to reload_cache.
(gpa_keytable_load_new): New.
* keytable.h: New function.
* keygenwizard.c (gpa_keygen_wizard_generate_action): Don't
generate the key here, just invoke a callback to let the operation
know it's time to generate it.
(gpa_keygen_wizard_destroy): Remove call to gtk_main_quit.
(gpa_keygen_wizard_new): Receive the callback. Don't go into a
nested main loop.
* keygenwizard.h (gpa_keygen_wizard_run): Rename to:
(gpa_keygen_wizard_new): Change prototype to receive a callback
* gpgmetools.c, gpgmetools.h (gpa_generate_key_start): Replace
gpa_generate_key with this.
* gpabackupop.c (gpa_backup_operation_get_property)
(gpa_backup_operation_set_property)
(gpa_backup_operation_class_init): Add fingerprint property. When
receiving a key, use just it's fingerprint.
(gpa_backup_operation_finalize, gpa_backup_operation_init): Account for
fingerprint and key id fields.
(gpa_backup_operation_do_backup): Use the stored fingerprint instead
of the key.
(gpa_backup_operation_dialog_run)
(gpa_backup_operation_idle_cb): Same thing with the key id.
(gpa_backup_operation_new_from_fpr): New.
* gpabackupop.h (gpa_backup_operation_new_from_fpr): New constructor
to backup a key by fingerprint.
* gpagenkeyop.h, gpagenkeyop.c, gpagenkeyadvop.h, gpagenkeyadvop.c,
gpagenkeysimpleop.h, gpagenkeysimpleop.c: New. The key generation
operations.
* Makefile.am (gpa_SOURCES): Add gpagenkeyop.h, gpagenkeyop.c,
gpagenkeyadvop.h, gpagenkeyadvop.c, gpagenkeysimpleop.h and
gpagenkeysimpleop.c.
* keytable.h (gpa_keytable_destroy): Removed.
* options.h, options.c (gpa_options_destroy): Removed.
* gpaoperation.c (gpa_operation_finalize): Replace gpa_context_destroy
with g_object_unref.
* verifydlg.c (gpa_file_verify_dialog_finalize): Likewise.
* gpacontext.h, gpacontext.c (gpa_context_destroy): Removed.
* gpaoperation.h, gpaoperation.c (gpa_operation_destroy): Removed.
* keyring.c (register_key_operation, register_import_operation)
(register_operation): Replace gpa_operation_destroy with
g_object_unref.
* fileman.c (register_operation): Likewise.
* keyeditdlg.c (gpa_key_edit_change_expiry)
(gpa_key_edit_change_passphrase): Likewise.
2003-10-03 Miguel Coca <mcoca@gnu.org>
* keyring.c (keyring_editor_key_listed): New.
(keyring_editor_selection_changed): Change to list the current key
asynchronously. Use the callback above.
(idle_update_details): Make sure the current key has been listed
before using it. Otherwise, wait until it's ready.
(display_popup_menu): Change to receive the editor. Block the
"selection changed" signal while messing with the selection.
(keyring_editor_new): Add new initialization.
2003-09-21 Miguel Coca <mcoca@gnu.org>
* passwddlg.c (gpa_change_passphrase_dialog_run): Fix bug by which the
dialog always complained about the passphrase confirmation.
* keyring.c (gpa_keyring_editor_key_modified): New. Signal
handler for edit dialog "key_modified".
(keyring_editor_edit): Use the new edit dialog.
* keyeditdlg.c, keyeditdlg.h: Turn the dialog into a subclass of
GtkDialog. Now it emits signals and can run concurrently with the
main keyring window.
* gpgmeedit.c (gpa_gpgme_edit_trust_parms_new)
(gpa_gpgme_edit_sign_parms_new): Do save the signal ID, so that
we don't run clean up twice for the same operation. Was broken
before.
(gpa_gpgme_edit_expire_parms_release)
(gpa_gpgme_edit_passwd_parms_release)
(gpa_gpgme_edit_expire_parms_new)
(gpa_gpgme_edit_passwd_parms_new): New.
(gpa_gpgme_edit_expire_start)
(gpa_gpgme_edit_passwd_start): Use the above. Change name (to
_start), receive a GpaContext, and change to only start the
operation without waiting for it.
* Makefile.am (gpa_SOURCES): Add gpakeyexpireop.h, gpakeyexpireop.c,
gpakeypasswdop.h, gpakeypasswdop.c.
* gpakeyexpireop.h, gpakeyexpireop.c, gpakeypasswdop.h,
gpakeypasswdop.c: New. Operations for the options in the edit dialog.
2003-09-18 Miguel Coca <mcoca@gnu.org>
* keyring.c (register_key_operation, register_import_operation)
(register_operation): Handle different types of operations differently.
(keyring_editor_import_do_import)
(keyring_editor_import_get_source)
(keyring_editor_export_do_export): Removed.
(keyring_editor_import, keyring_editor_export): Changed to use
operations.
(keyring_editor_retrieve, keyring_editor_send): New functions.
Import/Export with servers.
(keyring_editor_backup): Use a GpaOperation.
(keyring_editor_mapped): Backup using a GpaOperation.
(keyring_editor_paste, keyring_editor_copy): Use GpaOperation's.
(keyring_editor_menubar_new): Add a "Server" menu for send/receive
operations.
(keyring_editor_popup_menu_new): Add "Send keys" menu item.
* keylist.c (gpa_keylist_get_property, gpa_keylist_set_property)
(gpa_keylist_class_init, gpa_keylist_init)
(gpa_keylist_start_reload): Add property handling and parent window
property.
* keylist.h: Add parent window to structure.
* keygenwizard.c (gpa_keygen_wizard_generate_action): Disable backup
generation until key generation is redone as an operation.
* gpafileencryptop.c (gpa_file_encrypt_operation_done_error_cb): Fix
broken error check.
* gpafileverifyop.c (gpa_file_verify_operation_done_error_cb):
* gpafilesignop.c (gpa_file_sign_operation_done_error_cb): Likewise.
* keyexportdlg.c, keyexportdlg.h, keyimportdlg.c,
keyimportdlg.h: Remove files. All their functionality has been moved
to the GpaOperation objects.
* gpaexportop.h, gpaexportop.c, gpaexportfileop.h, gpaexportfileop.c,
gpaexportclipop.h, gpaexportclipop.c, gpaexportserverop.h,
gpaexportserverop.c, gpaimportop.h, gpaimportop.c, gpaimportfileop.h,
gpaimportfileop.c, gpaimportclipop.h, gpaimportclipop.c,
gpaimportserverop.h, gpaimportserverop.c, gpabackupop.h,
gpabackupop.c: New files. Separate GpaOperation subclasses for
each way to import/export/backup a file.
* gparecvkeydlg.h, gparecvkeydlg.c: New. Simple "Receive key"
dialog. Asks for the key ID to be retrieved.
* Makefile.am (gpa_SOURCES): Add new files, remove old.
2003-08-20 Miguel Coca <mcoca@gnu.org>
* gpgmetools.h, gpgmetools.c (gpa_gpgme_key_sig_get_userid)
(gpa_gpgme_key_sig_get_short_keyid)
(gpa_gpgme_key_sig_get_sig_status): Change to work on key signatures
instead of whole keys.
(gpa_gpgme_key_sig_get_level): New.
* siglist.c (gpa_siglist_new): Add columns for signature level and
whether a signature is local. Connect a callback to a change in the
UI mode.
(gpa_siglist_uid_add_columns): Add columns for level and local if in
advanced mode.
(add_signature): Receive a gpgme_key_sig_t and process it.
(add_signature_cb): New.
(gpa_siglist_set_all, revoked_signatures)
(gpa_siglist_set_userid): Replace deprecated gpgme calls.
(gpa_siglist_ui_mode_changed_cb): New.
(gpa_siglist_set_signatures): Adapt to new internal interface.
2003-08-18 Miguel Coca <mcoca@gnu.org>
* gpafileverifyop.c (gpa_file_verify_operation_init)
(gpa_file_verify_operation_start)
(gpa_file_verify_operation_done_cb): Add a field to the operation
to hold the name of the signed file for dettached signatures, and
use it.
* verifydlg.c (gpa_file_verify_dialog_finalize)
(gpa_file_verify_dialog_constructor): Add a GpaContext to the dialog,
to retrieve signature keys.
(fill_sig_model): Replace deprecated gpgme calls.
(signature_list, verify_file_page): Pass along the signatures. List
the verified files for dettached signatures.
* verifydlg.h, verifydlg.c (gpa_file_verify_dialog_add_file): Remove
context parameter, add the signatures themselvers, and the name of
the signed file for dettached signatures.
2003-07-30 Miguel Coca <mcoca@gnu.org>
* keyring.c (key_has_been_signed): Remove deprecated gpgme calls.
(keyring_editor_can_sign): Fix check for selected keys.
(keyring_editor_add_subkeys_page)
(keyring_editor_remove_subkeys_page): New. Add and remove the subkey
tab to the details notebook.
(keyring_details_notebook): Add capabilities and the subkeys page.
(keyring_details_page_fill_key): Set the capabilities text. Replace
deprecated gpgme calls.
(keyring_subkeys_page_fill_key, keyring_subkeys_page_empty): New.
(idle_update_details): Call them.
(keyring_ui_mode_changed): New. Manage the subkeys tab according to
the ui mode.
(keyring_editor_new): Use it.
* Makefile.am (gpa_SOURCES): Add gpasubkeylist.{c,h}.
* gpasubkeylist.h, gpasubkeylist.c: New. A list of the subkeys of a
key.
* gpgmetools.h, gpgmetools.c (gpa_get_key_capabilities_text): New.
Returns a user readable description of the capabilities of a key.
2003-07-29 Miguel Coca <mcoca@gnu.org>
* Makefile.am (gpa_SOURCES): Add gpakeytrustop.{c,h}.
* gpakeytrustop.h, gpakeytrustop.c: New.
* gpakeysignop.h: Remove unneeded include.
* keyring.c (keyring_editor_delete, keyring_editor_sign): Fix warnings.
(keyring_editor_trust): Use the GpaKeyTrustOperation.
* ownertrustdlg.h, ownertrustdlg.c (gpa_ownertrust_run_dialog): Return
the selected trust in an argument. Don't edit the key from this
function.
* gpgmeedit.h, gpgmeedit.c (gpa_gpgme_edit_trust_parms_new)
(gpa_gpgme_edit_trust_parms_release): New.
(gpa_gpgme_edit_trust): Renamed to:
(gpa_gpgme_edit_trust_start): Same changes as the "sign" operation.
2003-07-28 Miguel Coca <mcoca@gnu.org>
* Makefile.am (gpa_SOURCES): Add gpakeysignop.{c,h}
* gpakeysignop.h, gpakeysignop.c: New. The key signing operation.
* gpgmeedit.h, gpgmeedit.c (gpa_gpgme_edit_sign_parms_new)
(gpa_gpgme_edit_sign_parms_release): New.
(gpa_gpgme_edit_sign): Renamed to:
(gpa_gpgme_edit_sign_start): Use the event loop. Now receives a
GpaContext so that it can attach itself to the "done" signal and do
clean up after the signing completes.
* keyring.c (keyring_editor_sign): Use the GpaKeySignOperation.
* keylist.c (gpa_keylist_start_reload): Fix typo.
2003-07-25 Miguel Coca <mcoca@gnu.org>
* gpakeydeleteop.c, gpakeydeleteop.h, gpakeyop.c, gpakeyop.h: New.
* Makefile.am (gpa_SOURCES): Add gpakeyop.{c,h} and
gpakeydeleteop.{c,h}.
* keyring.c (gpa_keyring_editor_changed_wot_cb): New.
(register_operation): New.
(keyring_editor_delete): Use the GpaKeyDeleteOperation.
* keylist.h, keylist.c (gpa_keylist_init, gpa_keylist_start_reload)
(gpa_keylist_next): Display a warning while the trustdb rebuilds.
* gpafileverifyop.c (gpa_file_verify_operation_done_error_cb): Remove
obsolete comment.
* gpafilesignop.c (gpa_file_sign_operation_done_error_cb): Likewise.
* gpafiledecryptop.c (gpa_file_decrypt_operation_done_error_cb):
Likewise.
* gpafileencryptop.c (gpa_file_encrypt_operation_done_error_cb):
Likewise.
* keyring.c (keyring_editor_selection_changed): Run update_widgets
after loading the new current key,
2003-06-29 Miguel Coca <mcoca@gnu.org>
* gpaprogressdlg.c (gpa_progress_dialog_set_property)
(gpa_progress_dialog_progress_cb): Receive progress signals from the
context.
(gpa_progress_dialog_pulse, gpa_progress_dialog_start_cb)
(gpa_progress_dialog_done_cb): Remove the iddle function.
* gpacontext.h, gpacontext.c (gpa_context_class_init, gpa_context_init)
(gpa_context_progress, gpa_context_progress_cb): Add "progress" signal.
* keylist.c (gpa_keylist_start_reload): Empty the list before
reloading.
* gpakeyselector.c, keydeletedlg.c, keyeditdlg.c, keyexportdlg.c,
keylist.c, keyring.c, keytable.c, options.c: Fix syntax for accessing
the primary key.
2003-06-27 Miguel Coca <mcoca@gnu.org>
* keyring.c (keyring_signatures_page_fill_key): Save the label in the
signature page for later use.
(keyring_signatures_page_fill_key): Only show the list of user ids if
there is more than one.
2003-06-26 Miguel Coca <mcoca@gnu.org>
* gpakeyselector.c (gpa_key_selector_done): Don't sort automatically.
(gpa_key_selector_init): Allow sorting by different fields.
* keylist.c (gpa_keylist_next): Remove deprecated gpgme call.
(gpa_keylist_set_brief, gpa_keylist_set_detailed): Allow sorting
by columns.
(gpa_keylist_init, gpa_keylist_next): Add auxiliary sorting columns.
2003-06-22 Miguel Coca <mcoca@gnu.org>
* gpakeyselector.c (gpa_key_selector_new): Hack to fix default key
selection.
* options.c (gpa_options_set_default_key): Create a reference for
the key.
2003-06-22 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_generate_key): Return the key, not the fingerprint.
* keygenwizard.c (gpa_keygen_wizard_generate_action):
* keyring.c (keyring_editor_generate_key_advanced): Likewise.
* gpgmetools.c: Add missing include.
* keytable.c (gpa_keytable_lookup_key): Fix warning.
* keylist.c: Add missing include.
* keyeditdlg.c (key_edit_change_passphrase): Remove unused variable.
* gpakeyselector.c (gpa_key_selector_next_key): Fix default key check.
* settingsdlg.c (key_selected_cb): Fix crash.
2003-06-22 Miguel Coca <mcoca@gnu.org>
* All files: Replace old style error checking with libgpg-error.
* gpakeyselector.h, gpakeyselector.c: Use the keytable instead of
listing keys ourselves.
2003-06-21 Miguel Coca <mcoca@gnu.org>
* siglist.h, siglist.c (gpa_siglist_set_all)
(gpa_siglist_set_userid, gpa_siglist_set_signatures): Use
gpgme_key_t instead of fingerprints.
* options.h, options.c (gpa_options_init, gpa_options_finalize)
(gpa_options_set_default_key, gpa_options_get_default_key)
(determine_default_key, gpa_options_update_default_key)
(gpa_options_save_settings): The default key is now a
gpgme_key_t.
* keytable.h, keytable.h: Redo using a GpaContext to work
inside the Gtk main loop.
* keyring.c (struct _GPAKeyringEditor): Rename clist_keys to
keylist (since it's no longer a GtkCList). Add current_key field.
(keyring_editor_fill_keylist): Remove obsolete.
(key_has_been_signed): Use new keylist interface. Work with
keys instead of fingerprints.
(keyring_editor_can_sign):
(keyring_editor_has_private_selected):
(keyring_editor_delete):
(keyring_editor_sign, keyring_editor_edit, keyring_editor_trust)
(keyring_editor_import_do_import)
(keyring_editor_export_do_export, keyring_editor_export)
(keyring_editor_generate_key_advanced)
(keyring_editor_generate_key_advanced)
(idle_update_details)
(keyring_set_brief_listing, keyring_set_detailed_listing)
(keyring_update_status_bar)
(display_popup_menu, keyring_editor_new):
(keyring_editor_generate_key_simple): Likewise.
(keyring_editor_current_key): Rename from _current_key_id.
(keyring_editor_selection_changed): Set the current key with
all it's sigs here.
(keyring_editor_select_all): Use a TreeView instead of a CList.
(signatures_uid_selected): Use new siglist interface.
(keyring_editor_mapped): Change secret key tests.
(keyring_details_page_fill_key): Likewise.
(is_selected_row): Removed.
* keylist.h, keylist.c: Rewrite as a GtkTreeView. Change the
interface to a more sensible one.
* keyexportdlg.h, keyexportdlg.c (key_backup_dialog_run): Receive
the key to backup, not it's fingerprint
* keyeditdlg.h, keyeditdlg.c (gpa_key_edit_dialog_run): Receive
a key, not it's fingerprint.
(gpa_key_edit_dialog_run): Use new keytable
* keydeletedlg.h, keydeletedlg.c (gpa_delete_dialog_run): Figure
out whether the key is secret here, remove has_secret argument.
* icons.h, icons.c (gpa_create_icon_pixbuf): New.
* helpmenu.c (help_license): Replace deprecated GtkText with
GtkTextView.
* gpgmetools.c (gpa_generate_key): Don't save the key into the
keytable. With the new keytable, it should just be reloaded.
* gpgmeedit.h, gpgmeedit.c (gpa_gpgme_edit_sign): Receive the
signer as a gpgmekey, too. Use new keytable.
* gpa.h: Remove keytable variable.
(gpa_default_key, gpa_set_default_key)
(gpa_update_default_key): Remove obsolete.
* gpa.c: Remove keytable global varible.
(main): Don't initialize it.
2003-06-07 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_backup_key): Make backups 600. Patch by
Bastian Blank <waldi@debian.org>.
2003-05-30 Miguel Coca <mcoca@gnu.org>
* gpgmeedit.c (passwd_passphrase_cb): Use new passphrase interface.
(edit_fnc): New prototype.
* settingsdlg.c (key_selected_cb): Fix pointer type.
* qdchkpwd.c: Add include to remove warning.
* passwddlg.c (gpa_change_passphrase_dialog_run): New prototype.
* gpgmetools.h, gpgmetools.c (gpa_passphrase_cb)
(passphrase_question_label): Use new passphrase interface.
* keyring.c (keyring_editor_import_do_import): Use new gpgme type
names.
(keyring_editor_export_do_export): Use the new way to export keys
from gpgme.
* keyimportdlg.h, keyimportdlg.c (key_import_results_dialog_run): Use
new type name.
* gpafileencryptop.h: Change the way recipients are specified.
* gpafileencryptop.c (gpa_file_encrypt_operation_done_cb)
(set_recipients, gpa_file_encrypt_operation_start): Likewise.
2003-05-22 Miguel Coca <mcoca@gnu.org>
* encryptdlg.c, encryptdlg.h, expirydlg.c, expirydlg.h, fileman.c,
fileman.h, filesigndlg.c, filesigndlg.h, gpa.c, gpa.h,
gpa_license.c, gpa_license.h, gpacontext.c, gpacontext.h,
gpafiledecryptop.c, gpafiledecryptop.h, gpafileencryptop.c,
gpafileencryptop.h, gpafileop.c, gpafileop.h, gpafilesignop.c,
gpafilesignop.h, gpafileverifyop.c, gpafileverifyop.h,
gpakeyselector.c, gpakeyselector.h, gpaoperation.c,
gpaoperation.h, gpapastrings.c, gpapastrings.h, gpaprogressdlg.c,
gpaprogressdlg.h, gpawidgets.c, gpawidgets.h, gpawindowkeeper.c,
gpawindowkeeper.h, gpawizard.c, gpawizard.h, gpgmeedit.c,
gpgmeedit.h, gpgmetools.c, gpgmetools.h, gtktools.c, gtktools.h,
helpmenu.c, helpmenu.h, hidewnd.c, hidewnd.h, i18n.h, icons.c,
icons.h, keydeletedlg.c, keydeletedlg.h, keyeditdlg.c,
keyeditdlg.h, keyexportdlg.c, keyexportdlg.h, keygendlg.c,
keygendlg.h, keygenwizard.c, keygenwizard.h, keyimportdlg.c,
keyimportdlg.h, keyimpseldlg.c, keyimpseldlg.h, keylist.c,
keylist.h, keyring.c, keyring.h, keyserver.c, keyserver.h,
keysigndlg.c, keysigndlg.h, keytable.c, keytable.h, options.c,
options.h, ownertrustdlg.c, ownertrustdlg.h, passwddlg.c,
passwddlg.h, qdchkpwd.c, qdchkpwd.h, server_access.c,
server_access.h, settingsdlg.c, settingsdlg.h, siglist.c,
siglist.h, simple-gettext.c, verifydlg.c, verifydlg.h, w32reg.c,
w32reg.h: Do a global search and replace for new Gpgme type names.
2003-05-20 Miguel Coca <mcoca@gnu.org>
* gpawidgets.c (gpa_key_info_new): Fix memory leak.
2003-05-17 Miguel Coca <mcoca@gnu.org>
* gpakeyselector.c (gpa_key_selector_get_selected_keys): Don't
reference returned keys.
* settingsdlg.c (key_selected_cb): Don't unreference keys.
* gpafileencryptop.c (gpa_file_encrypt_operation_response_cb):
* gpafilesignop.c (gpa_file_sign_operation_response_cb): Likewise.
2003-05-16 Miguel Coca <mcoca@gnu.org>
* Makefile.am (gpa_SOURCES): Remove keyimpseldlg.{c,h}, as they
were not being used.
* gpawidgets.c (gpa_key_list_add_key, gpa_secret_key_list_new)
(gpa_public_key_list_new, gpa_key_list_new_from_glist)
(gpa_key_list_selection_length, gpa_key_list_selected_ids)
(gpa_key_list_selected_id): Remove the gpa_key_list.
* gpawidgets.h, gpawidgets.c (gpa_key_list_new):
* settingsdlg.c (default_key_frame): Use a GpaKeySelector.
2003-05-15 Miguel Coca <mcoca@gnu.org>
* Makefile.am (gpa_SOURCES): Add gpakeyselector.{c,h}
* gpakeyselector.h, gpakeyselector.c: New. A replacement for the
gpa_key_list that lists the keys itself.
* gpafilesignop.c (gpa_file_sign_operation_response_cb)
(set_signers):
* gpafileencryptop.c (set_recipients, set_signers)
(gpa_file_encrypt_operation_response_cb): Adapt to receive GLists of
keys instead of fingerprints from the encrypt dialog.
* filesigndlg.c (gpa_file_sign_dialog_constructor)
(gpa_file_sign_dialog_signers): Use a key selector.
* encryptdlg.c (select_row_cb, unselect_row_cb): Delete.
(changed_select_row_cb): New.
(gpa_file_encrypt_dialog_init)
(gpa_file_encrypt_dialog_recipients)
(gpa_file_encrypt_dialog_signers): Use key selectors.
2003-05-04 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c, server_access.c: Remove gpgmeparsers.h include.
2003-05-04 Miguel Coca <mcoca@gnu.org>
* gpgmeparsers.c, gpgmeparsers.h: Delete.
* Makefile.am (gpa_SOURCES): Remove gpgmeparsers.{c,h}
* keyimportdlg.c (key_import_results_dialog_run):
* keyring.c (keyring_editor_import_do_import): Use a GpgmeImportResult.
* gpafileverifyop.c (gpa_file_verify_operation_done_error_cb):
* gpafilesignop.c (gpa_file_sign_operation_done_error_cb):
* gpafileencryptop.c (gpa_file_encrypt_operation_done_error_cb):
* gpafiledecryptop.c (gpa_file_decrypt_operation_done_error_cb): Remove
error codes that no longer exist.
* siglist.c (gpa_siglist_set_all, gpa_siglist_set_userid):
* options.c (gpa_options_update_default_key):
* keyring.c (key_has_been_signed):
* gpafilesignop.c (set_signers):
* keyeditdlg.c (key_edit_change_passphrase):
* gpafileencryptop.c (set_recipients, set_signers): New gpgme_get_key
prototype.
2003-04-27 Miguel Coca <mcoca@gnu.org>
* gpafiledecryptop.c (gpa_file_decrypt_operation_done_error_cb):
* gpafileencryptop.c (gpa_file_encrypt_operation_done_error_cb):
* gpafilesignop.c (gpa_file_sign_operation_done_error_cb):
* gpafileverifyop.c (gpa_file_verify_operation_done_error_cb): Use
new names for error codes.
* gpgmetools.c (gpa_generate_key): Use new gpgme_op_genkey.
2003-04-05 Miguel Coca <mcoca@gnu.org>
* gpa.c (main): Open extra arguments as files in the filemanager.
* fileman.h, fileman.c (gpa_file_manager_open_file): New.
2003-04-05 Miguel Coca <mcoca@gnu.org>
* fileman.c (fileman_menu_new): Add a "clear" entry.
(fileman_toolbar_new): Likewise.
(toolbar_close_all, close_all_files): New.
2003-04-05 Miguel Coca <mcoca@gnu.org>
* gpa.c (quit_if_no_window, gpa_open_filemanager): Use new filemanager.
(gpa_get_filenamager): Remove.
* gpafileop.c (gpa_file_operation_finalize): Free the filenames too.
* verifydlg.c (signature_list): Show alternate colors for the list.
* siglist.c (gpa_siglist_new): Likewise.
* fileman.h, fileman.c: Reworked file manager. Use pure GTK+2 lists,
disable buttons when no file is selected, and don't display scrollbars
unless they are needed.
2003-03-23 Andy Ruddock <andy.ruddock@minnesund.net>
* options.h: Added 'detailed_view' configuration file option for
keylist window key view.
* options.c: Added functions to read/write 'detailed_view'
configuration file option.
* keyring.c: keylist window view reads configuration file and
defaults to brief/detailed view last used.
2003-03-22 Miguel Coca <mcoca@gnu.org>
* Makefile.am (gpa_SOURCES): Really remove gtkhacks.h.
2003-03-22 Miguel Coca <mcoca@gnu.org>
* options.h, options.c (gpa_options_get_instance): New. Turn the
GpaOptions object into a singleton.
* Change all users of GpaOptions.
* gpafileverifyop.c (gpa_file_verify_operation_done_error_cb):
* gpafilesignop.c (gpa_file_sign_operation_done_error_cb):
* gpafileencryptop.c (gpa_file_encrypt_operation_done_error_cb):
* gpafiledecryptop.c (gpa_file_decrypt_operation_done_error_cb): Make
all error cheking here.
* gpafileop.c (gpa_file_operation_done_error_cb): Remove error
handling.
* gpaoperation.c (gpa_operation_done_error_cb): Same here.
* gpgmetools.h, gpgmetools.c (gpa_gpgme_warning): New.
* fileman.c (gpa_fileman_toolbar_new): Remove GTK+ 1.2 compatibility.
* gpa.h: Remove gtkhacks.h. Remove gpa_options global variable.
* gtkhacks.h: Deleted.
2003-03-18 Miguel Coca <mcoca@gnu.org>
* verifydlg.h, verifydlg.c: Rewrite as widget.
* gpafileverifyop.c, gpafileverifyop.h: New.
* Makefile.am (gpa_SOURCES): Add new files.
* gpafileencryptop.c (gpa_file_encrypt_operation_done_cb): Advance the
current file here.
* gpafiledecryptop.c (gpa_file_decrypt_operation_done_cb): Likewise.
* gpafilesignop.c (gpa_file_sign_operation_done_cb): Likewise.
* gpafileop.c (gpa_file_operation_done_cb): Remove.
2003-03-09 Miguel Coca <mcoca@gnu.org>
* keyring.c (keyring_editor_delete): Remove the key from the keytable
before deleting the key from the list.
2003-03-07 Miguel Coca <mcoca@gnu.org>
* gpaoperation.c (gpa_operation_class_init)
(gpa_operation_constructor): Use a constructor.
* gpafileop.c, gpafileencryptop.c, gpafiledecryptop.c: Likewise.
* filesigndlg.c, filesigndlg.h: New API. Rewrite as a widget.
* fileman.c (sign_files): Use the GpaFileSignOperation.
* gpafilesignop.c, gpafilesignop.h: New.
* Makefile.am (gpa_SOURCES): Add new files.
2003-02-12 Miguel Coca <mcoca@gnu.org>
* fileman.c (encrypt_files): Use the GpaFileEncryptOperation.
* gpafiledecryptop.c (destination_filename): Mark static.
(gpa_file_decrypt_operation_start): Save the GpgmeData's for later.
(gpa_file_decrypt_operation_done_cb): Do proper cleanup.
* gpafiledecryptop.h: Add the GpgmeData's to the structure.
* gpaoperation.h, gpafileop.h: Include gpa.h
* encryptdlg.h, encryptdlg.c: New API. Remove encryption itself from
this file, as it is handled by the operation.
* Makefile.am (gpa_SOURCES): Add new files.
* gpafileencryptop.h, gpafileencryptop.c: New.
2003-02-10 Miguel Coca <mcoca@gnu.org>
* options.c (read_next_word): Fix unsafe use of char with getc.
2003-02-07 Miguel Coca <mcoca@gnu.org>
* fileman.c (get_selected_files): List files in the order they appear
on the screen.
(add_file): Add const to prototype.
(file_created_cb, register_operation): New. For use with operation
objects.
(decrypt_files): Use GpaFileDecryptOperation.
* passwddlg.c (gpa_change_passphrase_dialog_run): Use new prototype.
* gpgmetools.c (gpa_gpgme_new): Don't pass the context as data to
the passphrase callback.
(check_overwriting): New.
(gpa_fopen): Use it.
(gpa_open_output, gpa_open_input): New.
(gpa_passphrase_cb): Use new prototype.
* gpgmeedit.c (passwd_passphrase_cb): Use new prototype.
* gpacontext.c (gpa_context_busy): New function.
(gpa_context_destroy): Add some checking.
(struct gpa_io_cb_data): Add "registered" field.
(queue_callback): Rename to...
(add_callback): New.
(register_queued_callbacks): Rename to...
(register_all_callbacks): New. Don't remove from the list, as it now
holds all callbacks.
(unregister_all_callbacks): New.
(gpa_context_register_cb): Always add callbacks to the list.
(gpa_context_remove_cb): Always remove callbacks from the list.
(gpa_context_passphrase_cb): New. Our own passphrase callback.
(gpa_context_start, gpa_context_done): Remove debugging
* Makefile.am (gpa_SOURCES): Add new files.
* gpaprogressdlg.h, gpaprogressdlg.c: New. The progress dialog.
* gpaoperation.h, gpaoperation.c, gpafileop.h, gpafileop.c,
gpafiledecryptop.h, gpafiledecryptop.c: New. All operations will
now be objects.
2003-02-02 Miguel Coca <mcoca@gnu.org>
* gpacontext.c (register_callback, gpa_context_remove_cb): Fix clean
up issues.
2003-02-01 Miguel Coca <mcoca@gnu.org>
* Makefile.am (gpa_SOURCES): Add gpacontext.{c,h}
* gpacontext.h, gpacontext.c: New. A wrapper around the GpgmeCtx to
hook it to the gtk event loop.
* gpa.c (main): Remove unneeded variable.
* fileman.c (decrypt_files): Use one GpgmeCtx per operation.
* filesigndlg.c (sign_files):
* encryptdlg.c (encrypt_file, set_signers, do_encrypt):
* keyring.c (keyring_editor_delete, key_has_been_signed)
(keyring_editor_import_do_import)
(keyring_editor_export_do_export, keyring_editor_sign):
* keyeditdlg.c (key_edit_change_passphrase)
(key_edit_change_expiry):
* options.c (determine_default_key):
* gpgmetools.c (gpa_generate_key):
* keytable.c (do_keylisting, keytable_fill, load_keys):
* siglist.c (gpa_siglist_set_all, gpa_siglist_set_userid):
* keylist.c (keylist_fill_list): Likewise.
* gpgmeedit.h, gpgmeedit.c (gpa_gpgme_edit_trust)
(gpa_gpgme_edit_expire, gpa_gpgme_edit_sign)
(gpa_gpgme_edit_passwd): Add ctx argument.
* gpgmetools.c (gpa_passphrase_cb): Use the context as user data.
* passwddlg.c (gpa_change_passphrase_dialog_run): Likewise.
* gpa.h: Remove ctx global variable.
* gpa.c (main): Remove GpgmeCtx initialitation.
* gpgmetools.h, gpgmetools.c (gpa_gpgme_new): New.
2003-01-30 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_gpgme_key_get_fingerprint): Remove unnecessary
variable.
(get_gpg_path): New function.
(gpa_backup_key): Use it.
* verifydlg.c (verify_file): Remove gpgme 0.4.0 compatibility.
* gpgmeparsers.h, gpgmeparsers.c (gpa_parse_engine_info)
(parse_engine_info_text, parse_engine_info_end)
(parse_engine_info_start): Removed. No longer needed due to changes
in GPGME.
* helpmenu.c (help_about): Fix formatting and copyright message.
2003-01-24 Miguel Coca <mcoca@gnu.org>
* gpa.c (main): Replace getenv with more portable putenv.
2003-01-23 Miguel Coca <mcoca@gnu.org>
* verifydlg.c (verify_file): Another ugly hack, this time to allow
compilation with both gpgme 0.4.0 and 0.4.1.
* server_access.c (strsep): Ugly hack to get this to compile on
systems without strsep. To be fixed after the next release.
2003-01-21 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_gpgme_key_get_fingerprint): Check the fingerprint
length, instead of the algorithm, when deciding how to format the
fingerprint.
* gpgmetools.h (gpa_gpgme_key_get_fingerprint): Fix function
description.
2003-01-19 Miguel Coca <mcoca@gnu.org>
* gpa.h: Remove IS_DEVELOPMENT_VERSION define from this file.
* keygenwizard.c (gpa_keygen_wizard_run): Use the new wizard
interface.
* gpawizard.c, gpawizard.h (gpa_wizard_update_buttons)
(gpa_wizard_new, gpa_wizard_append_page): Changes to use GTK+2 stock
buttons.
2003-01-17 Miguel Coca <mcoca@gnu.org>
* keygendlg.c (gpa_key_gen_run_dialog): More UI Fixes.
(response_cb): Add check for empty or easy passphrase.
2003-01-15 Miguel Coca <mcoca@gnu.org>
* gpawidgets.c (gpa_expiry_frame_get_expiration): Fix bug in previous
change.
* gpawidgets.c (gpa_expiry_frame_dont, gpa_expiry_frame_after)
(gpa_expiry_frame_at, expire_date_toggled_cb)
(gpa_expiry_frame_new, gpa_expiry_frame_get_expiration)
(gpa_expiry_frame_validate): Use a calendar for choosing the
expiration date.
* keygendlg.c (gpa_key_gen_run_dialog): Port to use GTK+2 widgets.
(key_gen_cancel, key_gen_ok): Removed.
(response_cb): New.
* gpawidgets.c (gpa_expiry_frame_new):
* keygenwizard.c (gpa_keygen_wizard_generate_action): Don't set the
removed fields.
* gpgmetools.c (key_gen_params_new): Likewise.
* gpgmetools.h (GPAKeyGenParameters): Remove unused revocation and
send_to_server fields.
* options.c (gpa_options_update_default_key): Fix check for default
key, so that it is triggered if the key is deleted.
2003-01-08 Miguel Coca <mcoca@gnu.org>
* expirydlg.c (gpa_expiry_dialog_run): Fix label typo.
(gpa_expiry_dialog_run): Use a GtkCalendar for choosing the
expiration date.
(expire_date_toggled_cb): New.
(expiry_ok): Change to use the calendar.
* gpafilesel.c, gpafilesel.h: Remove.
* Makefile.am (gpa_SOURCES): Remove gpafilesel.{c,h}
* gtktools.c (file_dialog_ok, gpa_get_save_file_name): Use
GtkFileSelection.
* verifydlg.c (verify_file): Use the GPGME 0.4.0 interface.
2002-12-31 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_gpgme_key_get_userid): Tag revoked UID's as such.
* gpawidgets.c (gpa_key_info_new): Don't display revoked UID's.
* keysigndlg.c (gpa_key_sign_run_dialog): Likewise.
* keyring.c (keyring_editor_popup_menu_new): New. Creates the popup
menu.
(is_selected_row, display_popup_menu): Display it.
(keyring_editor_new): Use the above.
2002-12-30 Miguel Coca <mcoca@gnu.org>
* gpgmetools.c (gpa_passphrase_cb): Fix cleanup.
* gpgmeedit.c (edit_fnc): Ignore NEED_PASSPHRASE_SYM too.
(edit_passwd_fnc_action, edit_passwd_fnc_transit)
(passwd_passphrase_cb, gpa_gpgme_edit_passwd): New. Change the key's
passphrase.
* gpgmeedit.h (gpa_gpgme_edit_passwd): New.
* keyeditdlg.c (gpa_key_edit_dialog_run): Add "change passphrase"
button.
(key_edit_change_passphrase): New.
* qdchkpwd.c, qdchkpwd.h (qdchkpwd): Change prototype to remove
warnings.
* passwddlg.c, passwddlg.h: New. The "new passphrase" dialog.
* Makefile.am (gpa_SOURCES): Add passwddlh.{c,h}.
2002-12-29 Miguel Coca <mcoca@gnu.org>
* verifydlg.c (verify_file): Update for GPGME 0.4.1.
* keyring.c (keyring_editor_delete): Update the default key, in case
it's been deleted.
* server_access.c: Include signal.h.
2002-12-26 Miguel Coca <mcoca@gnu.org>
* keyring.c (key_has_been_signed): Account for a missing signing key.
* options.c (gpa_options_update_default_key): Check whether the
default key is really available.
2002-12-24 Miguel Coca <mcoca@gnu.org>
* keyring.c (keyring_editor_mapped): Fix backup at startup.
2002-12-18 Miguel Coca <mcoca@gnu.org>
* keyserver.c (keyserver_read_list): Clean default server list.
2002-12-17 Miguel Coca <mcoca@gnu.org>
* gpa.c (i18n_init): Output is always UTF-8.
2002-12-16 Miguel Coca <mcoca@gnu.org>
* keyring.c (keyring_editor_new): Remove specific font name.
* gpa.h: Include config.h here. Solves i18n problems.
2002-12-15 Miguel Coca <mcoca@gnu.org>
* gpawidgets.c (gpa_key_list_new): Use "User Name", as the rest of GPA
does.
* ownertrustdlg.c (gpa_ownertrust_run_dialog): Fix typo in "ultimate"
description.
* fileman.c (gpa_fileman_toolbar_new): Remove extra spaces around
"decrypt".
* expirydlg.c (gpa_expiry_dialog_run): Fix dialog title.
* helpmenu.c (help_about): Fix formatting of copyright notice.
* keyring.c (keyring_editor_paste): Fix segfault when the clipboard
was empty.
2002-12-13 Miguel Coca <mcoca@gnu.org>
* gpgmetools.h, gpgmetools.c (gpa_gpgme_key_sig_get_sig_status): Use
a hash of revoked signatures to check for them.
* siglist.c (gpa_siglist_set_userid, gpa_siglist_set_all)
(gpa_siglist_clear_columns, gpa_siglist_all_add_columns)
(gpa_siglist_uid_add_columns, gpa_siglist_new): Use different number
of columns and type for "all signatures" and individual uids.
(revoked_signatures, gpa_siglist_set_userid): Keep a list of revoked
signatures and use it.
* expirydlg.c (expiry_ok): Remove unused variable.
* keyring.c (keyring_editor_menubar_new): Add some checks to avoid
crashes on bad translations, as the menu items are not found, and
NULL's are appended to the selection sensitive lists.
2002-12-12 Miguel Coca <mcoca@gnu.org>
* fileman.c (gpa_fileman_toolbar_new, toolbar_preferences):
Disable the preferences button in the toolbar. It's long label
makes the toolbar far too long.
* keyring.c (keyring_toolbar_new, toolbar_preferences): Likewise.
* expirydlg.c (expiry_ok): Replace the gpa_message_box_run.
* keylist.c (keylist_fill_list): Likewise.
* keygenwizard.c (gpa_keygen_wizard_password_validate): Likewise.
* gtktools.h, gtktools.c (message_box_destroy, message_box_clicked)
(gpa_message_box_run, gpa_window_passphrase): Removed obsolete.
* Makefile.am (gpa_SOURCES): Remove icons.xpm
(INCLUDES): Add pixmap directory.
* icons.c: Include new icon files.
* icons.xpm: Removed, replaced by files in ../pixmaps.
* encrypt.xpm: Removed.
* verify.xpm, floppy.xpm, folder.xpm, icons.xpm, open_folder.xpm: Moved
to pixmap directory.
* fileman.c (gpa_fileman_toolbar_new): Add Preferences.
(toolbar_preferences): New.
* keyring.c (keyring_toolbar_new): Change tooltip for edit to make it
clear it's only for private keys.
Use stock icon for "Delete".
Add "Preferences".
(toolbar_preferences): New.
* options.c (gpa_options_read_settings): Don't report error if the
config file doesn't exist.
2002-12-11 Miguel Coca <mcoca@gnu.org>
* fileman.c (fileman_menu_new): Add the edit menu and stock icons.
Rename "Check" as "Verify" to match the toolbar button.
(fileman_select_all): New.
* helpmenu.c (gpa_help_menu_add_to_factory): Change order of buttons
to a more standard one.
* keyring.c (keyring_editor_import_get_source)
(keyring_editor_import_do_import, keyring_editor_import): Split import
into these functions.
(keyring_editor_export_do_export): New.
(keyring_editor_export): Use the above.
(keyring_editor_menubar_new): Add an edit menu. Move preferences
there. Use stock icons where possible.
(keyring_editor_select_all, keyring_editor_paste)
(keyring_editor_copy): New. The edit menu actions.
* keyexportdlg.c, keyexportdlg.h (key_backup_dialog_run, do_backup):
Add const to prototype. Fixes warning.
* keyexportdlg.c (key_export_dialog_run): Remove clipboard option.
Available from edit menu.
* keyimportdlg.c (key_import_dialog_run): Remove clipboard option,
as it is now available from the edit menu.
* gpgmetools.h, gpgmetools.c (fill_data_from_clipboard): Removed.
* keyring.c (keyring_editor_backup): Backup the selected key, not
the default one.
(keyring_editor_menubar_new): Enable "backup" only if a private key
has been selected.
2002-12-10 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_has_private_selected): New.
(key_has_been_signed): Reimplement.
(keyring_editor_can_sign): Use new key_has_been_signed.
(keyring_editor_sign): No need to check whether the key has been
signed, as the edit function handles that case gracefully (and it
should never happen anyway).
(keyring_editor_current_key): Removed #ifdef'ed out function.
(keyring_editor_menubar_new): Bring some order to the keys menu.
Only enable menu items when appropiate.
(keyring_toolbar_new): Only show the "edit" button if a private key
is selected.
2002-12-09 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_details_page_fill_key)
(keyring_details_notebook): Add key length and type to the details
notebook. They replace the public/private label, which is moved to the
top of the notebook.
2002-12-07 Miguel Coca <e970095@zipi.fi.upm.es>
* siglist.c (gpa_siglist_set_userid): Fix idiot bug.
* settingsdlg.c (gpa_settings_dialog_new): Close on enter.
* siglist.c (gpa_siglist_new): Sort the list by user ID. We should
find a way to make Unknown come last always.
* keyring.c (keyring_details_notebook): Add label to the menu.
(keyring_details_page_fill_num_keys): Change the text for "all
signatures."
* gpa.c (gpa_open_settings_dialog): Use the close_main_window callback
to track the destruction of the dialog.
* settingsdlg.c (gpa_settings_dialog_new): Destroy, not hide, the
dialog on close.
* keyring.c (keyring_editor_menubar_new): Move the settings menu item
to the file menu.
* fileman.c (fileman_menu_new): Likewise.
* keyring.c (signatures_uid_selected): New.
(keyring_details_notebook): Add the User ID popdown menu.
(keyring_signatures_page_fill_key): Rewrite to use the new siglist.
(keyring_signatures_page_empty): Clear the UID menu too.
(idle_update_details): Use new prototype of signatures_page_fill_key.
(keyring_editor_new): Increase default window size, leave more space
for the details notebook.
* siglist.h, siglist.c (gpa_siglist_new)
(gpa_siglist_set_signatures): Completely new signature list, for key
signatures only.
* gpgmetools.c (string_to_utf8): New.
(gpa_gpgme_key_get_userid): Use string_to_utf8.
* gpgmetools.h, gpgmetools.c (gpa_gpgme_key_sig_get_userid)
(gpa_gpgme_key_sig_get_short_keyid)
(gpa_gpgme_key_sig_get_sig_status): New.
2002-12-04 Miguel Coca <e970095@zipi.fi.upm.es>
* gpawidgets.c (gpa_key_list_new): Set the columns to autoresize.
* gpa.c, gpa.h (gpa_open_settings_dialog)
(gpa_get_settings_dialog): New.
* fileman.c (fileman_menu_new): Remove "Options" menu. Add "settings"
to the "Window" menu.
* keyring.c (keyring_editor_menubar_new): Likewise.
* settingsdlg.c, settingsdlg.h: New.
* optionsmenu.c, optionsmenuc.h: Removed.
* Makefile.am (gpa_SOURCES): Remove optionsmenu.{c,h}, add
settingsdlg.{c,h}.
2002-12-03 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmeedit.h, gpgmeedit.c (gpa_gpgme_edit_sign): Add const to
fingerprint declaration.
* keyring.c (keyring_editor_sign): Check for new return codes from
gpa_gpgme_edit_sign.
* gpgmeedit.c (edit_sign_fnc_transit): Set the error to GPGME_Conflict
if the key was already signed.
(gpa_gpgme_edit_sign): Check that there is really a default key.
2002-12-02 Miguel Coca <e970095@zipi.fi.upm.es>
* server_access.c (do_spawn): Fix shutdown of GIOChannel. Should fix
segfault on some systems.
2002-11-29 Miguel Coca <e970095@zipi.fi.upm.es>
* gpawidgets.c (struct add_key_data_s, gpa_key_list_add_key)
(gpa_public_key_list_new): Remove the default key row from here, as
reordering the clist was messing it up.
(gpa_secret_key_list_new): Add a loop to find and select the default
key.
* gpa.c: Rework the main function, and parsing of command line
arguments to use getopt.
* gpa.h, gpa.c (gpa_simplified_ui, gpa_set_simplified_ui)
(gpa_backup_generated, gpa_set_backup_generated)
(gpa_remember_backup_generated): Remove, superseded by the options
object.
* filesigndlg.c (file_sign_ok, gpa_file_sign_dialog_run)
(gpa_file_sign_dialog_run): Use the options object.
* gpawidgets.c (gpa_key_list_add_key):
* keyexportdlg.c (do_backup):
* keyimportdlg.c (key_import_dialog_run):
* keyring.c (keyring_editor_backup)
(keyring_editor_generate_key_advanced)
(keyring_editor_generate_key_simple, keyring_editor_generate_key)
(keyring_editor_mapped, keyring_editor_mapped)
(keyring_signatures_page_fill_key, keyring_update_status_bar)
(keyring_default_key_changed, keyring_editor_new):
* keysigndlg.c (gpa_key_sign_run_dialog):
* optionsmenu.c (options_keyserver_set, options_keyserver)
(options_key_set, options_key): Likewise.
* keyserver.c, keyserver.h: Remove management of the current
keyserver.
* fileman.c: Remove jnlib includes.
* gpa.h:
* helpmenu.c: Likewise.
* Makefile.am (INCLUDES, LDADD): Remove jnlib.
(gpa_SOURCES): Add options.c.
* options.c: New.
* options.h: Might as well be considered new.
* helpmenu.c (help_about): Fix copyright notice.
2002-11-28 Miguel Coca <e970095@zipi.fi.upm.es>
* server_access.c (protocol_version): The version number is
printed to stdout, not stderr!
2002-11-27 Miguel Coca <e970095@zipi.fi.upm.es>
* keyreceivedlg.c, keyreceivedlg.h: Removed obsolete.
* gpgmeedit.c (edit_trust_fnc_action)
(edit_trust_fnc_transit): Added a state for the "set_ultimate.okay"
prompt. Fixes a crash when setting a key to ultimate trust.
2002-11-22 Miguel Coca <e970095@zipi.fi.upm.es>
* Makefile.am (gpa_SOURCES): Add gtkhacks.h
* keylist.c (keylist_fill_list): Don't release the key until we are
done with it.
2002-11-20 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (gpa_generate_key): Load the generated key into the
keytable.
* keygenwizard.c (file_dirname, isdir): Removed.
(gpa_keygen_wizard_run): Remove the backup directory page.
(gpa_keygen_wizard_backup_dir_browse)
(gpa_keygen_wizard_backup_dir_page)
(gpa_keygen_wizard_backup_get_text)
(gpa_keygen_wizard_backup_dir_action): Removed.
(gpa_keygen_wizard_backup_action): Removed, replaced by
_generate_action.
(gpa_keygen_wizard_run, free_keygen_wizard): Remove backup filenames.
(gpa_keygen_wizard_generate_action): Do the key backup here.
(gpa_keygen_wizard_run): Make generate the action for the backup page.
* keyexportdlg.c (do_backup): New.
(key_backup_dialog_run): Do the backup here.
* keyring.c (keyring_editor_backup): Assume backups are done by the
dialog.
* gpa.c (main): Remove unused variable.
* keyring.c (keyring_editor_generate_key_advanced): Use the new
prototype of gpa_generate_key().
* keygenwizard.c (gpa_keygen_wizard_generate_action): Likewise.
* gpgmetools.h, gpgmetools.c (gpa_generate_key): Return the key
fingerprint.
* gpgmetools.c (dump_data_to_file, fill_data_from_clipboard)
(dump_data_to_clipboard): Change for GPGME 0.4.0.
* verifydlg.c (is_detached_sig): Fix dettached signatures.
(verify_file): Change for GPGME 0.4.0.
* verifydlg.c (verify_file): Changes for new verify ptrtotype on
GPGME 0.4.0.
* gpa.c (main): We no longer use a gtkrc.
Remove jnlib logging.
2002-11-13 Miguel Coca <e970095@zipi.fi.upm.es>
* keyserver.c: Replace all free() calls with g_free ().
* keyring.c: Likewise.
* keygenwizard.c: Likewise.
* keyeditdlg.c: Likewise.
* gpgmetools.c: Likewise.
* gpawindowkeeper.c: Likewise.
* gpawidgets.c: Likewise.
* gpa.c: Likewise.
* fileman.c: Likewise.
* expirydlg.c: Likewise.
2002-11-12 Miguel Coca <e970095@zipi.fi.upm.es>
* keylist.c (get_trust_value, get_ownertrust_value): Fix compiler
warnings.
* gpgmetools.c (gpa_backup_key): Likewise.
* gpgmeparsers.c (gpa_parse_engine_info, gpa_parse_import_info): Ditto.
* keyeditdlg.c: Removed obsolete ownertrust prototype.
* fileman.c: Forgot one of Francis's patches.
* gpa.c, gpa.h, gpawidgets.c, gpawindowkeeper.c, gpawizard.c,
gpgmetools.c, gtktools.c, gtktools.h, helpmenu.c, gtktools.h,
helpmenu.c, helpmenu.h, keyexportdlg.c, keygendlg.c,
keygenwizard.c, keyimportdlg.c, keyserver.c, optionsmenu.c,
siglist.c: Remove all calls to jnlib memory management and string
functions, fix compiler warnings and add conditional compilation
of headers where missing.
Submitted by Francis J. A. Pinteric <linuxdoctor@linux.ca>
2002-11-11 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (build_genkey_parms): Fix the date string.
* keyring.c (keyring_editor_generate_key_advanced): Remove bogus error
check.
2002-11-10 Miguel Coca <e970095@zipi.fi.upm.es>
* helpmenu.c (gpa_help_menu_add_to_factory): Renamed "Info" menu
back to "Help" for consistency with other programs.
(scroll_text): Added myself to the about dialog.
* keygenwizard.c (gpa_keygen_wizard_email_page)
(gpa_keygen_wizard_comment_page): Fix spelling of "address".
2002-11-09 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (gpa_key_validity_string): Add disabled and invalid
keys. Use "incomplete" for invalid.
(gpa_key_ownertrust_string): Add default option.
* keyring.c (keyring_editor_edit, keyring_editor_trust): New functions.
(keyring_editor_menubar_new): Add "edit" and "ownertrust" menu items.
(toolbar_edit_key): Use keyring_editor_edit.
* keyeditdlg.c (gpa_key_edit_dialog_run): Remove owner trust editing.
(key_edit_change_trust): Remove.
2002-11-08 Miguel Coca <e970095@zipi.fi.upm.es>
* verifydlg.c (signature_status_label): Add support for
revoked/expired keys. Don't talk about trust for keys.
* server_access.c (check_errors): Always return something.
(do_spawn): Report exec errors here, return boolean indicating
success.
(invoke_helper): Return boolean indicating success. Properly check
the return code of check_errors.
(server_send_keys, server_get_key): Check the return value of
invoke_helper.
* keyring.c (keyring_editor_import): Check for errors getting keys
from the server.
* server_access.c (server_get_key): Make sure a proper value is
returned for "data" everytime.
(helper_path): New function.
(check_errors): New function.
(server_get_key, server_send_keys): Removed dialog from here...
(invoke_helper): and added it here. Send some functionality into
other functions.
(protocol_version): Use the -V option of the plugins to find out the
version of a given plugin.
(do_spawn): New function. Run the helper asyncronously, and redraw the
dialog until it completes.
(close_dialog): New function.
* server_access.c, server_access.h (server_send_keys)
(server_get_key): Return a boolean indicating success.
* keyimportdlg.c (key_import_results_dialog_run): Added special
message if no keys were found in the import.
2002-11-06 Miguel Coca <e970095@zipi.fi.upm.es>
* verifydlg.c (verify_file): Check for GPGME_SIG_STAT_NONE too.
* encryptdlg.c (revoked_key, expired_key): New functions.
(set_recipients): Complain about revoked and expired keys.
* keyserver.c (keyserver_read_list): Added a couple of LDAP keyservers
to the default list.
2002-11-02 Miguel Coca <e970095@zipi.fi.upm.es>
* fileman.c (open_file, add_file): Only complain about an already
opened file when the user opens it from the menu.
* verifydlg.c (is_detached_sig): Take into account files without an
extension. Fixes segfault.
2002-10-30 Miguel Coca <e970095@zipi.fi.upm.es>
* gpapastrings.c, gpapastrings.h (gpa_trust_string)
(gpa_ownertrust_from_string, gpa_ownertrust_icon_name): Remove
obsolete.
* ownertrustdialog.h, ownertrustdlg.c (gpa_ownertrust_run_dialog):
Completedy redo the owner trust dialog. Edit the key inside this
function.
* keylist.c (get_trust_value, get_ownertrust_value): Rename key
trust as validity. Use new string functions.
* keyring.c (keyring_details_notebook)
(keyring_details_page_fill_key): Likewise.
* keyeditdlg.c (gpa_key_edit_dialog_run): Use the new string
functions.
(key_edit_change_trust): Use new version of owner trust dialog.
* gpgmetools.h, gpgmetools.c (gpa_key_ownertrust_string)
(gpa_key_validity_string): New functions.
* gpawidgets.c (gpa_key_info_new): Cosmetic fix to the label
alignment.
2002-10-27 Miguel Coca <e970095@zipi.fi.upm.es>
* helpmenu.c (gpa_help_menu_add_to_factory, help_warranty): Remove
the "warranty" item, as it just an exact copy of "license".
* encryptdlg.c (gpa_file_encrypt_dialog_run, file_encrypt_ok):
Enable encrypt+sign.
(toggle_sign_cb): New function.
* gpgmeparsers.c (gpa_parse_import_info): Free the operation
information.
* keyimportdlg.h, keyimportdlg.c (key_import_results_dialog_run):
New function.
* keyring.c (keyring_editor_import): Load only those keys we just
imported. Display a summary of the import results.
* keytable.c (keytable_fill, do_keylisting): Split the begining of
a keylist operation from actually reading the keys.
(load_keys): New function.
* keytable.h, keytable.c (gpa_keytable_load_key): New function.
* gpgmeparsers.c (gpa_parse_import_info, parse_import_info_text)
(parse_import_info_end, parse_import_info_start): Parse the import
operation detailed results.
2002-10-26 Miguel Coca <e970095@zipi.fi.upm.es>
* gtkrc: Remove.
* Makefile.am: Remove references to gtkrc.
* keyring.c (keyring_editor_new): Set the font of the large label
with pango markup. The gtkrc file is no longer needed.
2002-10-25 Miguel Coca <e970095@zipi.fi.upm.es>
* ownertrustdlg.c (gpa_ownertrust_run_dialog): Use new prototype of
gpa_key_info_new.
* keydeletedlg.c (gpa_delete_dialog_run): Likewise.
* encryptdlg.c (ignore_key_trust): Likewise.
* gpawidgets.c, gpawidgets.h (gpa_key_info_new): Remove the unused
"window" argument.
* keyeditdlg.c (gpa_key_edit_dialog_run): Use gpa_key_info_new to show
the key information.
(add_details_row): Remove.
* gpawidgets.c (gpa_key_info_new): Show all user ID's.
* server_access.c (protocol_version): New function.
(invoke_helper): Added support for error reporting under both
GnuPG 1.2 and 1.3.
* gpgmetools.c (parse_engine_info_start, parse_engine_info_end)
(parse_engine_info_text, find_gpg_executable): Remove from here.
Mostly moved (and expanded) to gpgmeparsers.c.
(gpa_backup_key): Use gpa_parse_engine_info.
* gpgmeparsers.c, gpgmeparsers.h: New files.
* Makefile.am (gpa_SOURCES): Add gpgmeparsers.{c,h}.
2002-10-20 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_mapped): Use GtkMessageDialog's for the
questions.
(keyring_editor_backup): Likewise.
* Makefile.am (gpa_SOURCES): Added verifydlc.{c,h}.
* verifydlg.h, verifydlg.c: New files. The "Verify files" dialog.
* fileman.c (verify_files): Implement.
* gpgmetools.h, gpgmetools.c (gpa_gpgme_data_new_from_file): New
function.
* encryptdlg.c (encrypt_file): Use gpa_gpgme_data_new_from_file.
* server_access.c (server_get_key): Likewise.
* keyring.c (keyring_editor_import): Likewise.
* fileman.c (decrypt_files): Likewise.
* filesigndlg.c (sign_files): Likewise.
* fileman.c (decrypt_files): Fix "typo" in error message.
2002-10-12 Miguel Coca <e970095@zipi.fi.upm.es>
* gpawizard.c (gpa_wizard_new, gpa_wizard_append_page): Use g_free()
instead of free().
* filesigndlg.c: Don't include passphrasedlg.h.
* fileman.c: Likewise.
* expirydlg.c: Likewise.
* Makefile.am (gpa_SOURCES): Removed passphrasedlg.c, passphrasedlg.h.
* passphrasedlg.c, passphrasedlg.h: Removed files.
* gpa.h, gpa.c: Removed global_lastCallbackResult.
* keyring.c: Don't include gpgpa.h.
* siglist.c: Likewise.
* keyimpseldlg.c: Likewise.
* keyexportdlg.c: Likewise.
* keyimportdlg.c: Likewise.
* keyeditdlg.c: Likewise.
* gpapastrings.c: Likewise.
* gpapastrings.c, gpapastrings.h (gpa_ownertrust_from_string)
(gpa_ownertrust_icon_name): Fix prototype.
(gpa_file_status_string)
(gpa_sig_validity_string): Removed.
* filesigndlg.c: Likewise.
* gpa.c: Likewise.
* encryptdlg.c: Likewise.
* gpapastrings.h: Likewise.
* gpa.h: Likewise.
* siglist.c (gpa_siglist_set_signatures): Disable until port to gpgme.
* keyimpseldlg.c (key_import_selection_do_import): Disable imports
from here until there is a way to search keys again.
* Makefile.am (gpa_SOURCES): Removed filemenu.{c,h}, keysmenu.{c,h},
gpapa.h and dummy_gpapa.c.
* optionsmenu.c (add_key): Fix warning.
* gpa.c, gpa.h (gpa_callback, gpa_get_global_clist_file, sigs_append)
(compareInts, gpa_selectRecipient, gpa_unselectRecipient)
(gpa_removeRecipients, gpa_addRecipient, gpa_addRecipients)
(freeRowData, gpa_recipientWindow_close): Removed obsolete.
* optionsmenu.c (options_recipients_fillDefault)
(options_recipients_set, options_recipients_destroy)
(options_recipients): Ditto.
* filemenu.c, filemenu.h, keysmenu.c, keysmenu.h, gpapa.h,
dummy_gpapa.c: Likewise for the whole files.
* ownertrustdlg.c (gpa_ownertrust_run_dialog): Use a gpa_key_info
instead of a gpa_tableKey.
* fileman.c (fileman_menu_new): Use gtk_main_quit() directly for
the quit menu entry.
* keyring.c (keyring_editor_menubar_new): Likewise.
* keyring.c (keyring_editor_export): Use gpa_fopen.
* fileman.c (decrypt_files): Implemented using Gpgme.
(show_file_detail): Removed.
(verify_files): New. Empty for now.
(toolbar_file_verify, fileman_menu_new): Use verify_files instead
of show_file_detail.
(encrypt_files): Free the list of files.
(gpa_window_file_new, add_file): Set the file list to have
just one column, the filename, as the other one left was useless.
* filesigndlg.c (open_destination_file): Make sure there is proper
cleanup on error. Use gpa_fopen.
* encryptdlg.c (open_destination_file): Likewise.
* gpgmetools.h, gpgmetools.c (gpa_fopen): New function.
* gpafile.h, gpafile.c: Removed obsolete files.
2002-10-11 Miguel Coca <e970095@zipi.fi.upm.es>
* server_access.c (error_string): Added KEYSERVER_UNREACHABLE error
code.
* gpgmeedit.c (edit_fnc, edit_expire_fnc_action)
(edit_expire_fnc_transit, edit_trust_fnc_action)
(edit_trust_fnc_transit, edit_sign_fnc_action)
(edit_sign_fnc_transit, gpa_gpgme_edit_trust)
(gpa_gpgme_edit_sign, gpa_gpgme_edit_expire): Rebuilt key editing to
follow a more consistent model. Use the same edit callback, with
different data, for all operations. Hopefully this will make it easier
to understand and write new operations.
* gpgmeedit.h, gpgmeedit.c (gpa_gpgme_edit_trust)
(gpa_gpgme_edit_expire)
(gpa_gpgme_edit_ownertrust)
(gpa_gpgme_edit_expiry): Renamed functions to match the edit commands.
* keyeditdlg.c (key_edit_change_trust, key_edit_change_expiry): Use
new names for edit operations.
2002-10-09 Miguel Coca <e970095@zipi.fi.upm.es>
* encryptdlg.c: Ported the dialog to Gpgme and a GtkDialog. Major
changes. Support for sign & encrypt as soon as some way to choose the
signing key is provided by the GUI.
* fileman.c (sign_files, encrypt_files): Use g_free() instead of
free().
* filesigndlg.c (sign_files): Only set the signer once for each group
of files. Other minor fixes.
2002-10-03 Miguel Coca <e970095@zipi.fi.upm.es>
* fileman.c (count_sigs, free_file_info, attach_file),
(get_file): Removed obsolete.
(get_selected_files, add_file, show_file_detail, sign_files)
(gpa_window_file_new): Change to use Gpgme.
* filesigndlg.c: Ported dialog to Gpgme. Use a GtkDialog.
* gpawidget.h, gpawidgets.c (gpa_key_list_new, gpa_key_list_add_key)
(gpa_secret_key_list_new, gpa_public_key_list_new): Port to Gpgme.
(gpa_key_list_new_from_glist): Disable. Unused at the moment.
* encryptdlg.c (gpa_file_encrypt_dialog_run): Fix call to
gpa_public_key_list_new.
* keyring.c (isdir): Remove obsolote.
2002-09-28 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (add_details_row): Use GtkLabel's always. Change alignment
of labels, so that we can have multiline fields.
(keyring_details_notebook): Add scrollbars. Make User names and
Key ID's scrollable.
(keyring_details_page_fill_key): Show all user ID's.
(keyring_editor_new): Increase default height of the details area.
* gpgmetools.c, gpgmetools.h (gpa_gpgme_key_get_short_keyid): Added
const qualifier.
* keylist.c (get_identifier_value): Always display short key ID's.
* keyexportdlg.c (key_backup_dialog_run): Likewise.
* keyeditdlg.c (gpa_key_edit_dialog_run): Likewise.
* gpawidgets.c (gpa_key_info_new): Likewise.
* keysmenu.c (gpa_tableKey_new): Likewise.
* keyring.c (keyring_details_page_fill_key)
(keyring_update_status_bar): Likewise.
2002-09-27 Miguel Coca <e970095@zipi.fi.upm.es>
* server_access.c: Copied error codes from gnupg code.
(parse_helper_output): New function.
(invoke_helper): Try to parse the helper output if it returned and
error code.
(server_send_keys): Remove placeholder code.
* keyring.c (keyring_editor_export): Minor fixes.
2002-09-24 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.h, gpgmetools.c (gpa_gpgme_key_get_short_keyid): New
function.
* keyring.c (keyring_editor_import, keyring_editor_export): Add
keyserver support.
* server_access.c, server_access.h: New files with the implementation
of all calls to the keyserver helpers.
* Makefile.am (gpa_SOURCES): Added server_access.{c,h}.
2002-09-17 Miguel Coca <e970095@zipi.fi.upm.es>
* keytable.c (keytable_fill): Make the progress bar move faster.
2002-09-13 Werner Koch <wk@gnupg.org>
* keytable.c (keytable_fill): Update progressbar only every 10 keys.
2002-09-12 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmeedit.c (gpa_gpgme_edit_ownertrust, gpa_gpgme_edit_expiry)
(gpa_gpgme_edit_sign): Fix error reporting: always report errors to
the caller.
* keyring.c (keyring_details_page_fill_key): Display the
fingerprint in a proper format (using
gpa_gpgme_key_get_fingerprint).
* keysigndlg.c (gpa_key_sign_run_dialog): Likewise.
* gpgmetools.c (gpa_gpgme_key_get_userid): A bit of cleaning up.
(gpa_gpgme_key_get_fingerprint): New function. Based on GPAPA code.
* gpgmeedit.c (edit_sign_fnc): Ignore "bad passphrase" status
lines. This solves the problem where a wrong passphrase terminated
GPA.
2002-09-11 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmeedit.c (edit_sign_fnc_action, edit_sign_fnc_transit)
(edit_sign_fnc): Use an enum for the state names. Minor fixes.
* gpgmetools.c, gpgmetools.h, gpgmeedit.c, gpgmeedit.h: Moved the
wrappers around gpgme_op_edit and related functions to the new
files gpgmeedit.{c,h}
(gpa_gpgme_key_get_userid): Return NULL if
gpgme_key_key_string_attr does.
* gpgmetools.c, gpgmetools.h (gpa_gpgme_key_get_userid): New
function, returns the User ID's of a key, always in UTF-8.
* optionsmenu.c (add_key): Get the user ID's with
gpa_gpgme_key_get_userid, so that it is always in UTF-8.
* keysmenu.c (gpa_tableKey_new): Likewise.
* keysigndlg.c (gpa_key_sign_run_dialog): Likewise.
* keyring.c (keyring_details_page_fill_key)
(keyring_update_status_bar): Likewise.
* keylist.c (get_name_value): Likewise.
* keyeditdlg.c (gpa_key_edit_dialog_run): Likewise.
* gpawidgets.c (gpa_key_info_new): Likewise.
* Makefile.am (gpa_SOURCES): Added gpgmeedit.{c,h} files.
* keyeditdlg.c (key_edit_change_expiry): Report an error if a wrong
passphrase was provided.
2002-09-04 Miguel Coca <e970095@zipi.fi.upm.es>
* keytable.c (keytable_fill): Display a dialog indicating that the
keyring is being read.
2002-08-31 Miguel Coca <e970095@zipi.fi.upm.es>
* expirydlg.c (expiry_cancel, expiry_destroy): Removed.
(expiry_ok): Modify not to be a callback.
(gpa_expiry_dialog_run): Use a GtkDialog.
* ownertrustdlg.c (ownertrust_cancel, ownertrust_destroy)
(ownertrust_ok): Remove functions.
(gpa_ownertrust_run_dialog): Use a GtkDialog.
* gtktools.c (gpa_window_message): Use a GtkDialog.
(gpa_window_error): Fixed border widths.
2002-08-30 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (gpa_gpgme_edit_sign): Fix reference count for the key.
* keyexportdlg.c (key_export_dialog_run, key_backup_dialog_run): Minor
UI fixes (dialog border width).
* keyimportdlg.c (key_import_dialog_run): Likewise.
* keyeditdlg.c (key_edit_close, key_edit_destroy): Removed.
(gpa_key_edit_dialog_run): Use a GtkDialog.
2002-08-29 Miguel Coca <e970095@zipi.fi.upm.es>
* keydeletedlg.c (confirm_delete_secret): Make "No" the default reply
to the dialog.
2002-08-28 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (find_gpg_executable): New function.
(parse_engine_info_text, parse_engine_info_end)
(parse_engine_info_start): Helper functions for a GLib XML parser.
* keyexportdlg.c (key_backup_dialog_run): Ask for a file, not a dir.
Give the focus to the entry, and close when enter is pressed on it.
Give a sane default value to the filename.
(key_export_dialog_run): Connect pressing enter on the filename entry
with the OK button.
* keyring.c (keyring_editor_backup): Backup to a file, not to a
directory.
* gpgmetools.c (gpa_backup_key): New function.
2002-08-27 Miguel Coca <e970095@zipi.fi.upm.es>
* keydeletedlg.c (confirm_delete_secret): New function.
(gpa_delete_dialog_run): Emit an extra warning if a secret key is to
be removed.
* keyexportdlg.c (export_destroy, export_cancel): Removed.
(secret_key_export_dialog_run): Removed. We don't support exporting
secret keys anymore.
(key_export_dialog_run, key_backup_dialog_run): Use GtkDialog.
(key_export_dialog_run): Armor by default, even when in advanced ui
mode.
2002-08-26 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_import): Implement importing keys from
the clipboard. Uses a GtkClipboard, so it should work on both X
and Win32. Don't abort if the import found no data.
(keyring_editor_export): Implement export to clipboard.
* gpgmetools.c (fill_data_from_clipboard)
(dump_data_to_clipboard): New function.
* keyimportdlg.c (import_destroy, import_cancel): Removed.
(key_import_dialog_run): Use a GtkDialog.
* gpgmetools.c (passphrase_question_label): Add empty line between
question and key.
(gpa_passphrase_cb): Added question icon.
* gtktools.c (gpa_window_error): Add error icon.
* gpgmetools.c (_gpa_gpgme_error): Use gpa_window_error.
* gtktools.c (gpa_window_error): Use a GtkDialog.
* keysigndlg.c (gpa_key_sign_run_dialog): Increase the width of the
border of the dialog. Make "Yes" the default action.
* keydeletedlg.c (delete_ok, delete_cancel, delete_destroy): Removed.
A GtkDialog does not need callbacks.
(gpa_delete_dialog_run): Use a GtkDialog.
2002-08-24 Miguel Coca <e970095@zipi.fi.upm.es>
* optionsmenu.c (add_key, options_key): Use the fingerprint
instead of the key ID. This is a a bit of a kludge to make it work.
* gpgmetools.c (edit_sign_fnc_transit, edit_sign_fnc_action): Correctly
detect when a key has expired.
2002-08-23 Miguel Coca <e970095@zipi.fi.upm.es>
* keysigndlg.c (gpa_key_sign_run_dialog): Change to use a GtkDialog.
(key_sign_cancel, key_sign_ok, key_sign_destroy): Deleted
functions, as the dialog does not need them.
(gpa_key_sign_run_dialog): Display all user ID's. Warn that all of
them will be signed. Use "user name" instead of "user id" on
screen.
2002-08-22 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (edit_sign_fnc, gpa_gpgme_edit_sign)
(edit_sign_fnc_action): New funtions.
* keyring.c (keyring_editor_sign): Reimplement with gpgme.
* keysigndlg.c (key_sign_ok): Remove passphrase stuff.
(gpa_key_sign_run_dialog): Port to gpgme. Remove unneeded
parameters and change the sign_type to just say whether the key
should be signed locally.
2002-08-21 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (_gpa_gpgme_error): Changed "OK" button to "Close".
* fileman.c: Reordered includes to avoid warnings. Kludge to avoid
a bug in GLib.
* gpa.c: Likewise.
* gpafilesel.c: Likewise.
* gpapa.h: Likewise.
* gpapastrings.c: Likewise.
* gpapastrings.h: Likewise.
* gpawidgets.c: Likewise.
* gtktools.c: Likewise.
* helpmenu.c: Likewise.
* icons.c: Likewise.
* keyeditdlg.c: Likewise.
* keyexportdlg.c: Likewise.
* keyimportdlg.c: Likewise.
* keyring.c: Likewise.
* keyserver.c: Likewise.
* optionsmenu.c: Likewise.
* siglist.c: Likewise.
* gpapastrings.c (gpa_unit_expiry_time_string): Renamed index
argument to idx.
* gpa.c (gpa_determine_default_key): Fixed bug when the secret keyring
was empty.
(gpa_set_default_key): Only save the default key if there is one.
* gpgmetools.h, gpgmetools.c (gpa_gpgme_error, _gpa_gpgme_error):
Turned the error reporting function into a macro. Report also the file
and line it was invoked from.
* keyring.c (keyring_editor_export): Cleaned up a bit, removing old
GPAPA code.
(keyring_editor_import): Don't expect EOF from gpgme. It's no longer
emited.
(keyring_editor_current_key): Change declaration of disabled function
for gpgme.
(keyring_editor_backup): Disable function until key backup is
implemented.
2002-08-20 Miguel Coca <e970095@zipi.fi.upm.es>
* gpgmetools.c (gpa_gpgme_edit_ownertrust, edit_ownertrust_fnc):
Implemented editing ownertrust values.
* keyeditdlg.c (key_edit_change_expiry): Account for cancelled
operations.
(key_edit_change_trust): No need to worry about passphrase errors.
Reload keys after editing.
* gpgmetools.c (gpa_passphrase_cb): Got the cancel button working.
2002-08-19 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_import): Fix to behave properly when gpgme
returns EOF error code. Clean up code.
* keytable.c (gpa_keytable_load_key): New function.
* gpgmetools.c (edit_expiry_fnc, gpa_gpgme_edit_expiry):
Implemented changing the expiry date of a key.
(gpa_passphrase_cb): Remove the cancel button, since it does nothing.
Make the question understandable.
(passphrase_question_label): New function.
* keyeditdlg.c (key_edit_change_expiry)
(key_edit_change_trust): Don't terminate on a bad passphrase.
2002-08-18 Miguel Coca <e970095@zipi.fi.upm.es>
* expirydlg.c (GPAExpiryDialog, gpa_expiry_dialog_run): Port to gpgme.
(expiry_ok): Don't ask for the passphrase here. That's gpgme's job.
* keyeditdlg.c (key_edit_change_expiry): Port to gpgme.
* keysmenu.c (gpa_tableKey_new): Port to gpgme.
* ownertrustdlg.c (GPAOwnertrustDialog, ownertrust_ok)
(gpa_ownertrust_run_dialog): Port to gpgme.
* gpgmetools.c (gpa_gpgme_edit_ownertrust)
(gpa_gpgme_edit_expiry): New (empty) functions.
* keyeditdlg.c (key_edit_change_trust): Change to use gpgme.
* gpa.c (main): Set the passphrase callback.
* gpgmetools.c, gpgmetools.h (gpa_passphrase_cb): New function.
* keylist.c (get_expirydate_value): Use new gpa_*_date_string
functions.
* keyring.c (keyring_details_page_fill_key): Likewise.
* keyeditdlg.c (key_edit_change_expiry): Likewise.
* gpawidgets.c (gpa_expiry_frame_new, gpa_expiry_frame_at): Likewise.
* gpapastrings.c (gpa_expiry_date_string): Change to receive the
expiration time instead of a GDate.
(gpa_creation_date_string): Likewise.
* keyeditdlg.c: Rename all key_id variables as fpr, since now they
represent the key's fingerprint.
(gpa_key_edit_dialog_run): Port to GPGME.
2002-08-17 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_generate_key_simple)
(keyring_editor_generate_key_advanced): Reload the keytable after
generating a key.
* keygendlg.c (gpa_key_gen_run_dialog): Use the new algorithm enums.
* gpapastrings.c, gpgmetools.c: Moved the algorithm string
functions, and fixed them for the new enums.
* gtktools.c, gtktools.h (gpa_window_error): Added const qualifier
to the error message.
* keyring.c (keyring_editor_generate_key_advanced): Port to GPGME.
* keygenwizard.c (GPAKeyGenWizard): Remove the members related to
GPAPA.
(gpa_keygen_generate_key): Removed.
(gpa_keygen_wizard_generate_action): Change to use
gpa_generate_key and a GPAKeyGenParmeters struct instead of gpapa.
(string_strip_dup): Use GLib.
* gpgmetools.c (gpa_generate_key)
(build_genkey_parms): New functions.
* keygendlg.c, gpgmetools.c (gpa_key_gen_free_parameters)
(key_gen_params_new): Moved functions to where they can be used by
other files.
* keygendlg.h, gpgmetools.h: Moved the GPAKeyGenParameters
definition and related functions to gpgmetools.h and changed the
fields that depended on GPAPA.
2002-08-16 Miguel Coca <e970095@zipi.fi.upm.es>
* keysmenu.c, keysmenu.h (keys_openSecret)
(keys_generateRevocation)
(keys_import)
(keys_importOwnertrust)
(keys_updateTrust)
(keys_openPublic_export_export_exec)
(keys_openPublic_export_export)
(keys_export_dialog)
(keys_openPublic_send_key)
(keys_openPublic_send)
(keys_openPublic_exportTrust_export)
(keys_openSecret_export_export)
(keys_openSecret_delete)
(keys_openSecret_revocation)
(keys_openSecret_editKey_close)
(keys_openSecret_editKey)
(keys_openSecret_evalMouse)
(keys_openSecret)
(keys_generateRevocation_generate_exec)
(keys_generateRevocation_generate)
(keys_generateRevocation)
(keys_import_ok)
(keys_import)
(keys_importOwnertrust_ok)
(keys_importOwnertrust)
(keys_updateTrust)
(gpa_frameExpire_dont)
(gpa_frameExpire_after)
(gpa_frameExpire_at)
(gpa_frameExpire_new): Removed obsolete functions.
* passphrasedlg.c (gpa_passphrase_run_dialog): In dialogs, set the
button ordering to [OK] [Cancel] in all cases.
* ownertrustdlg.c (gpa_ownertrust_run_dialog): Likewise.
* keyreceivedlg.c (key_receive_run_dialog): Likewise.
* keyimpseldlg.c (gpa_key_import_selection_dialog_run): Likewise.
* keyimportdlg.c (key_import_dialog_run): Likewise.
* keyexportdlg.c (key_export_dialog_run)
(secret_key_export_dialog_run, key_backup_dialog_run): Likewise.
* filesigndlg.c (gpa_file_sign_dialog_run): Likewise.
* encryptdlg.c (gpa_file_encrypt_dialog_run): Likewise.
* keyring.c (keyring_editor_import): Reload the keytable after
importing keys.
2002-08-14 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_menubar_new): Remove commented out
menu entries.
2002-08-13 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_can_sign): Use the keytable instead of
gpapa.
(key_has_been_signed): Disable function until it can be
implemented with gpgme.
* gtktools.c, gpgmetools.c (gpa_gpgme_error): Move function to
gpgmetools.c
2002-08-12 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_export_secret)
(keyring_editor_menubar_new): Removed the option to export secret
keys.
2002-08-11 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_export): Use a function in
gpgmetools.c to dump the data to a file.
(keyring_editor_import): Import keys from files using gpgme.
* Makefile.am (gpa_SOURCES): Added new files.
* gpgmetools.h, gpgmetools.c: New files.
2002-08-10 Miguel Coca <e970095@zipi.fi.upm.es>
* gpapastrings.h: Include gpgme.h
* Makefile.am (gpa_SOURCES): Added new file.
* gpapa.h: New file. All gpapa headers combined in one file that
can be used to compile GPA during the migration without any
problems.
* Makefile.am (INCLUDES): Removed gpapa directory.
2002-08-09 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_editor_export): Export keys to a file using
gpgme.
* gpawidgets.c (gpa_key_info_new): Port to GPGME.
* keydeletedlg.c (gpa_delete_dialog_run): Use GPGME instead of
GPAPA.
* keyring.c (keyring_editor_delete): Port to gpgme. Just delete
the selected keys from the clist and the keytable, but don't
reload anything else. Doesn't work right now, because of a known
bug in gpgme.
* keytable.c (gpa_keytable_remove): New function.
2002-08-08 Miguel Coca <e970095@zipi.fi.upm.es>
* gpa.c (main): Changed the default value of gpa_options.homedir
on Unix. The metacharacter '~' is interpreted by the shell, not by
libc, so we read the HOME environmental variable ourselves.
* optionsmenu.c (add_key): New function.
(options_key): Iterate over the keyring using the keytable
_foreach function instead of gpapa.
* keyring.c (keyring_editor_mapped): Change to use the keytable
instead of gpgme.
(keyring_signatures_page_fill_key): Disabled for now.
* keytable.c (gpa_keytable_size, gpa_keytable_secret_size): New
functions.
* keylist.c (get_key_type_pixmap_value): Fixed to properly detect
secret keys.
* keytable.c (keytable_fill, keytable_empty, gpa_keytable_new)
(gpa_keytable_reload, gpa_keytable_secret_lookup)
(gpa_keytable_secret_foreach, gpa_keytable_destroy): Added the
secret keyring to the keytable.
* keyring.c (idle_update_details): Port to gpgme.
(keyring_details_page_fill_key): Remove secret key argument. Port
to GPGME, minus checking for a secret key.
* keylist.c (gpa_keylist_set_column_defs, keylist_fill_list)
(gpa_keylist_new): Added calls to sort the CList according to the
user name. Use g_malloc and g_free.
* keyeditdlg.c (gpa_key_edit_dialog_run, key_edit_change_trust),
ownertrustdlg.c (gpa_ownertrust_run_dialog),
keyring.c (keyring_details_page_fill_key): Replace string functions.
* gpapastrings.c, gpapastrings.h
(gpa_keytrust_string, gpa_ownertrust_string, gpa_trust_string)
(gpa_ownertrust_from_string): Merged the trust strings fuctions
and arrays, since gpgme does not have different values for key
trust and owner trust.
* keylist.c (gpa_keylist_current_key): Ported to use gpgme and the
keytable.
2002-08-06 Miguel Coca <e970095@zipi.fi.upm.es>
* keylist.c (keylist_fill_list): Ported to gpgme. Use a foreach on
the key table for iterating over the keys. Removed the
keep_selection argument, since it was always called as true, and
would be needed in the new keylist_fill_row too.
(keylist_fill_row): Ported to gpgme. Now it's a callback for a
foreach iteration on a GpaKeyTable. Use fingerprints instead of
key ID's as the row data.
(get_name_value): Return the whole UserID, not just the name.
(get_expirydate_value): Fix the label for keys that don't expire.
2002-08-05 Miguel Coca <e970095@zipi.fi.upm.es>
* keylist.c (get_name_value, get_trust_value, get_ownertrust_value)
(get_identifier_value, get_key_type_pixmap_value): Ported to use GPGME.
* gpa.c (main): Remove commented out code.
* keytable.c (keytable_fill): Check for errors in gpgme.
* gpa.c (gpa_determine_default_key, main): Add proper error
checking for gpgme.
* gtktools.c, gtktools.h (gpa_gpgme_error): New function for
reporting unexpected (and therefore fatal) errors in GPGME.
* gpa.h (IS_DEVELOPMENT_VERSION): Define macro.
2002-08-04 Miguel Coca <e970095@zipi.fi.upm.es>
* keyring.c (keyring_update_status_bar): Use gpgme to read the
default key attributes.
* keylist.c, keylist.h (gpa_keylist_new): Use g_malloc instead of
xmalloc.
* keyring.c (keyring_editor_new): Use g_malloc instead of xmalloc.
* gpa.c, gpa.h : Added keytable and ctx global variables.
* gpa.c (main): Create a keytable here.
* keytable.h, keytable.c: New files. They implement a hash table
of all the keys in the keyring that can be accessed by fingerprint
or by iterating over it.
* gpa.c, gpa.h (main): Add creation of a GpgmeCtx for use by the
rest of the program.
(gpa_determine_default_key): Port to gpgme.
* gpa.h: Include gpgme.h.
* Makefile.am (LDADD): Removed gpapa.
(gpa_SOURCES): Added dummy_gpapa.c
* dummy_gpapa.c: New file. Just a dummy gpapa to assist during the
migration.
2002-08-02 Miguel Coca <e970095@zipi.fi.upm.es>
* gpa.c (main): Use GLib to find out where the gpa executable
resides, instead of walking the pathname ourselves.
(search_config_file): Use different search order for Unix and
Windows. We should never use the executable path on Unix. Use
standard GLib functions. This does not fix the fact that if a
GPA_DATADIR/gpa.conf (i.e. /usr/local/share/gpa/gpa.conf) file
exists, gpa will try to write to it to remember options.
2002-07-31 Miguel Coca <e970095@zipi.fi.upm.es>
* folder1.xpm, folder2.xpm, harddisk1.xpm, harddisk2.xpm,
harddisk3.xpm, open_folder1.xpm, open_folder2.xpm: Removed unused
icons. They were drafts of the final icons and should never have
been included.
* helpmenu.c (help_warranty): Changed the position of the cursor
in the GPL editable to a value less dependent on the length of
license text.
* gpa_license.c: Use the license in English, since it's the only
authoritative one.
2002-07-30 Miguel Coca <e970095@zipi.fi.upm.es>
* gpawidgets.c (gpa_key_list_new, gpa_secret_key_list_new)
(gpa_public_key_list_new, gpa_key_list_new_from_glist): Move the
repeated code for creating the CList to a new gpa_key_list_new
function. Changed the others to use it.
* filemenu.c (file_sign_sign_exec): Remove unused function.
2002-07-29 Werner Koch <wk@gnupg.org>
* Makefile.am (LDADD): Don't hardcode libs but take them all from
configure.
2002-02-25 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* gpafilesel.c (gpa_file_selection_dir_expand): Account for the
use of UTF8 for filenames.
Include io.h just when compiling for Windows.
(correct_parent): Fix to compile under non-Windows OS's.
* gpafilesel.h (gpa_file_selection_get_filename): Change return type
to const gchar*.
* keygenwizard.c: Include errno.h.
* keyring.c: Include errno.h.
(keyring_editor_import): Use different ways to import keys
depending on whether we are using HKP or gpg --recv-keys.
2002-02-24 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* Makefile.am (gpa_SOURCES): Added keyimpseldlg.c and keyimpseldlg.h.
* encrypt.xpm, verify.xpm: New icons.
* fileman.c (show_file_detail): Changed all the references to
"detail view" to "verify signature" in messages.
(toolbar_file_verify): New function.
(gpa_fileman_toolbar_new): Added "verify" button.
* filesigndlg.c: Small formatting changes.
* gpafilesel.c: Fixes to comments and spelling.
* gpawidgets.c (gpa_secret_key_list_new, gpa_public_key_list_new):
Swapped column titles. Changed default widths.
(gpa_key_list_new_from_glist): New function.
* gpawidgets.h: Added "extern" to declarations. Adde
gpa_key_list_new_from_glist function.
* gtktools.c (gpa_window_error): Remove call to gettext for the
error message. Was not needed.
* icons.c (xpms): Added verify_xpm to the list.
* keyimpseldlg.h, keyimpseldlg.c: New files. A new "key import
selection dialog" which shows the result of a key search on the
server and letws the user import them.
* keyring.c: Formatting changes all over.
(keyring_editor_import): Use the key import selection dialog when
the search returns more than one result.
* keysmenu.c (keys_generateRevocation): Swapped column titles.
Changed default widths.
* optionsmenu.c (options_recipients_set)
(options_recipients)
(options_key_select)
(options_key): Swapped column titles. Changed default widths.
2002-02-22 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* Makefile.am (gpa_SOURCES): Added gpa.rc
* fileman.c (fileman_menu_new): Renamed "Show Detail" menu item to
"Check".
* filesigndlg.c (gpa_file_sign_dialog_run): Renamed "copy and add
signature" button to "cleartext signature". Cleaned the code for
the creation of the different radio buttons a bit.
* gpa.rc: New MS-Windows resource file, which adds a custom icon
to GPA.
* gpa.c (cmd_and_opt_values, opts, main): Added new option,
default-key.
(opts): Changed description of --advanced-ui.
(gpa_set_default_key): Save the default key to the config file.
2002-02-21 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* filemenu.c, filesigndlg.c: Reformatted to completely comply with
the GNU Coding Standards.
* filemenu.c (file_sign_sign_exec): Choose the filename for the
dettached signature here, and not in gpapa.
* filesigndlg.c (file_sign_do_sign): Choose the filename for the
dettached signature here, and not in gpapa.
(file_sign_ok): If on simplified mode, assume the user wants armor
on non dettached signature, and doesn't want it on dettached ones.
(gpa_file_sign_dialog_run): Remove the armor option for simplified
mode. Don't offer to compress the signed file when in simplified
mode.
2002-02-20 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* helpmenu.c (help_warranty): Account for the different length of
the license in german.
2002-02-19 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* Makefile.am (LDADD): Added two win32 specific libraries.
* gtkhacks.h: New file, contains some definitions to work around
incompatibilities between GTK+ 1.2 and 2.0.
* fileman.c (show_file_detail): Use the new compatibility
functions defined in gtkhacks.h.
(gpa_fileman_toolbar_new): Allow compilation under both GTK 1.2
and 2.0.
* filemenu.c (file_encrypt_detail): Use the new compatibility
functions defined in gtkhacks.h.
* gpa.c (gpa_default_key_changed_marshal)
(gpa_create_default_key_signal): Enabled when compiling for GTK+
1.2, disabled for 2.0.
(dummy_log_func): New empty function.
(main): Disabled Glib/Gdk/Gtk error logging under all platforms to
keep MS-Windows from opening a console.
* gpa.h: Include the new gtkhacks.h. Define mkdir() and S_ISDIR
macros for win32.
* gpalicense.c, gpalicense.h: Cosmetic changes to the comments,
and added separated license texts for english and german. The
german text is used by default.
* gpafilesel.c, gpafilesel.h: Large changes for compatibility
between GTK+ versions.
* i18n.h: Removed "const" from gettext declaration.
* keyexportdlg.c (key_backup_dialog_run): Removed unused variable.
* keyring.c (keyring_editor_backup): Changed the type of some
variables to remove some warnings.
(keyring_editor_menubar_new): Removed unused variable.
(keyring_toolbar_new): Added some conditional compilation to allow
it to work with both GTK+ 1.2 and 2.0.
* keysmenu.c (gpa_tableKey_new): Use the new compatibility
functions defined in gtkhacks.h.
* optionsmenu.c: Removed everything related to the "default
recipients" menu item, to avoid confusing new users.
* simple-gettext.c (set_gettext_file): Return 0 instead of NULL,
since the function returns "int".
2002-02-15 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* keyring.c (keyring_editor_menubar_new): Added "Delete Keys" menu
item.
2002-02-14 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* fileman.c: Reformatted to completely comply with the GNU
Coding Standards.
(add_file): Display filenames in UTF8.
* gpa.c (keyservers_configname)
(main): Find out the file where keyserver list using the new
search_config_file(). Changed the order in which config files are
read.
(search_config_file): Fixed broken g_strconcat calls.
* gpafilesel.c (read_directory): Display the directory names using
UTF8.
* gtktools.c (gpa_window_error): i18n the message string.
* keyexportdlg.c (export_browse)
(export_ok)
keyimportdlg.c (import_browse)
(import_ok): Display filenames in UTF8.
* keyring.c (keyring_editor_backup): Only write to disk that we've
generated the backup (for later sessions) if the action was not
cancelled.
* keyserver.c (serverlist): Initialize as NULL.
(read_list): Changed to assume we receive the full pathname to the
keyserver file. Commented out error messages.
2002-02-13 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* gpa.c, keylist.c: Reformatted to completely comply with the GNU
Coding Standards.
* gpa.c (gpa_homedir): New global variable. Contains the directory
where the gpa executable is installed.
(search_config_file): New funtion to search for config
files in a series of typical locations.
(main) Set the gpa_homedir variable by manipulating argv[0]. Use
search_config_file. Delayed reading the gtkrc until we know the
GnuPG homedir.
* keygenwizard.c (gpa_keygen_wizard_backup_dir_action): Create the
backup directory if needed.
(gpa_keygen_wizard_generate_action): Save whether the key backup
was generated to the config file.
* keylist.c (keylist_fill_list): Added checks to verify that every
secret key has a corresponding public key in the keyring.
2002-02-11 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* keyring.c (keyring_editor_backup): Test for the directory the user
provided, and create it if it doesn't exist.
* optionsmenu.c (gpa_options_menu_add_to_factory): Disabled
"Default Recipients" menu item.
* gpafilesel.c: Extensive changes to the way directories are
handled. Now the directory list is a tree that expands as the user
navigates the filesystem.
2002-02-10 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* Makefile.am (LDADD): Added -lm and -lz to the hardcoded libraries.
(gpa_SOURCES): Added qdchkpwd.c and qdchkpwd.h to the list.
* qdchkpwd.c, qdchkpwd.h: New files. They contain a "Quick and
Dirty CHecK for PassWorDs", based on the zlib library.
* gpa.h: Some code cleaning.
* gpa.c, icons.c, keyserver.c, keyring.c: Fixed debug output.
* keyeditdlg.c, keyexportdlg.c, keyserver.c, keygenwizard.c,
keyring.c, gpawizard.h: Reformatted to completely comply with the
GNU Coding Standards.
* fileman.c, filemenu.c, gpawidgets.c: Use the GTK+ 2.0 API for
finding out the right width for GtkEntry's.
* keyserver.h, keyserver.c (keyserver_get_current): Added new
argument that requests that the returned value never be NULL.
* keyexportdlg.c, keyimportdlg.c, keysmenu.c, optionsmenu.c: Use
new keyserver_get_current().
* gpa.h, gpa.c (gpa_backup_generated)
(gpa_set_backup_generated)
(gpa_remember_backup_generated): New functions for implementing
new option "backup_generated".
* gpa.c (cmd_and_opt_values)
(opts)
(main): Added oBackupGenerated option. It signals whether the
user should be warned to generate a backup of his private key.
* gpafilesel.c (gpa_file_selection_init): Changed "Open" button to
read "Ok".
(gpa_file_selection_dir_button)
(gpa_file_selection_populate): Removed some debug output, other
fixes.
* gpawizard.c (gpa_wizard_update_buttons): Disable all buttons
when in the "wait" page. So, we explicitly enable the "Close"
button when we reach the last page.
* helpmenu.c (about_dialog_timer): Fixed wrong call to
gdk_draw_string.
(help_about): Added G-N-U GmbH copyright notice and other
documentation. Changed the way the text widths are calculated.
(gpa_help_menu_add_to_factory): Renamed help menu to "Info".
* keyexportdlg.c (export_ok): Cleaned up code a bit, reordered if
conditions (in preparation for adding export to clipboard).
* keyexportdlg.c, keyexportdlg.h (secret_key_export_dialog_run)
(key_backup_dialog_run): New dialogues. First exports secret keys,
and the second makes a backup of the user's keys.
* keygenwizard.c (gpa_keygen_wizard_password_validate): Added
check of the strength of the passphrase, using the new qdchkpwd.
* keyimportdlg.c (import_ok): Cleaned up code a bit, reordered if
conditions (in preparation for adding import to clipboard).
* keyring.c (keyring_editor_sign)
(keyring_editor_import)
(keyring_editor_export)
(keyring_editor_export_secret)
(keyring_editor_backup): Added prototypes.
(keyring_editor_import): Added support for import from the
clipboard.
(keyring_editor_export): Export to clipboard.
(keyring_editor_export_secret)
(isdir)
(keyring_editor_backup): New functions.
(keyring_editor_mapped): Reordered "if" conditions for speed.
Enabled key backups.
(keyring_editor_menubar_new): Changed the various menu items to
use the keyring_editor_* functions instead of the toolbar ones.
Added some code, but disabled it (doesn't work).
(export_secret_key): Removed function.
* keysmenu.c (gpa_tableKey_new)
(gpa_frameExpire_new): Changed the way GtkEntries widths are
calculated.
2002-02-05 Benedikt Wildenhain <benedikt.wildenhain@g-n-u.de>
* fileman.c (gpa_fileman_toolbar_new): Disabled the help button,
since it does nothing at the moment.
* keyring.c (keyring_toolbar_new): Disabled the help button, since
it does nothing at the moment.
2002-02-05 Peter Gerwinski <peter.gerwinski@g-n-u.de>
* Makefile.am (gpa_SOURCES): Included gpafilesel.c and gpafilesel.h
to the list.
* harddisk.xpm, harddisk1.xpm, harddisk2.xpm, harddisk3.xpm,
open_folder.xpm, open_folder1.xpm, open_folder2.xpm, floppy.xpm,
folder.xpm, folder1.xpm, folder2.xpm: New icons.
* encryptdlg.c, expirydlg.c, fileman.c, filemenu.c, filesigndlg.c,
gpawidgets.c, gpawidgets.c, gtktools.c, keygendlg.c,
keygenwizard.c, keysmenu.c, passphrasedlg.c: Small corrections to
message strings.
* encryptdlg.c, fileman.c, filemenu.c, filesigndlg.c,
gpawidgets.c, keyexportdlg.c, keygendlg.c, keygenwizard.c,
keyimportdlg.c, keysigndlg.c, keysmenu.c, optionsmenu.c,
ownertrustdlg.c, passphrasedlg.c: Added casts to remove compile
time warnings and other code cleanups. Changed comment layout.
* encryptdlg.c, expirydlg.c, fileman.c, filemenu.c, filesigndlg.c,
gtktools.c, helpmenu.c, keydeletedlg.c, keyeditdlg.c,
keyexportdlg.c, keygendlg.c, keygenwizard.c, keyimportdlg.c,
keysigndlg.c, keysmenu.c, optionsmenu.c, ownertrustdlg.c,
passphrasedlg.c: Changed to use GTK_WINDOW_TOPLEVEL instead of
GTK_WINDOW_DIALOG in all calls to gtk_window_new, since
GTK_WINDOW_DIALOG doesn't exist in GTK+ 2.0.
* fileman.c (show_file_detail)
filemenu.c (file_encrypt_detail)
gpawidgets.c (gpa_expiry_frame_new)
helpmenu.c (help_about)
keysmenu.c (gpa_tableKey_new): Use the GTK+ 2.0 API for finding out
the right width for GtkEntry's.
* gpafilesel.c, gpafilesel.h: New files. They define a version of
the GtkFileSelection dialog (GpaFileSelection) modified to look
more like what users of MS-Windows are accustomed to. It is
directly based on the source code for GTK+ 2.0.
* icons.c, siglist.c: Formatting change.
* fileman.c (gpa_fileman_toolbar_new): Use new GTK+ 2.0 API.
* filemenu.c, gtktools.c, keysmenu.c: Now uses the new GpaFileSelection
instead of GtkFileSelection.
* gpa.c: Added include for w32reg.h.
(gpa_default_key_changed_marshal)
(gpa_create_default_key_signal): Disabled functions for
compilation with GTK+ 2.0.
(main): Fixed several compile time errors on win32. Now we use
UTF-8 for output.
* gtktools.c (gpa_button_set_text): Disabled code that doesn't
compile with GTK+ 2.0.
* helpmenu.c (scroll_text): Updated.
(about_dialog_timer)
(help_about): Use gtk_style_get_font instead of directly accessing
the style struct.
(gpa_help_menu_add_to_factory): Disabled help button.
* keyexportdlg.c (_GPAKeyExportDialog)
(key_export_dialog_run): Support for exporting keys to the
clipboard.
* keygenwizard.c (gpa_keygen_wizard_password_validate): Added
check for a passphrase that is obviously too simple. At the moment
that is defined as being less than 10 characters long.
* keyring.c (keyring_editor_current_key): Removed prototype.
(toolbar_edit_key)
(toolbar_remove_key)
(toolbar_sign_key)
(toolbar_export_key)
(toolbar_import_keys): Added prototypes.
(export_secret_key): New (empty) function.
(keyring_editor_generate_key_advanced): Changed #warning to a comment.
(keyring_editor_mapped): Remind the user to make a backup of his
private key.
(keyring_editor_menubar_new): Added keyboard accelerator to the
File/Close menu item. Added key operations (sign, export, export
private, backup) to the menu. Moved "Options" menu to before
"Keys" menu.
(keyring_toolbar_new): Use new GTK+ 2.0 API. Added button to open
the file manager.
(keyring_editor_new): Changed default window size. Increased area
reserved for the key list.
* keyimportdlg.c (_GPAKeyImportDialog)
(key_import_dialog_run): Support for exporting keys to the
clipboard.
2002-01-14 Werner Koch <wk@gnupg.org>
* gpa.c (my_strusage): Take bug report address from configure.
2001-12-31 Werner Koch <wk@gnupg.org>
* gpapastrings.c, gpapastrings.h: Suport for creation dates.
* keyring.c:Ditto.
* keyring.c (keyring_update_status_bar): Fixed segv in case a key
does not exist. All by Michael Mauch.
* helpmenu.c (help_warranty): Added real code. By Michael Fischer
v. Mollard.
2001-08-23 Werner Koch <wk@gnupg.org>
* gpapastrings.c: Added a few more strings and made
keytrust_strings_advanced code. By Miguel Coca.
2001-06-06 Werner Koch <wk@gnupg.org>
* gpa.c (main): Convert the characters in the homedir from
backslash to standard slash. Note: We sill need to figure out a
way to handle the '\\server\path' style filenames - however, I am
pretty sure that a lot of other functions are not able to handle
them.
2001-05-30 Werner Koch <wk@gnupg.org>
* i18n.h, options.h: New.
* gpa.h: Moved some code to the new header files.
* keyserver.c, keyserver.h: New.
* keyexportdlg.c (key_export_dialog_run): Use functions from
keyserver to setup the list.
* keyimportdlg.c (key_import_dialog_run): Ditto.
* optionsmenu.c (options_keyserver): Ditto.
* gpa.c (main): Ditto.
* keysmenu.c (keys_openPublic_send_key): Ditto.
* keyreceivedlg.c (receive_ok): Ditto.
* optionsmenu.c (options_keyserver_set): Ditto.
* gpa.c, gpa.h (global_keyserver): Removed.
* gpa.c: New option --keyserver.
2001-03-28 Werner Koch <wk@gnupg.org>
* gpa.c (gpa_determine_default_key): Replaced xstrdup by
xstrdup_or_null to avoid a segv.
* optionsmenu.c (options_key_set): Ditto, to make it more robust.
(options_keyserver_set): Ditto.
* passphrasedlg.c (passphrase_ok): Ditto.
* keyimportdlg.c (import_ok): Ditto.
* keygendlg.c (gpa_key_gen_run_dialog): Ditto.
* keyexportdlg.c (export_ok): Ditto.
* gtktools.c (file_dialog_ok): Ditto.
* gpawidgets.c (gpa_secret_key_list_new): Ditto.
(gpa_public_key_list_new): Ditto.
* keylist.c (keylist_fill_list): Insert only if we got a keyID.
2001-02-27 Jan-Oliver Wagner <jan@intevation.de>
* helpmenu.c: Added some authors for scroll text
2001-02-15 Thomas Koester <tkoester@intevation.de>
* gpa.c (i18n_init): call gtk_set_locale even with USE_SIMPLE_GETTEXT
* keysmenu.c (gpa_frameExpire_at, gpa_frameExpire_after): obsolete
2001-02-15 Bernhard Herzog <bh@intevation.de>
* keygenwizard.c (gpa_keygen_wizard_backup_dir_browse): Check for
a cancelled dialog.
* encryptdlg.c (file_encrypt_ok, file_encrypt_cancel): Instead of
quitting the main loop, destroy the dialog window.
(file_sign_destroy, gpa_file_encrypt_dialog_run):Add a destroy
event handler and quit the recursive main loop there.Make the
dialog properly modal.
* filesigndlg.c (file_sign_ok, file_sign_cancel): Instead of
quitting the main loop, destroy the dialog window.
(file_sign_destroy, gpa_file_sign_dialog_run): Add a destroy event
handler and quit the recursive main loop there.
(gpa_file_sign_dialog_run): Make the dialog properly modal.
* gpapastrings.c (gpa_algorithm_from_string): Translate the
strings before comparing them.
* gpapastrings.c (gpa_ownertrust_from_string): Translate the
strings before comparing them.
* filesigndlg.c (gpa_file_sign_dialog_run): Make the key list
resize properly
* helpmenu.c (help_license): Display the text of the GPL, not
just the title
* gpa_license.h:
* gpa_license.c: New file containing the GPL as a C string and the
corresponding header.
* Makefile.am (gpa_SOURCES): Add the new files
* icons.xpm:
* icons.c (xpms): Add the new logo
* helpmenu.c (about_dialog_logo_expose, about_dialog_load_logo)
removed. The logo is now an xpm just lkike the icons.
(help_about): Use a pixmap widget instead of the drawing area to
display the logo
* keygenwizard.c (page_switched): Remove a debug printf
(gpa_keygen_wizard_backup_page): Change the wording a little
* gpa_logo.ppm: Update to new logo
* gpawizard.c (GPAWizard):
(gpa_wizard_new): Add some fields for a callback that's called
whenever a page is switched. (This should really be implemented as
a GTK signal)
(gpa_wizard_set_page_switched): Call the callback
(gpa_wizard_page_switched): Set the callback
(gpa_wizard_notebook_destroy): New. Handler for the notebook's
destroy signal to remove the callback to avoid segfaults
(gpa_wizard_new): Connect to the notebook's destroy signal.
* gpawizard.h: Add the new type and prototype
* keygenwizard.c (gpa_keygen_wizard_password_validate,
gpa_keygen_wizard_backup_action,
gpa_keygen_wizard_backup_dir_action): Don't change the pixmap.
(page_switched): Callback for the page switches of the wizard.
Change the pixmap depending on the current page.
* icons.xpm: Tweak the import icon a little
* keylist.c (gpa_keylist_update_list): Update the column widths
also when the list was empty before
2001-02-14 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_import): Update the widgets after
importing the key
(keyring_toolbar_new): Change "details" to "detailed"
* icons.xpm:
* icons.c (xpms): Add some new graphics
* keyring.c (keyring_toolbar_new):
* fileman.c (gpa_fileman_toolbar_new): Use the new toolbar icons
* keylist.c (get_key_type_pixmap_value): Use the new key icons
* keygenwizard.c: Add an option to create backup copies of the
keys and add some graphics:
(GPAKeyGenWizard): Add a few fields for the backup feature and the
graphics
(gpa_keygen_wizard_password_page): The passphrase page is not the
last page before the actual key generation anymore, so change the
wording.
(gpa_keygen_wizard_password_validate): Now used directly as the
action callback of the passphrase page, so change it display the
messages instead of returning them and return the appropriate
boolean.
(gpa_keygen_wizard_backup_page):
(gpa_keygen_wizard_backup_action):
(gpa_keygen_wizard_backup_dir_page):
(gpa_keygen_wizard_backup_get_text):
(gpa_keygen_wizard_backup_dir_action): New functions implementing
the backup pages, actions and helper functions.
(gpa_keygen_generate_key): Store the generated keys in the
keygenwizard struct
(gpa_keygen_wizard_generate_action): Remove the password
validation because that's already been done. Create the backups
after generating the key pair.
(free_keygen_wizard): New function to free the keygenwizard struct
and the file names.
(gpa_keygen_wizard_run): Add the new pages and the pixmap window
(isdir):
(file_dirname): Two new helper functions
2001-02-13 Thomas Koester <tkoester@intevation.de>
* expirydlg.c (gpa_expiry_dialog_run): Conflicting accelerator.
2001-02-13 Bernhard Herzog <bh@intevation.de>
* keysmenu.c (gpa_tableKey_new): Swap the table rows and change
the labels to be more consistent with the rest of the UI.
* keyring.c (keyring_editor_mapped): Add accelerators for the
message box
* gtktools.c (gpa_message_box_run): Add an accelgroup and handle
accelerators in the button labels.
* keyimportdlg.c (key_import_dialog_run): Make the accelerators
for the radio buttons and entry fields work
* keyeditdlg.c (gpa_key_edit_dialog_run): Remove the sign frame.
Add an accel-group and make the accelerators work.
2001-02-13 Thomas Koester <tkoester@intevation.de>
* expirydlg.c (expiry_ok):
(gpa_expiry_dialog_run):
keydeletedlg.c (gpa_delete_dialog_run):
* keyexportdlg.c (key_export_dialog_run):
* keyimportdlg.c (key_import_dialog_run): Use "_OK" instead of "Ok".
* keyeditdlg.c (gpa_key_edit_dialog_run):
* gpawizard.c (gpa_wizard_new):
* keyexportdlg.c (key_export_dialog_run):
* keyimportdlg.c (key_import_dialog_run): Add/Change accelerators.
2001-02-13 Bernhard Herzog <bh@intevation.de>
* gpawizard.h: Add prototype of gpa_wizard_next_page
* gpawizard.c (gpa_wizard_next_page):
(gpa_wizard_next): Put practically all of gpa_wizard_next in the
new public function gpa_wizard_next_page and just call the public
function in gpa_wizard_next. The user data parameter of
gpa_wizard_next is now the vbox widget.
(gpa_wizard_new): Pass the vbox widget as parameter to the
Next-button's callback.
* keygenwizard.c (switch_to_next_page): New. Handler for the
activate signals of several entry fields to switch the wizard to
the next page
(gpa_keygen_wizard_simple_page): Add the keygen_wizard as
parameter and connect to the entry's activate signal to switch to
the next page.
(gpa_keygen_wizard_comment_page):
(gpa_keygen_wizard_email_page):
(gpa_keygen_wizard_name_page): Add the keygen_wizard as parameter
and pass it through to gpa_keygen_wizard_simple_page
(focus_repeat_passphrase): New. Handler for the activate signal of
the passphrase entry to focus the repeat passhrase entry
(gpa_keygen_wizard_password_page): Add the keygen_wizard as
parameter and connect to the repeat pasphrase entry's activate
signal to switch to the next page. Also focus the repeat entry in
the activate handler of the passphrase entry.
* siglist.c (gpa_siglist_set_signatures): Call
gtk_container_check_resize to make sure that the sizes of the
title buttons are also taken into account.
* keyexportdlg.c (key_export_dialog_run): Use function from
gtktools.c to create the radio buttons, so that the accelerators
are handled correctly.
2001-02-13 Thomas Koester <tkoester@intevation.de>
* gtktools.c (gpa_window_error):
(gpa_window_message): Translate window titles.
* keygenwizard.c (gpa_keygen_wizard_run): Use "Finish" button
instead of "Next" on wait_page and final_page.
* gpawizard.c (gpa_wizard_new): Add accelerator to "Next" and "Prev"
2001-02-13 Bernhard Herzog <bh@intevation.de>
* Makefile.am (install-data-local):
(pkgdata_DATA): Remove install-data-local and use pkgdata_DATA to
install data files.
(logo):
(EXTRA_DIST): Add the gpa logo file and put it into pkgdata_DATA
and EXTRA_DIST
* helpmenu.c (about_dialog_load_logo): Take the logo from the data
dir.
* keygendlg.c (gpa_key_gen_run_dialog): Add some comments
2001-02-13 Jan-Oliver Wagner <jan@intevation.de>
* hidewnd.c (new): Hiding console window on W98 and ME
* hidewnd.h (new): Hiding console window on W98 and ME
* Makefile.am: added hidewnd.(h|c)
* gpa.c (main): added hiding of console window for W98, ME
2001-02-12 Bernhard Herzog <bh@intevation.de>
* optionsmenu.c (options_recipients):
(options_key): Translate the CList column titles
(options_keyserver): Translate the buttons
* keyring.c (keyring_details_page_fill_key):
(keyring_details_notebook):
(GPAKeyringEditor): Add the owner trust to the details page.
* gpapastrings.c (gpa_ownertrust_string):
(gpa_unit_expiry_time_string): Translate the returned strings.
* keyring.c (keyring_editor_new): Mark the big label for
translation
* keylist.c (gpa_keylist_update_list): Call
gtk_container_check_resize to make sure that the size changes in
the title buttons are correctly accounted for
(ColumnDef): title may now be NULL to indicate an empty title.
(keylist_fill_row): Handle NULL column titles.
* keyring.c (keyring_editor_mapped): Check for cancelling the
dialog via WM, in which case result is NULL
* fileman.c (gpa_fileman_toolbar_new): Use the new help icon
* gpapastrings.c (algorithm_strings): Add a missing ')'
* gtktools.c (GPASaveFileNameDialog): Rename the dialog field to
window as it's done in all other dialogs
(file_dialog_destroy):
(gpa_get_save_file_name): Add a destroy event handler and quit the
recursive main loop there.
(file_dialog_ok):
(file_dialog_cancel): Instead of quitting the main loop, destroy
the dialog window.
* gpa.c (gpa_addRecipient): Only add the key if it's not already
in the recipients list.
* keysmenu.c (keys_openPublic_exportTrust_export):
(keys_openPublic_exportTrust):
(keys_openSecret_editKey_close):
(keys_openSecret_editKey):
(keys_openSecret):
* filemenu.c (file_sign_sign):
(file_encryptAs):
(file_protect):
(file_protectAs): Don't translate the tip-strings. They aren't
used anymore at all and should be removed completely evetually.
* gpa.c (gpa_open_keyring_editor):
(gpa_open_filemanager): Only do a show_all once, when the window
is created for the first time. With recent changes not all
children of the keyring editor window are shown all the time and a
show_all will make them all visible again.
* fileman.c (gpa_fileman_new):
* keyring.c (keyring_editor_new): Realize the window before
creating the toolbar so that we can create pixmaps without
warnings
* keyring.c (keylist_columns_brief):
(keylist_columns_detailed): Add the new key type pixmap as the
first column
* keylist.h (GPAKeyListColumn):
* keylist.c (column_defs):
(get_key_type_pixmap_value): New value func and column defintion
to return a pixmap indicating the type of key: public only or
secret+public.
* keylist.c (ColumnValueFunc):
(ColumnDef):
(get_name_value):
(get_trust_value):
(get_ownertrust_value):
(get_expirydate_value):
(get_identifier_value): Change the prototype of ColumnValueFunc
and update all value functions accordingly. Now the value may be a
pixmap, but all existing functions only rerturn text as before.
The function itself now also indicates whether the text has to be
freed.
(keylist_row_labels):
(keylist_free_row_labels): Removed.
(keylist_fill_row): New function to fill a row with the
labels/pixmaps for one key
* keyring.c (keyring_toolbar_new): Use the new help icon
* icons.xpm:
* icons.c (xpms): Add some new icons
* keyring.c (keyring_editor_delete): Deleting keys has changed in
gpapa, so call either gpapa_secret_key_delete or
gpapa_public_key_delete, depending on whether there's a secret key
or not.
2001-02-09 Bernhard Herzog <bh@intevation.de>
* keyring.c (key_has_been_signed): New function to test whether a
key has been signed by a given other key id
(keyring_editor_can_sign): Use the new function
(keyring_editor_sign): For each key, test whether it has already
been signed by the secret key.
* keygenwizard.c (string_strip_dup): Helper function to create a
copy of a string stripped off leading and trailing whitespace
(gpa_keygen_wizard_simple_get_text): Return a string_strip_dup'ed
version of the user input
(gpa_keygen_wizard_password_action): Free the values read from the
"simple pages" because they're now malloced copies.
(gpa_keygen_wizard_name_validate):
(gpa_keygen_wizard_email_validate): New functions to validate the
user input for the name and email pages. The validation for the
emails address could be much more thorough.
(gpa_keygen_wizard_run): Hook up the new validation functions with
the pages.
* optionsmenu.c (options_keyserver):
(options_keyserver_destroy): Make the default key server dialog
properly modal with a recursive main loop and a handler for the
destroy signal
(options_keyserver_set): Actually set the default key server.
* optionsmenu.h: Remove the prototypes of functions that are long
gone or that are now static
* optionsmenu.c (options_recipients_fillDefault):
(options_recipients_set):
(options_recipients):
(options_key):
(options_key_set):
(options_key_select):
(options_keyserver):
(options_keyserver_set): Make them static. They're only used in
this file.
* keyring.c (toolbar_edit_key): Update the details notebook too
when the key has been changed
* keyeditdlg.c (key_edit_change_expiry): Set the key_has_changed
flag if the date has been changed
* keyring.c (keyring_details_notebook): Add a missing : in the key
type label
* helpmenu.h
* helpmenu.c (help_license):
(help_about):
(help_warranty): Make them static and remove them from the header
file as they're only used in helpmenu.c.
* helpmenu.c (help_license_destroy):
(help_license): Make the default license dialog properly modal
with a recursive main loop and a handler for the destroy signal
* optionsmenu.c (options_key):
(options_key_destroy): Make the default key dialog properly modal
with a recursive main loop and a handler for the destroy signal
(options_recipients):
(options_recipients_destroy): Make the default recipients dialog
properly modal with a recursive main loop and a handler for the
destroy signal
* filesigndlg.c (file_sign_ok): Pass the selected secret key to
the passphrase dialog
2001-02-08 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_new): Initialize the details notebook
properly
(keyring_details_page_fill_key):
(keyring_details_notebook): Add some new fields to the details
page.
(keyring_details_page_fill_key): Add the secret key as a parameter
to be able to show whether the key is owned by the user
(idle_update_details): Determine the secret key too to pass to
keyring_details_page_fill_key
* expirydlg.c (gpa_expiry_dialog_run): Pass the secret key into
the dialog instead of the expiry date so that we can display it in
the password dialog. Update the headerfile accordingly.
(GPAExpiryDialog): Add the key field.
(expiry_ok): Pass the key to the password dialog.
* keyeditdlg.c (key_edit_change_expiry): gpa_expiry_dialog_run has
a new calling sequence.
* gpawidgets.c (gpa_key_info_new): Tweak the spacing a bit
* passphrasedlg.c (gpa_passphrase_run_dialog): Add a label asking
for the passphrase
* keysigndlg.c (key_sign_ok): Pass the default key to the password
dialog
* passphrasedlg.h (gpa_passphrase_run_dialog):
* passphrasedlg.c (gpa_passphrase_run_dialog): Add a key parameter
and display information about the key whose password is required.
* keysigndlg.c (key_sign_ok):
* filesigndlg.c (file_sign_ok):
* fileman.c (decrypt_files):
* expirydlg.c (expiry_ok): Call gpa_passphrase_run_dialog with
NULL as the new key parameter. Should be replaced with the correct
key later.
* keyring.c (keyring_editor_toggle_show_trust): Removed because
it's no longer used. A similar effect is available with the
brief/detailed listings.
* keydeletedlg.h:
* keydeletedlg.c: New files for the key delete dialog.
* Makefile.am (gpa_SOURCES): Add the new key delete dialog files.
* keyring.c (keyring_editor_delete): Use the new delete dialog
instead of a simple message box.
* gpawidgets.h (gpa_key_info_new):
* gpawidgets.c (gpa_key_info_new): New function to create a simple
table with info about a key.
* keygenwizard.c (GPAKeyGenWizard): Add fields for the wizard
widget and the wait-page.
(gpa_keygen_wizard_password_action): Switch to the wait-page.
(gpa_keygen_wizard_wait_page): New function to create the
wait-page.
(gpa_keygen_wizard_run): Put the waitpage into the wizard. Also,
store the gpa wizard widget in the struct.
* gpawizard.h (gpa_wizard_next_page_no_action):
* gpawizard.c (gpa_wizard_next_page_no_action): New public
function to switch the wizard to the next page without running the
action callback associated with the page. This is used by the
action callback that is invoked by the finish button to display a
"wait" message.
2001-02-07 Thomas Koester <tkoester@intevation.de>
* gpapastrings.c (gpa_expiry_date_string): Use %x instead of
%d.%m.%Y as date format string.
* expirydlg.c (gpa_expiry_dialog_run):
* gpawidgets.c (gpa_expiry_frame_at):
(gpa_expiry_frame_new):
* keysmenu.c (gpa_frameExpire_at):
(gpa_frameExpire_new): Use gpa_expiry_date_string.
* keyring.c (keyring_details_page_fill_key): free unused text.
2001-02-07 Bernhard Herzog <bh@intevation.de>
* gpawidgets.h (gpa_signature_list_new):
* gpawidgets.c (add_sigs_to_clist):
(gpa_signature_list_new): Removed. Superseded by the siglist in
siglist.c
* fileman.c (show_file_detail): Use the siglist to display the
list of signatures
* siglist.h: Change the include guard to something more unique
* keyring.c (keyring_editor_sign):
(keyring_selection_update_widgets): Use the new
keyring_update_details_notebook function to update the pages in
the details notebook
(keyring_details_notebook): Add a label to the details page and
introduce a vbox holding both the label and the table so that we
can switch between either the label or the table to show very
different information when exactly one key is selected or when
zero or more than one key is selected
(keyring_update_signatures_page):
(keyring_update_details_page): Removed
(keyring_details_page_fill_key):
(keyring_details_page_fill_num_keys):
(keyring_signatures_page_fill_key):
(keyring_signatures_page_empty):
(idle_update_details):
(keyring_update_details_notebook): New functions replacing
keyring_update_details_page and keyring_update_signatures_page so
that either the details of the current key is shown or the number
of selected keys if several or no key is selected. Also only
update the notebook when idle.
(GPAKeyringEditor): Add some new fields for the new widgets and
idle handling
(keyring_editor_new): Initialize the idle handler id.
* keylist.h (gpa_keylist_selection_length):
* keylist.c (gpa_keylist_selection_length): New function to
determine the number of selected keys
* keyring.c (keyring_editor_generate_key_advanced): Pass the
password to gpapa_key_set_expiry_date
* keysmenu.c (keys_openSecret_editKey_close):
(keys_openSecret_editKey_close): Provide dummy passwords for
gpapa_key_set_expiry_date just to make them compile. The functions
are currently unused.
* keyeditdlg.c (key_edit_change_expiry): Use the new password
parameter of the expiry dialog and pass it to gpapa.
* expirydlg.h (gpa_expiry_dialog_run):
* expirydlg.c (gpa_expiry_dialog_run): Add a parameter to return
the password
(GPAExpiryDialog): Add a field for the password
(expiry_ok): Ask for the password and set the password field in
the dialog struct
2001-02-06 Bernhard Herzog <bh@intevation.de>
* gpa.h (global_defaultKey): Removed. Its definition was deleted
some time ago.
* gpa.h (global_homeDirectory):
* gpa.c (global_homeDirectory): Removed as it's no longer used.
* gpa.c (main): Don't init the home dir and load/save options dialogs.
* optionsmenu.c (homeDirSelect):
(loadOptionsSelect):
(saveOptionsSelect):
(gpa_homeDirSelect_ok):
(gpa_homeDirSelect_init):
(gpa_loadOptionsSelect_ok):
(gpa_loadOptionsSelect_init):
(gpa_saveOptionsSelect_ok):
(gpa_saveOptionsSelect_init):
(options_homedir):
(options_load):
(options_save): Removed. Loading and saving options wasn't
actually implemented in gpapa anyway and the home directory was
only used by the load/save options functions.
(gpa_options_menu_add_to_factory): Remove the menu entries for the
home directory and loading/saving options.
* fileman.c (decrypt_files): Update cur to the next list element
at the end of the while loop.
* helpmenu.c: Reformat several functions to conform more to GNU
standards.
(about_dialog_logo_expose): Don't add new timers here. Should fix
the segfaults that happened when the about dialog was closed.
* Makefile.am (gpa_SOURCES): Replace the keyreceivedlg files with
the keyimportdlg files.
* keyimportdlg.h:
* keyimportdlg.c: New files implementing the import dialog
* keyring.c (keyring_editor_import):
(keyring_editor_receive): Rename keyring_editor_receive to
keyring_editor_import and implement it with the new import dialog
(toolbar_import_keys): call keyring_editor_import.
2001-02-05 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_export): Use the server returned by
the dialog and not the default server.
* siglist.c (GPASigList):
(gpa_siglist_new):
(gpa_siglist_set_signatures): Don't try to be too clever about
when to set the columns to their optimal widths. Do it whenever
the list is changed and get rid of the widths_set flag.
* keyring.c (keyring_editor_export): Actually call the appropriate
gpap functions and handle sending keys to key servers as well.
* keyexportdlg.h:
* keyexportdlg.c: Substantial changes in practically all functions
to extend the dialog to support sending keys to key servers (which
includes a new parameter in key_export_dialog_run) as well and to
handle delete-event and destroy correctly.
2001-02-02 Bernhard Herzog <bh@intevation.de>
* gpa.c (gpa_removeRecipients): Change "files" to "keys" in the
error message when no items are selected
* keyring.c (toolbar_export_key): Call keyring_editor_export
* gtktools.c (gpa_window_show_centered): Set the WM_TRANSIENT_FOR
window manager hint so that the window manager treats dialog
windows properly
* keyring.c (keyring_toolbar_new): Correct the tooltip for the
remove button
2001-02-01 Bernhard Herzog <bh@intevation.de>
* Makefile.am (gpa_SOURCES): Add the new expiry dialog files
* expirydlg.h:
* expirydlg.c: New files implementing the dialog to change the
expiry date
* keyeditdlg.c (key_edit_change_expiry): New function. Handler for
the change button of the expiry date
(gpa_key_edit_dialog_run): Add the signal handler for the expiry
date change
* keyring.c (keyring_editor_generate_key_advanced):
* keygenwizard.c (gpa_keygen_wizard_password_action): Remove some
debug printfs
* gtktools.c (GPAMessageBox):
(message_box_clicked):
(message_box_destroy):
(message_box_delete):
(gpa_message_box_run): Connect to destroy instead of delete-event
and quit the main loop there. Also introduce the struct
GPAMessageBox to pass data to the various signal handlers and
results back to the message box function.
* keyring.c (keyring_editor_delete): Check whether the return
value from the message box is NULL, too, when checking for
"cancel". (it may be null if the user exited the message box
through the window manager)
* keyeditdlg.c (key_edit_change_trust):
* ownertrustdlg.h (gpa_ownertrust_run_dialog):
* ownertrustdlg.c (gpa_ownertrust_run_dialog): Remove the tip
parameter of gpa_ownertrust_run_dialog which was intended for the
now removed tip window. Update callers.
* keyring.c (keyring_editor_can_sign): Don't check explicitly
whether the selected key is the default key because the list of
signatures contains the self signature now.
2001-01-31 Bernhard Herzog <bh@intevation.de>
* gpa.h (global_noTips):
* gpa.c (global_noTips): Removed. not needed anymore now that the
tip window's gone
* optionsmenu.c (gpa_options_menu_add_to_factory): Remove the
"Online _tips" entry
* optionsmenu.h (options_tips):
* optionsmenu.c (options_tips):
* gpa.h (gpa_switch_tips):
* gpa.c (gpa_switch_tips): Removed because they're not needed
anymore now that the tip window's gone
* keyring.c (keyring_update_status_bar): Make the parameter
explicitly a GPAKeyringEditor pointer because it's not directly
used as a signal handler anymore
(keyring_default_key_changed): New signal handler for the
gpa_default_key_changed signal that updates the statusbar and the
selection sensitive widgets because some of them depend on the
default key
(keyring_editor_new): Use keyring_default_key_changed as the
handler for gpa_default_key_changed
(keyring_editor_sign): Update the selection sensitive widgets too
because some depend on what signatures a key has.
* keysmenu.h: Remove the prototypes of the functions deleted from
keysmenu.c
* keysmenu.c (keys_generateKey):
(keys_generateKey_generate):
(keys_openPublic):
(keys_openPublic_evalMouse):
(keys_openPublic_toggleClistKeys):
(keys_openPublic_fillClistKeys):
(keys_openPublic_receive):
(keys_openPublic_receive_receive):
(keys_openPublic_editKey):
(keys_openPublic_sign):
(keys_openPublic_sign_exec):
(keys_openPublic_editTrust):
(keys_openPublic_editTrust_accept):
(keys_openPublic_delete):
(getStringForKeytrust):
(getOwnertrustForString):
(writtenKeytrust):
(writtenOwnertrust):
(unitTime):
(writtenAlgorithm): Removed because they're not used anymore.
* optionsmenu.c (gpa_homeDirSelect_init):
(gpa_loadOptionsSelect_init):
(gpa_saveOptionsSelect_init): Remove commented out window tip code
* encryptdlg.c:
* fileman.c:
* filemenu.c:
* filesigndlg.c:
* gpa.c:
* gpawidgets.c:
* gtktools.c:
* optionsmenu.c: Don't include help.h
* tipwindow.c:
* help.h:
* help.c: Removed because the tip windows are not used anymore.
tipwindow.c wasn't actually used anyway
* Makefile.am (gpa_SOURCES): Removed help.c and help.h
* gpa.c (main): Don't init the tipwindow.
* optionsmenu.c (options_homedir):
(options_load):
(options_save): Remove the gpa_window_tip_show calls.
* gtktools.c (gpa_window_destroy): Remove the window tip handling
* filemenu.c (file_open):
(gpa_fileOpenSelect_init):
(file_open_ok):
(file_showDetail):
(file_close):
(file_sign):
(get_file_selection_count):
(file_encrypt):
(file_decrypt_decrypt_exec):
(file_decrypt_decrypt):
(file_decrypt): Remove because they're not used anymore
* filemenu.h: Removed the prototypes of the functions removed from
filemenu.c
* gtktools.h (gpa_widget_set_centered):
* gtktools.c (gpa_widget_set_centered): Removed. Use
gpa_window_show_centered instead
* gtktools.c (gpa_window_passphrase):
(gpa_window_message):
* helpmenu.c (help_license): Use gpa_window_show_centered instead
of gpa_widget_set_centered.
* gtktools.h (gpa_widget_show):
* gtktools.c (gpa_widget_show): Removed. Use
gpa_window_show_centered instead
* encryptdlg.c (gpa_file_encrypt_dialog_run):
* fileman.c (show_file_detail):
* filemenu.c (file_showDetail):
(file_sign_dialog):
(file_encrypt_detail):
(file_encrypt_dialog):
(file_protect_dialog):
(file_decryptAs):
* filesigndlg.c (gpa_file_sign_dialog_run):
* gtktools.c (gpa_window_error):
* keyexportdlg.c (key_export_dialog_run):
* keyreceivedlg.c (key_receive_run_dialog):
* keysmenu.c (keys_export_dialog):
(keys_openPublic_editTrust):
(keys_openPublic_editKey):
(keys_openPublic_receive):
(keys_openPublic_exportTrust):
(keys_openPublic):
(keys_openSecret_editKey):
(keys_openSecret):
(keys_generateKey):
(keys_generateRevocation):
(keys_import):
(keys_importOwnertrust):
* optionsmenu.c (options_keyserver):
(options_recipients):
(options_key):
(options_tips):
Call gpa_window_show_centered instead of gpa_widget_show
* keygendlg.c (gpa_key_gen_run_dialog): Remove the commented out
gpa_widget_show call
* keyring.c (keyring_editor_edit_trust): Removed because its now
replaced by the key edit dialog.
* keygenwizard.c (gpa_keygen_wizard_destroy):
(gpa_keygen_wizard_run): Add a destroy event handler and quit the
recursive main loop there.
(gpa_keygen_wizard_close): Instead of quitting the main loop,
destroy the dialog window. Also, use the correct prototype.
* keysigndlg.c (gpa_key_sign_run_dialog): Make sure dialog.result
is set to FALSE by default.
2001-01-30 Bernhard Herzog <bh@intevation.de>
* keysigndlg.c (key_sign_destroy):
(gpa_key_sign_run_dialog): Add a destroy event handler and quit
the recursive main loop there.
(key_sign_cancel):
(key_sign_ok): Instead of quitting the main loop, destroy the
dialog window.
(key_sign_delete): Removed because the default handler does
exactly what we need now.
(GPAKeySignDialog):
(key_sign_ok): Remove the clist_keys field completely and don't
access it in key_sign_ok.
* ownertrustdlg.c (ownertrust_ok):
(ownertrust_cancel): Fix comments
* passphrasedlg.c (passphrase_destroy):
(gpa_passphrase_run_dialog): Add a destroy event handler and quit
the recursive main loop there.
(passphrase_ok):
(passphrase_cancel): Instead of quitting the main loop, destroy
the dialog window.
(passphrase_delete_event): Removed because the default handler
does exactly what we need now.
(gpa_passphrase_run_dialog): use gtk_window_set_modal to get a
modal dialog and focus the password entry widget
(GPAPassphraseDialog): Add the window field to pass the dialog
window into the callbacks.
* ownertrustdlg.c: Add comments
(ownertrust_ok):
(ownertrust_cancel): Destroy the dialog window
(gpa_ownertrust_run_dialog):
(ownertrust_destroy): Add a destroy event handler and quit the
recursive main loop there.
(ownertrust_delete_event): Removed because the default handler
does exactly what we need now.
(gpa_ownertrust_run_dialog): Use gpa_window_show_centered instead
of gpa_widget_show and use gtk_window_set_modal to get a modal
dialog
* keyeditdlg.c (gpa_key_edit_dialog_run):
(key_edit_destroy): Add a destroy event handler and quit the
recursive main loop there.
(key_edit_close): Destroy the dialog window. Quitting the mainloop
is now handled in the destroy callback.
(key_edit_delete_event): Removed because the default handler does
exactly what we need now.
* keyeditdlg.h:
* keyeditdlg.c: New files implementing the key edit dialog (still
incomplete, though)
* Makefile.am (gpa_SOURCES): Add the edit dialog files
* keyring.c (toolbar_edit_key): Run the key edit dialog
2001-01-26 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_new): Initialize the status bar
properly
* gpa.c (gpa_update_default_key): If the default key is not set
yet, set it to (an approximation of) gpg's default key.
(gpa_determine_default_key): Make it static. It's better to use
gpa_update_default_key now.
* gpa.h: Update the prototypes accordingly.
* gpa.c (main):
* keyring.c (keyring_editor_generate_key_simple):
(keyring_editor_generate_key_advanced):
Use gpa_update_default_key instead of gpa_determine_default_key
* keyring.c (keyring_editor_mapped): Fix a typo
(keyring_statusbar_new): new function to create a status bar
showing the default key
(GPAKeyringEditor): Add the labels of the status bar.
(keyring_update_status_bar): New function to update the status bar
whenever the default key changes.
(keyring_editor_new): Add the status bar.
* gpa.h: Add the prototypes for gpa_get_keyring_editor and
gpa_get_filenamager
* gpa.c (gpa_default_key_changed_marshal):
(gpa_create_default_key_signal):
(gpa_emit_default_key_changed): New functions to implement a user
signal "gpa_default_key_changed" for GtkWindows that is emit on
all toplevel windows whenever the default key changes.
(main): Initialize the user signal
(gpa_set_default_key): Emit the new signal when the key changes.
(gpa_get_keyring_editor): New function to return the keyring
editor window
(gpa_get_filenamager): New function to return the filemanager
editor window
* keyring.c (keyring_editor_new): Remove the close button.
2001-01-25 Bernhard Herzog <bh@intevation.de>
* filemenu.c:
* gtktools.c:
* helpmenu.c:
* keysmenu.c:
* optionsmenu.c: Replace all those silly _("") with ""
2001-01-25 Jan-Oliver Wagner <jan@intevation.de>
* simple-gettext.c (get_string): removed ISO-8859-1 to IBM-CP-850
conversion (assuming .mo file is adequately encoded)
2001-01-24 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_update_signatures_page): Don't list the self
signaturs in simplified UI mode.
* siglist.c: Add some comments
* siglist.h:
* siglist.c (gpa_siglist_set_signatures): Add a key_id parameter
to filter out signatures of a given key. Useful to hide the self
signatures of keys.
* keyring.c (keyring_editor_new): Make the scrollbars of the
keylist appear automatically.
(keyring_editor_new): Put the keylist and the details notebook
into a paned window so that users can allocate the vertical space
for the widgets. Clean up the code a bit, too.
* Makefile.am (gpa_SOURCES):
* siglist.h:
* siglist.c: New files implementing the list of signatures in the
keying editor.
* keyring.c (keyring_details_notebook): Add the signatures page
(keyring_update_signatures_page): New function to update the
signatures page
(keyring_selection_update_widgets): Update the signatures page
too.
(GPAKeyringEditor): Add the signatures list widget
* keylist.c: Remove some uneeded includes
* keylist.c (keylist_fill_list): Try to keep the current selection
if the new keep_selection parameter is TRUE.
(gpa_keylist_update_list): Keep the current selection.
* keyring.c (keylist_columns_detailed):
(keylist_columns_brief): Put the name at the end.
* keylist.c (gpa_keylist_update_list): Make all columns have the
optimal width.
(gpa_keylist_new): Use gpa_keylist_update_list to fill the keylist
and create the title buttons, so that the columns havethe optimal
width.
2001-01-23 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_toolbar_new): Add buttons for brief and
detailed listing.
(keyring_set_brief_listing):
(keyring_set_detailed_listing): New. Signal handlers for the diref
and detailed listing buttons of the toolbar.
(keylist_columns_detailed):
(keylist_columns_brief): Definitions of the brief and detailed key
listing.
(keyring_editor_new): Use keylist_columns_brief to initialize the
key list
(add_details_row):
(keyring_details_notebook):
(keyring_update_details_page): Turn the fingerprint label in the
details notebook into an uneditable entry field so that users can
copy and paste the fingerprint. To that end add a new parameter to
add_details_row to indicate whether a label or entry is to be
created.
* keylist.c (keylist_fill_column_titles): Set the first
keylist->ncolumns to visible.
2001-01-23 Jan-Oliver Wagner <jan@intevation.de>
* simple-gettext.c: (new) "simple gettext method for
Windows (copied from gnupg
* Makefile.am: added simple-gettext
2001-01-23 Bernhard Herzog <bh@intevation.de>
* Makefile.am (gpa_SOURCES): Add the keylist files.
* keylist.h:
* keylist.c: New files implementing the key list of the key ring
editor.
* keyring.c (keyring_editor_new):
(keyring_editor_edit_trust):
(keyring_editor_delete):
(keyring_editor_sign):
(keyring_editor_export): replace the CList of the keys with the
keylist of keylist.c and modify all functions that use it to use
the appropriate functions of keylist.c
(keyring_editor_has_selection):
(keyring_editor_has_single_selection):
(keyring_editor_fill_keylist):
(keyring_editor_current_key_id):
(keyring_editor_current_key):
These function are now just frontends for the corresponding
functions in keylist.c
2001-01-23 Jan-Oliver Wagner <jan@intevation.de>
* w32reg: new module copied from gnupg
Access to Windows Registry
* Makefile.am: added w32reg
* gpa.c (main): now reads from Registry under Windows
2001-01-22 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_delete): Ask for confirmation before
deleting keys.
2001-01-19 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_can_sign): Check whether the default
has already signed the selected key and return FALSE in that case.
(keyring_editor_current_key_id): New function that returns the id
of the currently selected key.
* gpa.c (main): Read the gtkrc file
* Makefile.am: Add the gtkrc file
* gtkrc: New file with GTK style defaults
* keyring.c (keyring_editor_selection_changed):
(keyring_editor_end_selection):
(keyring_editor_fill_keylist):
(keyring_editor_menubar_new): make them static
(add_selection_sensitive_widget): Add the callback as a new
parameter.
(GPA_SENSITIVE_BUTTON): Get rid of this widget and use
add_selection_sensitive_widget.
(keyring_editor_new): Add a notebook showing details of the
selected key and a toolbar at the top which replaces the buttons
at the bottom
(GPAKeyringEditor): Add three new fields for the labels of the
details view.
(keyring_toolbar_new): New function to create the new toolbar
(toolbar_import_keys):
(toolbar_export_key):
(toolbar_sign_key):
(toolbar_remove_key):
(toolbar_edit_key): Signal handlers for the toolbar.
(add_details_row):
(keyring_details_notebook):
(keyring_update_details_page): New functions to create and update
the new details notebook.
(keyring_editor_current_key): New function to return the currently
selected key.
(keyring_selection_update_widgets): New function that bundles all
the updates that have to happen when the selection changes. Change
the relevant signal handlers to use it.
(keyring_editor_fill_keylist): The "show ownertrust" button is
unavailable for now, so assume that it's not checked by default,
just to make it work without the button.
(keyring_editor_delete): Check for the existence of a private key
and delete that first if it exists.
* keyring.c: Substantial code reorganization
2001-01-18 Bernhard Herzog <bh@intevation.de>
* gpa.c (cmd_and_opt_values):
(opts):
(main):
Rename the option simplified-ui to advanced-ui and
reverse its meaning. The simplified UI is now the default.
* keyring.c (keyring_editor_menubar_new): Add ... to "generate
key" because it pops up a dialog
2001-01-17 Bernhard Herzog <bh@intevation.de>
* keyring.c (keyring_editor_can_sign): Change the condition.
Signing is possible when at least one key is selected and there is
a default key.
(keyring_editor_generate_key_simple):
(keyring_editor_generate_key_advanced): Update the default key and
make sure all potentially sensitive widgets are updated.
* keysigndlg.h (gpa_key_sign_run_dialog): Update the parameter
list.
* keysigndlg.c (gpa_key_sign_run_dialog): Remove the list box with
the secret keys and the key_id paramter because we assume the
selected keys are always signed with the default key. Also, in
simplified ui mode, don't show the "sign locally" check box and
set dialog.check_local to NULL.
(key_sign_ok): Check whether dialog->check_local is NULL, i.e.
whether the dialog was created in simplified ui mode, before
retrieving the value. If it's NULL, set sign_type to normal.
(struct _GPAKeySignDialog): remove the key_id field and update all
users.
* keyring.c (keyring_editor_sign): Change default sign type to
normal which is probably better for the simplified UI mode. Also,
private_key_id is the default key now, because it's not a retrun
value of the key sign dialog anymore.
* gpa.c (gpa_determine_default_key): New function to guess a
useful default key.
(main): Use gpa_determine_default_key to initialize the default
key.
* gtktools.c (gpa_window_error): Make the messenger parameter
optional, i.e. it may be NULL now, so that gpa_callback can be
used with NULL as calldata.
* gpa.h:
* gpa.c: Turn the definition of opt in gpa.h into an extern
declaration and define it in gpa.c. Rename it to gpa_options. Fix
all references to it. Introduce a typedef for the struct.
* keysigndlg.h:
* keysigndlg.c (gpa_key_sign_run_dialog): Add the key to be signed
to the parameter list and display its user id and fingerprint.
* keyring.c (keyring_editor_generate_key_advanced): Do some error
checking after generating the key pair.
(keyring_editor_sign): Run the keysing dialog for each selected
key separately
2001-01-16 Bernhard Herzog <bh@intevation.de>
* filemenu.c (file_sign_dialog):
* gpawidgets.c (gpa_secret_key_list_new):
* optionsmenu.c (gpa_loadOptionsSelect_ok):
(gpa_saveOptionsSelect_ok):
(options_key_set):
(options_key): Use gpa_default_key and gpa_set_default_key instead
of accessing global_defaultKey directly.
* gpa.h: Add the two new functions gpa_default_key
gpa_set_default_key
* gpa.c (global_defaultKey):
(gpa_default_key):
(gpa_set_default_key): Turn global_defaultKey into a static
varible default_key and introduce gpa_set_default_key and
gpa_default_key to set and get its value
* gpa.c (gpa_popupMenu_init):
(global_popupMenu) Removed because they're no longer used.
* gpa.h: Removed global_tempWindows
* gpa.c:
* gpawindowkeeper.c:
Moved global_tempWindows to gpawindowkeeper as it's only used
there, made it static and renamed it to tempWindows because it's
not a global variable anymore.
2001-01-15 Bernhard Herzog <bh@intevation.de>
* keygenwizard.c (gpa_keygen_wizard_final_page):
Fix typo
* keyring.c: Add and update comments
(keyring_editor_can_sign): New function. Sensitivity callback for
the sign key button.
* keyring.c (keyring_editor_generate_key):
(keyring_editor_generate_key_advanced): Renamed
keyring_editor_generate_key to
keyring_editor_generate_key_advanced.
(keyring_editor_generate_key_simple): New function to call the key
generation wizard
(keyring_editor_generate_key): New function. Depending on the
simple_ui flag call either keyring_editor_generate_key_advanced or
keyring_editor_generate_key_simple
(keyring_editor_mapped): New function. Signal handler handler for
the map signal. If the simple_ui flag is set and no private key
is in the keyring, suggest creating a new keypair.
(keyring_editor_new): Connect to the map signal
* gpawizard.c:
* gpawizard.h:
New files implementing a simple generic wizard interface
* keygenwizard.h:
* keygenwizard.c:
New files implementing the key generation wizard
* Makefile.am: Add the new files.
* keygendlg.c (gpa_key_gen_run_dialog): Connect to delete-event
and use the new gpa_window_show_centered function.
* gtktools.h: Update the prototype of gpa_button_set_text and add
the new message box functions
* gtktools.c (gpa_button_set_text): Handle accelerators
(message_box_delete):
(message_box_clicked):
(gpa_message_box_run):
New functions implementing a flexible message box with caller
definable buttons.
* gpa.h: Add the prototypes for gpa_simplified_ui and
gpa_set_simplified_ui
* gpa.c (opts):
(cmd_and_opt_values)
Add a new option "simplified-ui" to turn on the simplified interface
(gpa_simplified_ui):
(gpa_set_simplified_ui):
New functions to read and set the simplified ui flag
(main): handle the simplified ui option in argument parsing
2001-01-11 Bernhard Herzog <bh@intevation.de>
* keysigndlg.c (gpa_key_sign_run_dialog):
(key_sign_delete): Add signal handler for the delete-event signal.
(gpa_key_sign_run_dialog): Use gpa_window_show_centered instead of
gpa_widget_show
* passphrasedlg.c
Add some comments
(gpa_passphrase_run_dialog): The handler for the
delete-event expected to be connected with gtk_signal_connect not
with gtk_signal_connect_object.
Use the new gpa_window_show_centered function
(passphrase_delete_event): Return FALSE to indicate that the
window is to be closed.
* gtktools.c (gpa_window_show_centered): Make it actually work.
2001-01-10 Bernhard Herzog <bh@intevation.de>
* gtktools.c (gpa_window_show_centered): Removed the debug
printf()s
2001-01-09 Bernhard Herzog <bh@intevation.de>
* gtktools.c (gpa_window_show_centered): New function. This is a
better way to center windows and it should replace
gpa_widget_set_centered one day.
(gpa_window_error): Use the new gpa_window_show_centered instead
of gpa_widget_show
(gpa_button_set_text): New function to update the text of a button
widget
* gtktools.h: Add the two new function in gtktools.c
* gpa.c (evalMouseClistFile):
(gpa_menubar_new):
(delete_event):
(evalKeyClistFile):
Removed because they're no longer used
* keyexportdlg.c (key_export_dialog_run):
get rid of the gpa_space_new () call
2001-01-05 Bernhard Herzog <bh@intevation.de>
* encryptdlg.c
* encryptdlg.h
* fileman.c
* fileman.h
* filesigndlg.c
* filesigndlg.h
* gpapastrings.c
* gpapastrings.h
* gpawidgets.c
* gpawidgets.h
* help.h
* keyexportdlg.c
* keyexportdlg.h
* keygendlg.c
* keygendlg.h
* keyreceivedlg.c
* keyreceivedlg.h
* keyring.c
* keyring.h
* keysigndlg.c
* keysigndlg.h
* ownertrustdlg.c
* ownertrustdlg.h
* passphrasedlg.c
* passphrasedlg.h
* tipwindow.c
new files
* filemenu.c:
* gpa.c:
* gpa.h:
* gtktools.c:
* gtktools.h:
* help.c:
* helpmenu.c:
* helpmenu.h:
* optionsmenu.c:
* optionsmenu.h:
A lot of changes and reorganization of the code. Much of the code
is now in the new files.
The reorganization has two goals:
1. Change the user interface to make the keyring editor the main
window.
2. Internal changes to make the code more object oriented and more
maintainable.
The changes are very extensive and touch practically all parts of
the UI code.
* Makefile.am: Added the new files
2000-09-01 Werner Koch <wk@gnupg.org>
* icons.c, icons.h: New. Changed all other includes of icons.xpm
to icons.h.
* gpa.c (gpa_file_toolbar_new): Use this new function here.
* gtktools.c (gpa_xpm_label_box): Ditto
* keysmenu.c (getIconNameForOwnertrust): Replaces
getIconForOwnertrust. Changed all callers to provide a string now.
2000-08-17 Werner Koch <wk@gnupg.org>
* gpa.c (i18n_init,main): Fixed locale setting as suggested by
Clive Lin.
2000-07-25 09:02:34 Werner Koch (wk@habibti.openit.de)
* gpa.c (gpa_windowTips_show): Moved from here to ...
* help.c: ... here. Complete rewrote to read the tips rom a file.
(get_language): New.
(gpa_tips.en, gpa_tips.de): New.
2000-06-28 17:23:03 Werner Koch (wk@habibti.openit.de)
* gpa.c: Removed the --tooltip-kludge option, becuase the bug as
been fixed meanwhile.
* gtktools.c (gpa_widget_show): Removed it here too.
2000-06-28 15:32:07 Jan-Oliver Wagner (jan@intevation.de)
* gtktools.c (gpa_widget_set_centered): fixed minimization bug
* icons.xpm: replaced temporary icons and added ownertrust icons
* keysmenu.c: added icon to button 'sign' in public keyring editor
dialog, added ownertrust icons in keylist of public keyring editor
dialog
2000-06-23 16:05:04 Jan-Oliver Wagner (jan@intevation.de)
* keysmenu.c: added icon to the delete button in the
public keyring editor dialog
2000-06-23 16:00:53 Jan-Oliver Wagner (jan@intevation.de)
* icons.xpm: added a trashcan (taken from KDE)
2000-06-23 10:11:02 Jan-Oliver Wagner (jan@intevation.de)
* icons.xpm: test icons for tool bar added
2000-06-23 10:10:44 Jan-Oliver Wagner (jan@intevation.de)
* gpa.c: test icons for tool bar added, seldom actions removed
from toolbar
2000-06-22 13:27:35 Jan-Oliver Wagner (jan@intevation.de)
* icons.xpm: new file, contains icon xpm's. Just tempory until
icons are treated in a more convenient way.
2000-06-20 16:45:31 Jan-Oliver Wagner (jan@intevation.de)
* gpa.c: added toolbar for main window - experimental stage, but
functioning
2000-05-25 17:54:29 Werner Koch (wk@habibti.openit.de)
* gpa.c (main): Add a call to gpapa_init
New option --gpg-program.
2000-05-24 10:01:06 Werner Koch (wk@habibti.openit.de)
* gpa.c (gpa_menubar_new): Reformated menu list.
* helpmenu.c (help_version): renamed to ...
(help_about): .. this and implemented.
* gpa.c, gpa.h (namesKeyservers): Replaced by ..
(main): ... opt.keyserver_names and malloced array.
* optionsmenu.c (options_keyserver): Put all keyservers into the list.
* gtktools.c (gpa_widget_show): Kludge for Sawmill and Windowmaker.
2000-05-16 19:57:28 Werner Koch (wk@habibti.openit.de)
Ran "indent -gnu -sc" on all source files.
2000-05-04 18:40:08 Werner Koch (wk@habibti.openit.de)
* *.c: Moved all gpa_widget_set_centered() before the
gtk_widget_show_all(), so that the windows are displayed
correctly.
2000-05-02 19:57:29 Werner Koch (wk@habibti.openit.de)
* gpa.c, keymenu.c, filemenu.c: Removed libiberty header.
* gpa.h: Included xmalloc header.
diff --git a/src/Makefile.am b/src/Makefile.am
index 726900d..1625ad6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,110 +1,123 @@
## Process this file with automake to produce Makefile.in
logo = gpa_logo.ppm
pkgdata_DATA = $(logo)
-EXTRA_DIST = $(logo) gpa.ico gpa-resource.rc
+EXTRA_DIST = $(logo) gpa.ico gpa-resource.rc gpa-marshal.list
+BUILT_SOURCES = gpa-marshal.h gpa-marshal.c
+MOSTLYCLEANFILES = gpa-marshal.h gpa-marshal.c
+
+GLIB_GENMARSHAL = glib-genmarshal
+
+gpa-marshal.h: gpa-marshal.list
+ $(GLIB_GENMARSHAL) --header --prefix=gpa_marshal $< > $@.tmp
+ mv $@.tmp $@
+
+gpa-marshal.c: gpa-marshal.list
+ $(GLIB_GENMARSHAL) --body --prefix=gpa_marshal $< > $@.tmp
+ mv $@.tmp $@
if HAVE_W32_SYSTEM
.rc.o:
$(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \
sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@
gpa_res_ldflag = -Wl,gpa-resource.o
gpa_deps = gpa-resource.o
gpa_w32_sources = w32reg.h w32reg.c w32-afunix.h w32-afunix.c
else
gpa_res_ldflag =
gpa_deps =
gpa_w32_sources =
endif
bin_PROGRAMS = gpa
noinst_PROGRAMS = dndtest
AM_CPPFLAGS = -I$(top_srcdir)/intl -I$(top_srcdir)/pixmaps
AM_CFLAGS = $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) \
$(GTK_CFLAGS)
LDADD = $(GPGME_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
$(GTK_LIBS) $(LIBINTL) $(NETLIBS)
gpa_LDFLAGS = $(gpa_res_ldflag)
gpa_DEPENDENCIES = $(gpa_deps)
gpa_SOURCES = get-path.h get-path.c \
gpa.c gpa.h i18n.h options.h \
gpawindowkeeper.c gpawindowkeeper.h \
gtktools.c gtktools.h \
helpmenu.c helpmenu.h \
icons.c icons.h \
gpawidgets.c gpawidgets.h \
fileman.c fileman.h \
clipboard.h clipboard.c \
filesigndlg.c filesigndlg.h \
encryptdlg.c encryptdlg.h \
verifydlg.c verifydlg.h \
recipientdlg.c recipientdlg.h \
selectkeydlg.c selectkeydlg.h \
keyring.c keyring.h \
ownertrustdlg.c ownertrustdlg.h \
keysigndlg.c keysigndlg.h \
keygendlg.c keygendlg.h \
keygenwizard.c keygenwizard.h \
qdchkpwd.c qdchkpwd.h \
keyeditdlg.c keyeditdlg.h \
expirydlg.c expirydlg.h \
keydeletedlg.c keydeletedlg.h \
keylist.c keylist.h \
siglist.c siglist.h \
gpasubkeylist.c gpasubkeylist.h \
gpapastrings.c gpapastrings.h\
gpl-text.c gpl-text.h \
keyserver.c keyserver.h \
hidewnd.c hidewnd.h \
keytable.c keytable.h \
gpgmetools.h gpgmetools.c \
gpgmeedit.h gpgmeedit.c \
server_access.h server_access.c \
settingsdlg.h settingsdlg.c \
passwddlg.h passwddlg.c \
gpacontext.h gpacontext.c \
gpaprogressdlg.h gpaprogressdlg.c \
gpaprogressbar.h gpaprogressbar.c \
gparecvkeydlg.h gparecvkeydlg.c \
gpaoperation.h gpaoperation.c \
gpastreamop.h gpastreamop.c \
gpastreamencryptop.h gpastreamencryptop.c \
gpastreamsignop.h gpastreamsignop.c \
gpafileop.h gpafileop.c \
gpafiledecryptop.h gpafiledecryptop.c \
gpafileencryptop.h gpafileencryptop.c \
gpafilesignop.h gpafilesignop.c \
gpafileverifyop.h gpafileverifyop.c \
gpakeyop.h gpakeyop.c \
gpakeydeleteop.h gpakeydeleteop.c \
gpakeysignop.h gpakeysignop.c \
gpakeytrustop.h gpakeytrustop.c \
gpakeyexpireop.h gpakeyexpireop.c \
gpakeypasswdop.h gpakeypasswdop.c \
gpaexportop.h gpaexportop.c \
gpaexportfileop.h gpaexportfileop.c \
gpaexportclipop.h gpaexportclipop.c \
gpaexportserverop.h gpaexportserverop.c \
gpaimportop.h gpaimportop.c \
gpaimportfileop.h gpaimportfileop.c \
gpaimportclipop.h gpaimportclipop.c \
gpaimportserverop.h gpaimportserverop.c \
gpagenkeyop.h gpagenkeyop.c \
gpagenkeyadvop.h gpagenkeyadvop.c \
gpagenkeysimpleop.h gpagenkeysimpleop.c \
gpabackupop.h gpabackupop.c \
gpakeyselector.h gpakeyselector.c \
server.c \
options.c \
confdialog.h confdialog.c \
+ gpa-marshal.c gpa-marshal.h \
utils.c $(gpa_w32_sources)
dndtest_SOURCES = dndtest.c
diff --git a/src/gpa-marshal.list b/src/gpa-marshal.list
new file mode 100644
index 0000000..081ce17
--- /dev/null
+++ b/src/gpa-marshal.list
@@ -0,0 +1 @@
+INT:STRING,STRING
diff --git a/src/gpabackupop.c b/src/gpabackupop.c
index 07ca48e..79cbf75 100644
--- a/src/gpabackupop.c
+++ b/src/gpabackupop.c
@@ -1,320 +1,321 @@
/* gpabackupop.c - The GpaBackupOperation object.
Copyright (C) 2003 Miguel Coca.
Copyright (C) 2005, 2008 g10 Code GmbH.
This file is part of GPA.
GPA 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.
GPA 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 GPA; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */
#include <config.h>
#include <gpgme.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpabackupop.h"
static GObjectClass *parent_class = NULL;
static gboolean gpa_backup_operation_idle_cb (gpointer data);
/* GObject boilerplate. */
/* Properties. */
enum
{
PROP_0,
PROP_KEY,
PROP_FINGERPRINT,
};
static void
gpa_backup_operation_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GpaBackupOperation *op = GPA_BACKUP_OPERATION (object);
switch (prop_id)
{
case PROP_KEY:
g_value_set_pointer (value, op->key);
break;
case PROP_FINGERPRINT:
g_value_set_string (value, op->fpr);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_backup_operation_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GpaBackupOperation *op = GPA_BACKUP_OPERATION (object);
gchar *fpr;
gpgme_key_t key;
switch (prop_id)
{
case PROP_KEY:
key = (gpgme_key_t) g_value_get_pointer (value);
if (key)
{
op->key = key;
gpgme_key_ref (op->key);
op->fpr = g_strdup (op->key->subkeys->fpr);
op->key_id = g_strdup (gpa_gpgme_key_get_short_keyid (op->key));
}
break;
case PROP_FINGERPRINT:
fpr = (gchar*) g_value_get_pointer (value);
if (fpr)
{
op->key = NULL;
op->fpr = g_strdup (fpr);
op->key_id = g_strdup (fpr + strlen (fpr) - 8);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_backup_operation_finalize (GObject *object)
{
GpaBackupOperation *op = GPA_BACKUP_OPERATION (object);
if (op->key)
{
gpgme_key_unref (op->key);
}
g_free (op->fpr);
g_free (op->key_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_backup_operation_init (GpaBackupOperation *op)
{
op->key = NULL;
op->fpr = NULL;
op->key_id = NULL;
}
static GObject*
gpa_backup_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaBackupOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_BACKUP_OPERATION (object);
/* Begin working when we are back into the main loop */
g_idle_add (gpa_backup_operation_idle_cb, op);
return object;
}
static void
gpa_backup_operation_class_init (GpaBackupOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_backup_operation_constructor;
object_class->finalize = gpa_backup_operation_finalize;
object_class->set_property = gpa_backup_operation_set_property;
object_class->get_property = gpa_backup_operation_get_property;
/* Properties */
g_object_class_install_property (object_class,
PROP_KEY,
g_param_spec_pointer
("key", "Key",
"Key",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_FINGERPRINT,
g_param_spec_pointer
("fpr", "fpr",
"Fingerprint",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
}
GType
gpa_backup_operation_get_type (void)
{
static GType file_operation_type = 0;
if (!file_operation_type)
{
static const GTypeInfo file_operation_info =
{
sizeof (GpaBackupOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_backup_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaBackupOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_backup_operation_init,
};
file_operation_type = g_type_register_static (GPA_OPERATION_TYPE,
"GpaBackupOperation",
&file_operation_info, 0);
}
return file_operation_type;
}
/* Private functions */
static void
gpa_backup_operation_do_backup (GpaBackupOperation *op, gchar *filename)
{
if (gpa_backup_key (op->fpr, filename))
{
gchar *message;
message = g_strdup_printf (_("A copy of your secret key has "
"been made to the file:\n\n"
"\t\"%s\"\n\n"
"This is sensitive information, "
"and should be stored carefully\n"
"(for example, in a floppy disk "
"kept in a safe place)."),
filename);
gpa_window_message (message, GPA_OPERATION (op)->window);
g_free (message);
gpa_options_set_backup_generated (gpa_options_get_instance (),
TRUE);
}
else
{
gchar *message = g_strdup_printf (_("An error ocurred during the "
"backup operation."));
gpa_window_error (message, GPA_OPERATION (op)->window);
}
}
/* Return the filename in filename encoding. */
static gchar*
gpa_backup_operation_dialog_run (GtkWidget *parent, const gchar *key_id)
{
static GtkWidget *dialog;
GtkResponseType response;
gchar *default_comp;
gchar *filename = NULL;
if (! dialog)
{
gchar *id_text;
GtkWidget *id_label;
dialog = gtk_file_chooser_dialog_new
(_("Backup key to file"), GTK_WINDOW (parent),
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_file_chooser_set_do_overwrite_confirmation
(GTK_FILE_CHOOSER (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
g_get_home_dir ());
/* Set the label with more explanations. */
id_text = g_strdup_printf (_("Generating backup of key: %s"), key_id);
id_label = gtk_label_new (id_text);
g_free (id_text);
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), id_label);
}
/* Set the default file name. */
default_comp = g_strdup_printf ("secret-key-%s.asc", key_id);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), default_comp);
g_free (default_comp);
response = gtk_dialog_run (GTK_DIALOG (dialog));
if (response == GTK_RESPONSE_OK)
{
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
if (filename)
g_strdup (filename);
}
gtk_widget_hide (dialog);
return filename;
}
static gboolean
gpa_backup_operation_idle_cb (gpointer data)
{
GpaBackupOperation *op = data;
gchar *file;
if ((file = gpa_backup_operation_dialog_run (GPA_OPERATION (op)->window,
op->key_id)))
gpa_backup_operation_do_backup (op, file);
-
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+
+ /* FIXME: Error handling. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
return FALSE;
}
/* API */
GpaBackupOperation*
gpa_backup_operation_new (GtkWidget *window, gpgme_key_t key)
{
GpaBackupOperation *op;
op = g_object_new (GPA_BACKUP_OPERATION_TYPE,
"window", window,
"key", key,
NULL);
return op;
}
GpaBackupOperation*
gpa_backup_operation_new_from_fpr (GtkWidget *window, const gchar *fpr)
{
GpaBackupOperation *op;
op = g_object_new (GPA_BACKUP_OPERATION_TYPE,
"window", window,
"fpr", fpr,
NULL);
return op;
}
diff --git a/src/gpacontext.c b/src/gpacontext.c
index 0628b94..b178d89 100644
--- a/src/gpacontext.c
+++ b/src/gpacontext.c
@@ -1,494 +1,493 @@
/* gpacontext.c - The GpaContext object.
* Copyright (C) 2003 Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#include <gpgme.h>
#include "gpa.h"
#include "gpgmetools.h"
#include "gpacontext.h"
/* GObject type functions */
static void gpa_context_init (GpaContext *context);
static void gpa_context_class_init (GpaContextClass *klass);
static void gpa_context_finalize (GObject *object);
/* Default signal handlers */
static void gpa_context_start (GpaContext *context);
static void gpa_context_done (GpaContext *context, gpg_error_t err);
static void gpa_context_next_key (GpaContext *context, gpgme_key_t key);
static void gpa_context_next_trust_item (GpaContext *context,
gpgme_trust_item_t item);
static void gpa_context_progress (GpaContext *context, int current, int total);
/* The GPGME I/O callbacks */
static gpg_error_t gpa_context_register_cb (void *data, int fd, int dir,
gpgme_io_cb_t fnc, void *fnc_data,
void **tag);
static void gpa_context_remove_cb (void *tag);
static void gpa_context_event_cb (void *data, gpgme_event_io_t type,
void *type_data);
static gpg_error_t
gpa_context_passphrase_cb (void *hook, const char *uid_hint,
const char *passphrase_info, int prev_was_bad,
int fd);
static void
gpa_context_progress_cb (void *opaque, const char *what,
int type, int current, int total);
/* Signals */
enum
{
START,
DONE,
NEXT_KEY,
NEXT_TRUST_ITEM,
PROGRESS,
LAST_SIGNAL
};
static GObjectClass *parent_class = NULL;
static guint signals [LAST_SIGNAL] = { 0 };
GType
gpa_context_get_type (void)
{
static GType context_type = 0;
if (!context_type)
{
static const GTypeInfo context_info =
{
sizeof (GpaContextClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_context_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaContext),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_context_init,
};
context_type = g_type_register_static (G_TYPE_OBJECT,
"GpaContext",
&context_info, 0);
}
return context_type;
}
static void
gpa_context_class_init (GpaContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gpa_context_finalize;
klass->start = gpa_context_start;
klass->done = gpa_context_done;
klass->next_key = gpa_context_next_key;
klass->next_trust_item = gpa_context_next_trust_item;
klass->progress = gpa_context_progress;
/* Signals */
signals[START] =
g_signal_new ("start",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaContextClass, start),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[DONE] =
g_signal_new ("done",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaContextClass, done),
NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1,
G_TYPE_INT);
signals[NEXT_KEY] =
g_signal_new ("next_key",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaContextClass, next_key),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[NEXT_TRUST_ITEM] =
g_signal_new ("next_trust_item",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaContextClass, next_trust_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
signals[PROGRESS] =
g_signal_new ("progress",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaContextClass, progress),
NULL, NULL,
gtk_marshal_VOID__INT_INT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_INT);
}
static void
gpa_context_init (GpaContext *context)
{
gpg_error_t err;
context->busy = FALSE;
/* The callback queue */
context->cbs = NULL;
/* The context itself */
err = gpgme_new (&context->ctx);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
return;
}
/* Set the appropriate callbacks. Note that we can't set the
passphrase callback in CMS mode because it is not implemented by
the CMS backend. To make things easier we never set in CMS mode
because we can then assume that a proper GnuPG-2 system (with
pinentry) is in use and then we don't need that callback for
OpenPGP either. */
if (!cms_hack)
gpgme_set_passphrase_cb (context->ctx, gpa_context_passphrase_cb, context);
gpgme_set_progress_cb (context->ctx, gpa_context_progress_cb, context);
/* Fill the CB structure */
context->io_cbs = g_malloc (sizeof (struct gpgme_io_cbs));
context->io_cbs->add = gpa_context_register_cb;
context->io_cbs->add_priv = context;
context->io_cbs->remove = gpa_context_remove_cb;
context->io_cbs->event = gpa_context_event_cb;
context->io_cbs->event_priv = context;
/* Set the callbacks */
gpgme_set_io_cbs (context->ctx, context->io_cbs);
}
static void
gpa_context_finalize (GObject *object)
{
GpaContext *context = GPA_CONTEXT (object);
gpgme_release (context->ctx);
g_list_free (context->cbs);
g_free (context->io_cbs);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/* API */
/* Create a new GpaContext object.
*/
GpaContext *
gpa_context_new (void)
{
GpaContext *context;
context = g_object_new (GPA_CONTEXT_TYPE, NULL);
return context;
}
/* TRUE if an operation is in progress.
*/
gboolean
gpa_context_busy (GpaContext *context)
{
g_return_val_if_fail (context != NULL, FALSE);
g_return_val_if_fail (GPA_IS_CONTEXT (context), FALSE);
return context->busy;
}
/*
* The GPGME I/O callbacks
*/
/* Registering callbacks with GLib */
/* Macros "borrowed" from GDK */
#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
#define WRITE_CONDITION (G_IO_OUT | G_IO_ERR)
struct gpa_io_cb_data
{
int fd;
int dir;
gpgme_io_cb_t fnc;
void *fnc_data;
gint watch;
GpaContext *context;
gboolean registered;
};
/* This function is called by GLib. It's a wrapper for the callback
* gpgme provided, whose prototype does not match the one needed
* by g_io_add_watch_full
*/
static gboolean
gpa_io_cb (GIOChannel *source, GIOCondition condition, gpointer data)
{
struct gpa_io_cb_data *cb = data;
/* We have to use the GPGME provided "file descriptor" here. It may
not be a system file descriptor after all. */
cb->fnc (cb->fnc_data, cb->fd);
return TRUE;
}
/* Register a GPGME callback with GLib.
*/
static void
register_callback (struct gpa_io_cb_data *cb)
{
GIOChannel *channel;
#ifdef G_OS_WIN32
/* We have to ask GPGME for the GIOChannel to use. The "file
descriptor" may not be a system file descriptor. */
channel = gpgme_get_giochannel (cb->fd);
g_assert (channel);
#else
channel = g_io_channel_unix_new (cb->fd);
#endif
cb->watch = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT,
cb->dir ? READ_CONDITION : WRITE_CONDITION,
gpa_io_cb, cb, NULL);
cb->registered = TRUE;
#ifdef G_OS_WIN32
/* Nothing do to here. */
#else
g_io_channel_unref (channel);
#endif
}
/* Queuing callbacks until the START event arrives */
/* Add a callback to the list, until the START event arrives
*/
static void
add_callback (GpaContext *context, struct gpa_io_cb_data *cb)
{
context->cbs = g_list_append (context->cbs, cb);
}
/* Register with GLib all previously unregistered callbacks. */
static void
register_all_callbacks (GpaContext *context)
{
struct gpa_io_cb_data *cb;
GList *list;
for (list = context->cbs; list; list = g_list_next (list))
{
cb = list->data;
if (!cb->registered)
{
register_callback (cb);
}
}
}
static void
unregister_all_callbacks (GpaContext *context)
{
struct gpa_io_cb_data *cb;
GList *list;
for (list = context->cbs; list; list = g_list_next (list))
{
cb = list->data;
if (cb->registered)
{
g_source_remove (cb->watch);
cb->registered = FALSE;
}
}
}
/* The real GPGME callbacks */
/* Register a callback. This is called by GPGME when a crypto
operation is initiated in this context. */
static gpg_error_t
gpa_context_register_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc,
void *fnc_data, void **tag)
{
GpaContext *context = data;
struct gpa_io_cb_data *cb = g_malloc (sizeof (struct gpa_io_cb_data));
cb->registered = FALSE;
cb->fd = fd;
cb->dir = dir;
cb->fnc = fnc;
cb->fnc_data = fnc_data;
cb->context = context;
/* If the context is busy, we already have a START event, and can
* register GLib callbacks immediately. */
if (context->busy)
- {
- register_callback (cb);
- }
+ register_callback (cb);
+
/* In any case, we add it to the list. */
add_callback (context, cb);
*tag = cb;
- return gpg_error (GPG_ERR_NO_ERROR);
+ return 0;
}
/* Remove a callback. This is called by GPGME if a context is to be
destroyed. */
static void
gpa_context_remove_cb (void *tag)
{
struct gpa_io_cb_data *cb = tag;
if (cb->registered)
{
g_source_remove (cb->watch);
}
cb->context->cbs = g_list_remove (cb->context->cbs, cb);
g_free (cb);
}
/* The event callback. It is called by GPGME to signal an event for
an operation running in this context. This fucntion merely emits
signals for GpaContext; the Glib signal handlers do the real
job. */
static void
gpa_context_event_cb (void *data, gpgme_event_io_t type, void *type_data)
{
GpaContext *context = data;
gpg_error_t *err;
switch (type)
{
case GPGME_EVENT_START:
g_signal_emit (context, signals[START], 0);
break;
case GPGME_EVENT_DONE:
err = type_data;
g_signal_emit (context, signals[DONE], 0, *err);
break;
case GPGME_EVENT_NEXT_KEY:
g_signal_emit (context, signals[NEXT_KEY], 0, type_data);
break;
case GPGME_EVENT_NEXT_TRUSTITEM:
g_signal_emit (context, signals[NEXT_TRUST_ITEM], 0,
type_data);
break;
default:
/* Ignore unsupported event types */
break;
}
}
/* Default signal handlers */
static void
gpa_context_start (GpaContext *context)
{
g_debug ("gpgme event START enter");
context->busy = TRUE;
/* We have START, register all queued callbacks */
register_all_callbacks (context);
g_debug ("gpgme event START leave");
}
static void
gpa_context_done (GpaContext *context, gpg_error_t err)
{
context->busy = FALSE;
g_debug ("gpgme event DONE ready");
}
static void
gpa_context_next_key (GpaContext *context, gpgme_key_t key)
{
/* Do nothing yet */
}
static void
gpa_context_next_trust_item (GpaContext *context, gpgme_trust_item_t item)
{
/* Do nothing yet */
}
static void
gpa_context_progress (GpaContext *context, int current, int total)
{
/* Do nothing yet */
}
/* The passphrase callback */
static gpg_error_t
gpa_context_passphrase_cb (void *hook, const char *uid_hint,
const char *passphrase_info, int prev_was_bad,
int fd)
{
GpaContext *context = hook;
gpg_error_t err;
unregister_all_callbacks (context);
err = gpa_passphrase_cb (NULL, uid_hint, passphrase_info, prev_was_bad, fd);
register_all_callbacks (context);
return err;
}
/* The progress callback */
static void
gpa_context_progress_cb (void *opaque, const char *what,
int type, int current, int total)
{
GpaContext *context = opaque;
g_signal_emit (context, signals[PROGRESS], 0, current, total);
}
diff --git a/src/gpaexportclipop.c b/src/gpaexportclipop.c
index be38439..11cd51a 100644
--- a/src/gpaexportclipop.c
+++ b/src/gpaexportclipop.c
@@ -1,156 +1,156 @@
/* gpaexportclipop.c - The GpaExportClipboardOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include <unistd.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpgmetools.h"
#include "gpaexportclipop.h"
static GObjectClass *parent_class = NULL;
static gboolean
gpa_export_clipboard_operation_get_destination (GpaExportOperation *operation,
gpgme_data_t *dest,
gboolean *armor);
static void
gpa_export_clipboard_operation_complete_export (GpaExportOperation *operation);
/* GObject boilerplate */
static void
gpa_export_clipboard_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_export_clipboard_operation_init (GpaExportClipboardOperation *op)
{
}
static GObject*
gpa_export_clipboard_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaExportClipboardOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_EXPORT_CLIPBOARD_OPERATION (object);
return object;
}
static void
gpa_export_clipboard_operation_class_init (GpaExportClipboardOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GpaExportOperationClass *export_class = GPA_EXPORT_OPERATION_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_export_clipboard_operation_constructor;
object_class->finalize = gpa_export_clipboard_operation_finalize;
export_class->get_destination = gpa_export_clipboard_operation_get_destination;
export_class->complete_export = gpa_export_clipboard_operation_complete_export;
}
GType
gpa_export_clipboard_operation_get_type (void)
{
static GType file_operation_type = 0;
if (!file_operation_type)
{
static const GTypeInfo file_operation_info =
{
sizeof (GpaExportClipboardOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_export_clipboard_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaExportClipboardOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_export_clipboard_operation_init,
};
file_operation_type = g_type_register_static (GPA_EXPORT_OPERATION_TYPE,
"GpaExportClipboardOperation",
&file_operation_info, 0);
}
return file_operation_type;
}
/* Virtual methods */
static gboolean
gpa_export_clipboard_operation_get_destination (GpaExportOperation *operation,
gpgme_data_t *dest,
gboolean *armor)
{
gpg_error_t err;
*armor = TRUE;
err = gpgme_data_new (dest);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
return FALSE;
}
else
{
return TRUE;
}
}
static void
gpa_export_clipboard_operation_complete_export (GpaExportOperation *operation)
{
GpaExportClipboardOperation *op = GPA_EXPORT_CLIPBOARD_OPERATION (operation);
dump_data_to_clipboard (operation->dest, gtk_clipboard_get
(GDK_SELECTION_CLIPBOARD));
gpa_window_message (_("The keys have been copied to the clipboard."),
GPA_OPERATION (op)->window);
}
/* API */
GpaExportClipboardOperation*
gpa_export_clipboard_operation_new (GtkWidget *window, GList *keys)
{
GpaExportClipboardOperation *op;
op = g_object_new (GPA_EXPORT_CLIPBOARD_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
diff --git a/src/gpaexportop.c b/src/gpaexportop.c
index bec3f14..51df806 100644
--- a/src/gpaexportop.c
+++ b/src/gpaexportop.c
@@ -1,258 +1,255 @@
/* gpaexportfileop.c - The GpaExportFileOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpaexportop.h"
static GObjectClass *parent_class = NULL;
/* Properties */
enum
{
PROP_0,
PROP_KEYS
};
static gboolean gpa_export_operation_idle_cb (gpointer data);
static void gpa_export_operation_done_cb (GpaContext *context, gpg_error_t err,
GpaExportOperation *op);
static void gpa_export_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaExportOperation *op);
/* GObject boilerplate */
static void
gpa_export_operation_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GpaExportOperation *op = GPA_EXPORT_OPERATION (object);
switch (prop_id)
{
case PROP_KEYS:
g_value_set_pointer (value, op->keys);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_export_operation_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GpaExportOperation *op = GPA_EXPORT_OPERATION (object);
switch (prop_id)
{
case PROP_KEYS:
op->keys = (GList*) g_value_get_pointer (value);
/* Make sure we keep a reference for our keys */
g_list_foreach (op->keys, (GFunc) gpgme_key_ref, NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_export_operation_finalize (GObject *object)
{
GpaExportOperation *op = GPA_EXPORT_OPERATION (object);
/* Free each key, and then the list of keys */
g_list_foreach (op->keys, (GFunc) gpgme_key_unref, NULL);
g_list_free (op->keys);
/* Free the data object, if it exists */
if (op->dest)
{
gpgme_data_release (op->dest);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_export_operation_init (GpaExportOperation *op)
{
op->keys = NULL;
op->dest = NULL;
}
static GObject*
gpa_export_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaExportOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_EXPORT_OPERATION (object);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_export_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_export_operation_done_cb), op);
/* Begin working when we are back into the main loop */
g_idle_add (gpa_export_operation_idle_cb, op);
return object;
}
static void
gpa_export_operation_class_init (GpaExportOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_export_operation_constructor;
object_class->finalize = gpa_export_operation_finalize;
object_class->set_property = gpa_export_operation_set_property;
object_class->get_property = gpa_export_operation_get_property;
/* Virtual methods */
klass->get_destination = NULL;
klass->complete_export = NULL;
/* Properties */
g_object_class_install_property (object_class,
PROP_KEYS,
g_param_spec_pointer
("keys", "Keys",
"Keys",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
}
GType
gpa_export_operation_get_type (void)
{
static GType file_operation_type = 0;
if (!file_operation_type)
{
static const GTypeInfo file_operation_info =
{
sizeof (GpaExportOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_export_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaExportOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_export_operation_init,
};
file_operation_type = g_type_register_static (GPA_OPERATION_TYPE,
"GpaExportOperation",
&file_operation_info, 0);
}
return file_operation_type;
}
/* Private functions */
static gboolean
gpa_export_operation_idle_cb (gpointer data)
{
GpaExportOperation *op = data;
gboolean armor = TRUE;
if (GPA_EXPORT_OPERATION_GET_CLASS (op)->get_destination (op, &op->dest,
&armor))
{
gpg_error_t err;
const char **patterns;
GList *k;
int i;
gpgme_set_armor (GPA_OPERATION (op)->context->ctx, armor);
/* Create the set of keys to export */
patterns = g_malloc0 (sizeof(gchar*)*(g_list_length(op->keys)+1));
for (i = 0, k = op->keys; k; i++, k = g_list_next (k))
{
gpgme_key_t key = (gpgme_key_t) k->data;
patterns[i] = key->subkeys->fpr;
}
/* Export to the gpgme_data_t */
err = gpgme_op_export_ext_start (GPA_OPERATION (op)->context->ctx,
patterns, 0, op->dest);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
/* Clean up */
g_free (patterns);
}
else
- {
- /* Abort the operation */
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ /* Abort the operation. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_CANCELED));
return FALSE;
}
static void
gpa_export_operation_done_cb (GpaContext *context, gpg_error_t err,
GpaExportOperation *op)
{
- if (gpg_err_code (err) == GPG_ERR_NO_ERROR)
- {
- GPA_EXPORT_OPERATION_GET_CLASS (op)->complete_export (op);
- }
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ if (! err)
+ GPA_EXPORT_OPERATION_GET_CLASS (op)->complete_export (op);
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
static void
gpa_export_operation_done_error_cb (GpaContext *context, gpg_error_t err,
GpaExportOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
/* Ignore these */
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpaexportserverop.c b/src/gpaexportserverop.c
index 9e152d8..a9ba214 100644
--- a/src/gpaexportserverop.c
+++ b/src/gpaexportserverop.c
@@ -1,205 +1,205 @@
/* gpaexportserverop.c - The GpaExportServerOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include <unistd.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpgmetools.h"
#include "server_access.h"
#include "gpaexportserverop.h"
static GObjectClass *parent_class = NULL;
static gboolean
gpa_export_server_operation_get_destination (GpaExportOperation *operation,
gpgme_data_t *dest,
gboolean *armor);
static void
gpa_export_server_operation_complete_export (GpaExportOperation *operation);
/* GObject boilerplate */
static void
gpa_export_server_operation_finalize (GObject *object)
{
GpaExportServerOperation *op = GPA_EXPORT_SERVER_OPERATION (object);
if (op->server)
{
g_free (op->server);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_export_server_operation_init (GpaExportServerOperation *op)
{
op->server = NULL;
}
static GObject*
gpa_export_server_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaExportServerOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_EXPORT_SERVER_OPERATION (object);
return object;
}
static void
gpa_export_server_operation_class_init (GpaExportServerOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GpaExportOperationClass *export_class = GPA_EXPORT_OPERATION_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_export_server_operation_constructor;
object_class->finalize = gpa_export_server_operation_finalize;
export_class->get_destination = gpa_export_server_operation_get_destination;
export_class->complete_export = gpa_export_server_operation_complete_export;
}
GType
gpa_export_server_operation_get_type (void)
{
static GType file_operation_type = 0;
if (!file_operation_type)
{
static const GTypeInfo file_operation_info =
{
sizeof (GpaExportServerOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_export_server_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaExportServerOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_export_server_operation_init,
};
file_operation_type = g_type_register_static (GPA_EXPORT_OPERATION_TYPE,
"GpaExportServerOperation",
&file_operation_info, 0);
}
return file_operation_type;
}
/* Internal */
static gboolean
confirm_send (GtkWidget * parent, const gchar *server)
{
GtkWidget *msgbox = gtk_message_dialog_new
(GTK_WINDOW(parent), GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
_("The selected key will be sent to a public key\n"
"server (\"%s\").\n"
"Are you sure you want to distribute this key?"),
server);
gtk_dialog_add_buttons (GTK_DIALOG (msgbox),
_("_Yes"), GTK_RESPONSE_YES,
_("_No"), GTK_RESPONSE_NO, NULL);
if (gtk_dialog_run (GTK_DIALOG (msgbox)) == GTK_RESPONSE_NO)
{
gtk_widget_destroy (msgbox);
return FALSE;
}
gtk_widget_destroy (msgbox);
return TRUE;
}
/* Virtual methods */
static gboolean
gpa_export_server_operation_get_destination (GpaExportOperation *operation,
gpgme_data_t *dest,
gboolean *armor)
{
if (confirm_send (GPA_OPERATION (operation)->window,
gpa_options_get_default_keyserver
(gpa_options_get_instance ())))
{
gpg_error_t err;
*armor = TRUE;
err = gpgme_data_new (dest);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
return FALSE;
}
else
{
return TRUE;
}
}
else
{
return FALSE;
}
}
static void
gpa_export_server_operation_complete_export (GpaExportOperation *operation)
{
GpaExportServerOperation *op = GPA_EXPORT_SERVER_OPERATION (operation);
gpgme_key_t key;
op->server = g_strdup (gpa_options_get_default_keyserver
(gpa_options_get_instance ()));
key = (gpgme_key_t) operation->keys->data;
if (server_send_keys (op->server, key->subkeys->keyid, operation->dest,
GPA_OPERATION (op)->window))
{
gpa_window_message (_("The keys have been sent to the server."),
GPA_OPERATION (op)->window);
}
}
/* API */
GpaExportServerOperation*
gpa_export_server_operation_new (GtkWidget *window, GList *keys)
{
GpaExportServerOperation *op;
op = g_object_new (GPA_EXPORT_SERVER_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
diff --git a/src/gpafiledecryptop.c b/src/gpafiledecryptop.c
index 8bdbd52..bc863fd 100644
--- a/src/gpafiledecryptop.c
+++ b/src/gpafiledecryptop.c
@@ -1,386 +1,395 @@
/* gpafiledecryptop.c - The GpaOperation object.
* Copyright (C) 2003 Miguel Coca.
* Copyright (C) 2008 g10 Code GmbH.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#include <glib/gstdio.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gtktools.h"
#include "gpgmetools.h"
#include "gpafiledecryptop.h"
/* Internal functions */
static gboolean gpa_file_decrypt_operation_idle_cb (gpointer data);
static void gpa_file_decrypt_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileDecryptOperation *op);
static void gpa_file_decrypt_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaFileDecryptOperation *op);
/* GObject */
static GObjectClass *parent_class = NULL;
static void
gpa_file_decrypt_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_file_decrypt_operation_init (GpaFileDecryptOperation *op)
{
op->cipher_fd = -1;
op->plain_fd = -1;
op->cipher = NULL;
op->plain = NULL;
}
static GObject*
gpa_file_decrypt_operation_constructor
(GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaFileDecryptOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_FILE_DECRYPT_OPERATION (object);
/* Initialize */
/* Start with the first file after going back into the main loop */
g_idle_add (gpa_file_decrypt_operation_idle_cb, op);
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_decrypt_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_decrypt_operation_done_cb), op);
/* Give a title to the progress dialog */
gtk_window_set_title (GTK_WINDOW (GPA_FILE_OPERATION (op)->progress_dialog),
_("Decrypting..."));
return object;
}
static void
gpa_file_decrypt_operation_class_init (GpaFileDecryptOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_file_decrypt_operation_constructor;
object_class->finalize = gpa_file_decrypt_operation_finalize;
}
GType
gpa_file_decrypt_operation_get_type (void)
{
static GType file_decrypt_operation_type = 0;
if (!file_decrypt_operation_type)
{
static const GTypeInfo file_decrypt_operation_info =
{
sizeof (GpaFileDecryptOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_file_decrypt_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaFileDecryptOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_file_decrypt_operation_init,
};
file_decrypt_operation_type = g_type_register_static
(GPA_FILE_OPERATION_TYPE, "GpaFileDecryptOperation",
&file_decrypt_operation_info, 0);
}
return file_decrypt_operation_type;
}
/* API */
GpaFileDecryptOperation*
gpa_file_decrypt_operation_new (GtkWidget *window,
GList *files)
{
GpaFileDecryptOperation *op;
op = g_object_new (GPA_FILE_DECRYPT_OPERATION_TYPE,
"window", window,
"input_files", files,
NULL);
return op;
}
/* Internal */
static gchar *
destination_filename (const gchar *filename)
{
gchar *extension, *plain_filename;
/* Find out the destination file */
extension = g_strrstr (filename, ".");
if (extension && (g_str_equal (extension, ".asc") ||
g_str_equal (extension, ".gpg") ||
g_str_equal (extension, ".pgp")))
{
/* Remove the extension */
plain_filename = g_strdup (filename);
*(plain_filename + (extension-filename)) = '\0';
}
else
{
plain_filename = g_strconcat (filename, ".txt", NULL);
}
return plain_filename;
}
-static gboolean
+static gpg_error_t
gpa_file_decrypt_operation_start (GpaFileDecryptOperation *op,
gpa_file_item_t file_item)
{
gpg_error_t err;
if (file_item->direct_in)
{
/* No copy is made. */
err = gpgme_data_new_from_mem (&op->cipher, file_item->direct_in,
file_item->direct_in_len, 0);
if (err)
{
gpa_gpgme_warning (err);
- return FALSE;
+ return err;
}
err = gpgme_data_new (&op->plain);
if (err)
{
gpa_gpgme_warning (err);
gpgme_data_release (op->cipher);
op->plain = NULL;
- return FALSE;
+ return err;
}
}
else
{
gchar *cipher_filename = file_item->filename_in;
file_item->filename_out = destination_filename (cipher_filename);
/* Open the files */
op->cipher_fd = gpa_open_input (cipher_filename, &op->cipher,
GPA_OPERATION (op)->window);
if (op->cipher_fd == -1)
- {
- return FALSE;
- }
+ /* FIXME: Error value. */
+ return gpg_error (GPG_ERR_GENERAL);
+
op->plain_fd = gpa_open_output (file_item->filename_out, &op->plain,
GPA_OPERATION (op)->window);
if (op->plain_fd == -1)
{
gpgme_data_release (op->cipher);
close (op->cipher_fd);
- return FALSE;
+ /* FIXME: Error value. */
+ return gpg_error (GPG_ERR_GENERAL);
}
}
- /* Start the operation */
+ /* Start the operation. */
err = gpgme_op_decrypt_start (GPA_OPERATION (op)->context->ctx, op->cipher,
op->plain);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
gpgme_data_release (op->plain);
op->plain = NULL;
close (op->plain_fd);
op->plain_fd = -1;
gpgme_data_release (op->cipher);
op->cipher = NULL;
close (op->cipher_fd);
op->cipher_fd = -1;
- return FALSE;
+ return err;
}
- /* Show and update the progress dialog */
+
+ /* Show and update the progress dialog. */
gtk_widget_show_all (GPA_FILE_OPERATION (op)->progress_dialog);
gpa_progress_dialog_set_label (GPA_PROGRESS_DIALOG
(GPA_FILE_OPERATION (op)->progress_dialog),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
- return TRUE;
+ return 0;
}
+
static void
gpa_file_decrypt_operation_next (GpaFileDecryptOperation *op)
{
- if (!GPA_FILE_OPERATION (op)->current
- || !(gpa_file_decrypt_operation_start
- (op, GPA_FILE_OPERATION (op)->current->data)))
+ gpg_error_t err;
+
+ if (! GPA_FILE_OPERATION (op)->current)
{
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+ return;
}
+
+ err = gpa_file_decrypt_operation_start
+ (op, GPA_FILE_OPERATION (op)->current->data);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
+
static void
gpa_file_decrypt_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileDecryptOperation *op)
{
gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
if (file_item->direct_in)
{
size_t len;
char *plain_gpgme = gpgme_data_release_and_get_mem (op->plain, &len);
op->plain = NULL;
/* Do the memory allocation dance. */
if (plain_gpgme)
{
/* Conveniently make ASCII stuff into a string. */
file_item->direct_out = g_malloc (len + 1);
memcpy (file_item->direct_out, plain_gpgme, len);
gpgme_free (plain_gpgme);
file_item->direct_out[len] = '\0';
/* Yep, excluding the trailing zero. */
file_item->direct_out_len = len;
}
else
{
file_item->direct_out = NULL;
file_item->direct_out_len = 0;
}
}
/* Do clean up on the operation */
gpgme_data_release (op->plain);
op->plain = NULL;
close (op->plain_fd);
op->plain_fd = -1;
gpgme_data_release (op->cipher);
op->cipher = NULL;
close (op->cipher_fd);
op->cipher_fd = -1;
gtk_widget_hide (GPA_FILE_OPERATION (op)->progress_dialog);
- /* Check for error */
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
if (! file_item->direct_in)
{
/* If an error happened, (or the user canceled) delete the
created file and abort further decryptions. */
g_unlink (file_item->filename_out);
g_free (file_item->filename_out);
file_item->filename_out = NULL;
}
/* FIXME:CLIPBOARD: Server finish? */
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
else
{
/* We've just created a file */
g_signal_emit_by_name (GPA_OPERATION (op), "created_file", file_item);
/* Go to the next file in the list and decrypt it */
GPA_FILE_OPERATION (op)->current = g_list_next
(GPA_FILE_OPERATION (op)->current);
gpa_file_decrypt_operation_next (op);
}
}
static gboolean
gpa_file_decrypt_operation_idle_cb (gpointer data)
{
GpaFileDecryptOperation *op = data;
gpa_file_decrypt_operation_next (op);
return FALSE;
}
static void
gpa_file_decrypt_operation_done_error_cb (GpaContext *context, gpg_error_t err,
GpaFileDecryptOperation *op)
{
gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
gchar *message;
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_NO_DATA:
message = g_strdup_printf (file_item->direct_name
? _("\"%s\" contained no OpenPGP data.")
: _("The file \"%s\" contained no OpenPGP"
"data."),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
gpa_window_error (message, GPA_OPERATION (op)->window);
g_free (message);
break;
case GPG_ERR_DECRYPT_FAILED:
message = g_strdup_printf (file_item->direct_name
? _("\"%s\" contained no valid "
"encrypted data.")
: _("The file \"%s\" contained no valid"
"encrypted data."),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
gpa_window_error (message, GPA_OPERATION (op)->window);
g_free (message);
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpafileencryptop.c b/src/gpafileencryptop.c
index d477b83..25db516 100644
--- a/src/gpafileencryptop.c
+++ b/src/gpafileencryptop.c
@@ -1,763 +1,757 @@
/* gpafiledecryptop.c - The GpaOperation object.
* Copyright (C) 2003 Miguel Coca.
* Copyright (C) 2008 g10 Code GmbH.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#include <glib/gstdio.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gtktools.h"
#include "gpgmetools.h"
#include "gpafileencryptop.h"
#include "encryptdlg.h"
#include "gpawidgets.h"
#include "gpapastrings.h"
/* Internal functions */
static void gpa_file_encrypt_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaFileEncryptOperation *op);
static void gpa_file_encrypt_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileEncryptOperation *op);
static void gpa_file_encrypt_operation_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
/* GObject */
static GObjectClass *parent_class = NULL;
/* Properties */
enum
{
PROP_0,
PROP_FORCE_ARMOR
};
static void
gpa_file_encrypt_operation_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GpaFileEncryptOperation *op = GPA_FILE_ENCRYPT_OPERATION (object);
switch (prop_id)
{
case PROP_FORCE_ARMOR:
g_value_set_boolean (value, op->force_armor);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_file_encrypt_operation_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
GpaFileEncryptOperation *op = GPA_FILE_ENCRYPT_OPERATION (object);
switch (prop_id)
{
case PROP_FORCE_ARMOR:
op->force_armor = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_file_encrypt_operation_finalize (GObject *object)
{
GpaFileEncryptOperation *op = GPA_FILE_ENCRYPT_OPERATION (object);
/* FIXME: The use of RSET is messed up. There is no clear concept
on who owns the key. This should be fixed by refing the keys
object. I doubt that the keys are at all released. */
g_free (op->rset);
op->rset = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_file_encrypt_operation_init (GpaFileEncryptOperation *op)
{
op->rset = NULL;
op->cipher_fd = -1;
op->plain_fd = -1;
op->cipher = NULL;
op->plain = NULL;
op->encrypt_dialog = NULL;
op->force_armor = FALSE;
}
static GObject*
gpa_file_encrypt_operation_constructor
(GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaFileEncryptOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_FILE_ENCRYPT_OPERATION (object);
/* Initialize */
/* Create the "Encrypt" dialog */
op->encrypt_dialog = gpa_file_encrypt_dialog_new
(GPA_OPERATION (op)->window, op->force_armor);
g_signal_connect (G_OBJECT (op->encrypt_dialog), "response",
G_CALLBACK (gpa_file_encrypt_operation_response_cb), op);
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_encrypt_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_encrypt_operation_done_cb), op);
/* Give a title to the progress dialog */
gtk_window_set_title (GTK_WINDOW (GPA_FILE_OPERATION (op)->progress_dialog),
_("Encrypting..."));
/* Here we go... */
gtk_widget_show_all (op->encrypt_dialog);
return object;
}
static void
gpa_file_encrypt_operation_class_init (GpaFileEncryptOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_file_encrypt_operation_constructor;
object_class->finalize = gpa_file_encrypt_operation_finalize;
object_class->set_property = gpa_file_encrypt_operation_set_property;
object_class->get_property = gpa_file_encrypt_operation_get_property;
g_object_class_install_property (object_class,
PROP_FORCE_ARMOR,
g_param_spec_boolean
("force-armor", "Force armor",
"Force armor mode", FALSE,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
GType
gpa_file_encrypt_operation_get_type (void)
{
static GType file_encrypt_operation_type = 0;
if (!file_encrypt_operation_type)
{
static const GTypeInfo file_encrypt_operation_info =
{
sizeof (GpaFileEncryptOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_file_encrypt_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaFileEncryptOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_file_encrypt_operation_init,
};
file_encrypt_operation_type = g_type_register_static
(GPA_FILE_OPERATION_TYPE, "GpaFileEncryptOperation",
&file_encrypt_operation_info, 0);
}
return file_encrypt_operation_type;
}
/* API */
GpaFileEncryptOperation*
gpa_file_encrypt_operation_new (GtkWidget *window, GList *files,
gboolean force_armor)
{
GpaFileEncryptOperation *op;
op = g_object_new (GPA_FILE_ENCRYPT_OPERATION_TYPE,
"window", window,
"input_files", files,
"force-armor", force_armor,
NULL);
return op;
}
GpaFileEncryptOperation*
gpa_file_encrypt_operation_new_for_server (GList *files, void *server_ctx)
{
GpaFileEncryptOperation *op;
op = g_object_new (GPA_FILE_ENCRYPT_OPERATION_TYPE,
"input_files", files,
"server-ctx", server_ctx,
NULL);
return op;
}
/* Internal */
static gchar*
destination_filename (const gchar *filename, gboolean armor)
{
const gchar *extension;
gchar *cipher_filename;
if (!armor)
{
extension = ".gpg";
}
else
{
extension = ".asc";
}
cipher_filename = g_strconcat (filename, extension, NULL);
return cipher_filename;
}
-static gboolean
+
+static gpg_error_t
gpa_file_encrypt_operation_start (GpaFileEncryptOperation *op,
gpa_file_item_t file_item)
{
gpg_error_t err;
if (file_item->direct_in)
{
gpgme_error_t err;
/* No copy is made. */
err = gpgme_data_new_from_mem (&op->plain, file_item->direct_in,
file_item->direct_in_len, 0);
if (err)
{
gpa_gpgme_warning (err);
- return FALSE;
+ return err;
}
err = gpgme_data_new (&op->cipher);
if (err)
{
gpa_gpgme_warning (err);
gpgme_data_release (op->plain);
op->plain = NULL;
- return FALSE;
+ return err;
}
}
else
{
gchar *plain_filename = file_item->filename_in;
file_item->filename_out = destination_filename
(plain_filename, gpgme_get_armor (GPA_OPERATION (op)->context->ctx));
/* Open the files */
op->plain_fd = gpa_open_input (plain_filename, &op->plain,
GPA_OPERATION (op)->window);
if (op->plain_fd == -1)
- {
- return FALSE;
- }
+ /* FIXME: Error value. */
+ return gpg_error (GPG_ERR_GENERAL);
+
op->cipher_fd = gpa_open_output (file_item->filename_out, &op->cipher,
GPA_OPERATION (op)->window);
if (op->cipher_fd == -1)
{
gpgme_data_release (op->plain);
close (op->plain_fd);
op->plain_fd = -1;
- return FALSE;
+ /* FIXME: Error value. */
+ return gpg_error (GPG_ERR_GENERAL);
}
}
- /* Start the operation */
- /* Always trust keys, because any untrusted keys were already confirmed
- * by the user.
- */
+ /* Start the operation. */
+ /* Always trust keys, because any untrusted keys were already
+ confirmed by the user. */
if (gpa_file_encrypt_dialog_sign
(GPA_FILE_ENCRYPT_DIALOG (op->encrypt_dialog)))
- {
- err = gpgme_op_encrypt_sign_start (GPA_OPERATION (op)->context->ctx,
- op->rset, GPGME_ENCRYPT_ALWAYS_TRUST,
- op->plain, op->cipher);
- }
+ err = gpgme_op_encrypt_sign_start (GPA_OPERATION (op)->context->ctx,
+ op->rset, GPGME_ENCRYPT_ALWAYS_TRUST,
+ op->plain, op->cipher);
else
- {
- err = gpgme_op_encrypt_start (GPA_OPERATION (op)->context->ctx,
- op->rset, GPGME_ENCRYPT_ALWAYS_TRUST,
- op->plain, op->cipher);
- }
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ err = gpgme_op_encrypt_start (GPA_OPERATION (op)->context->ctx,
+ op->rset, GPGME_ENCRYPT_ALWAYS_TRUST,
+ op->plain, op->cipher);
+
+ if (err)
{
gpa_gpgme_warning (err);
gpgme_data_release (op->plain);
op->plain = NULL;
close (op->plain_fd);
op->plain_fd = -1;
gpgme_data_release (op->cipher);
op->cipher = NULL;
close (op->cipher_fd);
op->cipher_fd = -1;
- return FALSE;
+ return err;
}
- /* Show and update the progress dialog */
+
+ /* Show and update the progress dialog. */
gtk_widget_show_all (GPA_FILE_OPERATION (op)->progress_dialog);
gpa_progress_dialog_set_label (GPA_PROGRESS_DIALOG
(GPA_FILE_OPERATION (op)->progress_dialog),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
- return TRUE;
+ return 0;
}
static void
gpa_file_encrypt_operation_next (GpaFileEncryptOperation *op)
{
- if (!GPA_FILE_OPERATION (op)->current ||
- !gpa_file_encrypt_operation_start (op, GPA_FILE_OPERATION (op)
- ->current->data))
+ gpg_error_t err;
+
+ if (! GPA_FILE_OPERATION (op)->current)
{
- gpa_operation_server_finish (GPA_OPERATION (op), 0);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+ return;
}
+
+ err = gpa_file_encrypt_operation_start
+ (op, GPA_FILE_OPERATION (op)->current->data);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
+
static void
gpa_file_encrypt_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileEncryptOperation *op)
{
gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
if (file_item->direct_in)
{
size_t len;
char *cipher_gpgme = gpgme_data_release_and_get_mem (op->cipher,
&len);
op->cipher = NULL;
/* Do the memory allocation dance. */
if (cipher_gpgme)
{
/* Conveniently make ASCII stuff into a string. */
file_item->direct_out = g_malloc (len + 1);
memcpy (file_item->direct_out, cipher_gpgme, len);
gpgme_free (cipher_gpgme);
file_item->direct_out[len] = '\0';
/* Yep, excluding the trailing zero. */
file_item->direct_out_len = len;
}
else
{
file_item->direct_out = NULL;
file_item->direct_out_len = 0;
}
}
/* Do clean up on the operation */
gpgme_data_release (op->plain);
op->plain = NULL;
close (op->plain_fd);
op->plain_fd = -1;
gpgme_data_release (op->cipher);
op->cipher = NULL;
close (op->cipher_fd);
op->cipher_fd = -1;
gtk_widget_hide (GPA_FILE_OPERATION (op)->progress_dialog);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
if (! file_item->direct_in)
{
/* If an error happened, (or the user canceled) delete the
created file and abort further encryptions. */
g_unlink (file_item->filename_out);
g_free (file_item->filename_out);
file_item->filename_out = NULL;
}
- gpa_operation_server_finish (GPA_OPERATION (op), err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
else
{
/* We've just created a file */
g_signal_emit_by_name (GPA_OPERATION (op), "created_file", file_item);
/* Go to the next file in the list and encrypt it */
GPA_FILE_OPERATION (op)->current = g_list_next
(GPA_FILE_OPERATION (op)->current);
gpa_file_encrypt_operation_next (op);
}
}
/*
* Setting the recipients for the context.
*/
static GtkResponseType
ignore_key_trust (gpgme_key_t key, GtkWidget *parent)
{
GtkWidget *dialog;
GtkWidget *key_info;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *image;
GtkResponseType response;
dialog = gtk_dialog_new_with_buttons (_("Unknown Key"), GTK_WINDOW(parent),
GTK_DIALOG_MODAL,
_("_Yes"), GTK_RESPONSE_YES,
_("_No"), GTK_RESPONSE_NO,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
hbox = gtk_hbox_new (FALSE, 6);
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox);
label = gtk_label_new (_("You are going to encrypt a document using "
"the following key:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
key_info = gpa_key_info_new (key);
gtk_box_pack_start (GTK_BOX (vbox), key_info, FALSE, TRUE, 5);
label = gtk_label_new (_("However, it is not certain that the key belongs "
"to that person."));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
_("Do you <b>really</b> want to use this key?"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
gtk_widget_show_all (dialog);
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return response;
}
static void
revoked_key (gpgme_key_t key, GtkWidget *parent)
{
GtkWidget *dialog;
GtkWidget *key_info;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *image;
dialog = gtk_dialog_new_with_buttons (_("Revoked Key"), GTK_WINDOW(parent),
GTK_DIALOG_MODAL,
_("_Close"), GTK_RESPONSE_CLOSE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
hbox = gtk_hbox_new (FALSE, 6);
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox);
label = gtk_label_new (_("The following key has been revoked by it's owner:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
key_info = gpa_key_info_new (key);
gtk_box_pack_start (GTK_BOX (vbox), key_info, FALSE, TRUE, 5);
label = gtk_label_new (_("And can not be used for encryption."));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
static void
expired_key (gpgme_key_t key, GtkWidget *parent)
{
GtkWidget *dialog;
GtkWidget *key_info;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *image;
gchar *message;
dialog = gtk_dialog_new_with_buttons (_("Revoked Key"), GTK_WINDOW(parent),
GTK_DIALOG_MODAL,
_("_Close"), GTK_RESPONSE_CLOSE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
hbox = gtk_hbox_new (FALSE, 6);
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox);
message = g_strdup_printf (_("The following key expired on %s:"),
gpa_expiry_date_string
(key->subkeys->expires));
label = gtk_label_new (message);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
key_info = gpa_key_info_new (key);
gtk_box_pack_start (GTK_BOX (vbox), key_info, FALSE, TRUE, 5);
label = gtk_label_new (_("And can not be used for encryption."));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 5);
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
static gboolean
set_recipients (GpaFileEncryptOperation *op, GList *recipients)
{
GList *cur;
int i;
gpgme_protocol_t protocol = GPGME_PROTOCOL_UNKNOWN;
g_free (op->rset);
op->rset = g_malloc0 (sizeof(gpgme_key_t)*(g_list_length(recipients)+1));
/* Figure out the the protocol to use. */
for (cur = recipients, i = 0; cur; cur = g_list_next (cur), i++)
{
gpgme_key_t key = cur->data;
if (protocol == GPGME_PROTOCOL_UNKNOWN)
protocol = key->protocol;
else if (key->protocol != protocol)
{
/* Should not happen either because the selection dialog
should have not allowed to select differet keys. */
gpa_window_error
(_("The selected certificates are not all of the same type."
" That is, you mixed OpenPGP and X.509 certificates."
" Please make sure to select only certificates of the"
" same type."),
GPA_OPERATION (op)->window);
return FALSE;
}
}
/* Perform validity checks. */
for (cur = recipients, i = 0; cur; cur = g_list_next (cur), i++)
{
/* Check that all recipients are valid */
gpgme_key_t key = cur->data;
gpgme_validity_t valid;
valid = key->uids->validity;
/* First, make sure the key is usable (not revoked or unusable) */
if (key->revoked)
{
revoked_key (key, GPA_OPERATION (op)->window);
return FALSE;
}
else if (key->expired)
{
expired_key (key, GPA_OPERATION (op)->window);
return FALSE;
}
/* Now, check it's validity. X.509 keys are always considered
valid becuase the backend will chekc this. FIXME: It would
be better to ask the backend to check the validity of the key
instead of letting it fail later. */
else if (valid == GPGME_VALIDITY_FULL
|| valid == GPGME_VALIDITY_ULTIMATE
|| key->protocol == GPGME_PROTOCOL_CMS)
{
op->rset[i] = key;
}
else
{
/* If an untrusted key is found ask the user what to do */
GtkResponseType response;
response = ignore_key_trust (key, GPA_OPERATION (op)->window);
if (response == GTK_RESPONSE_YES)
{
op->rset[i] = key;
}
else
{
/* Abort the encryption */
g_free (op->rset);
op->rset = NULL;
return FALSE;
}
}
}
gpgme_set_protocol (GPA_OPERATION (op)->context->ctx, protocol);
return TRUE;
}
/*
* Setting the signers for the context.
*/
static gboolean
set_signers (GpaFileEncryptOperation *op, GList *signers)
{
GList *cur;
gpg_error_t err;
gpgme_signers_clear (GPA_OPERATION (op)->context->ctx);
if (!signers)
{
/* Can't happen */
gpa_window_error (_("You didn't select any key for signing"),
GPA_OPERATION (op)->window);
return FALSE;
}
for (cur = signers; cur; cur = g_list_next (cur))
{
gpgme_key_t key = cur->data;
err = gpgme_signers_add (GPA_OPERATION (op)->context->ctx, key);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_error (err);
- }
+ if (err)
+ gpa_gpgme_error (err);
}
return TRUE;
}
/*
* The key selection dialog has returned.
*/
static void gpa_file_encrypt_operation_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data)
{
GpaFileEncryptOperation *op = user_data;
gtk_widget_hide (GTK_WIDGET (dialog));
if (response == GTK_RESPONSE_OK)
{
gboolean success = TRUE;
gboolean armor = gpa_file_encrypt_dialog_get_armor
(GPA_FILE_ENCRYPT_DIALOG (op->encrypt_dialog));
GList *signers = gpa_file_encrypt_dialog_signers
(GPA_FILE_ENCRYPT_DIALOG (op->encrypt_dialog));
GList *recipients = gpa_file_encrypt_dialog_recipients
(GPA_FILE_ENCRYPT_DIALOG (op->encrypt_dialog));
/* Set the armor value */
gpgme_set_armor (GPA_OPERATION (op)->context->ctx, armor);
- /* Set the signers for the context */
+ /* Set the signers for the context. */
if (gpa_file_encrypt_dialog_sign
(GPA_FILE_ENCRYPT_DIALOG (op->encrypt_dialog)))
- {
- success = set_signers (op, signers);
- }
- /* Set the recipients for the context */
+ success = set_signers (op, signers);
+
+ /* Set the recipients for the context. */
if (success)
- {
- success = set_recipients (op, recipients);
- }
- /* Actually run the operation or abort */
+ success = set_recipients (op, recipients);
+
+ /* Actually run the operation or abort. */
if (success)
- {
- gpa_file_encrypt_operation_next (op);
- }
+ gpa_file_encrypt_operation_next (op);
else
- {
- gpa_operation_server_finish (GPA_OPERATION (op),
- gpg_error (GPG_ERR_GENERAL));
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_GENERAL));
g_list_free (signers);
g_list_free (recipients);
}
else
{
/* The dialog was canceled, so we do nothing and complete the
- * operation */
- gpa_operation_server_finish (GPA_OPERATION (op),
- gpg_error (GPG_ERR_CANCELED));
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ operation */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_CANCELED));
}
}
static void
gpa_file_encrypt_operation_done_error_cb (GpaContext *context, gpg_error_t err,
GpaFileEncryptOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpafilesignop.c b/src/gpafilesignop.c
index 9d36fe1..028cde3 100644
--- a/src/gpafilesignop.c
+++ b/src/gpafilesignop.c
@@ -1,517 +1,522 @@
/* gpafiledecryptop.c - The GpaOperation object.
* Copyright (C) 2003 Miguel Coca.
* Copyright (C) 2008 g10 Code GmbH.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#include <glib/gstdio.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gtktools.h"
#include "gpgmetools.h"
#include "gpafilesignop.h"
#include "filesigndlg.h"
#include "gpawidgets.h"
#include "gpapastrings.h"
/* Internal functions */
static void gpa_file_sign_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaFileSignOperation *op);
static void gpa_file_sign_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileSignOperation *op);
static void gpa_file_sign_operation_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
/* GObject */
static GObjectClass *parent_class = NULL;
/* Properties */
enum
{
PROP_0,
PROP_FORCE_ARMOR
};
static void
gpa_file_sign_operation_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GpaFileSignOperation *op = GPA_FILE_SIGN_OPERATION (object);
switch (prop_id)
{
case PROP_FORCE_ARMOR:
g_value_set_boolean (value, op->force_armor);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_file_sign_operation_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
GpaFileSignOperation *op = GPA_FILE_SIGN_OPERATION (object);
switch (prop_id)
{
case PROP_FORCE_ARMOR:
op->force_armor = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_file_sign_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_file_sign_operation_init (GpaFileSignOperation *op)
{
op->sign_dialog = NULL;
op->sign_type = GPGME_SIG_MODE_NORMAL;
op->sig_fd = -1;
op->plain_fd = -1;
op->sig = NULL;
op->plain = NULL;
op->sig_filename = NULL;
op->force_armor = FALSE;
}
static GObject*
gpa_file_sign_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaFileSignOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_FILE_SIGN_OPERATION (object);
/* Initialize */
/* Create the "Sign" dialog */
op->sign_dialog = gpa_file_sign_dialog_new (GPA_OPERATION (op)->window,
op->force_armor);
g_signal_connect (G_OBJECT (op->sign_dialog), "response",
G_CALLBACK (gpa_file_sign_operation_response_cb), op);
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_sign_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_sign_operation_done_cb), op);
/* Give a title to the progress dialog */
gtk_window_set_title (GTK_WINDOW (GPA_FILE_OPERATION (op)->progress_dialog),
_("Signing..."));
/* Here we go... */
gtk_widget_show_all (op->sign_dialog);
return object;
}
static void
gpa_file_sign_operation_class_init (GpaFileSignOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_file_sign_operation_constructor;
object_class->finalize = gpa_file_sign_operation_finalize;
object_class->set_property = gpa_file_sign_operation_set_property;
object_class->get_property = gpa_file_sign_operation_get_property;
/* Properties */
g_object_class_install_property (object_class,
PROP_FORCE_ARMOR,
g_param_spec_boolean
("force-armor", "Force armor",
"Force armor mode", FALSE,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
GType
gpa_file_sign_operation_get_type (void)
{
static GType file_sign_operation_type = 0;
if (!file_sign_operation_type)
{
static const GTypeInfo file_sign_operation_info =
{
sizeof (GpaFileSignOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_file_sign_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaFileSignOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_file_sign_operation_init,
};
file_sign_operation_type = g_type_register_static
(GPA_FILE_OPERATION_TYPE, "GpaFileSignOperation",
&file_sign_operation_info, 0);
}
return file_sign_operation_type;
}
/* API */
GpaFileSignOperation*
gpa_file_sign_operation_new (GtkWidget *window, GList *files,
gboolean force_armor)
{
GpaFileSignOperation *op;
op = g_object_new (GPA_FILE_SIGN_OPERATION_TYPE,
"window", window,
"input_files", files,
"force-armor", force_armor,
NULL);
return op;
}
/* Internal */
static gchar*
destination_filename (const gchar *filename, gboolean armor,
gpgme_protocol_t protocol,
gpgme_sig_mode_t sign_type)
{
const gchar *extension;
gchar *signature_filename;
if (protocol == GPGME_PROTOCOL_CMS && armor
&& sign_type != GPGME_SIG_MODE_DETACH)
extension = ".pem";
else if (protocol == GPGME_PROTOCOL_CMS)
extension = ".p7s";
else if (sign_type == GPGME_SIG_MODE_DETACH)
extension = ".sig";
else if (sign_type == GPGME_SIG_MODE_CLEAR)
extension = ".asc";
else
extension = ".gpg";
signature_filename = g_strconcat (filename, extension, NULL);
return signature_filename;
}
-static gboolean
+
+static gpg_error_t
gpa_file_sign_operation_start (GpaFileSignOperation *op,
gpa_file_item_t file_item)
{
gpg_error_t err;
if (file_item->direct_in)
{
gpgme_error_t err;
/* No copy is made. */
err = gpgme_data_new_from_mem (&op->plain, file_item->direct_in,
file_item->direct_in_len, 0);
if (err)
{
gpa_gpgme_warning (err);
- return FALSE;
+ return err;
}
err = gpgme_data_new (&op->sig);
if (err)
{
gpa_gpgme_warning (err);
gpgme_data_release (op->plain);
op->plain = NULL;
- return FALSE;
+ return err;
}
}
else
{
gchar *plain_filename = file_item->filename_in;
file_item->filename_out = destination_filename
(plain_filename, gpgme_get_armor (GPA_OPERATION (op)->context->ctx),
gpgme_get_protocol (GPA_OPERATION (op)->context->ctx), op->sign_type);
/* Open the files */
op->plain_fd = gpa_open_input (plain_filename, &op->plain,
GPA_OPERATION (op)->window);
if (op->plain_fd == -1)
- {
- return FALSE;
- }
+ /* FIXME: Error value. */
+ return gpg_error (GPG_ERR_GENERAL);
+
op->sig_fd = gpa_open_output (file_item->filename_out, &op->sig,
GPA_OPERATION (op)->window);
if (op->sig_fd == -1)
{
gpgme_data_release (op->plain);
close (op->plain_fd);
- return FALSE;
+ /* FIXME: Error value. */
+ return gpg_error (GPG_ERR_GENERAL);
}
}
/* Start the operation */
err = gpgme_op_sign_start (GPA_OPERATION (op)->context->ctx, op->plain,
op->sig, op->sign_type);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
- return FALSE;
+ return err;
}
/* Show and update the progress dialog */
gtk_widget_show_all (GPA_FILE_OPERATION (op)->progress_dialog);
gpa_progress_dialog_set_label (GPA_PROGRESS_DIALOG
(GPA_FILE_OPERATION (op)->progress_dialog),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
- return TRUE;
+ return 0;
}
+
static void
gpa_file_sign_operation_next (GpaFileSignOperation *op)
{
- if (!GPA_FILE_OPERATION (op)->current ||
- !gpa_file_sign_operation_start (op, GPA_FILE_OPERATION (op)
- ->current->data))
+ gpg_error_t err;
+
+ if (! GPA_FILE_OPERATION (op)->current)
{
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+ return;
}
+
+ err = gpa_file_sign_operation_start (op,
+ GPA_FILE_OPERATION (op)->current->data);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
+
static void
gpa_file_sign_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileSignOperation *op)
{
gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
if (file_item->direct_in)
{
size_t len;
char *sig_gpgme = gpgme_data_release_and_get_mem (op->sig, &len);
op->sig = NULL;
/* Do the memory allocation dance. */
if (sig_gpgme)
{
/* Conveniently make ASCII stuff into a string. */
file_item->direct_out = g_malloc (len + 1);
memcpy (file_item->direct_out, sig_gpgme, len);
gpgme_free (sig_gpgme);
file_item->direct_out[len] = '\0';
/* Yep, excluding the trailing zero. */
file_item->direct_out_len = len;
}
else
{
file_item->direct_out = NULL;
file_item->direct_out_len = 0;
}
}
/* Do clean up on the operation */
gpgme_data_release (op->plain);
op->plain = NULL;
close (op->plain_fd);
op->plain_fd = -1;
gpgme_data_release (op->sig);
op->sig = NULL;
close (op->sig_fd);
op->sig_fd = -1;
gtk_widget_hide (GPA_FILE_OPERATION (op)->progress_dialog);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
if (! file_item->direct_in)
{
/* If an error happened, (or the user canceled) delete the
created file and abort further signions. */
g_unlink (op->sig_filename);
g_free (op->sig_filename);
}
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
else
{
/* We've just created a file */
g_signal_emit_by_name (GPA_OPERATION (op), "created_file",
file_item);
/* Go to the next file in the list and sign it */
GPA_FILE_OPERATION (op)->current = g_list_next
(GPA_FILE_OPERATION (op)->current);
gpa_file_sign_operation_next (op);
}
}
/*
* Setting the signers and the protocol for the context. The protocol
* to use is derived from the keys. An errro will be displayed if the
* selected keys are not all of one protocol.
*/
static gboolean
set_signers (GpaFileSignOperation *op, GList *signers)
{
GList *cur;
gpg_error_t err;
gpgme_protocol_t protocol = GPGME_PROTOCOL_UNKNOWN;
gpgme_signers_clear (GPA_OPERATION (op)->context->ctx);
if (!signers)
{
/* Can't happen */
gpa_window_error (_("You didn't select any key for signing"),
GPA_OPERATION (op)->window);
return FALSE;
}
for (cur = signers; cur; cur = g_list_next (cur))
{
gpgme_key_t key = cur->data;
if (protocol == GPGME_PROTOCOL_UNKNOWN)
protocol = key->protocol;
else if (key->protocol != protocol)
{
/* Should not happen because the selection dialog should
have not allowed to select different key types. */
gpa_window_error
(_("The selected certificates are not all of the same type."
" That is, you mixed OpenPGP and X.509 certificates."
" Please make sure to select only certificates of the"
" same type."),
GPA_OPERATION (op)->window);
return FALSE;
}
}
gpgme_set_protocol (GPA_OPERATION (op)->context->ctx, protocol);
for (cur = signers; cur; cur = g_list_next (cur))
{
gpgme_key_t key = cur->data;
err = gpgme_signers_add (GPA_OPERATION (op)->context->ctx, key);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_error (err);
- }
+ if (err)
+ gpa_gpgme_error (err);
}
return TRUE;
}
/*
* The key selection dialog has returned.
*/
static void
gpa_file_sign_operation_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data)
{
GpaFileSignOperation *op = user_data;
gtk_widget_hide (GTK_WIDGET (dialog));
if (response == GTK_RESPONSE_OK)
{
gboolean success = TRUE;
gboolean armor = gpa_file_sign_dialog_get_armor
(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
GList *signers = gpa_file_sign_dialog_signers
(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
op->sign_type = gpa_file_sign_dialog_get_sign_type
(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
/* Set the armor value */
gpgme_set_armor (GPA_OPERATION (op)->context->ctx, armor);
/* Set the signers for the context */
success = set_signers (op, signers);
- /* Actually run the operation or abort */
+ /* Actually run the operation or abort. */
if (success)
- {
- gpa_file_sign_operation_next (op);
- }
+ gpa_file_sign_operation_next (op);
else
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_GENERAL));
g_list_free (signers);
}
else
- {
- /* The dialog was canceled, so we do nothing and complete the
+ /* The dialog was canceled, so we do nothing and complete the
* operation */
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_CANCELED));
}
+
static void
gpa_file_sign_operation_done_error_cb (GpaContext *context, gpg_error_t err,
GpaFileSignOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpafileverifyop.c b/src/gpafileverifyop.c
index d295180..6a26549 100644
--- a/src/gpafileverifyop.c
+++ b/src/gpafileverifyop.c
@@ -1,476 +1,481 @@
/* gpafileverifyop.c - The GpaOperation object.
Copyright (C) 2003 Miguel Coca.
Copyright (C) 2008 g10 Code GmbH.
This file is part of GPA.
GPA 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 3 of the License, or
(at your option) any later version.
GPA 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, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <glib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gtktools.h"
#include "gpgmetools.h"
#include "gpafileverifyop.h"
#include "verifydlg.h"
/* Internal functions */
static gboolean gpa_file_verify_operation_idle_cb (gpointer data);
static void gpa_file_verify_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaFileVerifyOperation *op);
static void gpa_file_verify_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileVerifyOperation *op);
static void gpa_file_verify_operation_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
/* GObject */
static GObjectClass *parent_class = NULL;
static void
gpa_file_verify_operation_finalize (GObject *object)
{
GpaFileVerifyOperation *op = GPA_FILE_VERIFY_OPERATION (object);
gtk_widget_destroy (op->dialog);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_file_verify_operation_init (GpaFileVerifyOperation *op)
{
op->sig_fd = -1;
op->signed_text_fd = -1;
op->sig = NULL;
op->signed_text = NULL;
op->signed_file = NULL;
op->signature_file = NULL;
}
static GObject*
gpa_file_verify_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaFileVerifyOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_FILE_VERIFY_OPERATION (object);
/* Initialize */
/* Start with the first file after going back into the main loop */
g_idle_add (gpa_file_verify_operation_idle_cb, op);
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_verify_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_file_verify_operation_done_cb), op);
/* Give a title to the progress dialog */
gtk_window_set_title (GTK_WINDOW (GPA_FILE_OPERATION (op)->progress_dialog),
_("Verifying..."));
/* Create the verification dialog */
op->dialog = gpa_file_verify_dialog_new (GPA_OPERATION (op)->window);
g_signal_connect (G_OBJECT (op->dialog), "response",
G_CALLBACK (gpa_file_verify_operation_response_cb), op);
return object;
}
static void
gpa_file_verify_operation_class_init (GpaFileVerifyOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_file_verify_operation_constructor;
object_class->finalize = gpa_file_verify_operation_finalize;
}
GType
gpa_file_verify_operation_get_type (void)
{
static GType file_verify_operation_type = 0;
if (!file_verify_operation_type)
{
static const GTypeInfo file_verify_operation_info =
{
sizeof (GpaFileVerifyOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_file_verify_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaFileVerifyOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_file_verify_operation_init,
};
file_verify_operation_type = g_type_register_static
(GPA_FILE_OPERATION_TYPE, "GpaFileVerifyOperation",
&file_verify_operation_info, 0);
}
return file_verify_operation_type;
}
/* API */
GpaFileVerifyOperation*
gpa_file_verify_operation_new (GtkWidget *window, GList *files)
{
GpaFileVerifyOperation *op;
op = g_object_new (GPA_FILE_VERIFY_OPERATION_TYPE,
"window", window,
"input_files", files,
NULL);
return op;
}
/* Internal */
static gboolean
ask_use_detached_sig (const gchar *file, const gchar *sig, GtkWidget *parent)
{
GtkWidget *dialog = gtk_message_dialog_new
(GTK_WINDOW(parent), GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
_("GPA found a file that could be a signature of %s. "
"Would you like to verify it instead?\n\n"
"The file found is: %s"), file, sig);
gboolean result;
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
_("_Yes"), GTK_RESPONSE_YES,
_("_No"), GTK_RESPONSE_NO, NULL);
result = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES);
gtk_widget_destroy (dialog);
return result;
}
/* Check whether the file is a detached signature and deduce the name of the
* original file. Since we only have access to the filename, this is not
* very solid.
*/
static gboolean
is_detached_sig (const gchar *filename, gchar **signature_file,
gchar **signed_file, GtkWidget *window)
{
const gchar *sig_extension[] = {".sig", ".sign"};
int i;
gchar *extension;
/* First, check whether this file is a dettached signature */
*signed_file = g_strdup (filename);
extension = g_strrstr (*signed_file, ".");
if (extension &&
(g_str_equal (extension, ".sig") ||
g_str_equal (extension, ".sign")))
{
*extension++ = '\0';
*signature_file = g_strdup (filename);
return TRUE;
}
/* Now, check whether a dettached signature exists for this file */
else
{
g_free (*signed_file);
*signed_file = NULL;
for (i = 0; i < sizeof(sig_extension)/sizeof(sig_extension[0]); i++)
{
gchar *sig = g_strconcat (filename, sig_extension[i], NULL);
if (g_file_test (sig, G_FILE_TEST_EXISTS) &&
ask_use_detached_sig (filename, sig, window))
{
*signed_file = g_strdup (filename);
*signature_file = sig;
return TRUE;
}
else
{
g_free (sig);
}
}
return FALSE;
}
}
static gboolean
gpa_file_verify_operation_start (GpaFileVerifyOperation *op,
gpa_file_item_t file_item)
{
gpgme_error_t err;
if (file_item->direct_in)
{
/* Direct input is always an inline signature. */
/* No copy is made. */
err = gpgme_data_new_from_mem (&op->sig, file_item->direct_in,
file_item->direct_in_len, 0);
if (err)
{
gpa_gpgme_warning (err);
return FALSE;
}
err = gpgme_data_new (&op->plain);
if (err)
{
gpa_gpgme_warning (err);
gpgme_data_release (op->sig);
op->sig = NULL;
return FALSE;
}
}
else
{
const gchar *sig_filename = file_item->filename_in;
if (is_detached_sig (sig_filename, &op->signature_file, &op->signed_file,
GPA_OPERATION (op)->window))
{
/* Allocate data objects for a detached signature */
op->sig_fd = gpa_open_input (op->signature_file, &op->sig,
GPA_OPERATION (op)->window);
if (op->sig_fd == -1)
{
return FALSE;
}
op->signed_text_fd = gpa_open_input (op->signed_file, &op->signed_text,
GPA_OPERATION (op)->window);
if (op->signed_text_fd == -1)
{
gpgme_data_release (op->sig);
close (op->sig_fd);
return FALSE;
}
op->plain = NULL;
}
else
{
/* Allocate data object for non-detached signatures */
op->sig_fd = gpa_open_input (sig_filename, &op->sig,
GPA_OPERATION (op)->window);
if (op->sig_fd == -1)
{
return FALSE;
}
err = gpgme_data_new (&op->plain);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpgme_data_release (op->sig);
close (op->sig_fd);
return FALSE;
}
op->signed_text_fd = -1;
op->signed_text = NULL;
}
}
/* Start the operation */
err = gpgme_op_verify_start (GPA_OPERATION (op)->context->ctx, op->sig,
op->signed_text, op->plain);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
return FALSE;
}
/* Show and update the progress dialog */
gtk_widget_show_all (GPA_FILE_OPERATION (op)->progress_dialog);
gpa_progress_dialog_set_label (GPA_PROGRESS_DIALOG
(GPA_FILE_OPERATION (op)->progress_dialog),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
return TRUE;
}
+
static void
gpa_file_verify_operation_next (GpaFileVerifyOperation *op)
{
- if (!GPA_FILE_OPERATION (op)->current ||
- !gpa_file_verify_operation_start (op, GPA_FILE_OPERATION (op)
+ if (! GPA_FILE_OPERATION (op)->current ||
+ ! gpa_file_verify_operation_start (op, GPA_FILE_OPERATION (op)
->current->data))
{
/* All files have been verified: show the results dialog */
gtk_widget_show_all (op->dialog);
}
}
+
static void
gpa_file_verify_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaFileVerifyOperation *op)
{
gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
if (file_item->direct_in)
{
size_t len;
char *plain_gpgme = gpgme_data_release_and_get_mem (op->plain,
&len);
op->plain = NULL;
/* Do the memory allocation dance. */
if (plain_gpgme)
{
/* Conveniently make ASCII stuff into a string. */
file_item->direct_out = g_malloc (len + 1);
memcpy (file_item->direct_out, plain_gpgme, len);
gpgme_free (plain_gpgme);
file_item->direct_out[len] = '\0';
/* Yep, excluding the trailing zero. */
file_item->direct_out_len = len;
}
else
{
file_item->direct_out = NULL;
file_item->direct_out_len = 0;
}
}
/* Do clean up on the operation */
gpgme_data_release (op->plain);
op->plain = NULL;
gpgme_data_release (op->signed_text);
op->signed_text = NULL;
close (op->signed_text_fd);
op->signed_text_fd = -1;
gpgme_data_release (op->sig);
op->sig = NULL;
close (op->sig_fd);
op->sig_fd = -1;
gtk_widget_hide (GPA_FILE_OPERATION (op)->progress_dialog);
/* Check for error */
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
/* Abort further verifications */
}
else
{
gpgme_verify_result_t result;
result = gpgme_op_verify_result (GPA_OPERATION (op)->context->ctx);
/* Add the file to the result dialog. FIXME: Maybe we should
use the filename without the directory. */
gpa_file_verify_dialog_add_file (GPA_FILE_VERIFY_DIALOG (op->dialog),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in,
op->signed_file, op->signature_file,
result->signatures);
/* If this was a dettached sig, reset the signed file */
if (op->signed_file)
{
g_free (op->signed_file);
op->signed_file = NULL;
g_free (op->signature_file);
op->signature_file = NULL;
}
else
{
/* Otherwise, we created a "file" in direct mode. */
if (file_item->direct_in)
g_signal_emit_by_name (GPA_OPERATION (op), "created_file",
file_item);
}
/* Go to the next file in the list and verify it */
GPA_FILE_OPERATION (op)->current = g_list_next
(GPA_FILE_OPERATION (op)->current);
gpa_file_verify_operation_next (op);
}
}
static gboolean
gpa_file_verify_operation_idle_cb (gpointer data)
{
GpaFileVerifyOperation *op = data;
gpa_file_verify_operation_next (op);
return FALSE;
}
static void
gpa_file_verify_operation_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data)
{
GpaFileVerifyOperation *op = GPA_FILE_VERIFY_OPERATION (user_data);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+
+ /* FIXME: Error handling. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
}
+
static void
gpa_file_verify_operation_done_error_cb (GpaContext *context, gpg_error_t err,
GpaFileVerifyOperation *op)
{
gpa_file_item_t file_item = GPA_FILE_OPERATION (op)->current->data;
gchar *message;
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_NO_DATA:
message = g_strdup_printf (file_item->direct_name
? _("\"%s\" contained no OpenPGP data.")
: _("The file \"%s\" contained no OpenPGP"
"data."),
file_item->direct_name
? file_item->direct_name
: file_item->filename_in);
gpa_window_error (message, GPA_OPERATION (op)->window);
g_free (message);
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpagenkeyadvop.c b/src/gpagenkeyadvop.c
index 4489159..1353af3 100644
--- a/src/gpagenkeyadvop.c
+++ b/src/gpagenkeyadvop.c
@@ -1,205 +1,200 @@
/* gpagenkeyadvop.c - The GpaGenKeyAdvancedOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpagenkeyadvop.h"
#include "keygendlg.h"
static GObjectClass *parent_class = NULL;
static void gpa_gen_key_advanced_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeyAdvancedOperation *op);
static void gpa_gen_key_advanced_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeyAdvancedOperation *op);
static gboolean
gpa_gen_key_advanced_operation_idle_cb (gpointer data);
/* GObject boilerplate */
static void
gpa_gen_key_advanced_operation_init (GpaGenKeyAdvancedOperation *op)
{
op->progress_dialog = NULL;
}
static void
gpa_gen_key_advanced_operation_finalize (GObject *object)
{
GpaGenKeyAdvancedOperation *op = GPA_GEN_KEY_ADVANCED_OPERATION (object);
gtk_widget_destroy (op->progress_dialog);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GObject*
gpa_gen_key_advanced_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *
construct_properties)
{
GObject *object;
GpaGenKeyAdvancedOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_GEN_KEY_ADVANCED_OPERATION (object);
/* Create progress dialog */
op->progress_dialog = gpa_progress_dialog_new (GPA_OPERATION (op)->window,
GPA_OPERATION (op)->context);
gpa_progress_dialog_set_label (GPA_PROGRESS_DIALOG (op->progress_dialog),
_("Generating Key..."));
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_gen_key_advanced_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_gen_key_advanced_operation_done_cb), op);
/* Begin working when we are back into the main loop */
g_idle_add (gpa_gen_key_advanced_operation_idle_cb, op);
return object;
}
static void
gpa_gen_key_advanced_operation_class_init (GpaGenKeyAdvancedOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_gen_key_advanced_operation_constructor;
object_class->finalize = gpa_gen_key_advanced_operation_finalize;
}
GType
gpa_gen_key_advanced_operation_get_type (void)
{
static GType operation_type = 0;
if (!operation_type)
{
static const GTypeInfo operation_info =
{
sizeof (GpaGenKeyAdvancedOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_gen_key_advanced_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaGenKeyAdvancedOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_gen_key_advanced_operation_init,
};
operation_type = g_type_register_static (GPA_GEN_KEY_OPERATION_TYPE,
"GpaGenKeyAdvancedOperation",
&operation_info, 0);
}
return operation_type;
}
/* API */
GpaGenKeyAdvancedOperation*
gpa_gen_key_advanced_operation_new (GtkWidget *window)
{
GpaGenKeyAdvancedOperation *op;
op = g_object_new (GPA_GEN_KEY_ADVANCED_OPERATION_TYPE,
"window", window, NULL);
return op;
}
/* Internal */
static gboolean
gpa_gen_key_advanced_operation_idle_cb (gpointer data)
{
GpaGenKeyAdvancedOperation *op = data;
+ gpg_error_t err;
GPAKeyGenParameters *parms;
- if ((parms = gpa_key_gen_run_dialog (GPA_OPERATION (op)->window)))
+ if (! (parms = gpa_key_gen_run_dialog (GPA_OPERATION (op)->window)))
+ g_signal_emit_by_name (op, "completed", gpg_error (GPG_ERR_CANCELED));
+
+ err = gpa_generate_key_start (GPA_OPERATION (op)->context->ctx, parms);
+ if (err)
{
- gpg_error_t err;
-
- err = gpa_generate_key_start (GPA_OPERATION (op)->context->ctx, parms);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_warning (err);
- g_signal_emit_by_name (op, "completed");
- }
- else
- {
- gtk_widget_show_all (op->progress_dialog);
- }
+ gpa_gpgme_warning (err);
+ g_signal_emit_by_name (op, "completed", err);
}
else
- {
- g_signal_emit_by_name (op, "completed");
- }
+ gtk_widget_show_all (op->progress_dialog);
return FALSE;
}
+
static void
gpa_gen_key_advanced_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeyAdvancedOperation *op)
{
- if (gpg_err_code (err) == GPG_ERR_NO_ERROR)
+ if (! err)
{
gpgme_genkey_result_t result = gpgme_op_genkey_result (context->ctx);
g_signal_emit_by_name (op, "generated_key", result->fpr);
}
- g_signal_emit_by_name (op, "completed");
+ g_signal_emit_by_name (op, "completed", err);
}
+
static void
gpa_gen_key_advanced_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeyAdvancedOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpagenkeysimpleop.c b/src/gpagenkeysimpleop.c
index f10795d..0bc6b23 100644
--- a/src/gpagenkeysimpleop.c
+++ b/src/gpagenkeysimpleop.c
@@ -1,225 +1,223 @@
/* gpagenkeysimpleop.c - The GpaGenKeySimpleOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpagenkeysimpleop.h"
#include "gpabackupop.h"
#include "keygenwizard.h"
static GObjectClass *parent_class = NULL;
static void gpa_gen_key_simple_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeySimpleOperation *op);
static void gpa_gen_key_simple_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeySimpleOperation *op);
static gboolean
gpa_gen_key_simple_operation_generate (GPAKeyGenParameters *params,
gboolean do_backup, gpointer data);
/* GObject boilerplate */
static void
gpa_gen_key_simple_operation_init (GpaGenKeySimpleOperation *op)
{
op->wizard = NULL;
op->do_backup = FALSE;
}
static void
gpa_gen_key_simple_operation_finalize (GObject *object)
{
GpaGenKeySimpleOperation *op = GPA_GEN_KEY_SIMPLE_OPERATION (object);
gtk_widget_destroy (op->wizard);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GObject*
gpa_gen_key_simple_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *
construct_properties)
{
GObject *object;
GpaGenKeySimpleOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_GEN_KEY_SIMPLE_OPERATION (object);
/* Create progress dialog */
op->wizard = gpa_keygen_wizard_new (GPA_OPERATION (op)->window,
gpa_gen_key_simple_operation_generate,
op);
gtk_widget_show_all (op->wizard);
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_gen_key_simple_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_gen_key_simple_operation_done_cb), op);
return object;
}
static void
gpa_gen_key_simple_operation_class_init (GpaGenKeySimpleOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_gen_key_simple_operation_constructor;
object_class->finalize = gpa_gen_key_simple_operation_finalize;
}
GType
gpa_gen_key_simple_operation_get_type (void)
{
static GType operation_type = 0;
if (!operation_type)
{
static const GTypeInfo operation_info =
{
sizeof (GpaGenKeySimpleOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_gen_key_simple_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaGenKeySimpleOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_gen_key_simple_operation_init,
};
operation_type = g_type_register_static (GPA_GEN_KEY_OPERATION_TYPE,
"GpaGenKeySimpleOperation",
&operation_info, 0);
}
return operation_type;
}
/* API */
GpaGenKeySimpleOperation*
gpa_gen_key_simple_operation_new (GtkWidget *window)
{
GpaGenKeySimpleOperation *op;
op = g_object_new (GPA_GEN_KEY_SIMPLE_OPERATION_TYPE,
"window", window, NULL);
return op;
}
/* Internal */
static gboolean
gpa_gen_key_simple_operation_generate (GPAKeyGenParameters *params,
gboolean do_backup, gpointer data)
{
GpaGenKeySimpleOperation *op = data;
gpg_error_t err;
op->do_backup = do_backup;
err = gpa_generate_key_start (GPA_OPERATION (op)->context->ctx, params);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
- g_signal_emit_by_name (op, "completed");
+ g_signal_emit_by_name (op, "completed", err);
return FALSE;
}
return TRUE;
}
static void
gpa_gen_key_simple_operation_backup_complete (GpaBackupOperation *backup,
GpaGenKeySimpleOperation *op)
{
gpgme_genkey_result_t result = gpgme_op_genkey_result
(GPA_OPERATION (op)->context->ctx);
g_signal_emit_by_name (op, "generated_key", result->fpr);
g_object_unref (backup);
- g_signal_emit_by_name (op, "completed");
+ g_signal_emit_by_name (op, "completed", 0);
}
static void
gpa_gen_key_simple_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeySimpleOperation *op)
{
- if (gpg_err_code (err) == GPG_ERR_NO_ERROR)
+ if (! err)
{
gpgme_genkey_result_t result = gpgme_op_genkey_result (context->ctx);
if (op->do_backup)
{
GpaBackupOperation *backup = gpa_backup_operation_new_from_fpr
(op->wizard, result->fpr);
g_signal_connect (backup, "completed", G_CALLBACK
(gpa_gen_key_simple_operation_backup_complete),
op);
}
else
{
g_signal_emit_by_name (op, "generated_key", result->fpr);
- g_signal_emit_by_name (op, "completed");
+ g_signal_emit_by_name (op, "completed", err);
}
}
else
- {
- g_signal_emit_by_name (op, "completed");
- }
+ g_signal_emit_by_name (op, "completed", err);
}
static void
gpa_gen_key_simple_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaGenKeySimpleOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpaimportclipop.c b/src/gpaimportclipop.c
index 0d0108d..2e1eb59 100644
--- a/src/gpaimportclipop.c
+++ b/src/gpaimportclipop.c
@@ -1,132 +1,132 @@
/* gpaimportclipop.c - The GpaImportClipboardOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include <unistd.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpaimportclipop.h"
static GObjectClass *parent_class = NULL;
static gboolean
gpa_import_clipboard_operation_get_source (GpaImportOperation *operation,
gpgme_data_t *source);
static void
gpa_import_clipboard_operation_complete_import (GpaImportOperation *operation);
/* GObject boilerplate */
static void
gpa_import_clipboard_operation_init (GpaImportClipboardOperation *op)
{
}
static void
gpa_import_clipboard_operation_class_init (GpaImportClipboardOperationClass *klass)
{
GpaImportOperationClass *import_class = GPA_IMPORT_OPERATION_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
import_class->get_source = gpa_import_clipboard_operation_get_source;
import_class->complete_import = gpa_import_clipboard_operation_complete_import;
}
GType
gpa_import_clipboard_operation_get_type (void)
{
static GType clipboard_operation_type = 0;
if (!clipboard_operation_type)
{
static const GTypeInfo clipboard_operation_info =
{
sizeof (GpaImportClipboardOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_import_clipboard_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaImportClipboardOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_import_clipboard_operation_init,
};
clipboard_operation_type = g_type_register_static (GPA_IMPORT_OPERATION_TYPE,
"GpaImportClipboardOperation",
&clipboard_operation_info, 0);
}
return clipboard_operation_type;
}
/* Virtual methods */
static gboolean
gpa_import_clipboard_operation_get_source (GpaImportOperation *operation,
gpgme_data_t *source)
{
gpg_error_t err;
gchar *text = gtk_clipboard_wait_for_text (gtk_clipboard_get
(GDK_SELECTION_CLIPBOARD));
if (text)
{
/* Fill the data from the selection clipboard.
*/
err = gpgme_data_new_from_mem (source, text, strlen (text), FALSE);
}
else
{
/* If the keyboard was empty, create an empty data
*/
err = gpgme_data_new (source);
}
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
return FALSE;
}
return TRUE;
}
static void
gpa_import_clipboard_operation_complete_import (GpaImportOperation *operation)
{
/* Nothing special to do */
}
/* API */
GpaImportClipboardOperation*
gpa_import_clipboard_operation_new (GtkWidget *window)
{
GpaImportClipboardOperation *op;
op = g_object_new (GPA_IMPORT_CLIPBOARD_OPERATION_TYPE,
"window", window, NULL);
return op;
}
diff --git a/src/gpaimportop.c b/src/gpaimportop.c
index 86afefb..81ed769 100644
--- a/src/gpaimportop.c
+++ b/src/gpaimportop.c
@@ -1,260 +1,261 @@
/* gpaimportop.c - The GpaImportOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <gpgme.h>
#include "gpa.h"
#include "i18n.h"
#include "gtktools.h"
#include "gpaimportop.h"
static GObjectClass *parent_class = NULL;
/* Signals */
enum
{
IMPORTED_KEYS,
IMPORTED_SECRET_KEYS,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0 };
static gboolean gpa_import_operation_idle_cb (gpointer data);
static void gpa_import_operation_done_cb (GpaContext *context, gpg_error_t err,
GpaImportOperation *op);
static void gpa_import_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaImportOperation *op);
/* GObject boilerplate */
static void
gpa_import_operation_finalize (GObject *object)
{
GpaImportOperation *op = GPA_IMPORT_OPERATION (object);
/* Free the data object, if it exists */
if (op->source)
{
gpgme_data_release (op->source);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_import_operation_init (GpaImportOperation *op)
{
op->source = NULL;
}
static GObject*
gpa_import_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaImportOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_IMPORT_OPERATION (object);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_import_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_import_operation_done_cb), op);
/* Begin working when we are back into the main loop */
g_idle_add (gpa_import_operation_idle_cb, op);
return object;
}
static void
gpa_import_operation_class_init (GpaImportOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_import_operation_constructor;
object_class->finalize = gpa_import_operation_finalize;
/* Virtual methods */
klass->get_source = NULL;
klass->complete_import = NULL;
/* Signals */
klass->imported_keys = NULL;
signals[IMPORTED_KEYS] =
g_signal_new ("imported_keys",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaImportOperationClass, imported_keys),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[IMPORTED_SECRET_KEYS] =
g_signal_new ("imported_secret_keys",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaImportOperationClass, imported_keys),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
GType
gpa_import_operation_get_type (void)
{
static GType file_operation_type = 0;
if (!file_operation_type)
{
static const GTypeInfo file_operation_info =
{
sizeof (GpaImportOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_import_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaImportOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_import_operation_init,
};
file_operation_type = g_type_register_static (GPA_OPERATION_TYPE,
"GpaImportOperation",
&file_operation_info, 0);
}
return file_operation_type;
}
/* Private functions */
static gboolean
gpa_import_operation_idle_cb (gpointer data)
{
GpaImportOperation *op = data;
if (GPA_IMPORT_OPERATION_GET_CLASS (op)->get_source (op, &op->source))
{
gpg_error_t err;
err = gpgme_op_import_start (GPA_OPERATION (op)->context->ctx,
op->source);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
}
else
- {
- /* Abort the operation */
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ /* Abort the operation. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_CANCELED));
return FALSE;
}
static void
key_import_results_dialog_run (GtkWidget *parent,
gpgme_import_result_t info)
{
GtkWidget *dialog;
if (info->considered == 0)
{
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_CLOSE,
_("No keys were found."));
}
else
{
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
_("%i public keys read\n"
"%i public keys imported\n"
"%i public keys unchanged\n"
"%i secret keys read\n"
"%i secret keys imported\n"
"%i secret keys unchanged"),
info->considered, info->imported,
info->unchanged, info->secret_read,
info->secret_imported,
info->secret_unchanged);
}
/* Run the dialog */
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+
static void
gpa_import_operation_done_cb (GpaContext *context, gpg_error_t err,
GpaImportOperation *op)
{
- if (gpg_err_code (err) == GPG_ERR_NO_ERROR)
+ if (! err)
{
gpgme_import_result_t res;
GPA_IMPORT_OPERATION_GET_CLASS (op)->complete_import (op);
res = gpgme_op_import_result (GPA_OPERATION (op)->context->ctx);
if (res->imported > 0 && res->secret_imported )
{
g_signal_emit_by_name (GPA_OPERATION (op), "imported_secret_keys");
}
else if (res->imported > 0)
{
g_signal_emit_by_name (GPA_OPERATION (op), "imported_keys");
}
key_import_results_dialog_run (GPA_OPERATION (op)->window, res);
}
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
+
static void
gpa_import_operation_done_error_cb (GpaContext *context, gpg_error_t err,
GpaImportOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
/* Ignore these */
break;
default:
gpa_gpgme_warning (err);
break;
}
}
diff --git a/src/gpakeydeleteop.c b/src/gpakeydeleteop.c
index fac2903..860948f 100644
--- a/src/gpakeydeleteop.c
+++ b/src/gpakeydeleteop.c
@@ -1,214 +1,219 @@
/* gpakeydeleteop.c - The GpaKeyDeleteOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gpakeydeleteop.h"
/* Internal functions */
static gboolean gpa_key_delete_operation_idle_cb (gpointer data);
static void gpa_key_delete_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyDeleteOperation *op);
static void gpa_key_delete_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyDeleteOperation *op);
/* GObject */
static GObjectClass *parent_class = NULL;
static void
gpa_key_delete_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_key_delete_operation_init (GpaKeyDeleteOperation *op)
{
}
static GObject*
gpa_key_delete_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaKeyDeleteOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_KEY_DELETE_OPERATION (object);
/* Initialize */
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_delete_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_delete_operation_done_cb), op);
/* Start with the first key after going back into the main loop */
g_idle_add (gpa_key_delete_operation_idle_cb, op);
return object;
}
static void
gpa_key_delete_operation_class_init (GpaKeyDeleteOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_key_delete_operation_constructor;
object_class->finalize = gpa_key_delete_operation_finalize;
}
GType
gpa_key_delete_operation_get_type (void)
{
static GType key_delete_operation_type = 0;
if (!key_delete_operation_type)
{
static const GTypeInfo key_delete_operation_info =
{
sizeof (GpaKeyDeleteOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_key_delete_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaKeyDeleteOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_key_delete_operation_init,
};
key_delete_operation_type = g_type_register_static
(GPA_KEY_OPERATION_TYPE, "GpaKeyDeleteOperation",
&key_delete_operation_info, 0);
}
return key_delete_operation_type;
}
/* API */
/* Creates a new key deletion operation.
*/
GpaKeyDeleteOperation*
gpa_key_delete_operation_new (GtkWidget *window, GList *keys)
{
GpaKeyDeleteOperation *op;
op = g_object_new (GPA_KEY_DELETE_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
/* Internal */
-static gboolean
+static gpg_error_t
gpa_key_delete_operation_start (GpaKeyDeleteOperation *op)
{
- gpgme_key_t key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+ gpg_error_t err;
+ gpgme_key_t key;
- if (gpa_delete_dialog_run (GPA_OPERATION (op)->window, key))
- {
- gpg_error_t err;
- err = gpgme_op_delete_start (GPA_OPERATION(op)->context->ctx, key, TRUE);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_warning (err);
- return FALSE;
- }
- }
- else
+ key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+
+ if (! gpa_delete_dialog_run (GPA_OPERATION (op)->window, key))
+ return gpg_error (GPG_ERR_CANCELED);
+
+ err = gpgme_op_delete_start (GPA_OPERATION(op)->context->ctx, key, TRUE);
+ if (err)
{
- return FALSE;
+ gpa_gpgme_warning (err);
+ return err;
}
- return TRUE;
+
+ return 0;
}
static gboolean
gpa_key_delete_operation_idle_cb (gpointer data)
{
+ gpg_error_t err;
GpaKeyDeleteOperation *op = data;
- if (!gpa_key_delete_operation_start (op))
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ err = gpa_key_delete_operation_start (op);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
return FALSE;
}
+
static void
gpa_key_delete_operation_next (GpaKeyDeleteOperation *op)
{
- if (!GPA_KEY_OPERATION (op)->current ||
- !gpa_key_delete_operation_start (op))
+ gpg_error_t err;
+
+ if (! GPA_KEY_OPERATION (op)->current)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+
+ err = gpa_key_delete_operation_start (op);
+ if (err)
{
g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
}
static void gpa_key_delete_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyDeleteOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
default:
gpa_gpgme_warning (err);
break;
}
}
static void gpa_key_delete_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyDeleteOperation *op)
{
GPA_KEY_OPERATION (op)->current = g_list_next
(GPA_KEY_OPERATION (op)->current);
gpa_key_delete_operation_next (op);
}
diff --git a/src/gpakeyexpireop.c b/src/gpakeyexpireop.c
index 6360189..51c1723 100644
--- a/src/gpakeyexpireop.c
+++ b/src/gpakeyexpireop.c
@@ -1,270 +1,272 @@
/* gpakeyexpireop.c - The GpaKeyExpireOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gpakeyexpireop.h"
#include "expirydlg.h"
#include "gpgmeedit.h"
#include "gtktools.h"
/* Internal functions */
static gboolean gpa_key_expire_operation_idle_cb (gpointer data);
static void gpa_key_expire_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyExpireOperation *op);
static void gpa_key_expire_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyExpireOperation *op);
/* GObject */
/* Signals */
enum
{
NEW_EXPIRATION,
LAST_SIGNAL
};
static guint signals [LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
static void
gpa_key_expire_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_key_expire_operation_init (GpaKeyExpireOperation *op)
{
op->modified_keys = 0;
}
static GObject*
gpa_key_expire_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaKeyExpireOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_KEY_EXPIRE_OPERATION (object);
/* Initialize */
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_expire_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_expire_operation_done_cb), op);
/* Start with the first key after going back into the main loop */
g_idle_add (gpa_key_expire_operation_idle_cb, op);
return object;
}
static void
gpa_key_expire_operation_class_init (GpaKeyExpireOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_key_expire_operation_constructor;
object_class->finalize = gpa_key_expire_operation_finalize;
/* Signals */
signals[NEW_EXPIRATION] =
g_signal_new ("new_expiration",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GpaKeyExpireOperationClass, new_expiration),
NULL, NULL,
gtk_marshal_VOID__POINTER_POINTER,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
}
GType
gpa_key_expire_operation_get_type (void)
{
static GType key_expire_operation_type = 0;
if (!key_expire_operation_type)
{
static const GTypeInfo key_expire_operation_info =
{
sizeof (GpaKeyExpireOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_key_expire_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaKeyExpireOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_key_expire_operation_init,
};
key_expire_operation_type = g_type_register_static
(GPA_KEY_OPERATION_TYPE, "GpaKeyExpireOperation",
&key_expire_operation_info, 0);
}
return key_expire_operation_type;
}
/* API */
/* Creates a new key deletion operation.
*/
GpaKeyExpireOperation*
gpa_key_expire_operation_new (GtkWidget *window, GList *keys)
{
GpaKeyExpireOperation *op;
op = g_object_new (GPA_KEY_EXPIRE_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
/* Internal */
-static gboolean
+static gpg_error_t
gpa_key_expire_operation_start (GpaKeyExpireOperation *op)
{
- gpgme_key_t key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+ gpg_error_t err;
+ gpgme_key_t key;
GDate *date;
- if (gpa_expiry_dialog_run (GPA_OPERATION (op)->window, key, &date))
- {
- gpg_error_t err;
- err = gpa_gpgme_edit_expire_start (GPA_OPERATION(op)->context, key,
- date);
- op->date = date;
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_warning (err);
- return FALSE;
- }
- }
- else
+ key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+
+ if (! gpa_expiry_dialog_run (GPA_OPERATION (op)->window, key, &date))
+ return gpg_error (GPG_ERR_CANCELED);
+
+ err = gpa_gpgme_edit_expire_start (GPA_OPERATION(op)->context, key, date);
+ op->date = date;
+ if (err)
{
- return FALSE;
+ gpa_gpgme_warning (err);
+ return err;
}
- return TRUE;
+
+ return 0;
}
+
static gboolean
gpa_key_expire_operation_idle_cb (gpointer data)
{
GpaKeyExpireOperation *op = data;
+ gpg_error_t err;
- if (!gpa_key_expire_operation_start (op))
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ err = gpa_key_expire_operation_start (op);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
return FALSE;
}
+
static void
gpa_key_expire_operation_next (GpaKeyExpireOperation *op)
{
- if (!GPA_KEY_OPERATION (op)->current ||
- !gpa_key_expire_operation_start (op))
+ gpg_error_t err;
+
+ if (! GPA_KEY_OPERATION (op)->current)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+
+ err = gpa_key_expire_operation_start (op);
+ if (err)
{
if (op->modified_keys > 0)
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
- }
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
}
static void
gpa_key_expire_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyExpireOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
op->modified_keys++;
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
case GPG_ERR_INV_TIME:
gpa_window_error
(_("Invalid time given.\n"
"(you may not set the expiration time to the past.)"),
GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
static void
gpa_key_expire_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyExpireOperation *op)
{
- if (gpg_err_code (err) == GPG_ERR_NO_ERROR)
- {
- /* The expiration was changed */
- g_signal_emit_by_name (op, "new_expiration",
- GPA_KEY_OPERATION (op)->current->data, op->date);
- }
- /* Clean previous date */
+ if (! err)
+ /* The expiration was changed. */
+ g_signal_emit_by_name (op, "new_expiration",
+ GPA_KEY_OPERATION (op)->current->data, op->date);
+
+ /* Clean previous date. */
if (op->date)
{
g_date_free (op->date);
op->date = NULL;
}
- /* Go to the next key */
+ /* Go to the next key. */
GPA_KEY_OPERATION (op)->current = g_list_next
(GPA_KEY_OPERATION (op)->current);
gpa_key_expire_operation_next (op);
}
diff --git a/src/gpakeypasswdop.c b/src/gpakeypasswdop.c
index e91d6dc..1409391 100644
--- a/src/gpakeypasswdop.c
+++ b/src/gpakeypasswdop.c
@@ -1,212 +1,221 @@
/* gpakeypasswdop.c - The GpaKeyPasswdOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gpakeypasswdop.h"
#include "gpgmeedit.h"
#include "gtktools.h"
/* Internal functions */
static gboolean gpa_key_passwd_operation_idle_cb (gpointer data);
static void gpa_key_passwd_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyPasswdOperation *op);
static void gpa_key_passwd_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyPasswdOperation *op);
/* GObject */
static GObjectClass *parent_class = NULL;
static void
gpa_key_passwd_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_key_passwd_operation_init (GpaKeyPasswdOperation *op)
{
}
static GObject*
gpa_key_passwd_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaKeyPasswdOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_KEY_PASSWD_OPERATION (object);
/* Initialize */
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_passwd_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_passwd_operation_done_cb), op);
/* Start with the first key after going back into the main loop */
g_idle_add (gpa_key_passwd_operation_idle_cb, op);
return object;
}
static void
gpa_key_passwd_operation_class_init (GpaKeyPasswdOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_key_passwd_operation_constructor;
object_class->finalize = gpa_key_passwd_operation_finalize;
}
GType
gpa_key_passwd_operation_get_type (void)
{
static GType key_passwd_operation_type = 0;
if (!key_passwd_operation_type)
{
static const GTypeInfo key_passwd_operation_info =
{
sizeof (GpaKeyPasswdOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_key_passwd_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaKeyPasswdOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_key_passwd_operation_init,
};
key_passwd_operation_type = g_type_register_static
(GPA_KEY_OPERATION_TYPE, "GpaKeyPasswdOperation",
&key_passwd_operation_info, 0);
}
return key_passwd_operation_type;
}
/* API */
/* Creates a new key deletion operation.
*/
GpaKeyPasswdOperation*
gpa_key_passwd_operation_new (GtkWidget *window, GList *keys)
{
GpaKeyPasswdOperation *op;
op = g_object_new (GPA_KEY_PASSWD_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
/* Internal */
-static gboolean
+static gpg_error_t
gpa_key_passwd_operation_start (GpaKeyPasswdOperation *op)
{
- gpgme_key_t key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
gpg_error_t err;
+ gpgme_key_t key;
+
+ key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
err = gpa_gpgme_edit_passwd_start (GPA_OPERATION(op)->context, key);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ if (err)
{
gpa_gpgme_warning (err);
- return FALSE;
+ return err;
}
- return TRUE;
+ return 0;
}
+
static gboolean
gpa_key_passwd_operation_idle_cb (gpointer data)
{
GpaKeyPasswdOperation *op = data;
+ gpg_error_t err;
- if (!gpa_key_passwd_operation_start (op))
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ err = gpa_key_passwd_operation_start (op);
+
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
return FALSE;
}
+
static void
gpa_key_passwd_operation_next (GpaKeyPasswdOperation *op)
{
- if (!GPA_KEY_OPERATION (op)->current ||
- !gpa_key_passwd_operation_start (op))
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ gpg_error_t err;
+
+ if (! GPA_KEY_OPERATION (op)->current)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+
+ err = gpa_key_passwd_operation_start (op);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
+
static void gpa_key_passwd_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyPasswdOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
static void gpa_key_passwd_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyPasswdOperation *op)
{
GPA_KEY_OPERATION (op)->current = g_list_next
(GPA_KEY_OPERATION (op)->current);
gpa_key_passwd_operation_next (op);
}
diff --git a/src/gpakeysignop.c b/src/gpakeysignop.c
index 7b16845..d29da1c 100644
--- a/src/gpakeysignop.c
+++ b/src/gpakeysignop.c
@@ -1,258 +1,264 @@
/* gpakeysignop.c - The GpaKeySignOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gpakeysignop.h"
#include "keysigndlg.h"
#include "gpgmeedit.h"
#include "gtktools.h"
/* Internal functions */
static gboolean gpa_key_sign_operation_idle_cb (gpointer data);
static void gpa_key_sign_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeySignOperation *op);
static void gpa_key_sign_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeySignOperation *op);
/* GObject */
static GObjectClass *parent_class = NULL;
static void
gpa_key_sign_operation_finalize (GObject *object)
{
GpaKeySignOperation *op = GPA_KEY_SIGN_OPERATION (object);
if (op->signer_key)
{
gpgme_key_unref (op->signer_key);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_key_sign_operation_init (GpaKeySignOperation *op)
{
op->signer_key = NULL;
op->signed_keys = 0;
}
static GObject*
gpa_key_sign_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaKeySignOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_KEY_SIGN_OPERATION (object);
/* Initialize */
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_sign_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_sign_operation_done_cb), op);
/* Start with the first key after going back into the main loop */
g_idle_add (gpa_key_sign_operation_idle_cb, op);
return object;
}
static void
gpa_key_sign_operation_class_init (GpaKeySignOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_key_sign_operation_constructor;
object_class->finalize = gpa_key_sign_operation_finalize;
}
GType
gpa_key_sign_operation_get_type (void)
{
static GType key_sign_operation_type = 0;
if (!key_sign_operation_type)
{
static const GTypeInfo key_sign_operation_info =
{
sizeof (GpaKeySignOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_key_sign_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaKeySignOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_key_sign_operation_init,
};
key_sign_operation_type = g_type_register_static
(GPA_KEY_OPERATION_TYPE, "GpaKeySignOperation",
&key_sign_operation_info, 0);
}
return key_sign_operation_type;
}
/* API */
/* Creates a new key deletion operation.
*/
GpaKeySignOperation*
gpa_key_sign_operation_new (GtkWidget *window, GList *keys)
{
GpaKeySignOperation *op;
op = g_object_new (GPA_KEY_SIGN_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
/* Internal */
-static gboolean
+static gpg_error_t
gpa_key_sign_operation_start (GpaKeySignOperation *op)
{
- gpgme_key_t key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+ gpg_error_t err;
+ gpgme_key_t key;
gboolean sign_locally = FALSE;
- if (gpa_key_sign_run_dialog (GPA_OPERATION (op)->window, key, &sign_locally))
- {
- gpg_error_t err;
- err = gpa_gpgme_edit_sign_start (GPA_OPERATION(op)->context, key,
- op->signer_key, sign_locally);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_warning (err);
- return FALSE;
- }
- }
- else
+ key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+ if (! gpa_key_sign_run_dialog (GPA_OPERATION (op)->window,
+ key, &sign_locally))
+ return gpg_error (GPG_ERR_CANCELED);
+
+ err = gpa_gpgme_edit_sign_start (GPA_OPERATION(op)->context, key,
+ op->signer_key, sign_locally);
+ if (err)
{
- return FALSE;
+ gpa_gpgme_warning (err);
+ return err;
}
- return TRUE;
+
+ return 0;
}
+
static gboolean
gpa_key_sign_operation_idle_cb (gpointer data)
{
GpaKeySignOperation *op = data;
+ gpg_error_t err;
/* Get the signer key and abort if there isn't one */
op->signer_key = gpa_options_get_default_key (gpa_options_get_instance ());
- if (!op->signer_key)
+ if (! op->signer_key)
{
gpa_window_error (_("No private key for signing."),
GPA_OPERATION (op)->window);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ /* FIXME: Error code? */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
return FALSE;
}
gpgme_key_ref (op->signer_key);
- if (!gpa_key_sign_operation_start (op))
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ err = gpa_key_sign_operation_start (op);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
return FALSE;
}
+
static void
gpa_key_sign_operation_next (GpaKeySignOperation *op)
{
- if (!GPA_KEY_OPERATION (op)->current ||
- !gpa_key_sign_operation_start (op))
+ gpg_error_t err;
+
+ if (! GPA_KEY_OPERATION (op)->current)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+
+ err = gpa_key_sign_operation_start (op);
+ if (err)
{
if (op->signed_keys > 0)
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
- }
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
}
+
static void gpa_key_sign_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeySignOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
op->signed_keys++;
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
case GPG_ERR_UNUSABLE_PUBKEY:
/* Couldn't sign because the key was expired */
gpa_window_error (_("This key has expired! "
"Unable to sign."), GPA_OPERATION (op)->window);
break;
case GPG_ERR_CONFLICT:
gpa_window_error (_("This key has already been signed with "
"your own!"), GPA_OPERATION (op)->window);
break;
case GPG_ERR_NO_SECKEY:
/* Couldn't sign because there is no default key */
gpa_window_error (_("You haven't selected a default key "
"to sign with!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
static void gpa_key_sign_operation_done_cb (GpaContext *context,
- gpg_error_t err,
- GpaKeySignOperation *op)
+ gpg_error_t err,
+ GpaKeySignOperation *op)
{
GPA_KEY_OPERATION (op)->current = g_list_next
(GPA_KEY_OPERATION (op)->current);
gpa_key_sign_operation_next (op);
}
diff --git a/src/gpakeytrustop.c b/src/gpakeytrustop.c
index 08cdaea..546cd03 100644
--- a/src/gpakeytrustop.c
+++ b/src/gpakeytrustop.c
@@ -1,223 +1,228 @@
/* gpakeytrustop.c - The GpaKeyTrustOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include <glib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <io.h>
#endif
#include "gpa.h"
#include "gpakeytrustop.h"
#include "ownertrustdlg.h"
#include "gpgmeedit.h"
#include "gtktools.h"
/* Internal functions */
static gboolean gpa_key_trust_operation_idle_cb (gpointer data);
static void gpa_key_trust_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyTrustOperation *op);
static void gpa_key_trust_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyTrustOperation *op);
/* GObject */
static GObjectClass *parent_class = NULL;
static void
gpa_key_trust_operation_finalize (GObject *object)
{
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_key_trust_operation_init (GpaKeyTrustOperation *op)
{
op->modified_keys = 0;
}
static GObject*
gpa_key_trust_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaKeyTrustOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_KEY_TRUST_OPERATION (object);
/* Initialize */
/* Connect to the "done" signal */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_trust_operation_done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (gpa_key_trust_operation_done_cb), op);
/* Start with the first key after going back into the main loop */
g_idle_add (gpa_key_trust_operation_idle_cb, op);
return object;
}
static void
gpa_key_trust_operation_class_init (GpaKeyTrustOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_key_trust_operation_constructor;
object_class->finalize = gpa_key_trust_operation_finalize;
}
GType
gpa_key_trust_operation_get_type (void)
{
static GType key_trust_operation_type = 0;
if (!key_trust_operation_type)
{
static const GTypeInfo key_trust_operation_info =
{
sizeof (GpaKeyTrustOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_key_trust_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaKeyTrustOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_key_trust_operation_init,
};
key_trust_operation_type = g_type_register_static
(GPA_KEY_OPERATION_TYPE, "GpaKeyTrustOperation",
&key_trust_operation_info, 0);
}
return key_trust_operation_type;
}
/* API */
/* Creates a new key deletion operation.
*/
GpaKeyTrustOperation*
gpa_key_trust_operation_new (GtkWidget *window, GList *keys)
{
GpaKeyTrustOperation *op;
op = g_object_new (GPA_KEY_TRUST_OPERATION_TYPE,
"window", window,
"keys", keys,
NULL);
return op;
}
/* Internal */
-static gboolean
+static gpg_error_t
gpa_key_trust_operation_start (GpaKeyTrustOperation *op)
{
- gpgme_key_t key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+ gpg_error_t err;
+ gpgme_key_t key;
gpgme_validity_t trust;
- if (gpa_ownertrust_run_dialog (key, GPA_OPERATION (op)->window, &trust))
- {
- gpg_error_t err;
- err = gpa_gpgme_edit_trust_start (GPA_OPERATION(op)->context, key,trust);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_warning (err);
- return FALSE;
- }
- }
- else
+ key = gpa_key_operation_current_key (GPA_KEY_OPERATION (op));
+
+ if (! gpa_ownertrust_run_dialog (key, GPA_OPERATION (op)->window, &trust))
+ return gpg_error (GPG_ERR_CANCELED);
+
+ err = gpa_gpgme_edit_trust_start (GPA_OPERATION(op)->context, key,trust);
+ if (err)
{
- return FALSE;
+ gpa_gpgme_warning (err);
+ return err;
}
- return TRUE;
+
+ return 0;
}
+
static gboolean
gpa_key_trust_operation_idle_cb (gpointer data)
{
GpaKeyTrustOperation *op = data;
+ gpg_error_t err;
- if (!gpa_key_trust_operation_start (op))
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ err = gpa_key_trust_operation_start (op);
+ if (err)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
return FALSE;
}
+
static void
gpa_key_trust_operation_next (GpaKeyTrustOperation *op)
{
- if (!GPA_KEY_OPERATION (op)->current ||
- !gpa_key_trust_operation_start (op))
- {
- if (op->modified_keys > 0)
- {
- g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
- }
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ gpg_error_t err;
+
+ if (! GPA_KEY_OPERATION (op)->current)
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", 0);
+
+ err = gpa_key_trust_operation_start (op);
+ if (err)
+ {
+ if (op->modified_keys > 0)
+ g_signal_emit_by_name (GPA_OPERATION (op), "changed_wot");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
+ }
}
+
static void gpa_key_trust_operation_done_error_cb (GpaContext *context,
gpg_error_t err,
GpaKeyTrustOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
op->modified_keys++;
case GPG_ERR_CANCELED:
/* Ignore these */
break;
default:
gpa_gpgme_warning (err);
break;
}
}
static void gpa_key_trust_operation_done_cb (GpaContext *context,
gpg_error_t err,
GpaKeyTrustOperation *op)
{
GPA_KEY_OPERATION (op)->current = g_list_next
(GPA_KEY_OPERATION (op)->current);
gpa_key_trust_operation_next (op);
}
diff --git a/src/gpaoperation.c b/src/gpaoperation.c
index 8753a41..819f989 100644
--- a/src/gpaoperation.c
+++ b/src/gpaoperation.c
@@ -1,268 +1,251 @@
/* gpaop.c - The GpaOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#include <config.h>
#include "gpaoperation.h"
#include <gtk/gtk.h>
#include "gtktools.h"
#include "gpgmetools.h"
#include "i18n.h"
-
+#include "gpa-marshal.h"
#ifndef G_PARAM_STATIC_STRINGS
#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK \
| G_PARAM_STATIC_BLURB)
#endif
/* Signals */
enum
{
COMPLETED,
+ STATUS,
LAST_SIGNAL
};
/* Properties */
enum
{
PROP_0,
PROP_WINDOW,
- PROP_SERVER_CTX
};
static GObjectClass *parent_class = NULL;
static guint signals [LAST_SIGNAL] = { 0 };
static void
gpa_operation_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GpaOperation *op = GPA_OPERATION (object);
switch (prop_id)
{
case PROP_WINDOW:
g_value_set_object (value, op->window);
break;
- case PROP_SERVER_CTX:
- g_value_set_pointer (value, op->server_ctx);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_operation_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GpaOperation *op = GPA_OPERATION (object);
switch (prop_id)
{
case PROP_WINDOW:
op->window = (GtkWidget*) g_value_get_object (value);
break;
- case PROP_SERVER_CTX:
- op->server_ctx = g_value_get_pointer (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_operation_finalize (GObject *object)
{
GpaOperation *op = GPA_OPERATION (object);
g_object_unref (op->context);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_operation_init (GpaOperation *op)
{
op->window = NULL;
op->context = NULL;
- op->server_ctx = NULL;
}
static GObject*
gpa_operation_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaOperation *op;
/* Invoke parent's constructor */
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_OPERATION (object);
/* Initialize */
op->context = gpa_context_new ();
return object;
}
static void
gpa_operation_class_init (GpaOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_operation_constructor;
object_class->finalize = gpa_operation_finalize;
object_class->set_property = gpa_operation_set_property;
object_class->get_property = gpa_operation_get_property;
klass->completed = NULL;
+ klass->status = NULL;
- /* Signals */
+ /* Signals. */
signals[COMPLETED] =
g_signal_new ("completed",
G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (GpaOperationClass, completed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1, G_TYPE_INT);
+
+ signals[STATUS] =
+ g_signal_new ("status",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
G_STRUCT_OFFSET (GpaOperationClass, completed),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- /* Properties */
+ gpa_marshal_INT__STRING_STRING,
+ G_TYPE_INT, 1, G_TYPE_STRING, 1, G_TYPE_STRING);
+
+
+ /* Properties. */
g_object_class_install_property
(object_class, PROP_WINDOW,
g_param_spec_object ("window", "Parent window",
"Parent window",
GTK_TYPE_WIDGET,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property
- (object_class, PROP_SERVER_CTX,
- g_param_spec_pointer ("server-ctx", "Server Context",
- "The Assuan context of the connection",
- G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
}
GType
gpa_operation_get_type (void)
{
static GType operation_type = 0;
if (!operation_type)
{
static const GTypeInfo operation_info =
{
sizeof (GpaOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_operation_init,
};
operation_type = g_type_register_static (G_TYPE_OBJECT,
"GpaOperation",
&operation_info, 0);
}
return operation_type;
}
+
/* API */
-/* Whether the operation is currently busy (i.e. gpg is running).
- */
+/* Whether the operation is currently busy (i.e. gpg is running). */
gboolean
gpa_operation_busy (GpaOperation *op)
{
g_return_val_if_fail (op != NULL, FALSE);
g_return_val_if_fail (GPA_IS_OPERATION (op), FALSE);
return gpa_context_busy (op->context);
}
-/* Tell the UI-server that the current operation has finished with
- error code ERR. Note that the server context will be disabled
- after this operation. */
-void
-gpa_operation_server_finish (GpaOperation *op, gpg_error_t err)
-{
- g_return_if_fail (op);
- g_return_if_fail (GPA_IS_OPERATION (op));
- if (op->server_ctx)
- {
- assuan_context_t ctx = op->server_ctx;
- op->server_ctx = NULL;
- gpa_run_server_continuation (ctx, err);
- }
-}
-
-
-/* If running in server mode, write a status line names STATUSNAME
- plus space delimited arguments. */
+/* Emit a status line names STATUSNAME plus space delimited
+ arguments. */
gpg_error_t
gpa_operation_write_status (GpaOperation *op, const char *statusname, ...)
{
gpg_error_t err = 0;
+ va_list arg_ptr;
+ char buf[950], *p;
+ const char *text;
+ size_t n;
g_return_val_if_fail (op, gpg_error (GPG_ERR_BUG));
g_return_val_if_fail (GPA_IS_OPERATION (op), gpg_error (GPG_ERR_BUG));
- if (op->server_ctx)
- {
- assuan_context_t ctx = op->server_ctx;
- va_list arg_ptr;
- char buf[950], *p;
- const char *text;
- size_t n;
- va_start (arg_ptr, statusname);
-
- p = buf;
- n = 0;
- while ( (text = va_arg (arg_ptr, const char *)) )
- {
- if (n)
- {
- *p++ = ' ';
- n++;
- }
- for ( ; *text && n < DIM (buf)-2; n++)
- *p++ = *text++;
- }
- *p = 0;
- err = assuan_write_status (ctx, statusname, buf);
- va_end (arg_ptr);
+ va_start (arg_ptr, statusname);
+
+ p = buf;
+ n = 0;
+ while ((text = va_arg (arg_ptr, const char *)))
+ {
+ if (n)
+ {
+ *p++ = ' ';
+ n++;
+ }
+ for ( ; *text && n < DIM (buf)-2; n++)
+ *p++ = *text++;
}
+ *p = 0;
+
+ /* FIXME: Get return value. Might require an allocator to not only
+ get the last one. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "status", buf);
+
+ va_end (arg_ptr);
return err;
}
diff --git a/src/gpaoperation.h b/src/gpaoperation.h
index 9b8d44c..b28c63b 100644
--- a/src/gpaoperation.h
+++ b/src/gpaoperation.h
@@ -1,74 +1,70 @@
/* gpaop.h - The GpaOperation object.
* Copyright (C) 2003, Miguel Coca.
*
* This file is part of GPA
*
* GPA 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.
*
* GPA 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
*/
#ifndef GPA_OPERATION_H
#define GPA_OPERATION_H
#include "gpa.h"
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "gpacontext.h"
/* GObject stuff */
#define GPA_OPERATION_TYPE (gpa_operation_get_type ())
#define GPA_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_OPERATION_TYPE, GpaOperation))
#define GPA_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPA_OPERATION_TYPE, GpaOperationClass))
#define GPA_IS_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_OPERATION_TYPE))
#define GPA_IS_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_OPERATION_TYPE))
#define GPA_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GPA_OPERATION_TYPE, GpaOperationClass))
typedef struct _GpaOperation GpaOperation;
typedef struct _GpaOperationClass GpaOperationClass;
struct _GpaOperation {
GObject parent;
GtkWidget *window;
GpaContext *context;
- void *server_ctx;
};
struct _GpaOperationClass {
GObjectClass parent_class;
/* Signal handlers */
- void (*completed) (GpaOperation *operation);
+ void (*completed) (GpaOperation *operation, gpg_error_t err);
+ void (*status) (GpaOperation *operation, gchar *status);
};
GType gpa_operation_get_type (void) G_GNUC_CONST;
/*** API ***/
/* Whether the operation is currently busy (i.e. gpg is running). */
gboolean gpa_operation_busy (GpaOperation *op);
-/* Tell the UI-server that the current operation has finished with
- error code ERR. Note that the server context will be disabled
- after this operation. */
-void gpa_operation_server_finish (GpaOperation *op, gpg_error_t err);
/* If running in server mode, write a status line names STATUSNAME
plus space delimited arguments. */
gpg_error_t gpa_operation_write_status (GpaOperation *op,
const char *statusname, ...);
#endif
diff --git a/src/gpaprogressbar.c b/src/gpaprogressbar.c
index 93c9bd0..901cc12 100644
--- a/src/gpaprogressbar.c
+++ b/src/gpaprogressbar.c
@@ -1,234 +1,233 @@
/* gpaprogressbar.c - The GpaProgressBar object.
Copyright (C) 2003 Miguel Coca.
Copyright (C) 2008 g10 Code GmbH.
This file is part of GPA.
GPA 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.
GPA 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "gpaprogressbar.h"
#include "i18n.h"
/* Properties. */
enum
{
PROP_0,
PROP_CONTEXT
};
static GObjectClass *parent_class = NULL;
static void
gpa_progress_bar_get_property (GObject *object, guint prop_id, GValue *value,
GParamSpec *pspec)
{
GpaProgressBar *pbar = GPA_PROGRESS_BAR (object);
switch (prop_id)
{
case PROP_CONTEXT:
g_value_set_object (value, pbar->context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_progress_bar_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
GpaProgressBar *pbar = GPA_PROGRESS_BAR (object);
switch (prop_id)
{
case PROP_CONTEXT:
gpa_progress_bar_set_context (pbar, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_progress_bar_finalize (GObject *object)
{
GpaProgressBar *pbar = GPA_PROGRESS_BAR (object);
GpaContext *context = pbar->context;
if (context)
{
g_signal_handler_disconnect (G_OBJECT (context), pbar->sig_id_start);
g_signal_handler_disconnect (G_OBJECT (context), pbar->sig_id_done);
g_signal_handler_disconnect (G_OBJECT (context), pbar->sig_id_progress);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_progress_bar_class_init (GpaProgressBarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gpa_progress_bar_finalize;
object_class->set_property = gpa_progress_bar_set_property;
object_class->get_property = gpa_progress_bar_get_property;
/* Properties. */
g_object_class_install_property (object_class,
PROP_CONTEXT,
g_param_spec_object
("context", "context",
"context", GPA_CONTEXT_TYPE,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
static void
gpa_progress_bar_init (GpaProgressBar *pbar)
{
}
GType
gpa_progress_bar_get_type (void)
{
static GType progress_bar_type = 0;
if (! progress_bar_type)
{
static const GTypeInfo progress_bar_info =
{
sizeof (GpaProgressBarClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_progress_bar_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaProgressBar),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_progress_bar_init,
};
progress_bar_type = g_type_register_static (GTK_TYPE_PROGRESS_BAR,
"GpaProgressBar",
&progress_bar_info, 0);
}
return progress_bar_type;
}
/* API. */
/* Create a new progress bar. */
GtkWidget *
gpa_progress_bar_new (void)
{
GpaProgressBar *pbar;
pbar = g_object_new (GPA_PROGRESS_BAR_TYPE, NULL);
return GTK_WIDGET (pbar);
}
/* Create a new progress bar for the given context. */
GtkWidget *
gpa_progress_bar_new_with_context (GpaContext *context)
{
GpaProgressBar *pbar;
pbar = g_object_new (GPA_PROGRESS_BAR_TYPE, "context", context, NULL);
return GTK_WIDGET (pbar);
}
static void
progress_cb (GpaContext *context, int current, int total, GpaProgressBar *pbar)
{
- g_print ("progress %i %i\n", current, total);
if (total > 0)
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pbar),
(gdouble) current / (gdouble) total);
else
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (pbar));
}
static void
start_cb (GpaContext *context, GpaProgressBar *pbar)
{
progress_cb (context, 0, 1, pbar);
}
static void
done_cb (GpaContext *context, gpg_error_t err, GpaProgressBar *pbar)
{
progress_cb (context, 1, 1, pbar);
}
GpaContext *
gpa_progress_bar_get_context (GpaProgressBar *pbar)
{
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), 0);
return pbar->context;
}
void
gpa_progress_bar_set_context (GpaProgressBar *pbar, GpaContext *context)
{
g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));
if (pbar->context)
{
g_signal_handler_disconnect (G_OBJECT (pbar->context),
pbar->sig_id_start);
g_signal_handler_disconnect (G_OBJECT (pbar->context),
pbar->sig_id_done);
g_signal_handler_disconnect (G_OBJECT (pbar->context),
pbar->sig_id_progress);
}
pbar->context = context;
if (context)
{
pbar->sig_id_start = g_signal_connect (G_OBJECT (context), "start",
G_CALLBACK (start_cb), pbar);
pbar->sig_id_done = g_signal_connect (G_OBJECT (context), "done",
G_CALLBACK (done_cb), pbar);
pbar->sig_id_progress = g_signal_connect (G_OBJECT (context), "progress",
G_CALLBACK (progress_cb), pbar);
}
}
diff --git a/src/gpastreamencryptop.c b/src/gpastreamencryptop.c
index 8f30026..fa957f6 100644
--- a/src/gpastreamencryptop.c
+++ b/src/gpastreamencryptop.c
@@ -1,516 +1,505 @@
/* gpastreamdecryptop.c - The GpaOperation object.
* Copyright (C) 2007, 2008 g10 Code GmbH
*
* This file is part of GPA.
*
* GPA 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 3 of the License, or
* (at your option) any later version.
*
* GPA 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <glib.h>
#include "gpgmetools.h"
#include "recipientdlg.h"
#include "gpawidgets.h"
#include "gpapastrings.h"
#include "gpastreamencryptop.h"
struct _GpaStreamEncryptOperation
{
GpaStreamOperation parent;
RecipientDlg *recp_dialog;
GSList *recipients;
gpgme_key_t *keys;
gpgme_protocol_t selected_protocol;
};
struct _GpaStreamEncryptOperationClass
{
GpaStreamOperationClass parent_class;
};
/* Indentifiers for our properties. */
enum
{
PROP_0,
PROP_RECIPIENTS,
PROP_RECIPIENT_KEYS,
PROP_PROTOCOL
};
static void response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
static gboolean start_encryption_cb (gpointer data);
static void done_error_cb (GpaContext *context, gpg_error_t err,
GpaStreamEncryptOperation *op);
static void done_cb (GpaContext *context, gpg_error_t err,
GpaStreamEncryptOperation *op);
static GObjectClass *parent_class;
/* Helper to be used as a GFunc for free. */
static void
free_func (void *p, void *dummy)
{
(void)dummy;
g_free (p);
}
static void
release_recipients (GSList *recipients)
{
if (recipients)
{
g_slist_foreach (recipients, free_func, NULL);
g_slist_free (recipients);
}
}
/* Return a deep copy of the recipients list. */
static GSList *
copy_recipients (GSList *recipients)
{
GSList *recp, *newlist;
newlist= NULL;
for (recp = recipients; recp; recp = g_slist_next (recp))
newlist = g_slist_append (newlist, g_strdup (recp->data));
return newlist;
}
static void
gpa_stream_encrypt_operation_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GpaStreamEncryptOperation *op = GPA_STREAM_ENCRYPT_OPERATION (object);
switch (prop_id)
{
case PROP_RECIPIENTS:
g_value_set_pointer (value, op->recipients);
break;
case PROP_RECIPIENT_KEYS:
g_value_set_pointer (value, op->keys);
break;
case PROP_PROTOCOL:
g_value_set_int (value, op->selected_protocol);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_stream_encrypt_operation_set_property (GObject *object, guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GpaStreamEncryptOperation *op = GPA_STREAM_ENCRYPT_OPERATION (object);
switch (prop_id)
{
case PROP_RECIPIENTS:
op->recipients = (GSList*)g_value_get_pointer (value);
break;
case PROP_RECIPIENT_KEYS:
op->keys = (gpgme_key_t*)g_value_get_pointer (value);
break;
case PROP_PROTOCOL:
op->selected_protocol = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_stream_encrypt_operation_finalize (GObject *object)
{
GpaStreamEncryptOperation *op = GPA_STREAM_ENCRYPT_OPERATION (object);
release_recipients (op->recipients);
op->recipients = NULL;
gpa_gpgme_release_keyarray (op->keys);
op->keys = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_stream_encrypt_operation_init (GpaStreamEncryptOperation *op)
{
op->recp_dialog = NULL;
op->recipients = NULL;
op->keys = NULL;
op->selected_protocol = GPGME_PROTOCOL_UNKNOWN;
}
static GObject*
gpa_stream_encrypt_operation_constructor
(GType type,
guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaStreamEncryptOperation *op;
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_STREAM_ENCRYPT_OPERATION (object);
/* Create the recipient key selection dialog if we don't know the
keys yet. */
if (!op->keys)
{
op->recp_dialog = recipient_dlg_new (GPA_OPERATION (op)->window);
recipient_dlg_set_recipients (op->recp_dialog,
op->recipients,
op->selected_protocol);
g_signal_connect (G_OBJECT (op->recp_dialog), "response",
G_CALLBACK (response_cb), op);
}
else
g_idle_add (start_encryption_cb, op);
/* We connect the done signal to two handles. The error handler is
called first. */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (done_cb), op);
gtk_window_set_title
(GTK_WINDOW (GPA_STREAM_OPERATION (op)->progress_dialog),
_("Encrypting message ..."));
if (op->recp_dialog)
gtk_widget_show_all (GTK_WIDGET (op->recp_dialog));
return object;
}
static void
gpa_stream_encrypt_operation_class_init (GpaStreamEncryptOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_stream_encrypt_operation_constructor;
object_class->finalize = gpa_stream_encrypt_operation_finalize;
object_class->set_property = gpa_stream_encrypt_operation_set_property;
object_class->get_property = gpa_stream_encrypt_operation_get_property;
g_object_class_install_property
(object_class, PROP_RECIPIENTS,
g_param_spec_pointer
("recipients", "Recipients",
"A list of recipients in rfc-822 mailbox format.",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_RECIPIENT_KEYS,
g_param_spec_pointer
("recipient-keys", "Recipient-keys",
"An array of gpgme_key_t with the selected keys.",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_PROTOCOL,
g_param_spec_int
("protocol", "Protocol",
"The gpgme protocol currently selected.",
GPGME_PROTOCOL_OpenPGP, GPGME_PROTOCOL_UNKNOWN, GPGME_PROTOCOL_UNKNOWN,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
}
GType
gpa_stream_encrypt_operation_get_type (void)
{
static GType stream_encrypt_operation_type = 0;
if (!stream_encrypt_operation_type)
{
static const GTypeInfo stream_encrypt_operation_info =
{
sizeof (GpaStreamEncryptOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_stream_encrypt_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaStreamEncryptOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_stream_encrypt_operation_init,
};
stream_encrypt_operation_type = g_type_register_static
(GPA_STREAM_OPERATION_TYPE, "GpaStreamEncryptOperation",
&stream_encrypt_operation_info, 0);
}
return stream_encrypt_operation_type;
}
/* Return true if all keys are matching the protocol. */
static int
keys_match_protocol_p (gpgme_key_t *keys, gpgme_protocol_t protocol)
{
int idx;
if (!keys)
return 1; /* No keys: assume match. */
for (idx = 0; keys[idx]; idx++)
if (keys[idx]->protocol != protocol)
return 0;
return 1;
}
/*
* Fire up the encryption.
*/
static void
start_encryption (GpaStreamEncryptOperation *op)
{
gpg_error_t err;
int prep_only = 0;
if (!op->keys || !op->keys[0])
{
err = gpg_error (GPG_ERR_NO_PUBKEY);
goto leave;
}
if (op->selected_protocol == GPGME_PROTOCOL_OpenPGP)
err = gpa_operation_write_status (GPA_OPERATION (op), "PROTOCOL",
"OpenPGP", NULL);
else if (op->selected_protocol == GPGME_PROTOCOL_CMS)
err = gpa_operation_write_status (GPA_OPERATION (op), "PROTOCOL",
"CMS", NULL);
else
err = gpg_error (GPG_ERR_NO_PUBKEY);
if (err)
goto leave;
/* Set the output encoding. */
if (GPA_STREAM_OPERATION (op)->input_stream
&& GPA_STREAM_OPERATION (op)->output_stream)
{
if (op->selected_protocol == GPGME_PROTOCOL_CMS)
gpgme_data_set_encoding (GPA_STREAM_OPERATION (op)->output_stream,
GPGME_DATA_ENCODING_BASE64);
else
gpgme_set_armor (GPA_OPERATION (op)->context->ctx, 1);
if (!keys_match_protocol_p (op->keys, op->selected_protocol))
{
g_debug ("the selected keys do not match the protocol");
err = gpg_error (GPG_ERR_CONFLICT);
goto leave;
}
gpgme_set_protocol (GPA_OPERATION (op)->context->ctx,
op->selected_protocol);
/* We always trust the keys because the recipient selection
dialog has already sorted unusable out. */
err = gpgme_op_encrypt_start (GPA_OPERATION (op)->context->ctx,
op->keys, GPGME_ENCRYPT_ALWAYS_TRUST,
GPA_STREAM_OPERATION (op)->input_stream,
GPA_STREAM_OPERATION (op)->output_stream);
if (err)
{
gpa_gpgme_warning (err);
goto leave;
}
/* Show and update the progress dialog. */
gtk_widget_show_all (GPA_STREAM_OPERATION (op)->progress_dialog);
gpa_progress_dialog_set_label
(GPA_PROGRESS_DIALOG (GPA_STREAM_OPERATION (op)->progress_dialog),
_("Message encryption"));
}
else
{
/* We are just preparing an encryption. */
prep_only = 1;
err = 0;
}
leave:
if (err || prep_only)
- {
- gpa_operation_server_finish (GPA_OPERATION (op), err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
/* The recipient key selection dialog has returned. */
static void
response_cb (GtkDialog *dialog, int response, void *user_data)
{
GpaStreamEncryptOperation *op = user_data;
gtk_widget_hide (GTK_WIDGET (dialog));
if (response != GTK_RESPONSE_OK)
{
/* The dialog was canceled, so we do nothing and complete the
- * operation. */
- gpa_operation_server_finish (GPA_OPERATION (op),
+ operation. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
gpg_error (GPG_ERR_CANCELED));
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
return;
}
/* Get the keys. */
gpa_gpgme_release_keyarray (op->keys);
op->keys = NULL;
op->keys = recipient_dlg_get_keys (op->recp_dialog, &op->selected_protocol);
start_encryption (op);
}
/* This is the idle function used to start the encryption if no
recipient key selection dialog has been requested. */
static gboolean
start_encryption_cb (void *user_data)
{
GpaStreamEncryptOperation *op = user_data;
start_encryption (op);
return FALSE; /* Remove this callback from the event loop. */
}
/*Show an error message. */
static void
done_error_cb (GpaContext *context, gpg_error_t err,
GpaStreamEncryptOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
/* case GPG_ERR_BAD_PASSPHRASE: */
/* gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window); */
/* break; */
default:
gpa_gpgme_warning (err);
break;
}
}
/* Operation is ready. Tell the server. */
static void
done_cb (GpaContext *context, gpg_error_t err, GpaStreamEncryptOperation *op)
{
gtk_widget_hide (GPA_STREAM_OPERATION (op)->progress_dialog);
- /* Tell the server that we finished and delete ourself. */
- gpa_operation_server_finish (GPA_OPERATION (op), err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
-/************************************************************
- ********************** Public API ************************
- ************************************************************/
+/* Public API. */
-/* Start encrypting INPUT_STREAM to OUTPUT_STREAM using SERVER_CTX and
- WINDOW. RECIPIENTS gives a list of recipients and the function
- matches them with existing keys and selects appropriate keys.
- RECP_KEYS is either NULL or an array with gpgme keys which will
- then immediatley be used and suppresses the recipient key selection
- dialog.
+/* Start encrypting INPUT_STREAM to OUTPUT_STREAM using WINDOW.
+ RECIPIENTS gives a list of recipients and the function matches them
+ with existing keys and selects appropriate keys. RECP_KEYS is
+ either NULL or an array with gpgme keys which will then immediatley
+ be used and suppresses the recipient key selection dialog.
If it is not possible to unambigiously select keys and SILENT is
not given, a key selection dialog offers the user a way to manually
select keys. INPUT_STREAM and OUTPUT_STREAM may be given as NULL
in which case the function skips the actual encryption step and
just verifies the recipients. */
GpaStreamEncryptOperation*
gpa_stream_encrypt_operation_new (GtkWidget *window,
gpgme_data_t input_stream,
gpgme_data_t output_stream,
GSList *recipients,
gpgme_key_t *recp_keys,
gpgme_protocol_t protocol,
- int silent,
- void *server_ctx)
+ int silent)
{
GpaStreamEncryptOperation *op;
/* Fixme: SILENT is not yet implemented. */
op = g_object_new (GPA_STREAM_ENCRYPT_OPERATION_TYPE,
"window", window,
"input_stream", input_stream,
"output_stream", output_stream,
"recipients", copy_recipients (recipients),
"recipient-keys", gpa_gpgme_copy_keyarray (recp_keys),
"protocol", (int)protocol,
- "server-ctx", server_ctx,
NULL);
return op;
}
/* Return an array of keys for the set of recipients of this object.
The function also returns the selected protocol. */
gpgme_key_t *
gpa_stream_encrypt_operation_get_keys (GpaStreamEncryptOperation *op,
gpgme_protocol_t *r_protocol)
{
g_return_val_if_fail (op, NULL);
if (r_protocol)
*r_protocol = op->selected_protocol;
return gpa_gpgme_copy_keyarray (op->keys);
}
diff --git a/src/gpastreamencryptop.h b/src/gpastreamencryptop.h
index e580e93..385d95f 100644
--- a/src/gpastreamencryptop.h
+++ b/src/gpastreamencryptop.h
@@ -1,80 +1,79 @@
/* gpastreamencryptop.h - The GpaStreamEncryptOperation object.
* Copyright (C) 2007 g10 Code GmbH
*
* This file is part of GPA
*
* GPA 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 3 of the License, or
* (at your option) any later version.
*
* GPA 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPA_STREAM_ENCRYPT_OP_H
#define GPA_STREAM_ENCRYPT_OP_H
#include <glib.h>
#include <glib-object.h>
#include "gpastreamop.h"
/* GObject stuff */
#define GPA_STREAM_ENCRYPT_OPERATION_TYPE \
(gpa_stream_encrypt_operation_get_type ())
#define GPA_STREAM_ENCRYPT_OPERATION(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), GPA_STREAM_ENCRYPT_OPERATION_TYPE,\
GpaStreamEncryptOperation))
#define GPA_STREAM_ENCRYPT_OPERATION_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
GPA_STREAM_ENCRYPT_OPERATION_TYPE, \
GpaStreamEncryptOperationClass))
#define GPA_IS_STREAM_ENCRYPT_OPERATION(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
GPA_STREAM_ENCRYPT_OPERATION_TYPE))
#define GPA_IS_STREAM_ENCRYPT_OPERATION_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
GPA_STREAM_ENCRYPT_OPERATION_TYPE))
#define GPA_STREAM_ENCRYPT_OPERATION_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
GPA_STREAM_ENCRYPT_OPERATION_TYPE, \
GpaStreamEncryptOperationClass))
typedef struct _GpaStreamEncryptOperation GpaStreamEncryptOperation;
typedef struct _GpaStreamEncryptOperationClass GpaStreamEncryptOperationClass;
GType gpa_stream_encrypt_operation_get_type (void) G_GNUC_CONST;
/************************************
************ Public API ************
************************************/
/* Creates a new encryption operation. */
GpaStreamEncryptOperation *
gpa_stream_encrypt_operation_new (GtkWidget *window,
gpgme_data_t input_stream,
gpgme_data_t output_stream,
GSList *recipients,
gpgme_key_t *recp_keys,
gpgme_protocol_t protocol,
- int silent,
- void *server_ctx);
+ int silent);
gpgme_key_t *gpa_stream_encrypt_operation_get_keys
(GpaStreamEncryptOperation *op, gpgme_protocol_t *r_protocol);
#endif /*GPA_STREAM_ENCRYPT_OP_H*/
diff --git a/src/gpastreamsignop.c b/src/gpastreamsignop.c
index 9cadab3..f52c87b 100644
--- a/src/gpastreamsignop.c
+++ b/src/gpastreamsignop.c
@@ -1,475 +1,463 @@
/* gpastreamsignop.c - The GpaStreamSignOperation object.
* Copyright (C) 2008 g10 Code GmbH
*
* This file is part of GPA.
*
* GPA 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 3 of the License, or
* (at your option) any later version.
*
* GPA 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <glib.h>
#include "gpgmetools.h"
#include "gtktools.h"
#include "filesigndlg.h"
#include "gpastreamsignop.h"
struct _GpaStreamSignOperation
{
GpaStreamOperation parent;
GtkWidget *sign_dialog;
const char *sender;
gpgme_protocol_t requested_protocol;
gboolean detached;
};
struct _GpaStreamSignOperationClass
{
GpaStreamOperationClass parent_class;
};
/* Indentifiers for our properties. */
enum
{
PROP_0,
PROP_SENDER,
PROP_PROTOCOL,
PROP_DETACHED
};
static void response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
static void done_error_cb (GpaContext *context, gpg_error_t err,
GpaStreamSignOperation *op);
static void done_cb (GpaContext *context, gpg_error_t err,
GpaStreamSignOperation *op);
static GObjectClass *parent_class;
static void
gpa_stream_sign_operation_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
GpaStreamSignOperation *op = GPA_STREAM_SIGN_OPERATION (object);
switch (prop_id)
{
case PROP_SENDER:
g_value_set_string (value, op->sender);
break;
case PROP_PROTOCOL:
g_value_set_int (value, op->requested_protocol);
break;
case PROP_DETACHED:
g_value_set_boolean (value, op->detached);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_stream_sign_operation_set_property (GObject *object, guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GpaStreamSignOperation *op = GPA_STREAM_SIGN_OPERATION (object);
switch (prop_id)
{
case PROP_SENDER:
op->sender = g_value_get_string (value);
break;
case PROP_PROTOCOL:
op->requested_protocol = g_value_get_int (value);
break;
case PROP_DETACHED:
op->detached = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gpa_stream_sign_operation_finalize (GObject *object)
{
/* GpaStreamSignOperation *op = GPA_STREAM_SIGN_OPERATION (object); */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gpa_stream_sign_operation_init (GpaStreamSignOperation *op)
{
op->requested_protocol = GPGME_PROTOCOL_UNKNOWN;
}
static GObject*
gpa_stream_sign_operation_ctor (GType type, guint n_construct_properties,
GObjectConstructParam *construct_properties)
{
GObject *object;
GpaStreamSignOperation *op;
object = parent_class->constructor (type,
n_construct_properties,
construct_properties);
op = GPA_STREAM_SIGN_OPERATION (object);
op->sign_dialog = gpa_file_sign_dialog_new (GPA_OPERATION (op)->window,
0);
g_signal_connect (G_OBJECT (op->sign_dialog), "response",
G_CALLBACK (response_cb), op);
/* We connect the done signal to two handles. The error handler is
called first. */
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (done_error_cb), op);
g_signal_connect (G_OBJECT (GPA_OPERATION (op)->context), "done",
G_CALLBACK (done_cb), op);
gtk_window_set_title
(GTK_WINDOW (GPA_STREAM_OPERATION (op)->progress_dialog),
_("Signing message ..."));
if (op->sign_dialog)
gtk_widget_show_all (GTK_WIDGET (op->sign_dialog));
return object;
}
static void
gpa_stream_sign_operation_class_init (GpaStreamSignOperationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gpa_stream_sign_operation_ctor;
object_class->finalize = gpa_stream_sign_operation_finalize;
object_class->set_property = gpa_stream_sign_operation_set_property;
object_class->get_property = gpa_stream_sign_operation_get_property;
g_object_class_install_property
(object_class, PROP_SENDER,
g_param_spec_pointer
("sender", "Sender",
"The sender of the message in rfc-822 mailbox format or NULL.",
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_PROTOCOL,
g_param_spec_int
("protocol", "Protocol",
"The requested gpgme protocol.",
GPGME_PROTOCOL_OpenPGP, GPGME_PROTOCOL_UNKNOWN, GPGME_PROTOCOL_UNKNOWN,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_DETACHED,
g_param_spec_boolean
("detached", "Detached",
"Flag requesting a detached signature.",
FALSE,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
}
GType
gpa_stream_sign_operation_get_type (void)
{
static GType stream_sign_operation_type = 0;
if (!stream_sign_operation_type)
{
static const GTypeInfo stream_sign_operation_info =
{
sizeof (GpaStreamSignOperationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gpa_stream_sign_operation_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GpaStreamSignOperation),
0, /* n_preallocs */
(GInstanceInitFunc) gpa_stream_sign_operation_init,
};
stream_sign_operation_type = g_type_register_static
(GPA_STREAM_OPERATION_TYPE, "GpaStreamSignOperation",
&stream_sign_operation_info, 0);
}
return stream_sign_operation_type;
}
/* Setting the signers and the protocol for the context. The protocol
* to use is derived from the keys. An error will be displayed if the
* selected keys are not all of one protocol. Returns true on
* success. */
static gboolean
set_signers (GpaStreamSignOperation *op, GList *signers)
{
GList *cur;
gpg_error_t err;
gpgme_protocol_t protocol = GPGME_PROTOCOL_UNKNOWN;
gpgme_signers_clear (GPA_OPERATION (op)->context->ctx);
if (!signers)
{
/* Can't happen */
gpa_window_error (_("You didn't select any key for signing"),
GPA_OPERATION (op)->window);
return FALSE;
}
for (cur = signers; cur; cur = g_list_next (cur))
{
gpgme_key_t key = cur->data;
if (protocol == GPGME_PROTOCOL_UNKNOWN)
protocol = key->protocol;
else if (key->protocol != protocol)
{
/* Should not happen because the selection dialog should
have not allowed to select different key types. */
gpa_window_error
(_("The selected certificates are not all of the same type."
" That is, you mixed OpenPGP and X.509 certificates."
" Please make sure to select only certificates of the"
" same type."),
GPA_OPERATION (op)->window);
return FALSE;
}
}
gpgme_set_protocol (GPA_OPERATION (op)->context->ctx, protocol);
for (cur = signers; cur; cur = g_list_next (cur))
{
gpgme_key_t key = cur->data;
err = gpgme_signers_add (GPA_OPERATION (op)->context->ctx, key);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- gpa_gpgme_error (err);
- }
+ if (err)
+ gpa_gpgme_error (err);
}
return TRUE;
}
/*
* Fire up the signing
*/
static void
start_signing (GpaStreamSignOperation *op)
{
gpg_error_t err;
int prep_only = 0;
GList *signers;
gpgme_protocol_t protocol;
signers = gpa_file_sign_dialog_signers
(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
if (!set_signers (op, signers))
{
err = gpg_error (GPG_ERR_NO_SECKEY);
goto leave;
}
protocol = gpgme_get_protocol (GPA_OPERATION (op)->context->ctx);
if (protocol == GPGME_PROTOCOL_OpenPGP)
err = gpa_operation_write_status (GPA_OPERATION (op), "PROTOCOL",
"OpenPGP", NULL);
else if (protocol == GPGME_PROTOCOL_CMS)
err = gpa_operation_write_status (GPA_OPERATION (op), "PROTOCOL",
"CMS", NULL);
else
err = gpg_error (GPG_ERR_NO_SECKEY);
if (err)
goto leave;
/* Set the output encoding. */
if (GPA_STREAM_OPERATION (op)->input_stream
&& GPA_STREAM_OPERATION (op)->output_stream)
{
if (protocol == GPGME_PROTOCOL_CMS)
gpgme_data_set_encoding (GPA_STREAM_OPERATION (op)->output_stream,
GPGME_DATA_ENCODING_BASE64);
else
gpgme_set_armor (GPA_OPERATION (op)->context->ctx, 1);
err = gpgme_op_sign_start (GPA_OPERATION (op)->context->ctx,
GPA_STREAM_OPERATION (op)->input_stream,
GPA_STREAM_OPERATION (op)->output_stream,
(op->detached? GPGME_SIG_MODE_DETACH
/* */ : GPGME_SIG_MODE_NORMAL));
if (err)
{
gpa_gpgme_warning (err);
goto leave;
}
/* Show and update the progress dialog. */
gtk_widget_show_all (GPA_STREAM_OPERATION (op)->progress_dialog);
gpa_progress_dialog_set_label
(GPA_PROGRESS_DIALOG (GPA_STREAM_OPERATION (op)->progress_dialog),
_("Message signing"));
}
else
{
/* We are just preparing an encryption. */
prep_only = 1;
err = 0;
}
leave:
if (err || prep_only)
- {
- gpa_operation_server_finish (GPA_OPERATION (op), err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
- }
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
/* The recipient key selection dialog has returned. */
static void
response_cb (GtkDialog *dialog, int response, void *user_data)
{
GpaStreamSignOperation *op = user_data;
gtk_widget_hide (GTK_WIDGET (dialog));
if (response != GTK_RESPONSE_OK)
{
/* The dialog was canceled, so we do nothing and complete the
- * operation. */
- gpa_operation_server_finish (GPA_OPERATION (op),
- gpg_error (GPG_ERR_CANCELED));
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ operation. */
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed",
+ gpg_error (GPG_ERR_CANCELED));
return;
}
start_signing (op);
}
/* This is the idle function used to start the encryption if no
recipient key selection dialog has been requested. */
#if 0 /* Not yet used. */
static gboolean
start_signing_cb (void *user_data)
{
GpaStreamSignOperation *op = user_data;
start_signing (op);
return FALSE; /* Remove this callback from the event loop. */
}
#endif
/* Show an error message. */
static void
done_error_cb (GpaContext *context, gpg_error_t err,
GpaStreamSignOperation *op)
{
switch (gpg_err_code (err))
{
case GPG_ERR_NO_ERROR:
case GPG_ERR_CANCELED:
/* Ignore these */
break;
case GPG_ERR_BAD_PASSPHRASE:
gpa_window_error (_("Wrong passphrase!"), GPA_OPERATION (op)->window);
break;
default:
gpa_gpgme_warning (err);
break;
}
}
/* Operation is ready. Tell the server. */
static void
done_cb (GpaContext *context, gpg_error_t err, GpaStreamSignOperation *op)
{
gtk_widget_hide (GPA_STREAM_OPERATION (op)->progress_dialog);
- /* Tell the server that we finished and delete ourself. */
- gpa_operation_server_finish (GPA_OPERATION (op), err);
- g_signal_emit_by_name (GPA_OPERATION (op), "completed");
+ g_signal_emit_by_name (GPA_OPERATION (op), "completed", err);
}
-/************************************************************
- ********************** Public API ************************
- ************************************************************/
+/* Public API. */
-/* Start signing INPUT_STREAM to OUTPUT_STREAM using SERVER_CTX and
- WINDOW. SENDER gives the name of the sender's role (usually a
- mailbox) or is NULL for the default sender.
+/* Start signing INPUT_STREAM to OUTPUT_STREAM using WINDOW. SENDER
+ gives the name of the sender's role (usually a mailbox) or is NULL
+ for the default sender.
If it is not possible to unambigiously select a signing key a key
selection dialog offers the user a way to manually select signing
keys. INPUT_STREAM and OUTPUT_STREAM may be given as NULL in which
case the function skips the actual signing step and just verifies
the signing key. */
GpaStreamSignOperation*
gpa_stream_sign_operation_new (GtkWidget *window,
gpgme_data_t input_stream,
gpgme_data_t output_stream,
- const char *sender,
+ const gchar *sender,
gpgme_protocol_t protocol,
- gboolean detached,
- void *server_ctx)
+ gboolean detached)
{
GpaStreamSignOperation *op;
op = g_object_new (GPA_STREAM_SIGN_OPERATION_TYPE,
"window", window,
"input_stream", input_stream,
"output_stream", output_stream,
"sender", sender,
"protocol", (int)protocol,
"detached", detached,
- "server-ctx", server_ctx,
NULL);
return op;
}
diff --git a/src/gpastreamsignop.h b/src/gpastreamsignop.h
index 3cc2d28..d088a95 100644
--- a/src/gpastreamsignop.h
+++ b/src/gpastreamsignop.h
@@ -1,77 +1,76 @@
/* gpastreamsignop.h - The GpaStreamSignOperation object.
* Copyright (C) 2008 g10 Code GmbH
*
* This file is part of GPA
*
* GPA 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 3 of the License, or
* (at your option) any later version.
*
* GPA 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPA_STREAM_SIGN_OP_H
#define GPA_STREAM_SIGN_OP_H
#include <glib.h>
#include <glib-object.h>
#include "gpastreamop.h"
/* GObject stuff */
#define GPA_STREAM_SIGN_OPERATION_TYPE \
(gpa_stream_sign_operation_get_type ())
#define GPA_STREAM_SIGN_OPERATION(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), GPA_STREAM_SIGN_OPERATION_TYPE,\
GpaStreamSignOperation))
#define GPA_STREAM_SIGN_OPERATION_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
GPA_STREAM_SIGN_OPERATION_TYPE, \
GpaStreamSignOperationClass))
#define GPA_IS_STREAM_SIGN_OPERATION(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
GPA_STREAM_SIGN_OPERATION_TYPE))
#define GPA_IS_STREAM_SIGN_OPERATION_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
GPA_STREAM_SIGN_OPERATION_TYPE))
#define GPA_STREAM_SIGN_OPERATION_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
GPA_STREAM_SIGN_OPERATION_TYPE, \
GpaStreamSignOperationClass))
typedef struct _GpaStreamSignOperation GpaStreamSignOperation;
typedef struct _GpaStreamSignOperationClass GpaStreamSignOperationClass;
GType gpa_stream_sign_operation_get_type (void) G_GNUC_CONST;
/************************************
************ Public API ************
************************************/
/* Creates a new sign operation. */
GpaStreamSignOperation*
gpa_stream_sign_operation_new (GtkWidget *window,
gpgme_data_t input_stream,
gpgme_data_t output_stream,
- const char *sender,
+ const gchar *sender,
gpgme_protocol_t protocol,
- gboolean detached,
- void *server_ctx);
+ gboolean detached);
#endif /*GPA_STREAM_SIGN_OP_H*/
diff --git a/src/server.c b/src/server.c
index 85af5c5..bbdf068 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1,1134 +1,1148 @@
/* server.c - The UI server part of GPA.
* Copyright (C) 2007, 2008 g10 Code GmbH
*
* This file is part of GPA
*
* GPA 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 3 of the License, or
* (at your option) any later version.
*
* GPA 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#ifndef HAVE_W32_SYSTEM
# include <sys/socket.h>
# include <sys/un.h>
#endif /*HAVE_W32_SYSTEM*/
#include <gpgme.h>
#include <glib.h>
#include <assuan.h>
#include "gpa.h"
#include "i18n.h"
#include "gpastreamencryptop.h"
+#include "gpastreamsignop.h"
#define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t))
/* The object used to keep track of the a connection's state. */
struct conn_ctrl_s;
typedef struct conn_ctrl_s *conn_ctrl_t;
struct conn_ctrl_s
{
/* True if we are currently processing a command. */
int in_command;
/* NULL or continuation function for a command. */
void (*cont_cmd) (assuan_context_t, gpg_error_t);
/* Flag indicating that the client died while a continuation was
still registyered. */
int client_died;
/* This is a helper to detect that the unfinished erroe code actually
comes from our command handler. */
int is_unfinished;
/* An GPAOperation object. */
GpaOperation *gpa_op;
/* File descriptors used by the gpgme callbacks. */
int input_fd;
int output_fd;
/* Channels used with the gpgme callbacks. */
GIOChannel *input_channel;
GIOChannel *output_channel;
/* List of collected recipients. */
GSList *recipients;
/* Array of keys already prepared for RECIPIENTS. */
gpgme_key_t *recipient_keys;
/* The protocol as selected by the user. */
gpgme_protocol_t selected_protocol;
/* The current sender address (malloced). */
- char *sender;
+ gchar *sender;
};
/* The number of active connections. */
static int connection_counter;
/* A flag requesting a shutdown. */
static gboolean shutdown_pending;
/* The nonce used by the server connection. This nonce is required
uner Windows to emulate Unix Domain Sockets. This is managed by
libassuan but we need to store the nonce in the application. Under
Unix this is just a stub. */
static assuan_sock_nonce_t socket_nonce;
static int
not_finished (conn_ctrl_t ctrl)
{
ctrl->is_unfinished = 1;
return gpg_error (GPG_ERR_UNFINISHED);
}
/* Test whether LINE contains thye option NAME. An optional argument
of the option is ignored. For example with NAME being "--protocol"
this function returns true for "--protocol" as well as for
"--protocol=foo". The returned pointer points right behind the
option name, which may be an equal sign, Nul or a space. If tehre
is no option NAME, false (i.e. NULL) is returned.
*/
static const char *
has_option_name (const char *line, const char *name)
{
const char *s;
int n = strlen (name);
s = strstr (line, name);
return (s && (s == line || spacep (s-1))
&& (!s[n] || spacep (s+n) || s[n] == '=')) ? (s+n) : NULL;
}
/* Check whether LINE coontains the option NAME. */
static int
has_option (const char *line, const char *name)
{
const char *s;
int n = strlen (name);
s = strstr (line, name);
return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n)));
}
/* Skip over options. */
static char *
skip_options (char *line)
{
while (spacep (line))
line++;
while ( *line == '-' && line[1] == '-' )
{
while (*line && !spacep (line))
line++;
while (spacep (line))
line++;
}
return line;
}
/* Helper to be used as a GFunc for free. */
static void
free_func (void *p, void *dummy)
{
(void)dummy;
g_free (p);
}
static ssize_t
my_gpgme_read_cb (void *opaque, void *buffer, size_t size)
{
conn_ctrl_t ctrl = opaque;
GIOStatus status;
size_t nread;
int retval;
/* g_debug ("my_gpgme_read_cb: requesting %d bytes\n", (int)size); */
status = g_io_channel_read_chars (ctrl->input_channel, buffer, size,
&nread, NULL);
if (status == G_IO_STATUS_AGAIN
|| (status == G_IO_STATUS_NORMAL && !nread))
{
errno = EAGAIN;
retval = -1;
}
else if (status == G_IO_STATUS_NORMAL)
retval = (int)nread;
else if (status == G_IO_STATUS_EOF)
retval = 0;
else
{
errno = EIO;
retval = -1;
}
/* g_debug ("my_gpgme_read_cb: got status=%x, %d bytes, retval=%d\n", */
/* status, (int)size, retval); */
return retval;
}
static ssize_t
my_gpgme_write_cb (void *opaque, const void *buffer, size_t size)
{
conn_ctrl_t ctrl = opaque;
GIOStatus status;
size_t nwritten;
int retval;
status = g_io_channel_write_chars (ctrl->output_channel, buffer, size,
&nwritten, NULL);
if (status == G_IO_STATUS_AGAIN)
{
errno = EAGAIN;
retval = -1;
}
else if (status == G_IO_STATUS_NORMAL)
retval = (int)nwritten;
else
{
errno = EIO;
retval = 1;
}
return retval;
}
static struct gpgme_data_cbs my_gpgme_data_cbs =
{
my_gpgme_read_cb,
my_gpgme_write_cb,
NULL,
NULL
};
/* Release the recipients stored in the connection context. */
static void
release_recipients (conn_ctrl_t ctrl)
{
if (ctrl->recipients)
{
g_slist_foreach (ctrl->recipients, free_func, NULL);
g_slist_free (ctrl->recipients);
ctrl->recipients = NULL;
}
}
static void
release_keys (gpgme_key_t *keys)
{
if (keys)
{
int idx;
for (idx=0; keys[idx]; idx++)
gpgme_key_unref (keys[idx]);
g_free (keys);
}
}
/* Reset already prepared keys. */
static void
reset_prepared_keys (conn_ctrl_t ctrl)
{
release_keys (ctrl->recipient_keys);
ctrl->recipient_keys = NULL;
ctrl->selected_protocol = GPGME_PROTOCOL_UNKNOWN;
}
-
+/* Forward declaration. */
+static void run_server_continuation (assuan_context_t ctx, gpg_error_t err);
+
/* RECIPIENT <recipient>
Set the recipient for the encryption. <recipient> is an RFC2822
recipient name. This command may or may not check the recipient for
validity right away; if it does not (as here) all recipients are
checked at the time of the ENCRYPT command. All RECIPIENT commands
are cumulative until a RESET or an successful ENCRYPT command. */
static int
cmd_recipient (assuan_context_t ctx, char *line)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err = 0;
reset_prepared_keys (ctrl);
if (*line)
ctrl->recipients = g_slist_append (ctrl->recipients, xstrdup (line));
return assuan_process_done (ctx, err);
}
/* Continuation for cmd_encrypt. */
static void
cont_encrypt (assuan_context_t ctx, gpg_error_t err)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
g_debug ("cont_encrypt called with with ERR=%s <%s>",
gpg_strerror (err), gpg_strsource (err));
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
ctrl->input_channel = NULL;
}
if (ctrl->output_channel)
{
g_io_channel_shutdown (ctrl->output_channel, 0, NULL);
ctrl->output_channel = NULL;
}
if (!err)
release_recipients (ctrl);
assuan_process_done (ctx, err);
}
/* ENCRYPT --protocol=OpenPGP|CMS
Encrypt the data received on INPUT to OUTPUT.
*/
static int
cmd_encrypt (assuan_context_t ctx, char *line)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err;
gpgme_protocol_t protocol = 0;
GpaStreamEncryptOperation *op;
gpgme_data_t input_data = NULL;
gpgme_data_t output_data = NULL;
if (has_option (line, "--protocol=OpenPGP"))
protocol = GPGME_PROTOCOL_OpenPGP;
else if (has_option (line, "--protocol=CMS"))
protocol = GPGME_PROTOCOL_CMS;
else if (has_option_name (line, "--protocol"))
{
err = set_error (GPG_ERR_ASS_PARAMETER, "invalid protocol");
goto leave;
}
else
{
err = set_error (GPG_ERR_ASS_PARAMETER, "no protocol specified");
goto leave;
}
if (protocol != ctrl->selected_protocol)
{
if (ctrl->selected_protocol != GPGME_PROTOCOL_UNKNOWN)
g_debug ("note: protocol does not macth the one from PREP_ENCRYPT");
reset_prepared_keys (ctrl);
}
line = skip_options (line);
if (*line)
{
err = set_error (GPG_ERR_ASS_SYNTAX, NULL);
goto leave;
}
ctrl->input_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
if (ctrl->input_fd == -1)
{
err = set_error (GPG_ERR_ASS_NO_INPUT, NULL);
goto leave;
}
ctrl->output_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
if (ctrl->output_fd == -1)
{
err = set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
goto leave;
}
#ifdef HAVE_W32_SYSTEM
ctrl->input_channel = g_io_channel_win32_new_fd (ctrl->input_fd);
#else
ctrl->input_channel = g_io_channel_unix_new (ctrl->input_fd);
#endif
if (!ctrl->input_channel)
{
g_debug ("error creating input channel");
err = GPG_ERR_EIO;
goto leave;
}
g_io_channel_set_encoding (ctrl->input_channel, NULL, NULL);
g_io_channel_set_buffered (ctrl->input_channel, FALSE);
#ifdef HAVE_W32_SYSTEM
ctrl->output_channel = g_io_channel_win32_new_fd (ctrl->output_fd);
#else
ctrl->output_channel = g_io_channel_unix_new (ctrl->output_fd);
#endif
if (!ctrl->output_channel)
{
g_debug ("error creating output channel");
err = GPG_ERR_EIO;
goto leave;
}
g_io_channel_set_encoding (ctrl->output_channel, NULL, NULL);
g_io_channel_set_buffered (ctrl->output_channel, FALSE);
err = gpgme_data_new_from_cbs (&input_data, &my_gpgme_data_cbs, ctrl);
if (err)
goto leave;
err = gpgme_data_new_from_cbs (&output_data, &my_gpgme_data_cbs, ctrl);
if (err)
goto leave;
ctrl->cont_cmd = cont_encrypt;
op = gpa_stream_encrypt_operation_new (NULL, input_data, output_data,
ctrl->recipients,
ctrl->recipient_keys,
- protocol,
- 0, ctx);
+ protocol, 0);
input_data = output_data = NULL;
+ g_signal_connect_swapped (G_OBJECT (op), "completed",
+ G_CALLBACK (run_server_continuation), ctx);
g_signal_connect (G_OBJECT (op), "completed",
G_CALLBACK (g_object_unref), NULL);
+ g_signal_connect_swapped (G_OBJECT (op), "status",
+ G_CALLBACK (assuan_write_status), ctx);
return not_finished (ctrl);
leave:
gpgme_data_release (input_data);
gpgme_data_release (output_data);
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
ctrl->input_channel = NULL;
}
if (ctrl->output_channel)
{
g_io_channel_shutdown (ctrl->output_channel, 0, NULL);
ctrl->output_channel = NULL;
}
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return assuan_process_done (ctx, err);
}
/* Continuation for cmd_prep_encrypt. */
static void
cont_prep_encrypt (assuan_context_t ctx, gpg_error_t err)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
g_debug ("cont_prep_encrypt called with with ERR=%s <%s>",
gpg_strerror (err), gpg_strsource (err));
if (!err)
{
release_keys (ctrl->recipient_keys);
ctrl->recipient_keys = gpa_stream_encrypt_operation_get_keys
(GPA_STREAM_ENCRYPT_OPERATION (ctrl->gpa_op),
&ctrl->selected_protocol);
if (ctrl->recipient_keys)
g_print ("received some keys\n");
else
g_print ("received no keys\n");
}
if (ctrl->gpa_op)
{
g_object_unref (ctrl->gpa_op);
ctrl->gpa_op = NULL;
}
assuan_process_done (ctx, err);
}
/* PREP_ENCRYPT [--protocol=OpenPGP|CMS]
Dummy encryption command used to check whether the given recipients
are all valid and to tell the client the preferred protocol. */
static int
cmd_prep_encrypt (assuan_context_t ctx, char *line)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err;
gpgme_protocol_t protocol = GPGME_PROTOCOL_UNKNOWN;
GpaStreamEncryptOperation *op;
if (has_option (line, "--protocol=OpenPGP"))
protocol = GPGME_PROTOCOL_OpenPGP;
else if (has_option (line, "--protocol=CMS"))
protocol = GPGME_PROTOCOL_CMS;
else if (has_option_name (line, "--protocol"))
{
err = set_error (GPG_ERR_ASS_PARAMETER, "invalid protocol");
goto leave;
}
line = skip_options (line);
if (*line)
{
err = set_error (GPG_ERR_ASS_SYNTAX, NULL);
goto leave;
}
reset_prepared_keys (ctrl);
if (ctrl->gpa_op)
{
g_debug ("Oops: there is still an GPA_OP active\n");
g_object_unref (ctrl->gpa_op);
ctrl->gpa_op = NULL;
}
ctrl->cont_cmd = cont_prep_encrypt;
op = gpa_stream_encrypt_operation_new (NULL, NULL, NULL,
ctrl->recipients,
ctrl->recipient_keys,
- protocol,
- 0, ctx);
+ protocol, 0);
/* Store that instance for later use but also install a signal
handler to unref it. */
g_object_ref (op);
ctrl->gpa_op = GPA_OPERATION (op);
+ g_signal_connect_swapped (G_OBJECT (op), "completed",
+ G_CALLBACK (run_server_continuation), ctx);
g_signal_connect (G_OBJECT (op), "completed",
G_CALLBACK (g_object_unref), NULL);
+ g_signal_connect_swapped (G_OBJECT (op), "status",
+ G_CALLBACK (assuan_write_status), ctx);
return not_finished (ctrl);
leave:
return assuan_process_done (ctx, err);
}
/* SENDER <email>
EMAIL is the plain ASCII encoded address ("addr-spec" as per
RFC-2822) enclosed in angle brackets. The address set by this
command is valid until a successful @code{SIGN} command or until a
@code{RESET} command. A second command overrides the effect of
the first one; if EMAIL is not given the server shall use the
default signing key. */
static int
cmd_sender (assuan_context_t ctx, char *line)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err = 0;
xfree (ctrl->sender);
ctrl->sender = NULL;
if (*line)
ctrl->sender = xstrdup (line);
return assuan_process_done (ctx, err);
}
/* Continuation for cmd_sign. */
static void
cont_sign (assuan_context_t ctx, gpg_error_t err)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
g_debug ("cont_sign called with with ERR=%s <%s>",
gpg_strerror (err), gpg_strsource (err));
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
ctrl->input_channel = NULL;
}
if (ctrl->output_channel)
{
g_io_channel_shutdown (ctrl->output_channel, 0, NULL);
ctrl->output_channel = NULL;
}
if (!err)
{
xfree (ctrl->sender);
ctrl->sender = NULL;
}
assuan_process_done (ctx, err);
}
/* SIGN --protocol=OpenPGP|CMS [--detached]
Sign the data received on INPUT to OUTPUT.
*/
static int
cmd_sign (assuan_context_t ctx, char *line)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err;
gpgme_protocol_t protocol = 0;
- int detached;
- GpaStreamEncryptOperation *op;
+ gboolean detached;
+ GpaStreamSignOperation *op;
gpgme_data_t input_data = NULL;
gpgme_data_t output_data = NULL;
if (has_option (line, "--protocol=OpenPGP"))
protocol = GPGME_PROTOCOL_OpenPGP;
else if (has_option (line, "--protocol=CMS"))
protocol = GPGME_PROTOCOL_CMS;
else if (has_option_name (line, "--protocol"))
{
err = set_error (GPG_ERR_ASS_PARAMETER, "invalid protocol");
goto leave;
}
else
{
err = set_error (GPG_ERR_ASS_PARAMETER, "no protocol specified");
goto leave;
}
detached = has_option (line, "--detached");
line = skip_options (line);
if (*line)
{
err = set_error (GPG_ERR_ASS_SYNTAX, NULL);
goto leave;
}
ctrl->input_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
if (ctrl->input_fd == -1)
{
err = set_error (GPG_ERR_ASS_NO_INPUT, NULL);
goto leave;
}
ctrl->output_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
if (ctrl->output_fd == -1)
{
err = set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
goto leave;
}
#ifdef HAVE_W32_SYSTEM
ctrl->input_channel = g_io_channel_win32_new_fd (ctrl->input_fd);
#else
ctrl->input_channel = g_io_channel_unix_new (ctrl->input_fd);
#endif
if (!ctrl->input_channel)
{
g_debug ("error creating input channel");
err = GPG_ERR_EIO;
goto leave;
}
g_io_channel_set_encoding (ctrl->input_channel, NULL, NULL);
g_io_channel_set_buffered (ctrl->input_channel, FALSE);
#ifdef HAVE_W32_SYSTEM
ctrl->output_channel = g_io_channel_win32_new_fd (ctrl->output_fd);
#else
ctrl->output_channel = g_io_channel_unix_new (ctrl->output_fd);
#endif
if (!ctrl->output_channel)
{
g_debug ("error creating output channel");
err = GPG_ERR_EIO;
goto leave;
}
g_io_channel_set_encoding (ctrl->output_channel, NULL, NULL);
g_io_channel_set_buffered (ctrl->output_channel, FALSE);
err = gpgme_data_new_from_cbs (&input_data, &my_gpgme_data_cbs, ctrl);
if (err)
goto leave;
err = gpgme_data_new_from_cbs (&output_data, &my_gpgme_data_cbs, ctrl);
if (err)
goto leave;
ctrl->cont_cmd = cont_sign;
op = gpa_stream_sign_operation_new (NULL, input_data, output_data,
- ctrl->sender, protocol, detached, ctx);
+ ctrl->sender, protocol, detached);
input_data = output_data = NULL;
+ g_signal_connect_swapped (G_OBJECT (op), "completed",
+ G_CALLBACK (run_server_continuation), ctx);
g_signal_connect (G_OBJECT (op), "completed",
G_CALLBACK (g_object_unref), NULL);
+ g_signal_connect_swapped (G_OBJECT (op), "status",
+ G_CALLBACK (assuan_write_status), ctx);
+
return not_finished (ctrl);
leave:
gpgme_data_release (input_data);
gpgme_data_release (output_data);
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
ctrl->input_channel = NULL;
}
if (ctrl->output_channel)
{
g_io_channel_shutdown (ctrl->output_channel, 0, NULL);
ctrl->output_channel = NULL;
}
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return assuan_process_done (ctx, err);
}
/* START_KEYMANAGER
Pop up the key manager window. The client expects that the key
manager is brought into the foregound and that this command
immediatley returns.
*/
static int
cmd_start_keymanager (assuan_context_t ctx, char *line)
{
gpa_open_keyring_editor (NULL, NULL);
return assuan_process_done (ctx, 0);
}
/* GETINFO <what>
Multipurpose function to return a variety of information.
Supported values for WHAT are:
version - Return the version of the program.
pid - Return the process id of the server.
*/
static int
cmd_getinfo (assuan_context_t ctx, char *line)
{
gpg_error_t err;
if (!strcmp (line, "version"))
{
const char *s = PACKAGE_NAME " " PACKAGE_VERSION;
err = assuan_send_data (ctx, s, strlen (s));
}
else if (!strcmp (line, "pid"))
{
char numbuf[50];
snprintf (numbuf, sizeof numbuf, "%lu", (unsigned long)getpid ());
err = assuan_send_data (ctx, numbuf, strlen (numbuf));
}
else
err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
return assuan_process_done (ctx, err);
}
static void
reset_notify (assuan_context_t ctx)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
reset_prepared_keys (ctrl);
release_recipients (ctrl);
xfree (ctrl->sender);
ctrl->sender = NULL;
if (ctrl->input_channel)
{
g_io_channel_shutdown (ctrl->input_channel, 0, NULL);
ctrl->input_channel = NULL;
}
if (ctrl->output_channel)
{
g_io_channel_shutdown (ctrl->output_channel, 0, NULL);
ctrl->output_channel = NULL;
}
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
if (ctrl->gpa_op)
{
g_object_unref (ctrl->gpa_op);
ctrl->gpa_op = NULL;
}
}
/* Tell the assuan library about our commands. */
static int
register_commands (assuan_context_t ctx)
{
static struct {
const char *name;
int (*handler)(assuan_context_t, char *line);
} table[] = {
{ "RECIPIENT", cmd_recipient },
{ "INPUT", NULL },
{ "OUTPUT", NULL },
{ "ENCRYPT", cmd_encrypt },
{ "PREP_ENCRYPT", cmd_prep_encrypt },
{ "SENDER", cmd_sender },
{ "SIGN", cmd_sign },
{ "START_KEYMANAGER", cmd_start_keymanager },
{ "GETINFO", cmd_getinfo },
{ NULL }
};
int i, rc;
for (i=0; table[i].name; i++)
{
rc = assuan_register_command (ctx, table[i].name, table[i].handler);
if (rc)
return rc;
}
return 0;
}
/* Prepare for a new connection on descriptor FD. */
static assuan_context_t
connection_startup (int fd)
{
gpg_error_t err;
assuan_context_t ctx;
conn_ctrl_t ctrl;
/* Get an Assuan context for the already accepted file descriptor
FD. Allow descriptor passing. */
err = assuan_init_socket_server_ext (&ctx, ASSUAN_INT2FD(fd), 1|2);
if (err)
{
g_debug ("failed to initialize the new connection: %s",
gpg_strerror (err));
return NULL;
}
err = register_commands (ctx);
if (err)
{
g_debug ("failed to register commands with Assuan: %s",
gpg_strerror (err));
assuan_deinit_server (ctx);
return NULL;
}
ctrl = g_malloc0 (sizeof *ctrl);
assuan_set_pointer (ctx, ctrl);
assuan_set_log_stream (ctx, stderr);
assuan_register_reset_notify (ctx, reset_notify);
connection_counter++;
return ctx;
}
/* Finish a connection. This releases all resources and needs to be
called becore the file descriptor is closed. */
static void
connection_finish (assuan_context_t ctx)
{
if (ctx)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
reset_notify (ctx);
assuan_deinit_server (ctx);
g_free (ctrl);
connection_counter--;
if (!connection_counter && shutdown_pending)
gtk_main_quit ();
}
}
/* If the assuan context CTX has a registered continuation function,
run it. */
-void
-gpa_run_server_continuation (assuan_context_t ctx, gpg_error_t err)
+static void
+run_server_continuation (assuan_context_t ctx, gpg_error_t err)
{
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
void (*cont_cmd) (assuan_context_t, gpg_error_t);
if (!ctrl)
{
g_debug ("no context in gpa_run_server_continuation");
return;
}
g_debug ("calling gpa_run_server_continuation (%s)", gpg_strerror (err));
if (!ctrl->cont_cmd)
{
g_debug ("no continuation defined; using default");
assuan_process_done (ctx, err);
}
else if (ctrl->client_died)
{
g_debug ("not running continuation as client has disconnected");
connection_finish (ctx);
}
else
{
cont_cmd = ctrl->cont_cmd;
ctrl->cont_cmd = NULL;
cont_cmd (ctx, err);
}
g_debug ("leaving gpa_run_server_continuation");
}
/* This function is called by the main event loop if data can be read
from the status channel. */
static gboolean
receive_cb (GIOChannel *channel, GIOCondition condition, void *data)
{
assuan_context_t ctx = data;
conn_ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err;
assert (ctrl);
if (condition & G_IO_IN)
{
g_debug ("receive_cb");
if (ctrl->cont_cmd)
{
g_debug (" input received while waiting for continuation");
g_usleep (2000000);
}
else if (ctrl->in_command)
{
g_debug (" input received while still processing command");
g_usleep (2000000);
}
else
{
ctrl->in_command++;
err = assuan_process_next (ctx);
ctrl->in_command--;
g_debug ("assuan_process_next returned: %s",
err == -1? "EOF": gpg_strerror (err));
if (gpg_err_code (err) == GPG_ERR_EAGAIN)
; /* Ignore. */
else if (gpg_err_code (err) == GPG_ERR_EOF || err == -1)
{
if (ctrl->cont_cmd)
ctrl->client_died = 1; /* Need to delay the cleanup. */
else
connection_finish (ctx);
return FALSE; /* Remove from the watch. */
}
else if (gpg_err_code (err) == GPG_ERR_UNFINISHED)
{
if (!ctrl->is_unfinished)
{
/* It is quite possible that some other subsystem
returns that error code. Tell the user about
this curiosity and finish the command. */
g_debug ("note: Unfinished error code not emitted by us");
if (ctrl->cont_cmd)
g_debug ("OOPS: pending continuation!");
assuan_process_done (ctx, err);
}
}
else
assuan_process_done (ctx, err);
}
}
return TRUE;
}
/* This function is called by the main event loop if the listen fd is
readable. The function runs the accept and prepares the
connection. */
static gboolean
accept_connection_cb (GIOChannel *listen_channel,
GIOCondition condition, void *data)
{
gpg_error_t err;
int listen_fd, fd;
struct sockaddr_un paddr;
socklen_t plen = sizeof paddr;
assuan_context_t ctx;
GIOChannel *channel;
unsigned int source_id;
g_debug ("new connection request");
#ifdef HAVE_W32_SYSTEM
listen_fd = g_io_channel_win32_get_fd (listen_channel);
#else
listen_fd = g_io_channel_unix_get_fd (listen_channel);
#endif
fd = accept (listen_fd, (struct sockaddr *)&paddr, &plen);
if (fd == -1)
{
g_debug ("error accepting connection: %s", strerror (errno));
goto leave;
}
if (assuan_sock_check_nonce (ASSUAN_INT2FD(fd), &socket_nonce))
{
g_debug ("new connection at fd %d refused", fd);
goto leave;
}
g_debug ("new connection at fd %d", fd);
ctx = connection_startup (fd);
if (!ctx)
goto leave;
#ifdef HAVE_W32_SYSTEM
channel = g_io_channel_win32_new_socket (fd);
#else
channel = g_io_channel_unix_new (fd);
#endif
if (!channel)
{
g_debug ("error creating a channel for fd %d\n", fd);
goto leave;
}
g_io_channel_set_encoding (channel, NULL, NULL);
g_io_channel_set_buffered (channel, FALSE);
source_id = g_io_add_watch (channel, G_IO_IN, receive_cb, ctx);
if (!source_id)
{
g_debug ("error creating watch for fd %d", fd);
g_io_channel_shutdown (channel, 0, NULL);
goto leave;
}
err = assuan_accept (ctx);
if (err)
{
g_debug ("assuan accept failed: %s", gpg_strerror (err));
g_io_channel_shutdown (channel, 0, NULL);
goto leave;
}
g_debug ("connection at fd %d ready", fd);
fd = -1;
leave:
if (fd != -1)
assuan_sock_close (ASSUAN_INT2FD (fd));
return TRUE; /* Keep the listen_fd in the event loop. */
}
/* Startup the server. */
void
gpa_start_server (void)
{
char *socket_name;
int rc;
assuan_fd_t fd;
struct sockaddr_un serv_addr;
socklen_t serv_addr_len = sizeof serv_addr;
GIOChannel *channel;
unsigned int source_id;
assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT);
socket_name = g_build_filename (gnupg_homedir, "S.uiserver", NULL);
if (strlen (socket_name)+1 >= sizeof serv_addr.sun_path )
{
g_debug ("name of socket too long\n");
g_free (socket_name);
return;
}
g_debug ("using server socket `%s'", socket_name);
fd = assuan_sock_new (AF_UNIX, SOCK_STREAM, 0);
if (fd == ASSUAN_INVALID_FD)
{
g_debug ("can't create socket: %s\n", strerror(errno));
g_free (socket_name);
return;
}
memset (&serv_addr, 0, sizeof serv_addr);
serv_addr.sun_family = AF_UNIX;
strcpy (serv_addr.sun_path, socket_name);
serv_addr_len = (offsetof (struct sockaddr_un, sun_path)
+ strlen(serv_addr.sun_path) + 1);
rc = assuan_sock_bind (fd, (struct sockaddr*) &serv_addr, serv_addr_len);
if (rc == -1 && errno == EADDRINUSE)
{
remove (socket_name);
rc = assuan_sock_bind (fd, (struct sockaddr*) &serv_addr, serv_addr_len);
}
if (rc != -1 && (rc=assuan_sock_get_nonce ((struct sockaddr*) &serv_addr,
serv_addr_len, &socket_nonce)))
g_debug ("error getting nonce for the socket");
if (rc == -1)
{
g_debug ("error binding socket to `%s': %s\n",
serv_addr.sun_path, strerror (errno) );
assuan_sock_close (fd);
g_free (socket_name);
return;
}
g_free (socket_name);
socket_name = NULL;
if (listen (ASSUAN_FD2INT (fd), 5) == -1)
{
g_debug ("listen() failed: %s\n", strerror (errno));
assuan_sock_close (fd);
return;
}
#ifdef HAVE_W32_SYSTEM
channel = g_io_channel_win32_new_socket (ASSUAN_FD2INT(fd));
#else
channel = g_io_channel_unix_new (fd);
#endif
if (!channel)
{
g_debug ("error creating a new listening channel\n");
assuan_sock_close (fd);
return;
}
g_io_channel_set_encoding (channel, NULL, NULL);
g_io_channel_set_buffered (channel, FALSE);
source_id = g_io_add_watch (channel, G_IO_IN, accept_connection_cb, NULL);
if (!source_id)
{
g_debug ("error creating watch for listening channel\n");
g_io_channel_shutdown (channel, 0, NULL);
assuan_sock_close (fd);
return;
}
}
/* Set a flag to shutdown the server in a friendly way. */
void
gpa_stop_server (void)
{
shutdown_pending = TRUE;
if (!connection_counter)
gtk_main_quit ();
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Feb 26, 7:04 PM (1 d, 2 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ae/73/9758408e7af650c74bb1ea5a5156

Event Timeline