Sat, 28 Oct 2006 20:04:03 +0000
[gaim-migrate @ 17606]
Add a "handle" parameter to gaim_proxy_connect(). It seemed like
people thought this was a good idea. You can still cancel
each gaim_proxy_connect() individually, if needed. I passed in
NULL for the handle in most places. It might be better to pass
in the gc in more places, but these changes do no harm, and they
should help some Yahoo! things, and I wanted to get the API change in.
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZSetLocation, ZUnsetLocation, and | |
| 3 | * ZFlushMyLocations functions. | |
| 4 | * | |
| 5 | * Created by: Robert French | |
| 6 | * | |
| 7 | * Copyright (c) 1987,1988,1991 by the Massachusetts Institute of Technology. | |
| 8 | * For copying and distribution information, see the file | |
| 9 | * "mit-copyright.h". | |
| 10 | */ | |
| 11 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
7475
diff
changeset
|
12 | #include "internal.h" |
| 2086 | 13 | |
| 10867 | 14 | #ifndef WIN32 |
| 2086 | 15 | #include <pwd.h> |
| 10867 | 16 | #endif |
| 2086 | 17 | |
|
13583
29c0a756c086
[gaim-migrate @ 15964]
Richard Laager <rlaager@pidgin.im>
parents:
11105
diff
changeset
|
18 | #include <stdlib.h> |
|
29c0a756c086
[gaim-migrate @ 15964]
Richard Laager <rlaager@pidgin.im>
parents:
11105
diff
changeset
|
19 | #include <errno.h> |
| 2086 | 20 | |
| 21 | Code_t ZSetLocation(exposure) | |
| 22 | char *exposure; | |
| 23 | { | |
| 24 | return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, | |
| 25 | "$sender logged in to $1 on $3 at $2")); | |
| 26 | } | |
| 27 | ||
| 28 | Code_t ZUnsetLocation() | |
| 29 | { | |
| 30 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, | |
| 31 | "$sender logged out of $1 on $3 at $2")); | |
| 32 | } | |
| 33 | ||
| 34 | Code_t ZFlushMyLocations() | |
| 35 | { | |
| 36 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); | |
| 37 | } | |
| 38 | ||
| 39 | static char host[MAXHOSTNAMELEN], mytty[MAXPATHLEN]; | |
| 40 | static int reenter = 0; | |
| 41 | ||
| 42 | Code_t Z_SendLocation(class, opcode, auth, format) | |
| 43 | char *class; | |
| 44 | char *opcode; | |
| 45 | Z_AuthProc auth; | |
| 46 | char *format; | |
| 47 | { | |
| 48 | int retval; | |
| 49 | time_t ourtime; | |
| 50 | ZNotice_t notice, retnotice; | |
| 10867 | 51 | char *bptr[3]; |
| 2086 | 52 | #ifndef X_DISPLAY_MISSING |
| 53 | char *display; | |
| 54 | #endif | |
| 10867 | 55 | #ifndef WIN32 |
| 2086 | 56 | char *ttyp; |
| 10867 | 57 | char *p; |
| 58 | #endif | |
| 2086 | 59 | struct hostent *hent; |
| 60 | short wg_port = ZGetWGPort(); | |
| 61 | ||
| 62 | (void) memset((char *)¬ice, 0, sizeof(notice)); | |
| 63 | notice.z_kind = ACKED; | |
|
7475
987384816492
[gaim-migrate @ 8088]
Mark Doliner <markdoliner@pidgin.im>
parents:
2419
diff
changeset
|
64 | notice.z_port = (unsigned short) ((wg_port == -1) ? 0 : wg_port); |
| 2086 | 65 | notice.z_class = class; |
| 66 | notice.z_class_inst = ZGetSender(); | |
| 67 | notice.z_opcode = opcode; | |
| 68 | notice.z_sender = 0; | |
| 69 | notice.z_recipient = ""; | |
| 70 | notice.z_num_other_fields = 0; | |
| 71 | notice.z_default_format = format; | |
| 72 | ||
| 73 | /* | |
| 74 | keep track of what we said before so that we can be consistent | |
| 75 | when changing location information. | |
| 76 | This is done mainly for the sake of the WindowGram client. | |
| 77 | */ | |
| 78 | ||
| 79 | if (!reenter) { | |
| 80 | if (gethostname(host, MAXHOSTNAMELEN) < 0) | |
| 81 | return (errno); | |
| 82 | ||
| 83 | hent = gethostbyname(host); | |
| 84 | if (hent) { | |
| 85 | (void) strncpy(host, hent->h_name, sizeof(host)); | |
| 86 | host[sizeof(host) - 1] = '\0'; | |
| 87 | } | |
| 88 | #ifndef X_DISPLAY_MISSING | |
| 89 | if ((display = getenv("DISPLAY")) && *display) { | |
|
10328
b097a5cc92f3
[gaim-migrate @ 11535]
Mark Doliner <markdoliner@pidgin.im>
parents:
10326
diff
changeset
|
90 | (void) strncpy(mytty, display, sizeof(mytty)); |
| 2086 | 91 | } else { |
| 92 | #endif | |
| 10867 | 93 | #ifdef WIN32 |
|
10897
98867eee9779
[gaim-migrate @ 12612]
Mark Doliner <markdoliner@pidgin.im>
parents:
10867
diff
changeset
|
94 | strncpy(mytty, "WinGaim", sizeof(mytty)); |
| 10867 | 95 | #else |
| 2086 | 96 | ttyp = ttyname(0); |
| 2419 | 97 | if (ttyp && *ttyp) { |
| 98 | p = strchr(ttyp + 1, '/'); | |
| 99 | strcpy(mytty, (p) ? p + 1 : ttyp); | |
| 100 | } else { | |
|
10897
98867eee9779
[gaim-migrate @ 12612]
Mark Doliner <markdoliner@pidgin.im>
parents:
10867
diff
changeset
|
101 | strncpy(mytty, "unknown", sizeof(mytty)); |
| 2086 | 102 | } |
| 10867 | 103 | #endif |
|
10897
98867eee9779
[gaim-migrate @ 12612]
Mark Doliner <markdoliner@pidgin.im>
parents:
10867
diff
changeset
|
104 | mytty[sizeof(mytty)-1] = '\0'; |
| 2086 | 105 | #ifndef X_DISPLAY_MISSING |
| 106 | } | |
| 107 | #endif | |
| 108 | reenter = 1; | |
| 109 | } | |
| 110 | ||
| 111 | ourtime = time((time_t *)0); | |
| 2419 | 112 | bptr[0] = host; |
| 2086 | 113 | bptr[1] = ctime(&ourtime); |
| 114 | bptr[1][strlen(bptr[1])-1] = '\0'; | |
| 2419 | 115 | bptr[2] = mytty; |
| 2086 | 116 | |
| 117 | ||
| 118 | if ((retval = ZSendList(¬ice, bptr, 3, auth)) != ZERR_NONE) | |
| 119 | return (retval); | |
| 120 | ||
| 121 | retval = Z_WaitForNotice (&retnotice, ZCompareUIDPred, ¬ice.z_uid, | |
| 122 | SRV_TIMEOUT); | |
| 123 | if (retval != ZERR_NONE) | |
| 124 | return retval; | |
| 125 | ||
| 126 | if (retnotice.z_kind == SERVNAK) { | |
| 127 | if (!retnotice.z_message_len) { | |
| 128 | ZFreeNotice(&retnotice); | |
| 129 | return (ZERR_SERVNAK); | |
| 130 | } | |
| 131 | if (!strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) { | |
| 132 | ZFreeNotice(&retnotice); | |
| 133 | return (ZERR_AUTHFAIL); | |
| 134 | } | |
| 135 | if (!strcmp(retnotice.z_message, ZSRVACK_FAIL)) { | |
| 136 | ZFreeNotice(&retnotice); | |
| 137 | return (ZERR_LOGINFAIL); | |
| 138 | } | |
| 139 | ZFreeNotice(&retnotice); | |
| 140 | return (ZERR_SERVNAK); | |
| 141 | } | |
| 142 | ||
| 143 | if (retnotice.z_kind != SERVACK) { | |
| 144 | ZFreeNotice(&retnotice); | |
| 145 | return (ZERR_INTERNAL); | |
| 146 | } | |
| 147 | ||
| 148 | if (!retnotice.z_message_len) { | |
| 149 | ZFreeNotice(&retnotice); | |
| 150 | return (ZERR_INTERNAL); | |
| 151 | } | |
| 152 | ||
| 153 | if (strcmp(retnotice.z_message, ZSRVACK_SENT) && | |
| 154 | strcmp(retnotice.z_message, ZSRVACK_NOTSENT)) { | |
| 155 | ZFreeNotice(&retnotice); | |
| 156 | return (ZERR_INTERNAL); | |
| 157 | } | |
| 158 | ||
| 159 | ZFreeNotice(&retnotice); | |
| 160 | ||
| 161 | return (ZERR_NONE); | |
| 162 | } |