--- a/libpurple/protocols/zephyr/zephyr.c Wed Jan 13 04:35:43 2021 -0600
+++ b/libpurple/protocols/zephyr/zephyr.c Thu Jan 14 07:41:45 2021 -0600
@@ -64,6 +64,7 @@
typedef gssize (*PollableInputStreamReadFunc)(GPollableInputStream *stream, void *bufcur, GError **error);
typedef gboolean (*ZephyrLoginFunc)(zephyr_account *zephyr);
+typedef Code_t (*ZephyrSubscribeToFunc)(zephyr_account *zephyr, char *class, char *instance, char *recipient); PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */
@@ -93,6 +94,7 @@
GOutputStream *tzc_stdin;
GInputStream *tzc_stdout;
+ ZephyrSubscribeToFunc subscribe_to; @@ -138,33 +140,32 @@
-static Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) {
+subscribe_to_tzc(zephyr_account *zephyr, char *class, char *instance, char *recipient)
- /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */
- zsubstr = g_strdup_printf(
- "((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n", class,
- if (zephyr_write_message(zephyr, zsubstr)) {
+ /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ + zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n", + class, instance, recipient); + if (zephyr_write_message(zephyr, zsubstr)) {
- if (use_zeph02(zephyr)) {
- sub.zsub_class = class;
- sub.zsub_classinst = instance;
- sub.zsub_recipient = recipient;
- ret_val = ZSubscribeTo(&sub,1,0);
+subscribe_to_zeph02(G_GNUC_UNUSED zephyr_account *zephyr, char *class, char *instance, char *recipient) + sub.zsub_class = class; + sub.zsub_classinst = instance; + sub.zsub_recipient = recipient; + return ZSubscribeTo(&sub, 1, 0); char *local_zephyr_normalize(zephyr_account* zephyr,const char *);
static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic);
char* zephyr_tzc_deescape_str(const char *message);
@@ -1030,7 +1031,6 @@
while (fgets(buff, BUFSIZ, f)) {
@@ -1088,8 +1088,7 @@
/* There should be some sort of error report listing classes that couldn't be subbed to.
Not important right now though */
- if (zephyr_subscribe_to(zephyr,z_class, z_instance, recip,z_galaxy) != ZERR_NONE) {
+ if (zephyr->subscribe_to(zephyr, z_class, z_instance, recip) != ZERR_NONE) { purple_debug_error("zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip);
@@ -1444,10 +1443,12 @@
zephyr->connection_type = PURPLE_ZEPHYR_TZC;
check_notify = check_notify_tzc;
+ zephyr->subscribe_to = subscribe_to_tzc; zephyr->connection_type = PURPLE_ZEPHYR_KRB4;
check_notify = check_notify_zeph02;
+ zephyr->subscribe_to = subscribe_to_zeph02; zephyr->encoding = (char *)purple_account_get_string(account, "encoding", ZEPHYR_FALLBACK_CHARSET);
@@ -1464,7 +1465,7 @@
zephyr->krbtkfile = NULL;
zephyr_inithosts(zephyr);
- if (zephyr_subscribe_to(zephyr,"MESSAGE","PERSONAL",zephyr->username,NULL) != ZERR_NONE) {
+ if (zephyr->subscribe_to(zephyr, "MESSAGE", "PERSONAL", zephyr->username) != ZERR_NONE) { /* XXX don't translate this yet. It could be written better */
/* XXX error messages could be handled with more detail */
purple_notify_error(gc, NULL,
@@ -2053,7 +2054,7 @@
sub.zsub_classinst = zt1->instance;
sub.zsub_recipient = zt1->recipient; */
- if (zephyr_subscribe_to(zephyr,zt1->class,zt1->instance,zt1->recipient,NULL) != ZERR_NONE) {
+ if (zephyr->subscribe_to(zephyr, zt1->class, zt1->instance, zt1->recipient) != ZERR_NONE) { /* XXX output better subscription information */
zephyr_subscribe_failed(gc,zt1->class,zt1->instance,zt1->recipient,NULL);
@@ -2411,13 +2412,10 @@
/* Resubscribe to the in-memory list of subscriptions and also
zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
- GSList *s = zephyr->subscrips;
+ for (GSList *s = zephyr->subscrips; s; s = s->next) { + zephyr_triple *zt = s->data; /* XXX We really should care if this fails */
- zephyr_subscribe_to(zephyr,zt->class,zt->instance,zt->recipient,NULL);
+ zephyr->subscribe_to(zephyr, zt->class, zt->instance, zt->recipient); /* XXX handle unsubscriptions */