| 62 typedef struct _zephyr_triple zephyr_triple; |
62 typedef struct _zephyr_triple zephyr_triple; |
| 63 typedef struct _zephyr_account zephyr_account; |
63 typedef struct _zephyr_account zephyr_account; |
| 64 |
64 |
| 65 typedef gssize (*PollableInputStreamReadFunc)(GPollableInputStream *stream, void *bufcur, GError **error); |
65 typedef gssize (*PollableInputStreamReadFunc)(GPollableInputStream *stream, void *bufcur, GError **error); |
| 66 typedef gboolean (*ZephyrLoginFunc)(zephyr_account *zephyr); |
66 typedef gboolean (*ZephyrLoginFunc)(zephyr_account *zephyr); |
| |
67 typedef Code_t (*ZephyrSubscribeToFunc)(zephyr_account *zephyr, char *class, char *instance, char *recipient); |
| 67 |
68 |
| 68 typedef enum { |
69 typedef enum { |
| 69 PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ |
70 PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ |
| 70 PURPLE_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ |
71 PURPLE_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ |
| 71 PURPLE_ZEPHYR_TZC, /* tzc executable proxy */ |
72 PURPLE_ZEPHYR_TZC, /* tzc executable proxy */ |
| 91 char *exposure; |
92 char *exposure; |
| 92 GSubprocess *tzc_proc; |
93 GSubprocess *tzc_proc; |
| 93 GOutputStream *tzc_stdin; |
94 GOutputStream *tzc_stdin; |
| 94 GInputStream *tzc_stdout; |
95 GInputStream *tzc_stdout; |
| 95 gchar *away; |
96 gchar *away; |
| |
97 ZephyrSubscribeToFunc subscribe_to; |
| 96 }; |
98 }; |
| 97 |
99 |
| 98 #define MAXCHILDREN 20 |
100 #define MAXCHILDREN 20 |
| 99 |
101 |
| 100 struct _zephyr_triple { |
102 struct _zephyr_triple { |
| 136 g_error_free(error); |
138 g_error_free(error); |
| 137 } |
139 } |
| 138 return success; |
140 return success; |
| 139 } |
141 } |
| 140 |
142 |
| 141 static Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) { |
143 static Code_t |
| |
144 subscribe_to_tzc(zephyr_account *zephyr, char *class, char *instance, char *recipient) |
| |
145 { |
| 142 Code_t ret_val = -1; |
146 Code_t ret_val = -1; |
| 143 |
147 gchar *zsubstr; |
| 144 if (use_tzc(zephyr)) { |
148 |
| 145 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ |
149 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ |
| 146 gchar *zsubstr; |
150 zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n", |
| 147 |
151 class, instance, recipient); |
| 148 zsubstr = g_strdup_printf( |
152 if (zephyr_write_message(zephyr, zsubstr)) { |
| 149 "((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n", class, |
153 ret_val = ZERR_NONE; |
| 150 instance, recipient); |
154 } |
| 151 if (zephyr_write_message(zephyr, zsubstr)) { |
155 g_free(zsubstr); |
| 152 ret_val = ZERR_NONE; |
|
| 153 } |
|
| 154 g_free(zsubstr); |
|
| 155 } |
|
| 156 else { |
|
| 157 if (use_zeph02(zephyr)) { |
|
| 158 ZSubscription_t sub; |
|
| 159 sub.zsub_class = class; |
|
| 160 sub.zsub_classinst = instance; |
|
| 161 sub.zsub_recipient = recipient; |
|
| 162 ret_val = ZSubscribeTo(&sub,1,0); |
|
| 163 } |
|
| 164 } |
|
| 165 return ret_val; |
156 return ret_val; |
| |
157 } |
| |
158 |
| |
159 static Code_t |
| |
160 subscribe_to_zeph02(G_GNUC_UNUSED zephyr_account *zephyr, char *class, char *instance, char *recipient) |
| |
161 { |
| |
162 ZSubscription_t sub; |
| |
163 sub.zsub_class = class; |
| |
164 sub.zsub_classinst = instance; |
| |
165 sub.zsub_recipient = recipient; |
| |
166 return ZSubscribeTo(&sub, 1, 0); |
| 166 } |
167 } |
| 167 |
168 |
| 168 char *local_zephyr_normalize(zephyr_account* zephyr,const char *); |
169 char *local_zephyr_normalize(zephyr_account* zephyr,const char *); |
| 169 static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic); |
170 static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic); |
| 170 char* zephyr_tzc_deescape_str(const char *message); |
171 char* zephyr_tzc_deescape_str(const char *message); |
| 1028 if (f) { |
1029 if (f) { |
| 1029 char **triple; |
1030 char **triple; |
| 1030 char *recip; |
1031 char *recip; |
| 1031 char *z_class; |
1032 char *z_class; |
| 1032 char *z_instance; |
1033 char *z_instance; |
| 1033 char *z_galaxy = NULL; |
|
| 1034 |
1034 |
| 1035 while (fgets(buff, BUFSIZ, f)) { |
1035 while (fgets(buff, BUFSIZ, f)) { |
| 1036 strip_comments(buff); |
1036 strip_comments(buff); |
| 1037 if (buff[0]) { |
1037 if (buff[0]) { |
| 1038 triple = g_strsplit(buff, ",", 3); |
1038 triple = g_strsplit(buff, ",", 3); |
| 1086 } |
1086 } |
| 1087 |
1087 |
| 1088 /* There should be some sort of error report listing classes that couldn't be subbed to. |
1088 /* There should be some sort of error report listing classes that couldn't be subbed to. |
| 1089 Not important right now though */ |
1089 Not important right now though */ |
| 1090 |
1090 |
| 1091 if (zephyr_subscribe_to(zephyr,z_class, z_instance, recip,z_galaxy) != ZERR_NONE) { |
1091 if (zephyr->subscribe_to(zephyr, z_class, z_instance, recip) != ZERR_NONE) { |
| 1092 |
|
| 1093 purple_debug_error("zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip); |
1092 purple_debug_error("zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip); |
| 1094 } |
1093 } |
| 1095 |
1094 |
| 1096 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,z_class,z_instance,recip)); |
1095 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,z_class,z_instance,recip)); |
| 1097 /* g_hash_table_destroy(sub_hash_table); */ |
1096 /* g_hash_table_destroy(sub_hash_table); */ |
| 1442 |
1441 |
| 1443 if (purple_account_get_bool(account, "use_tzc", FALSE)) { |
1442 if (purple_account_get_bool(account, "use_tzc", FALSE)) { |
| 1444 zephyr->connection_type = PURPLE_ZEPHYR_TZC; |
1443 zephyr->connection_type = PURPLE_ZEPHYR_TZC; |
| 1445 login = login_tzc; |
1444 login = login_tzc; |
| 1446 check_notify = check_notify_tzc; |
1445 check_notify = check_notify_tzc; |
| |
1446 zephyr->subscribe_to = subscribe_to_tzc; |
| 1447 } else { |
1447 } else { |
| 1448 zephyr->connection_type = PURPLE_ZEPHYR_KRB4; |
1448 zephyr->connection_type = PURPLE_ZEPHYR_KRB4; |
| 1449 login = login_zeph02; |
1449 login = login_zeph02; |
| 1450 check_notify = check_notify_zeph02; |
1450 check_notify = check_notify_zeph02; |
| |
1451 zephyr->subscribe_to = subscribe_to_zeph02; |
| 1451 } |
1452 } |
| 1452 |
1453 |
| 1453 zephyr->encoding = (char *)purple_account_get_string(account, "encoding", ZEPHYR_FALLBACK_CHARSET); |
1454 zephyr->encoding = (char *)purple_account_get_string(account, "encoding", ZEPHYR_FALLBACK_CHARSET); |
| 1454 purple_connection_update_progress(gc, _("Connecting"), 0, 8); |
1455 purple_connection_update_progress(gc, _("Connecting"), 0, 8); |
| 1455 |
1456 |
| 1462 /* For now */ |
1463 /* For now */ |
| 1463 zephyr->galaxy = NULL; |
1464 zephyr->galaxy = NULL; |
| 1464 zephyr->krbtkfile = NULL; |
1465 zephyr->krbtkfile = NULL; |
| 1465 zephyr_inithosts(zephyr); |
1466 zephyr_inithosts(zephyr); |
| 1466 |
1467 |
| 1467 if (zephyr_subscribe_to(zephyr,"MESSAGE","PERSONAL",zephyr->username,NULL) != ZERR_NONE) { |
1468 if (zephyr->subscribe_to(zephyr, "MESSAGE", "PERSONAL", zephyr->username) != ZERR_NONE) { |
| 1468 /* XXX don't translate this yet. It could be written better */ |
1469 /* XXX don't translate this yet. It could be written better */ |
| 1469 /* XXX error messages could be handled with more detail */ |
1470 /* XXX error messages could be handled with more detail */ |
| 1470 purple_notify_error(gc, NULL, |
1471 purple_notify_error(gc, NULL, |
| 1471 "Unable to subscribe to messages", "Unable to subscribe to initial messages", |
1472 "Unable to subscribe to messages", "Unable to subscribe to initial messages", |
| 1472 purple_request_cpar_from_connection(gc)); |
1473 purple_request_cpar_from_connection(gc)); |
| 2051 |
2052 |
| 2052 /* sub.zsub_class = zt1->class; |
2053 /* sub.zsub_class = zt1->class; |
| 2053 sub.zsub_classinst = zt1->instance; |
2054 sub.zsub_classinst = zt1->instance; |
| 2054 sub.zsub_recipient = zt1->recipient; */ |
2055 sub.zsub_recipient = zt1->recipient; */ |
| 2055 |
2056 |
| 2056 if (zephyr_subscribe_to(zephyr,zt1->class,zt1->instance,zt1->recipient,NULL) != ZERR_NONE) { |
2057 if (zephyr->subscribe_to(zephyr, zt1->class, zt1->instance, zt1->recipient) != ZERR_NONE) { |
| 2057 /* XXX output better subscription information */ |
2058 /* XXX output better subscription information */ |
| 2058 zephyr_subscribe_failed(gc,zt1->class,zt1->instance,zt1->recipient,NULL); |
2059 zephyr_subscribe_failed(gc,zt1->class,zt1->instance,zt1->recipient,NULL); |
| 2059 free_triple(zt1); |
2060 free_triple(zt1); |
| 2060 return; |
2061 return; |
| 2061 } |
2062 } |
| 2409 static int zephyr_resubscribe(PurpleConnection *gc) |
2410 static int zephyr_resubscribe(PurpleConnection *gc) |
| 2410 { |
2411 { |
| 2411 /* Resubscribe to the in-memory list of subscriptions and also |
2412 /* Resubscribe to the in-memory list of subscriptions and also |
| 2412 unsubscriptions*/ |
2413 unsubscriptions*/ |
| 2413 zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
2414 zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
| 2414 GSList *s = zephyr->subscrips; |
2415 for (GSList *s = zephyr->subscrips; s; s = s->next) { |
| 2415 zephyr_triple *zt; |
2416 zephyr_triple *zt = s->data; |
| 2416 while (s) { |
|
| 2417 zt = s->data; |
|
| 2418 /* XXX We really should care if this fails */ |
2417 /* XXX We really should care if this fails */ |
| 2419 zephyr_subscribe_to(zephyr,zt->class,zt->instance,zt->recipient,NULL); |
2418 zephyr->subscribe_to(zephyr, zt->class, zt->instance, zt->recipient); |
| 2420 s = s->next; |
|
| 2421 } |
2419 } |
| 2422 /* XXX handle unsubscriptions */ |
2420 /* XXX handle unsubscriptions */ |
| 2423 return 1; |
2421 return 1; |
| 2424 } |
2422 } |
| 2425 |
2423 |