Changeset - 835c66fc6137
[Not reviewed]
0 2 0
Jan Kaluza - 14 years ago 2011-07-26 09:12:34
hanzz.k@gmail.com
force returning of memory chunks allocated by libxml2 to kernel
2 files changed with 8 insertions and 1 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -14,24 +14,27 @@
 
#include "transport/conversation.h"
 
#include "transport/networkplugin.h"
 
#include "spectrumeventloop.h"
 
#include "geventloop.h"
 
#include "log4cxx/logger.h"
 
#include "log4cxx/consoleappender.h"
 
#include "log4cxx/patternlayout.h"
 
#include "log4cxx/propertyconfigurator.h"
 
#include "log4cxx/helpers/properties.h"
 
#include "log4cxx/helpers/fileinputstream.h"
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 
// #include "valgrind/memcheck.h"
 
#include "malloc.h"
 

	
 

	
 
using namespace log4cxx;
 

	
 
static LoggerPtr logger_libpurple = Logger::getLogger("backend.libpurple");
 
static LoggerPtr logger = Logger::getLogger("backend");
 

	
 
using namespace Transport;
 

	
 
class SpectrumNetworkPlugin;
 

	
 

	
 
SpectrumNetworkPlugin *np;
 
@@ -209,24 +212,25 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
			
 
			const PurpleStatusType *status_type = purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AVAILABLE);
 
			if (status_type != NULL) {
 
				purple_account_set_status(account, purple_status_type_get_id(status_type), TRUE, NULL);
 
			}
 
			m_accounts[account] = user;
 
		}
 

	
 
		void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
 
			const char *protocol = CONFIG_STRING(config, "service.protocol").c_str();
 
			PurpleAccount *account = purple_accounts_find(legacyName.c_str(), protocol);
 
			if (account) {
 
// 				VALGRIND_DO_LEAK_CHECK;
 
				m_sessions[user] = NULL;
 
				purple_account_set_enabled(account, "spectrum", FALSE);
 

	
 
				// Remove conversations.
 
				// This has to be called before m_account->ui_data = NULL;, because it uses
 
				// ui_data to call SpectrumMessageHandler::purpleConversationDestroyed() callback.
 
				GList *iter;
 
				for (iter = purple_get_conversations(); iter; ) {
 
					PurpleConversation *conv = (PurpleConversation*) iter->data;
 
					iter = iter->next;
 
					if (purple_conversation_get_account(conv) == account)
 
						purple_conversation_destroy(conv);
 
@@ -254,24 +258,25 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
					it = it->next;
 
					if (purple_conversation_get_account(conv) == account)
 
						purple_conversation_destroy(conv);
 
				}
 

	
 
				/* Remove this account's pounces */
 
					// purple_pounce_destroy_all_by_account(account);
 

	
 
				/* This will cause the deletion of an old buddy icon. */
 
				purple_buddy_icons_set_account_icon(account, NULL, 0);
 

	
 
				purple_account_destroy(account);
 
// 				VALGRIND_DO_LEAK_CHECK;
 
			}
 
		}
 

	
 
		void handleStatusChangeRequest(const std::string &user, int status, const std::string &statusMessage) {
 
			PurpleAccount *account = m_sessions[user];
 
			if (account) {
 
				int st;
 
				switch(status) {
 
					case Swift::StatusShow::Away: {
 
						st = PURPLE_STATUS_AWAY;
 
						if (!purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AWAY))
 
							st = PURPLE_STATUS_EXTENDED_AWAY;
 
@@ -931,24 +936,26 @@ static PurpleCoreUiOps coreUiOps =
 
	NULL,
 
	transport_core_ui_init,
 
	NULL,
 
	spectrum_ui_get_info,
 
	NULL,
 
	NULL,
 
	NULL
 
};
 

	
 
static void signed_on(PurpleConnection *gc, gpointer unused) {
 
	PurpleAccount *account = purple_connection_get_account(gc);
 
	np->handleConnected(np->m_accounts[account]);
 
	// force returning of memory chunks allocated by libxml2 to kernel
 
	malloc_trim(0);
 
}
 

	
 
static void printDebug(PurpleDebugLevel level, const char *category, const char *arg_s) {
 
	std::string c("");
 
	std::string args(arg_s);
 
	args.erase(args.size() - 1);
 

	
 
	if (category) {
 
		c.append(category);
 
	}
 

	
 
	c.push_back(':');
spectrum/src/sample.cfg
Show inline comments
 
[service]
 
jid = localhost
 
password = secret
 
server = 127.0.0.1
 
port = 5222
 
server_mode = 1
 
backend_host=localhost # < this option doesn't work yet
 
backend_port=10001
 
admin_username=admin
 
admin_password=test
 
#cert= #patch to PKCS#12 certificate
 
#cert_password= #password to that certificate if any
 
users_per_backend=2
 
users_per_backend=10
 
backend=../../backends/libpurple/spectrum_libpurple_backend
 
#backend=../../backends/libircclient-qt/spectrum_libircclient-qt_backend
 
#protocol=prpl-jabber
 
protocol=prpl-msn
 
#protocol=prpl-icq
 

	
 
[backend]
 
default_avatar=catmelonhead.jpg
 

	
 
[logging]
 
#config=logging.cfg # log4cxx/log4j logging configuration file
 
#backend_config=backend_logging.cfg # log4cxx/log4j logging configuration file for backends
0 comments (0 inline, 0 general)