Changeset - 5dba4612b5f7
[Not reviewed]
0 4 0
Florian Kinder - 7 years ago 2018-12-01 11:38:15
florian.kinder@fankserver.com
Syntax fixes
4 files changed with 14 insertions and 6 deletions:
0 comments (0 inline, 0 general)
Dockerfile
Show inline comments
 
FROM frolvlad/alpine-glibc:alpine-3.6
 

	
 
EXPOSE 5222 5269
 
VOLUME ["/etc/spectrum2/transports", "/var/lib/spectrum2"]
 

	
 
ADD . /usr/src/spectrum2
 

	
 
RUN apk add --no-cache ca-certificates && \
 
    apk add --no-cache --virtual .build-deps cmake make gcc g++ musl-dev boost-dev glib-dev protobuf-dev mariadb-dev sqlite-dev postgresql-dev pidgin-dev libev-dev qt-dev apr-util-dev automake autoconf libtool git popt-dev curl-dev openssl && \
 
    apk add --no-cache --virtual .build-deps cmake make gcc g++ musl-dev boost-dev glib-dev protobuf-dev mariadb-dev sqlite-dev postgresql-dev pidgin-dev libev-dev qt-dev apr-util-dev automake autoconf libtool git popt-dev curl-dev openssl libevent-dev && \
 
    cd /usr/src/ && \
 

	
 
    wget https://github.com/communi/libcommuni/archive/v3.5.0.tar.gz -O libcommuni-3.5.0.tar.gz && \
 
    tar xfz libcommuni-*.tar.gz && \
 
    cd libcommuni-* && \
 
    ./configure && \
 
    make && \
 
    make install && \
 
    cd .. && rm -rf libcommuni-* && \
 

	
 
    git clone git://git.apache.org/logging-log4cxx.git && \
 
    cd logging-log4cxx && \
 
    ./autogen.sh && \
 
    ./configure && \
 
    make && \
 
    make install && \
 
    cd .. && rm -rf logging-log4cxx && \
 

	
 
    wget http://pqxx.org/download/software/libpqxx/libpqxx-4.0.1.tar.gz && \
 
    tar xfz libpqxx-*.tar.gz && \
 
    cd libpqxx-* && \
 
    ./autogen.sh && \
 
    ./configure --disable-documentation && \
 
    ./configure --enable-shared --disable-documentation && \
 
    make && \
 
    make install && \
 
    cd .. && rm -rf libpqxx-* && \
 

	
 
    wget https://swift.im/downloads/releases/swift-4.0rc2/swift-4.0rc2.tar.gz && \
 
    tar xfz swift-*.tar.gz && \
 
    cd swift-* && \
 
    ./scons SWIFT_INSTALLDIR=/usr/local /usr/local && \
 
    ./scons Swiften SWIFTEN_INSTALLDIR=/usr/local /usr/local && \
 
    cd .. && rm -rf swift-* && \
 

	
 
    cd spectrum2 && \
 
    cmake . && \
 
    make && \
 

	
 
    apk del .build-deps
backends/libpurple/main.cpp
Show inline comments
 
@@ -461,49 +461,49 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
 
		}
 

	
 
		void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
 
			PurpleAccount *account = m_sessions[user];
 
			if (account) {
 
				if (account->ui_data) {
 
					NodeCache *cache = (NodeCache *) account->ui_data;
 
					purple_timeout_remove_wrapped(cache->timer);
 
					delete cache;
 
					account->ui_data = NULL;
 
				}
 
				if (purple_account_get_int_wrapped(account, "version", 0) != 0) {
 
					std::string data = stringOf(purple_account_get_int_wrapped(account, "version", 0));
 
					g_file_set_contents ("gfire.cfg", data.c_str(), data.size(), NULL);
 
				}
 
// 				VALGRIND_DO_LEAK_CHECK;
 
				m_sessions.erase(user);
 
				purple_account_disconnect_wrapped(account);
 
				purple_account_set_enabled_wrapped(account, "spectrum", FALSE);
 

	
 
				m_accounts.erase(account);
 

	
 
				purple_accounts_delete_wrapped(account);
 
#ifndef WIN32
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
#if !defined(__FreeBSD__) && !defined(__APPLE__) && defined (__GLIBC__)
 
				malloc_trim(0);
 
#endif
 
#endif
 
// 				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 pbnetwork::STATUS_AWAY: {
 
						st = PURPLE_STATUS_AWAY;
 
						if (!purple_account_get_status_type_with_primitive_wrapped(account, PURPLE_STATUS_AWAY))
 
							st = PURPLE_STATUS_EXTENDED_AWAY;
 
						else
 
							st = PURPLE_STATUS_AWAY;
 
						break;
 
					}
 
					case pbnetwork::STATUS_DND: {
 
						st = PURPLE_STATUS_UNAVAILABLE;
 
						break;
 
					}
 
