Changeset - 89967ed37388
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-02-07 21:53:19
jkaluza@redhat.com
Libpurple: Check if 'topic' and 'who' is not null
1 file changed with 4 insertions and 6 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -513,34 +513,32 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
					else if (purple_conversation_get_type_wrapped(conv) == PURPLE_CONV_TYPE_CHAT) {
 
						purple_conv_chat_send_wrapped(PURPLE_CONV_CHAT_WRAPPED(conv), xhtml.c_str());
 
					}
 
				}
 
			}
 
		}
 

	
 
		void handleRoomSubjectChangedRequest(const std::string &user, const std::string &legacyName, const std::string &message) {
 
			PurpleAccount *account = m_sessions[user];
 
			if (account) {
 
				PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, legacyName.c_str(), account);
 
				if (!conv) {
 
					conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_IM, legacyName.c_str(), account);
 
					if (!conv) {
 
						conv = purple_conversation_new_wrapped(PURPLE_CONV_TYPE_IM, account, legacyName.c_str());
 
					}
 
					LOG4CXX_ERROR(logger, user << ": Cannot set room subject. There is now conversation " << legacyName);
 
				}
 

	
 
				PurplePlugin *prpl = purple_find_prpl_wrapped(purple_account_get_protocol_id_wrapped(account));
 
				PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
 
				bool support_set_chat_topic = prpl_info && prpl_info->set_chat_topic;
 
				if (support_set_chat_topic) {
 
					LOG4CXX_INFO(logger, user << ": Setting room subject for room " << legacyName);
 
					prpl_info->set_chat_topic(purple_account_get_connection_wrapped(account),
 
											  purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)),
 
											  message.c_str());
 
				}
 
			}
 
		}
 

	
 
		void handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id) {
 
			PurpleAccount *account = m_sessions[user];
 
			if (account) {
 
				std::string name = legacyName;
 
				if (CONFIG_STRING(config, "service.protocol") == "any" && legacyName.find("prpl-") == 0) {
 
@@ -1790,27 +1788,27 @@ static void buddyTypingStopped(PurpleAccount *account, const char *who, gpointer
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleBuddyStoppedTyping(np->m_accounts[account], w);
 
}
 

	
 
static void gotAttention(PurpleAccount *account, const char *who, PurpleConversation *conv, guint type) {
 
	std::string w = purple_normalize_wrapped(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleAttention(np->m_accounts[account], w, "");
 
}
 

	
 
static void conv_chat_topic_changed(PurpleConversation *conv, const char *old, const char *topic) {
 
static void conv_chat_topic_changed(PurpleConversation *conv, const char *who, const char *topic) {
 
	PurpleAccount *account = purple_conversation_get_account_wrapped(conv);
 
	np->handleSubject(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), topic, "Spectrum 2");
 
	np->handleSubject(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), topic ? topic : "", who ? who : "Spectrum 2");
 
}
 

	
 
static bool initPurple() {
 
	bool ret;
 

	
 
	std::string libPurpleDllPath = CONFIG_STRING_DEFAULTED(config, "purple.libpurple_dll_path", "");
 

	
 
	if (!resolvePurpleFunctions()) {
 
		LOG4CXX_ERROR(logger, "Unable to load libpurple.dll or some of the needed methods");
 
		return false;
 
	}
 

	
0 comments (0 inline, 0 general)