comparison plugins/gaim-remote/remote.c @ 8704:581c94348984

[gaim-migrate @ 9457] " Currently if a user attempts to load the remote control plugin but it can't assign the socket (often a result of an old socket in /tmp, possibly with incorrect permissions), the plugin will silently fail to load. This patch adds a bit of feedback so the user isn't left completely in the dark." --Stu Tomlinson this should thus make one faq entry obsolete, but given how some people don't upgrade, its best to leave it there for now. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 18 Apr 2004 19:26:33 +0000
parents 795b71216887
children d7b8eb1f0a18
comparison
equal deleted inserted replaced
8703:5779e1beef8d 8704:581c94348984
33 33
34 #include "conversation.h" 34 #include "conversation.h"
35 #include "core.h" 35 #include "core.h"
36 #include "debug.h" 36 #include "debug.h"
37 #include "prpl.h" 37 #include "prpl.h"
38 #include "notify.h"
38 39
39 /* XXX */ 40 /* XXX */
40 #include "gtkconv.h" 41 #include "gtkconv.h"
41 #include "gtkplugin.h" 42 #include "gtkplugin.h"
42 #include "gaim.h" 43 #include "gaim.h"
626 gaim_debug(GAIM_DEBUG_MISC, "cui", "Got one\n"); 627 gaim_debug(GAIM_DEBUG_MISC, "cui", "Got one\n");
627 return TRUE; 628 return TRUE;
628 } 629 }
629 630
630 static gint 631 static gint
631 open_socket() 632 open_socket(char **error)
632 { 633 {
633 struct sockaddr_un saddr; 634 struct sockaddr_un saddr;
634 gint fd; 635 gint fd;
635 636
636 while (gaim_remote_session_exists(gaim_session)) 637 while (gaim_remote_session_exists(gaim_session))
645 g_snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", 646 g_snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d",
646 g_get_tmp_dir(), g_get_user_name(), gaim_session); 647 g_get_tmp_dir(), g_get_user_name(), gaim_session);
647 if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) 648 if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1)
648 listen(fd, 100); 649 listen(fd, 100);
649 else { 650 else {
651 *error = g_strdup_printf(_("Failed to assign %s to a socket:\n%s"),
652 saddr.sun_path, strerror(errno));
650 g_log(NULL, G_LOG_LEVEL_CRITICAL, 653 g_log(NULL, G_LOG_LEVEL_CRITICAL,
651 "Failed to assign %s to a socket (Error: %s)", 654 "Failed to assign %s to a socket (Error: %s)",
652 saddr.sun_path, strerror(errno)); 655 saddr.sun_path, strerror(errno));
653 umask(m); 656 umask(m);
654 return -1; 657 return -1;
663 static gboolean 666 static gboolean
664 plugin_load(GaimPlugin *plugin) 667 plugin_load(GaimPlugin *plugin)
665 { 668 {
666 #ifndef _WIN32 669 #ifndef _WIN32
667 GIOChannel *channel; 670 GIOChannel *channel;
668 671 char *buf;
669 if ((UI_fd = open_socket()) < 0) 672
673 if ((UI_fd = open_socket(&buf)) < 0) {
674 gaim_notify_error(NULL, NULL, _("Unable to open socket"), buf);
675 g_free(buf);
670 return FALSE; 676 return FALSE;
677 }
671 678
672 channel = g_io_channel_unix_new(UI_fd); 679 channel = g_io_channel_unix_new(UI_fd);
673 watcher = g_io_add_watch(channel, G_IO_IN, socket_readable, NULL); 680 watcher = g_io_add_watch(channel, G_IO_IN, socket_readable, NULL);
674 g_io_channel_unref(channel); 681 g_io_channel_unref(channel);
675 682