@@ -2090,49 +2090,49 @@ debug_init(void)
 
	REGISTER_G_LOG_HANDLER("GLib-GObject");
 
	REGISTER_G_LOG_HANDLER("GThread");
 
	REGISTER_G_LOG_HANDLER("GConf");
 

	
 

	
 
#undef REGISTER_G_LOD_HANDLER
 
}
 

	
 
static PurpleCoreUiOps coreUiOps =
 
{
 
	NULL,
 
	debug_init,
 
	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_wrapped(gc);
 
	np->handleConnected(np->m_accounts[account]);
 
#ifndef WIN32
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
#if !defined(__FreeBSD__) && !defined(__APPLE__) && defined (__GLIBC__)
 
	// force returning of memory chunks allocated by libxml2 to kernel
 
	malloc_trim(0);
 
#endif
 
#endif
 
	purple_roomlist_get_list_wrapped(gc);
 

	
 
	// For prpl-gg
 
	execute_purple_plugin_action(gc, "Download buddylist from Server");
 
	if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
 
		storeUserToken(np->m_accounts[account], OAUTH_TOKEN, purple_account_get_password_wrapped(account));
 
	}
 
	else if (CONFIG_STRING(config, "service.protocol") == "prpl-steam-mobile") {
 
		storeUserToken(np->m_accounts[account], STEAM_ACCESS_TOKEN, purple_account_get_string_wrapped(account, "access_token", NULL));
 
	}
 
    else if (CONFIG_STRING(config, "service.protocol") == "prpl-eionrobb-discord") {
 
        storeUserToken(np->m_accounts[account], DISCORD_ACCESS_TOKEN, purple_account_get_string_wrapped(account, "token", NULL));
 
    }
 
}
 

	
 
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);
 

	
 
@@ -2314,49 +2314,49 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
 
			if (CONFIG_BOOL(config, "service.server_mode") || CONFIG_STRING(config, "service.protocol") == "prpl-irc") {
 
				cfg.setNeedRegistration(false);
 
			}
 
			else {
 
				cfg.setNeedRegistration(true);
 
			}
 
			np->sendConfig(cfg);
 
		}
 

	
 
		np->handleDataRead(d);
 
	}
 
	else {
 
		if (writeInput != 0) {
 
			purple_input_remove_wrapped(writeInput);
 
			writeInput = 0;
 
		}
 
		np->readyForData();
 
	}
 
}
 

	
 
int main(int argc, char **argv) {
 
	boost::locale::generator gen;
 
	std::locale::global(gen(""));
 
#ifndef WIN32
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
#if !defined(__FreeBSD__) && !defined(__APPLE__) && defined (__GLIBC__)
 
		mallopt(M_CHECK_ACTION, 2);
 
		mallopt(M_PERTURB, 0xb);
 
#endif
 

	
 
		signal(SIGPIPE, SIG_IGN);
 

	
 
		if (signal(SIGCHLD, spectrum_sigchld_handler) == SIG_ERR) {
 
			std::cout << "SIGCHLD handler can't be set\n";
 
			return -1;
 
		}
 
#endif
 

	
 
	std::string error;
 
	Config *cfg = Config::createFromArgs(argc, argv, error, host, port);
 
	if (cfg == NULL) {
 
		std::cerr << error;
 
		return 1;
 
	}
 

	
 
	config = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Config>(cfg);
 

	
 
	Logging::initBackendLogging(config.get());
 
	if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts" || CONFIG_STRING(config, "service.protocol") == "prpl-steam-mobile" || CONFIG_STRING(config, "service.protocol") == "prpl-eionrobb-discord") {
 
		storagebackend = StorageBackend::createBackend(config.get(), error);
backends/swiften/main.cpp
Show inline comments
 
@@ -206,52 +206,54 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
 
					case Swift::ClientError::CertificatePathLengthExceededError: message = ("Certificate path length constraint exceeded"); break;
 
					case Swift::ClientError::InvalidCertificateSignatureError: message = ("Invalid certificate signature"); break;
 
					case Swift::ClientError::InvalidCAError: message = ("Invalid Certificate Authority"); break;
 
					case Swift::ClientError::InvalidServerIdentityError: message = ("Certificate does not match the host identity"); break;
 
					case Swift::ClientError::CertificateCardRemoved: message = ("Certificate card has been removed"); break;
 
					case Swift::ClientError::RevokedError: message = ("Certificate has been revoked"); break;
 
					case Swift::ClientError::RevocationCheckFailedError: message = ("Certificate revocation check has failed"); break;
 
				}
 
			}
 
			LOG4CXX_INFO(logger, user << ": Disconnected " << message);
 
			handleDisconnected(user, reconnect ? 0 : 3, message);
 

	
 
			SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
 
			if (client) {
 
				client->onConnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
 
				client->onDisconnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftDisconnected, this, user, _1));
 
				client->onMessageReceived.disconnect(boost::bind(&SwiftenPlugin::handleSwiftMessageReceived, this, user, _1));
 
				m_users.erase(user);
 
				m_handlers.erase(user);
 
			}
 

	
 
