[pkg-otr-team] [irssi-plugin-otr] 22/167: * otr-plugin.c: Use g_fopen() to open the otr files, so that on Windows, the UTF8 filename encoding is respected.

Holger Levsen holger at moszumanska.debian.org
Mon Mar 3 21:55:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to tag 4.0.0
in repository irssi-plugin-otr.

commit 317be115ba7c9574c28368d22bb423fb25c0936c
Author: cypherpunk <cypherpunk>
Date:   Mon Jul 24 14:40:04 2006 +0000

    	* otr-plugin.c: Use g_fopen() to open the otr files, so that on
    	Windows, the UTF8 filename encoding is respected.
---
 ChangeLog    |  5 +++++
 otr-plugin.c | 41 ++++++++++++++++++++++++++++++++++-------
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de2d29c..31e9566 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-24
+
+	* otr-plugin.c: Use g_fopen() to open the otr files, so that on
+	Windows, the UTF8 filename encoding is respected.
+
 2006-01-20
 
 	* otr-plugin.c: Track the gaim-2 API changes.
diff --git a/otr-plugin.c b/otr-plugin.c
index ceec0fc..77c4df8 100644
--- a/otr-plugin.c
+++ b/otr-plugin.c
@@ -60,6 +60,15 @@
 #include "gtk-dialog.h"
 #endif
 
+/* If we're using glib on Windows, we need to use g_fopen to open files.
+ * On other platforms, it's also safe to use it.  If we're not using
+ * glib, just use fopen. */
+#ifdef USING_GTK
+#include <glib/gstdio.h>
+#else
+#define g_fopen fopen
+#endif
+
 GaimPlugin *otrg_plugin_handle;
 
 /* We'll only use the one OtrlUserState. */
@@ -119,19 +128,26 @@ void otrg_plugin_create_privkey(const char *accountname,
 	const char *protocol)
 {
     OtrgDialogWaitHandle waithandle;
+    FILE *privf;
 
     gchar *privkeyfile = g_build_filename(gaim_user_dir(), PRIVKEYFNAME, NULL);
     if (!privkeyfile) {
 	fprintf(stderr, "Out of memory building filenames!\n");
 	return;
     }
+    privf = g_fopen(privkeyfile, "w+b");
+    g_free(privkeyfile);
+    if (!privf) {
+	fprintf(stderr, "Could not write private key file\n");
+	return;
+    }
 
     waithandle = otrg_dialog_private_key_wait_start(accountname, protocol);
 
     /* Generate the key */
-    otrl_privkey_generate(otrg_plugin_userstate, privkeyfile,
+    otrl_privkey_generate_FILEp(otrg_plugin_userstate, privf,
 	    accountname, protocol);
-    g_free(privkeyfile);
+    fclose(privf);
     otrg_ui_update_fingerprint();
 
     /* Mark the dialog as done. */
@@ -461,9 +477,13 @@ void otrg_plugin_disconnect(ConnContext *context)
 /* Write the fingerprints to disk. */
 void otrg_plugin_write_fingerprints(void)
 {
+    FILE *storef;
     gchar *storefile = g_build_filename(gaim_user_dir(), STOREFNAME, NULL);
-    otrl_privkey_write_fingerprints(otrg_plugin_userstate, storefile);
+    storef = g_fopen(storefile, "wb");
     g_free(storefile);
+    if (!storef) return;
+    otrl_privkey_write_fingerprints_FILEp(otrg_plugin_userstate, storef);
+    fclose(storef);
 }
 
 /* Find the ConnContext appropriate to a given GaimConversation. */
@@ -560,6 +580,8 @@ static gboolean otr_plugin_load(GaimPlugin *handle)
     void *conn_handle = gaim_connections_get_handle();
     void *blist_handle = gaim_blist_get_handle();
     void *core_handle = gaim_get_core();
+    FILE *privf;
+    FILE *storef;
 
     if (!privkeyfile || !storefile) {
 	g_free(privkeyfile);
@@ -567,16 +589,21 @@ static gboolean otr_plugin_load(GaimPlugin *handle)
 	return 0;
     }
 
+    privf = g_fopen(privkeyfile, "rb");
+    storef = g_fopen(storefile, "rb");
+    g_free(privkeyfile);
+    g_free(storefile);
+
     otrg_plugin_handle = handle;
 
     /* Make our OtrlUserState; we'll only use the one. */
     otrg_plugin_userstate = otrl_userstate_create();
 
-    otrl_privkey_read(otrg_plugin_userstate, privkeyfile);
-    g_free(privkeyfile);
-    otrl_privkey_read_fingerprints(otrg_plugin_userstate, storefile,
+    otrl_privkey_read_FILEp(otrg_plugin_userstate, privf);
+    otrl_privkey_read_fingerprints_FILEp(otrg_plugin_userstate, storef,
 	    NULL, NULL);
-    g_free(storefile);
+    if (privf) fclose(privf);
+    if (storef) fclose(storef);
 
     otrg_ui_update_fingerprint();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-otr/packages/irssi-plugin-otr.git



More information about the Pkg-otr-team mailing list