[Commits] vcard-extension.c 1.4 1.5
miras at claws-mail.org
miras at claws-mail.org
Thu Jan 5 02:38:32 CET 2012
Update of /home/claws-mail/contacts/extensions/vcard/src
In directory claws-mail:/tmp/cvs-serv25056/extensions/vcard/src
Modified Files:
vcard-extension.c
Log Message:
2012-01-05 [mir] 0.6.0cvs76
* extensions/vcard/src/vcard-extension.c
Fix likely dereferencing of NULL pointer
Index: vcard-extension.c
===================================================================
RCS file: /home/claws-mail/contacts/extensions/vcard/src/vcard-extension.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- vcard-extension.c 3 Jan 2012 23:01:54 -0000 1.4
+++ vcard-extension.c 5 Jan 2012 01:38:30 -0000 1.5
@@ -38,6 +38,7 @@
#include <glib/gprintf.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -60,8 +61,14 @@
static gchar* vcard_file_chooser(MenuItem* item, int mode) {
GtkWidget* dialog;
gchar* filename = NULL;
+ gchar* title;
- dialog = gtk_file_chooser_dialog_new(_("Open file"),
+ if (mode == GTK_FILE_CHOOSER_ACTION_SAVE)
+ title = N_("Save file");
+ else
+ title = N_("Open file");
+
+ dialog = gtk_file_chooser_dialog_new(title,
GTK_WINDOW(item->mainwindow->window),
mode,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -106,7 +113,7 @@
abook = get_selected_address_book(view);
if (abook == NULL) {
iter = set_selection_combobox(item->mainwindow->window,
- _("[New Contact] Choose address book"),
+ _("[vCard Import] Choose address book"),
gtk_tree_view_get_model(view),
BOOK_NAME_COLUMN);
if (! iter)
@@ -115,6 +122,7 @@
row = gtk_tree_view_get_selection(view);
gtk_tree_selection_select_iter(row, iter);
g_free(iter);
+ abook = get_selected_address_book(view);
}
plugin = get_selected_plugin(GTK_TREE_VIEW(item->mainwindow->abook_list));
@@ -191,7 +199,7 @@
abook = get_selected_address_book(view);
if (abook == NULL) {
iter = set_selection_combobox(item->mainwindow->window,
- _("[New Contact] Choose address book"),
+ _("[vCard Export] Choose address book"),
gtk_tree_view_get_model(view),
BOOK_NAME_COLUMN);
if (! iter)
@@ -200,6 +208,7 @@
row = gtk_tree_view_get_selection(view);
gtk_tree_selection_select_iter(row, iter);
g_free(iter);
+ abook = get_selected_address_book(view);
}
plugin = get_selected_plugin(GTK_TREE_VIEW(item->mainwindow->abook_list));
@@ -257,10 +266,40 @@
_("%s: Exported %d contacts"), abook->abook_name, count);
}
+static void vcard_create(GtkWidget* widget, gpointer data) {
+ MenuItem* item = (MenuItem *) data;
+ VObject* vcard;
+ gchar* error = NULL;
+ FILE* fp;
+
+ vcard = personal_vcard(&error);
+ if (error) {
+ show_message(item->mainwindow->window, GTK_UTIL_MESSAGE_ERROR, error);
+ }
+ else if (vcard) {
+ gchar* file = vcard_file_chooser(item, GTK_FILE_CHOOSER_ACTION_SAVE);
+ if (! file)
+ return;
+ fp = g_fopen(file, "w");
+ if (! fp) {
+ show_message(item->mainwindow->window, GTK_UTIL_MESSAGE_ERROR, strerror(errno));
+ g_free(file);
+ return;
+ }
+ g_free(file);
+ writeVObject(fp, vcard);
+ fclose(fp);
+ }
+ if (vcard) {
+ cleanVObject(vcard);
+ }
+}
+
static void setup(const MainWindow* mainwindow, gpointer object) {
GtkWidget *menu;
MenuItem* menu_item;
+ // Add a menu item into the tools menu
menu = gtk_image_menu_item_new_with_mnemonic("_vCard");
menu_item = menu_item_new();
menu_item->menu = CONTACTS_MAIN_MENU;
@@ -272,6 +311,7 @@
G_CALLBACK(vcard_export), (gpointer) menu_item);
add_menu_item(GTK_IMAGE_MENU_ITEM(menu), menu_item);
+ // Add a menu item into the tools menu
menu = gtk_image_menu_item_new_with_mnemonic("_vCard");
menu_item = menu_item_new();
menu_item->menu = CONTACTS_MAIN_MENU;
@@ -283,6 +323,20 @@
G_CALLBACK(vcard_import), (gpointer) menu_item);
add_menu_item(GTK_IMAGE_MENU_ITEM(menu), menu_item);
+ // Add a menu item into the tools menu
+ menu = gtk_image_menu_item_new_with_mnemonic("_Create vCard");
+ gtk_widget_add_accelerator(menu, "activate", mainwindow->accel,
+ GDK_C, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ menu_item = menu_item_new();
+ menu_item->menu = CONTACTS_MAIN_MENU;
+ menu_item->parent = "tools";
+ menu_item->sublabel = NULL;
+ menu_item->submenu = FALSE;
+ menu_item->mainwindow = mainwindow;
+ g_signal_connect(menu, "activate",
+ G_CALLBACK(vcard_create), (gpointer) menu_item);
+ add_menu_item(GTK_IMAGE_MENU_ITEM(menu), menu_item);
+
// Add a menu item into the context menu of contact
menu = gtk_image_menu_item_new_with_mnemonic("_vCard");
menu_item = menu_item_new();
More information about the Commits
mailing list