annotate src/protocols/zephyr/ZhmStat.c @ 12498:a2de852981c1

[gaim-migrate @ 14810] SF Patch #1380806 from charkins "leave docklet loaded when notification area is not present" "From the summary, this sounds weird, but I think its better behavior. This really only effects some odd corner cases. The existing behavior is that the docklet plugin unloads itself after 10 seconds if the tray icon isn't created. The behavior with this patch is that there is a 3 second timeout (this is necessary to avoid race condition when restoring the gtkblist's visibility state on startup). After this timeout, the docklet plugin stays loaded waiting for a notification to appear, but is essentially non-functional. In the typical scenario, this patch doesn't effect the behavior. Here are some examples of where it does matter: 1) If gaim is closed with the buddy list hidden to the docklet, then gaim is started again without a notification area, the buddy list doesn't show up for 10 seconds (the time it takes for the docklet to timeout). This patch would reduce this to 3 seconds. 2) If the user removes the notification area from their panel, maybe to remove it from one panel and add it to a different panel, but doesn't add a new one back within 10 seconds, the current behavior would cause the docklet plugin to be unloaded. With this patch, the tray icon would automatically be added to the new notification area when it becomes available. 3) The gnome-panel dies and is not restarted within 10 seconds. Similar to #2. (There was a bug filed for this, but can't find it right now). My main concern was that it could be confusing to the user if they enable the docklet plugin, then 10 seconds later it gets disabled without any notification. This patch doesn't add any notification, but leaves the plugin running so it will automatically use a notification area when one becomes available. I also removed an unused parameter from docklet_remove() and changed the plugin description slightly to reflect the change in queuing/notification. Not sure how clear this is, so bug me on #gaim if you have any questions. --charkins" I made a few changes to this patch, but nothing terribly significant... committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 16 Dec 2005 09:16:14 +0000
parents 64895571248f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* This file is part of the Project Athena Zephyr Notification System.
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * It contains the ZhmStat() function.
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Created by: Marc Horowitz
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * Copyright (c) 1996 by the Massachusetts Institute of Technology.
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * For copying and distribution information, see the file
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * "mit-copyright.h".
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10
8792
43d6c08d7e96 [gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents: 2419
diff changeset
11 #include "internal.h"
10867
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
12
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
13 #ifdef WIN32
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
14 #include <winsock2.h>
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
15 #else
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 #include <sys/socket.h>
10867
5727afad0fb8 [gaim-migrate @ 12553]
Mark Doliner <mark@kingant.net>
parents: 8792
diff changeset
17 #endif
2419
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 #ifndef INADDR_LOOPBACK
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 #define INADDR_LOOPBACK 0x7f000001
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 #endif
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 Code_t ZhmStat(hostaddr, notice)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 struct in_addr *hostaddr;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 ZNotice_t *notice;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 {
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 struct servent *sp;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 struct sockaddr_in sin;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 ZNotice_t req;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 Code_t code;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 struct timeval tv;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 fd_set readers;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 sp = getservbyname(HM_SVCNAME, "udp");
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 sin.sin_family = AF_INET;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 if (hostaddr)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 sin.sin_addr = *hostaddr;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 else
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 (void) memset((char *)&req, 0, sizeof(req));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 req.z_kind = STAT;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 req.z_port = 0;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 req.z_class = HM_STAT_CLASS;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 req.z_class_inst = HM_STAT_CLIENT;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 req.z_opcode = HM_GIMMESTATS;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 req.z_sender = "";
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 req.z_recipient = "";
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 req.z_default_format = "";
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 req.z_message_len = 0;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 if ((code = ZSetDestAddr(&sin)) != ZERR_NONE)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 return(code);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 return(code);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 /* Wait up to ten seconds for a response. */
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 FD_ZERO(&readers);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 FD_SET(ZGetFD(), &readers);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 tv.tv_sec = 10;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 tv.tv_usec = 0;
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 if (code < 0 && errno != EINTR)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 return(errno);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0)
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 return(ZERR_HMDEAD);
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 return(ZReceiveNotice(notice, (struct sockaddr_in *) 0));
7ba69b8e0de5 [gaim-migrate @ 2432]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 }