Mon, 22 Aug 2022 21:40:04 -0500
Inline pidgin_make_scrollable
We need to change it for GTK4, and there are few enough that it can be inlined. Eventually, that code might be a `.ui` anyway.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/1615/
| 2086 | 1 | /* This file is part of the Project Athena Zephyr Notification System. |
| 2 | * It contains source for the ZSubscribeTo, ZUnsubscribeTo, and | |
| 3 | * ZCancelSubscriptions functions. | |
| 4 | * | |
| 5 | * Created by: Robert French | |
| 6 | * | |
| 7 | * Copyright (c) 1987,1988 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:
15435
diff
changeset
|
9 | * "mit-copyright.h". |
| 2086 | 10 | */ |
| 11 | ||
|
8792
b0645c9dc276
[gaim-migrate @ 9554]
Christian Hammond <chipx86@chipx86.com>
parents:
3277
diff
changeset
|
12 | #include "internal.h" |
| 2086 | 13 | |
|
39829
ce056c64e426
zephyr: Remove support for compilers without __STDC__.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
14 | static Code_t Z_Subscriptions(register ZSubscription_t *sublist, int nitems, |
|
ce056c64e426
zephyr: Remove support for compilers without __STDC__.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
15 | unsigned int port, char *opcode, int authit); |
|
ce056c64e426
zephyr: Remove support for compilers without __STDC__.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
16 | static Code_t subscr_sendoff(ZNotice_t *notice, char **lyst, int num, |
|
ce056c64e426
zephyr: Remove support for compilers without __STDC__.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
17 | int authit); |
| 2086 | 18 | |
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
19 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
20 | ZSubscribeTo(ZSubscription_t *sublist, int nitems, unsigned int port) |
| 2086 | 21 | { |
| 22 | return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE, 1)); | |
| 23 | } | |
| 24 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
25 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
26 | ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems, |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
27 | unsigned int port) |
| 2086 | 28 | { |
| 29 | return (Z_Subscriptions(sublist, nitems, port, CLIENT_SUBSCRIBE_NODEFS, | |
| 30 | 1)); | |
| 31 | } | |
| 32 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
33 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
34 | ZUnsubscribeTo(ZSubscription_t *sublist, int nitems, unsigned int port) |
| 2086 | 35 | { |
| 36 | return (Z_Subscriptions(sublist, nitems, port, CLIENT_UNSUBSCRIBE, 1)); | |
| 37 | } | |
| 38 | ||
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
39 | Code_t |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
40 | ZCancelSubscriptions(unsigned int port) |
| 2086 | 41 | { |
| 42 | return (Z_Subscriptions((ZSubscription_t *)0, 0, port, | |
| 43 | CLIENT_CANCELSUB, 0)); | |
| 44 | } | |
| 45 | ||
| 46 | /* | |
| 47 | * This routine must do its own fragmentation. Subscriptions must | |
| 48 | * not be broken across packet boundaries, or else the server will | |
| 49 | * mis-interpret them. | |
| 50 | */ | |
| 51 | ||
| 52 | static Code_t | |
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
53 | Z_Subscriptions(register ZSubscription_t *sublist, int nitems, |
|
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
54 | unsigned int port, char *opcode, int authit) |
| 2086 | 55 | { |
| 56 | register int i, j; | |
| 57 | int retval; | |
| 58 | ZNotice_t notice; | |
| 59 | char header[Z_MAXHEADERLEN]; | |
| 60 | char **list; | |
| 3277 | 61 | char *recip; |
| 2086 | 62 | int hdrlen; |
| 63 | int size_avail = Z_MAXPKTLEN-Z_FRAGFUDGE; /* space avail for data, | |
| 64 | adjusted below */ | |
| 65 | int size, start, numok; | |
| 66 | ||
| 67 | /* nitems = 0 means cancel all subscriptions; still need to allocate a */ | |
| 68 | /* array for one item so we can cancel, however. */ | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
69 | |
| 2086 | 70 | list = (char **)malloc((unsigned)((nitems==0)?1:nitems)*3*sizeof(char *)); |
| 71 | if (!list) | |
| 72 | return (ENOMEM); | |
| 73 | ||
| 74 | (void) memset((char *)¬ice, 0, sizeof(notice)); | |
| 75 | notice.z_kind = ACKED; | |
| 76 | notice.z_port = port; | |
| 77 | notice.z_class = ZEPHYR_CTL_CLASS; | |
| 78 | notice.z_class_inst = ZEPHYR_CTL_CLIENT; | |
| 79 | notice.z_opcode = opcode; | |
| 80 | notice.z_sender = 0; | |
| 81 | notice.z_recipient = ""; | |
| 82 | notice.z_default_format = ""; | |
| 83 | notice.z_message_len = 0; | |
| 84 | ||
| 85 | /* format the header to figure out how long it is */ | |
| 86 | retval = Z_FormatHeader(¬ice, header, sizeof(header), &hdrlen, ZAUTH); | |
| 87 | if (retval != ZERR_NONE && !authit) | |
| 88 | retval = Z_FormatHeader(¬ice, header, sizeof(header), | |
| 2419 | 89 | &hdrlen, ZNOAUTH); |
| 2086 | 90 | if (retval != ZERR_NONE) { |
| 91 | free((char *)list); | |
| 92 | return(retval); | |
| 93 | } | |
| 94 | ||
| 95 | /* compute amount of room left */ | |
| 96 | size_avail -= hdrlen; | |
| 97 | size = size_avail; | |
| 98 | ||
| 99 | /* assemble subs into an array of pointers */ | |
| 100 | for (i=0;i<nitems;i++) { | |
| 101 | list[i*3] = sublist[i].zsub_class; | |
| 102 | list[i*3+1] = sublist[i].zsub_classinst; | |
| 3277 | 103 | recip = sublist[i].zsub_recipient; |
| 104 | if (recip && *recip == '*') | |
| 105 | recip++; | |
| 106 | if (!recip || (*recip != 0 && *recip != '@')) | |
| 107 | recip = ZGetSender(); | |
| 108 | list[i*3+2] = recip; | |
| 2086 | 109 | } |
| 110 | ||
| 111 | start = -1; | |
| 112 | i = 0; | |
| 113 | numok = 0; | |
| 114 | if (!nitems) { | |
| 115 | /* there aren't really any, but we need to xmit anyway */ | |
| 116 | retval = subscr_sendoff(¬ice, list, 0, authit); | |
| 117 | free((char *)list); | |
| 118 | return(retval); | |
| 119 | } | |
| 120 | while(i < nitems) { | |
| 121 | if (start == -1) { | |
| 122 | size = size_avail; | |
| 123 | start = i; | |
| 124 | numok = 0; | |
| 125 | } | |
| 126 | if ((j = strlen(list[i*3]) | |
| 127 | + strlen(list[i*3+1]) | |
| 128 | + strlen(list[i*3+2]) + 3) <= size) { | |
| 129 | /* it will fit in this packet */ | |
| 130 | size -= j; | |
| 131 | numok++; | |
| 132 | i++; | |
| 133 | continue; | |
| 134 | } | |
| 135 | if (!numok) { /* a single subscription won't | |
| 136 | fit into one packet */ | |
| 137 | free((char *)list); | |
| 138 | return(ZERR_FIELDLEN); | |
| 139 | } | |
| 140 | retval = subscr_sendoff(¬ice, &list[start*3], numok, authit); | |
| 141 | if (retval) { | |
| 142 | free((char *)list); | |
| 143 | return(retval); | |
| 144 | } | |
| 145 | start = -1; | |
| 146 | } | |
| 147 | if (numok) | |
| 148 | retval = subscr_sendoff(¬ice, &list[start*3], numok, authit); | |
| 149 | free((char *)list); | |
| 150 | return(retval); | |
| 151 | } | |
| 152 | ||
| 153 | static Code_t | |
|
40166
811f82db29dd
zephyr: Modernize K&R function prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39829
diff
changeset
|
154 | subscr_sendoff(ZNotice_t *notice, char **lyst, int num, int authit) |
| 2086 | 155 | { |
| 156 | register Code_t retval; | |
| 157 | ZNotice_t retnotice; | |
| 158 | ||
| 159 | retval = ZSendList(notice, lyst, num*3, ZAUTH); | |
| 160 | if (retval != ZERR_NONE && !authit) | |
| 161 | retval = ZSendList(notice, lyst, num*3, ZNOAUTH); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
15435
diff
changeset
|
162 | |
| 2086 | 163 | if (retval != ZERR_NONE) |
| 164 | return (retval); | |
|
40643
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
165 | retval = ZIfNotice(&retnotice, NULL, ZCompareUIDPred, |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
166 | (char *)¬ice->z_uid); |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
167 | if (retval != ZERR_NONE) { |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
168 | return retval; |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40166
diff
changeset
|
169 | } |
| 2086 | 170 | if (retnotice.z_kind == SERVNAK) { |
| 171 | ZFreeNotice(&retnotice); | |
| 172 | return (ZERR_SERVNAK); | |
| 173 | } | |
| 174 | if (retnotice.z_kind != SERVACK) { | |
| 175 | ZFreeNotice(&retnotice); | |
| 176 | return (ZERR_INTERNAL); | |
| 177 | } | |
| 178 | ZFreeNotice(&retnotice); | |
| 179 | return (ZERR_NONE); | |
| 180 | } |