#ifndef WIN32
 
#ifndef __FreeBSD__
 
#ifndef __MACH__
 
#if defined (__GLIBC__)
 
			// force returning of memory chunks allocated by libxml2 to kernel
 
			malloc_trim(0);
 
#endif
 
#endif
 
#endif
 
#endif
 
		}
 

	
 
		void handleSwiftConnected(const std::string &user) {
 
			LOG4CXX_INFO(logger, user << ": Connected to XMPP server.");
 
			handleConnected(user);
 
			m_users[user]->requestRoster();
 
			Swift::Presence::ref response = Swift::Presence::create();
 
			response->setFrom(m_users[user]->getJID());
 
			m_users[user]->sendPresence(response);
 
		}
 

	
 
		void handleSwiftRosterReceived(const std::string &user) {
 
			Swift::PresenceOracle *oracle = m_users[user]->getPresenceOracle();
 
			BOOST_FOREACH(const Swift::XMPPRosterItem &item, m_users[user]->getRoster()->getItems()) {
 
				Swift::Presence::ref lastPresence = oracle->getLastPresence(item.getJID());
 
				pbnetwork::StatusType status = lastPresence ? ((pbnetwork::StatusType) lastPresence->getShow()) : pbnetwork::STATUS_NONE;
 
				handleBuddyChanged(user, item.getJID().toBare().toString(),
 
					item.getName(), item.getGroups(), status);
 
			}
 
		}
 

	
 
		void handleSwiftPresenceChanged(const std::string &user, Swift::Presence::ref presence) {
 
//			SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
spectrum/src/main.cpp
Show inline comments
 
@@ -299,53 +299,55 @@ int mainloop() {
 
	delete factories;
 
	return 0;
 
}
 

	
 

	
 
int main(int argc, char **argv)
 
{
 
	Config config(argc, argv);
 
	config_ = &config;
 
	boost::program_options::variables_map vm;
 
	bool no_daemon = false;
 
	std::string config_file;
 
	std::string jid;
 
#ifdef WIN32
 
	std::string install_service_name, uninstall_service_name, run_service_name;
 
	// determine the name of the currently executing file
 
	char szFilePath[MAX_PATH];
 
	GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath));
 
	std::string exe_file(szFilePath);
 
#endif
 
	setlocale(LC_ALL, "");
 
#ifndef WIN32
 
#ifndef __FreeBSD__
 
#ifndef __MACH__
 
#if defined (__GLIBC__)
 
	mallopt(M_CHECK_ACTION, 2);
 
	mallopt(M_PERTURB, 0xb);
 
#endif
 
#endif
 
#endif
 
#endif
 

	
 
#ifndef WIN32
 
	if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) {
 
		std::cout << "SIGINT handler can't be set\n";
 
		return -1;
 
	}
 

	
 
	if (signal(SIGTERM, spectrum_sigterm_handler) == SIG_ERR) {
 
		std::cout << "SIGTERM handler can't be set\n";
 
		return -1;
 
	}
 
#else
 
	if( !SetConsoleCtrlHandler( (PHANDLER_ROUTINE) spectrum_control_handler, TRUE ) )
 
	{
 
		std::cout << "control handler can't be set\n";
 
		return -1;
 
	}
 
#endif
 
	boost::program_options::options_description desc(std::string("Spectrum version: ") + SPECTRUM_VERSION + "\nUsage: spectrum [OPTIONS] <config_file.cfg>\nAllowed options");
 
	desc.add_options()
 
		("help,h", "help")
 
		("no-daemonize,n", "Do not run spectrum as daemon")
 
		("no-debug,d", "Create coredumps on crash")
 
		("jid,j", boost::program_options::value<std::string>(&jid)->default_value(""), "Specify JID of transport manually")
0 comments (0 inline, 0 general)