Wed, 25 May 2022 23:52:45 -0500
Remove prpl-gtalk from XMPP console
It no longer exists, and complicates the code a bit.
| 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 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
9 | * "mit-copyright.h". |
| 2086 | 10 | */ |
| 11 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
7475
diff
changeset
|
12 | #include "internal.h" |
|
40474
1341be8e3402
Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents:
40166
diff
changeset
|
13 | |
|
1341be8e3402
Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents:
40166
diff
changeset
|
14 | #include <purple.h> |
| 2086 | 15 | |
| 10867 | 16 | #ifndef WIN32 |
| 2086 | 17 | #include <pwd.h> |
| 10867 | 18 | #endif |
| 2086 | 19 | |
|
13583
29c0a756c086
[gaim-migrate @ 15964]
Richard Laager <rlaager@pidgin.im>
parents:
11105
diff
changeset
|
20 | #include <stdlib.h> |
|
29c0a756c086
[gaim-migrate @ 15964]
Richard Laager <rlaager@pidgin.im>
parents:
11105
diff
changeset
|
21 | #include <errno.h> |
| 2086 | 22 | |
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
23 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
24 | ZSetLocation(char *exposure) |
| 2086 | 25 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
26 | return (Z_SendLocation(LOGIN_CLASS, exposure, ZAUTH, |
| 2086 | 27 | "$sender logged in to $1 on $3 at $2")); |
| 28 | } | |
| 29 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
30 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
31 | ZUnsetLocation(void) |
| 2086 | 32 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
33 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_LOGOUT, ZNOAUTH, |
| 2086 | 34 | "$sender logged out of $1 on $3 at $2")); |
| 35 | } | |
| 36 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
37 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
38 | ZFlushMyLocations(void) |
| 2086 | 39 | { |
| 40 | return (Z_SendLocation(LOGIN_CLASS, LOGIN_USER_FLUSH, ZAUTH, "")); | |
| 41 | } | |
| 42 | ||
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
43 | static char host[MAXHOSTNAMELEN]; |
|
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
44 | static char *mytty = NULL; |
| 2086 | 45 | static int reenter = 0; |
| 46 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
47 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38259
diff
changeset
|
48 | Z_SendLocation(char *class, char *opcode, Z_AuthProc auth, char *format) |
| 2086 | 49 | { |
| 50 | int retval; | |
| 51 | time_t ourtime; | |
| 52 | ZNotice_t notice, retnotice; | |
| 10867 | 53 | char *bptr[3]; |
| 2086 | 54 | #ifndef X_DISPLAY_MISSING |
| 55 | char *display; | |
| 56 | #endif | |
| 10867 | 57 | #ifndef WIN32 |
| 2086 | 58 | char *ttyp; |
| 10867 | 59 | char *p; |
| 60 | #endif | |
| 2086 | 61 | struct hostent *hent; |
| 62 | short wg_port = ZGetWGPort(); | |
| 63 | ||
| 64 | (void) memset((char *)¬ice, 0, sizeof(notice)); | |
| 65 | notice.z_kind = ACKED; | |
|
7475
987384816492
[gaim-migrate @ 8088]
Mark Doliner <markdoliner@pidgin.im>
parents:
2419
diff
changeset
|
66 | notice.z_port = (unsigned short) ((wg_port == -1) ? 0 : wg_port); |
| 2086 | 67 | notice.z_class = class; |
| 68 | notice.z_class_inst = ZGetSender(); | |
| 69 | notice.z_opcode = opcode; | |
| 70 | notice.z_sender = 0; | |
| 71 | notice.z_recipient = ""; | |
| 72 | notice.z_num_other_fields = 0; | |
| 73 | notice.z_default_format = format; | |
| 74 | ||
| 75 | /* | |
| 76 | keep track of what we said before so that we can be consistent | |
| 77 | when changing location information. | |
| 78 | This is done mainly for the sake of the WindowGram client. | |
| 79 | */ | |
| 80 | ||
| 81 | if (!reenter) { | |
|
40809
691bd780ab06
Replace gethostname by g_get_host_name
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40474
diff
changeset
|
82 | hent = gethostbyname(g_get_host_name()); |
| 2086 | 83 | if (hent) { |
| 84 | (void) strncpy(host, hent->h_name, sizeof(host)); | |
| 85 | host[sizeof(host) - 1] = '\0'; | |
| 86 | } | |
| 87 | #ifndef X_DISPLAY_MISSING | |
| 88 | if ((display = getenv("DISPLAY")) && *display) { | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
89 | mytty = g_strdup(display); |
| 2086 | 90 | } else { |
| 91 | #endif | |
| 10867 | 92 | #ifdef WIN32 |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
93 | mytty = g_strdup("WinPurple"); |
| 10867 | 94 | #else |
| 2086 | 95 | ttyp = ttyname(0); |
| 2419 | 96 | if (ttyp && *ttyp) { |
| 97 | p = strchr(ttyp + 1, '/'); | |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
98 | mytty = g_strdup((p) ? p + 1 : ttyp); |
| 2419 | 99 | } else { |
|
18220
c88669a9d3dd
Use dynamicly allocated string manipulation here as well to avoid a
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
100 | mytty = g_strdup("unknown"); |
| 2086 | 101 | } |
| 10867 | 102 | #endif |
| 2086 | 103 | #ifndef X_DISPLAY_MISSING |
| 104 | } | |
| 105 | #endif | |
| 106 | reenter = 1; | |
| 107 | } | |
| 108 | ||
| 109 | ourtime = time((time_t *)0); | |
| 2419 | 110 | bptr[0] = host; |
| 2086 | 111 | bptr[1] = ctime(&ourtime); |
| 112 | bptr[1][strlen(bptr[1])-1] = '\0'; | |
| 2419 | 113 | bptr[2] = mytty; |
| 2086 | 114 | |
| 115 | if ((retval = ZSendList(¬ice, bptr, 3, auth)) != ZERR_NONE) | |
| 116 | return (retval); | |
| 117 | ||
| 118 | retval = Z_WaitForNotice (&retnotice, ZCompareUIDPred, ¬ice.z_uid, | |
| 119 | SRV_TIMEOUT); | |
| 120 | if (retval != ZERR_NONE) | |
| 121 | return retval; | |
| 122 | ||
| 123 | if (retnotice.z_kind == SERVNAK) { | |
| 124 | if (!retnotice.z_message_len) { | |
| 125 | ZFreeNotice(&retnotice); | |
| 126 | return (ZERR_SERVNAK); | |
| 127 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31294
diff
changeset
|
128 | if (purple_strequal(retnotice.z_message, ZSRVACK_NOTSENT)) { |
| 2086 | 129 | ZFreeNotice(&retnotice); |
| 130 | return (ZERR_AUTHFAIL); | |
| 131 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31294
diff
changeset
|
132 | if (purple_strequal(retnotice.z_message, ZSRVACK_FAIL)) { |
| 2086 | 133 | ZFreeNotice(&retnotice); |
| 134 | return (ZERR_LOGINFAIL); | |
| 135 | } | |
| 136 | ZFreeNotice(&retnotice); | |
| 137 | return (ZERR_SERVNAK); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
138 | } |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
139 | |
| 2086 | 140 | if (retnotice.z_kind != SERVACK) { |
| 141 | ZFreeNotice(&retnotice); | |
| 142 | return (ZERR_INTERNAL); | |
| 143 | } | |
| 144 | ||
| 145 | if (!retnotice.z_message_len) { | |
| 146 | ZFreeNotice(&retnotice); | |
| 147 | return (ZERR_INTERNAL); | |
| 148 | } | |
| 149 | ||
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
150 | if (!purple_strequal(retnotice.z_message, ZSRVACK_SENT) && |
|
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
151 | !purple_strequal(retnotice.z_message, ZSRVACK_NOTSENT)) { |
| 2086 | 152 | ZFreeNotice(&retnotice); |
| 153 | return (ZERR_INTERNAL); | |
| 154 | } | |
| 155 | ||
| 156 | ZFreeNotice(&retnotice); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
18220
diff
changeset
|
157 | |
| 2086 | 158 | return (ZERR_NONE); |
| 159 | } |