Changeset 725f942 for protocols/purple
- Timestamp:
- 2016-09-20T03:39:05Z (8 years ago)
- Branches:
- master
- Children:
- 7e4f439c
- Parents:
- a33ee0f
- git-author:
- jgeboski <jgeboski@…> (24-06-16 20:21:42)
- git-committer:
- jgeboski <jgeboski@…> (20-09-16 03:39:05)
- Location:
- protocols/purple
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/purple/bpurple.h
ra33ee0f r725f942 15 15 }; 16 16 17 struct purple_roomlist_data 18 { 19 GSList *chats; 20 gint topic; 21 }; 22 17 23 #endif /* !BPURPLE_H */ -
protocols/purple/purple.c
ra33ee0f r725f942 354 354 } 355 355 356 static void purple_chatlist_free(struct im_connection *ic) 357 { 358 bee_chat_info_t *ci; 359 GSList *l = ic->chatlist; 360 361 while (l) { 362 ci = l->data; 363 l = g_slist_delete_link(l, l); 364 365 g_free(ci->title); 366 g_free(ci->topic); 367 g_free(ci); 368 } 369 } 370 356 371 static void purple_logout(struct im_connection *ic) 357 372 { … … 369 384 purple_connections = g_slist_remove(purple_connections, ic); 370 385 purple_accounts_remove(pd->account); 386 purple_chatlist_free(ic); 371 387 g_hash_table_destroy(pd->input_requests); 372 388 g_free(pd); … … 730 746 731 747 return imcb_chat_new(ic, room); 748 } 749 750 void purple_chat_list(struct im_connection *ic, const char *server) 751 { 752 PurpleRoomlist *list; 753 struct purple_data *pd = ic->proto_data; 754 755 list = purple_roomlist_get_list(pd->account->gc); 756 757 if (list) { 758 purple_roomlist_ref(list); 759 } else { 760 imcb_log(ic, "Room listing unsupported by this purple plugin"); 761 } 732 762 } 733 763 … … 1267 1297 }; 1268 1298 1299 static void prplcb_roomlist_create(PurpleRoomlist *list) 1300 { 1301 struct purple_roomlist_data *rld; 1302 1303 list->ui_data = rld = g_new0(struct purple_roomlist_data, 1); 1304 rld->topic = -1; 1305 } 1306 1307 static void prplcb_roomlist_set_fields(PurpleRoomlist *list, GList *fields) 1308 { 1309 gint topic = -1; 1310 GList *l; 1311 guint i; 1312 PurpleRoomlistField *field; 1313 struct purple_roomlist_data *rld = list->ui_data; 1314 1315 for (i = 0, l = fields; l; i++, l = l->next) { 1316 field = l->data; 1317 1318 /* Use the first visible string field as a fallback topic */ 1319 if (i != 0 && topic < 0 && !field->hidden && 1320 field->type == PURPLE_ROOMLIST_FIELD_STRING) { 1321 topic = i; 1322 } 1323 1324 if ((g_strcasecmp(field->name, "description") == 0) || 1325 (g_strcasecmp(field->name, "topic") == 0)) { 1326 if (field->type == PURPLE_ROOMLIST_FIELD_STRING) { 1327 rld->topic = i; 1328 } 1329 } 1330 } 1331 1332 if (rld->topic < 0) { 1333 rld->topic = topic; 1334 } 1335 } 1336 1337 static void prplcb_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *room) 1338 { 1339 bee_chat_info_t *ci; 1340 const char *title; 1341 const char *topic; 1342 GList *fields; 1343 struct purple_roomlist_data *rld = list->ui_data; 1344 1345 fields = purple_roomlist_room_get_fields(room); 1346 title = purple_roomlist_room_get_name(room); 1347 1348 if (rld->topic >= 0) { 1349 topic = g_list_nth_data(fields, rld->topic); 1350 } else { 1351 topic = NULL; 1352 } 1353 1354 ci = g_new(bee_chat_info_t, 1); 1355 ci->title = g_strdup(title); 1356 ci->topic = g_strdup(topic); 1357 rld->chats = g_slist_prepend(rld->chats, ci); 1358 } 1359 1360 static void prplcb_roomlist_in_progress(PurpleRoomlist *list, gboolean in_progress) 1361 { 1362 struct im_connection *ic; 1363 struct purple_roomlist_data *rld = list->ui_data; 1364 1365 if (in_progress) { 1366 return; 1367 } 1368 1369 ic = purple_ic_by_pa(list->account); 1370 purple_chatlist_free(ic); 1371 1372 ic->chatlist = g_slist_reverse(rld->chats); 1373 rld->chats = NULL; 1374 1375 bee_chat_list_finish(ic); 1376 purple_roomlist_unref(list); 1377 } 1378 1379 static void prplcb_roomlist_destroy(PurpleRoomlist *list) 1380 { 1381 g_free(list->ui_data); 1382 list->ui_data = NULL; 1383 } 1384 1385 static PurpleRoomlistUiOps bee_roomlist_uiops = 1386 { 1387 NULL, /* show_with_account */ 1388 prplcb_roomlist_create, /* create */ 1389 prplcb_roomlist_set_fields, /* set_fields */ 1390 prplcb_roomlist_add_room, /* add_room */ 1391 prplcb_roomlist_in_progress, /* in_progress */ 1392 prplcb_roomlist_destroy, /* destroy */ 1393 }; 1394 1269 1395 static void prplcb_debug_print(PurpleDebugLevel level, const char *category, const char *arg_s) 1270 1396 { … … 1431 1557 purple_request_set_ui_ops(&bee_request_uiops); 1432 1558 purple_privacy_set_ui_ops(&bee_privacy_uiops); 1559 purple_roomlist_set_ui_ops(&bee_roomlist_uiops); 1433 1560 purple_notify_set_ui_ops(&bee_notify_uiops); 1434 1561 purple_accounts_set_ui_ops(&bee_account_uiops); … … 1528 1655 funcs.chat_leave = purple_chat_leave; 1529 1656 funcs.chat_join = purple_chat_join; 1657 funcs.chat_list = purple_chat_list; 1530 1658 funcs.transfer_request = purple_transfer_request; 1531 1659
Note: See TracChangeset
for help on using the changeset viewer.