changeset 9426:dfee44a581a4

[gaim-migrate @ 10244] " This patch causes gaim to write out a file containing an ascii representation of the big-endian version of the port number which gaim listens in on for incoming zephyrs, of the form "gaimwgXXXXXX". It will be useful for debugging occasional problems with zephyr loss of subscriptions (chats). I've made some changes in util.c to allow the creation of temporary files with arbitrary templates: I've renamed gaim_mkstemp to gaim_mkstemp_template, modifying it to take a second argument, template, and use that instead of gaim_mkstemp_templ. A new gaim_mkstemp which is a wrapper around gaim_mkstemp_template has been put in place for compatibility with all the existing code using this function." --Arun A Tharuvai "The patch I submitted causes the wgfile to always be written out, because it would be useful for endusers too, and also to try to keep it consistent with the standard zephyr distribution." --Arun A Tharuvai committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 29 Jun 2004 17:23:08 +0000
parents 42afbd004e6a
children 66b3f54527e6
files src/protocols/zephyr/zephyr.c src/util.c src/util.h
diffstat 3 files changed, 38 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/zephyr/zephyr.c	Tue Jun 29 13:33:44 2004 +0000
+++ b/src/protocols/zephyr/zephyr.c	Tue Jun 29 17:23:08 2004 +0000
@@ -894,7 +894,9 @@
 static void zephyr_login(GaimAccount * account)
 {
 	ZSubscription_t sub;
-
+	unsigned short port = 0;
+	FILE* wgfile;
+	char* wgfilename;
 	if (zgc) {
 		gaim_notify_error(account->gc, NULL,
 						  _("Already logged in with Zephyr"), _("Because Zephyr uses your system username, you " "are unable to have multiple accounts on it " "when logged in as the same user."));
@@ -906,19 +908,24 @@
 	gaim_connection_update_progress(zgc, _("Connecting"), 0, 2);
 
 	z_call_s(ZInitialize(), "Couldn't initialize zephyr");
-	z_call_s(ZOpenPort(NULL), "Couldn't open port");
+	z_call_s(ZOpenPort(&port), "Couldn't open port");
 	z_call_s(ZSetLocation((char *)
 						  gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location");
 
 	sub.zsub_class = "MESSAGE";
 	sub.zsub_classinst = "PERSONAL";
 	sub.zsub_recipient = (char *)gaim_zephyr_get_sender();
-
+	
 	/* we don't care if this fails. i'm lying right now. */
 	if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
 		gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to messages!\n");
 	}
 
+	wgfile = gaim_mkstemp_template(&wgfilename,"gaimwgXXXXXX");
+	if (wgfile) {
+		fprintf(wgfile,"%d\n",port);
+		fclose(wgfile);
+	}
 	gaim_connection_set_state(zgc, GAIM_CONNECTED);
 	serv_finish_login(zgc);
 
--- a/src/util.c	Tue Jun 29 13:33:44 2004 +0000
+++ b/src/util.c	Tue Jun 29 17:23:08 2004 +0000
@@ -1951,7 +1951,13 @@
 static const char *gaim_mkstemp_templ = {"gaimXXXXXX"};
 
 FILE *
-gaim_mkstemp(char **fpath)
+gaim_mkstemp(char **fpath) {
+  return gaim_mkstemp_template(fpath, gaim_mkstemp_templ);
+}
+
+
+FILE *
+gaim_mkstemp_template(char **fpath, const char *template)
 {
 	const gchar *tmpdir;
 #ifndef _WIN32
@@ -1962,7 +1968,7 @@
 	g_return_val_if_fail(fpath != NULL, NULL);
 
 	if((tmpdir = (gchar*)g_get_tmp_dir()) != NULL) {
-		if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, gaim_mkstemp_templ)) != NULL) {
+		if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, template)) != NULL) {
 #ifdef _WIN32
 			char* result = _mktemp( *fpath );
 			if( result == NULL )
--- a/src/util.h	Tue Jun 29 13:33:44 2004 +0000
+++ b/src/util.h	Tue Jun 29 17:23:08 2004 +0000
@@ -394,6 +394,26 @@
 FILE *gaim_mkstemp(char **path);
 
 /**
+ * Creates a temporary file and returns a file pointer to it.
+ *
+ * This is like mkstemp(), but returns a file pointer. It uses the
+ * semantics of tempnam() for the directory to use and allocates the
+ * space for the file path.
+ *
+ * The caller is responsible for closing the file and removing it when
+ * done, as well as freeing the space pointed to by @a path with
+ * g_free().
+ *
+ * @param path The returned path to the temp file.
+ *
+ * @param pattern Pattern for use with the returned filename.
+ *
+ * @return A file pointer to the temporary file, or @c NULL on failure.
+ */
+
+FILE *gaim_mkstemp_template(char **path,const char *template);
+
+/**
  * Checks if the given program name is valid and executable.
  *
  * @param program The file name of the application.