Changeset - 43f871a93ff5
[Not reviewed]
0 1 0
Jan Kaluza - 9 years ago 2016-02-08 13:16:49
jkaluza@redhat.com
Libpurple: Fallback to users-list for room-list when topic is not set
1 file changed with 16 insertions and 2 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -1604,29 +1604,31 @@ static PurpleXferUiOps xferUiOps =
 
static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
 
{
 
	if (!in_progress) {
 
		GList *fields = purple_roomlist_get_fields(list);
 
		GList *field;
 
		int topicId = -1;
 
		int usersId = -1;
 
		int id = 0;
 
		for (field = fields; field != NULL; field = field->next, id++) {
 
			PurpleRoomlistField *f = (PurpleRoomlistField *) field->data;
 
			if (!f || !f->name) {
 
				continue;
 
			}
 
			std::string fstring = f->name;
 
			if (fstring == "topic") {
 
				topicId = id;
 
			}
 
			else if (fstring == "users") {
 
				usersId = id;
 
			}
 
			else {
 
				LOG4CXX_INFO(logger, "Uknown RoomList field " << fstring);
 
			}
 
		}
 

	
 
		LOG4CXX_INFO(logger, "RoomList topic ID: " << topicId);
 

	
 
		GList *rooms;
 
		std::list<std::string> m_rooms;
 
		std::list<std::string> m_topics;
 
		for (rooms = list->rooms; rooms != NULL; rooms = rooms->next) {
 
			PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;	
 
			m_rooms.push_back(room->name);
 
@@ -1636,18 +1638,30 @@ static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
 
			}
 
			else {
 
				char *topic = (char *) g_list_nth_data(purple_roomlist_room_get_fields(room), topicId);
 
				if (topic) {
 
					m_topics.push_back(topic);
 
				}
 
				else {
 
					if (usersId) {
 
						char *users = (char *) g_list_nth_data(purple_roomlist_room_get_fields(room), usersId);
 
						if (users) {
 
							m_topics.push_back(users);
 
						}
 
						else {
 
							LOG4CXX_WARN(logger, "RoomList topic and users is NULL");
 
							m_topics.push_back(room->name);
 
						}
 
					}
 
					else {
 
						LOG4CXX_WARN(logger, "RoomList topic is NULL");
 
						m_topics.push_back(room->name);
 
					}
 
				}
 
			}
 
		}
 

	
 
		std::string user = "";
 
		if (list->account) {
 
			user = np->m_accounts[list->account];
 
		}
 

	
0 comments (0 inline, 0 general)