Changeset - 719e5d2dc018
[Not reviewed]
0 5 0
Joel Reymont - 12 years ago 2013-07-10 17:20:59
joelr1@gmail.com
build on the mac
5 files changed with 17 insertions and 5 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
#include "utils.h"
 

	
 
#include "glib.h"
 

	
 
// win32/libc_interface.h defines its own socket(), read() and so on.
 
// We don't want to use it here.
 
#define _LIBC_INTERFACE_H_ 1
 

	
 
#include "purple.h"
 
#include <algorithm>
 
#include <iostream>
 

	
 
#include "transport/networkplugin.h"
 
#include "transport/logging.h"
 
#include "transport/config.h"
 
#include "transport/logging.h"
 
#include "geventloop.h"
 

	
 
// #include "valgrind/memcheck.h"
 
#ifndef __FreeBSD__
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
#include "malloc.h"
 
#endif
 
#include <algorithm>
 
#include "errno.h"
 
#include <boost/make_shared.hpp>
 

	
 
#ifdef WITH_LIBEVENT
 
#include <event.h>
 
#endif
 

	
 
#ifdef WIN32
 
#include "win32/win32dep.h"
 
#define close closesocket
 
#define ssize_t SSIZE_T
 
#include <process.h>
 
#define getpid _getpid
 
#endif
 

	
 
#include "purple_defs.h"
 

	
 
DEFINE_LOGGER(logger_libpurple, "libpurple");
 
DEFINE_LOGGER(logger, "backend");
 

	
 
int main_socket;
 
@@ -396,49 +396,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
 
#ifndef __FreeBSD__
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
				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;
 
					}
 
@@ -1562,49 +1562,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
 
#ifndef __FreeBSD__
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
	// force returning of memory chunks allocated by libxml2 to kernel
 
	malloc_trim(0);
 
#endif
 
#endif
 

	
 
	// For prpl-gg
 
	execute_purple_plugin_action(gc, "Download buddylist from Server");
 
}
 

	
 
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(':');
 

	
 
	LOG4CXX_INFO(logger_libpurple, c << args);
 
}
 

	
 
/*
 
@@ -1761,49 +1761,49 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
 
			exit(errno);
 
		}
 
		std::string d = std::string(buffer, n);
 

	
 
		if (firstPing) {
 
			firstPing = false;
 
			NetworkPlugin::PluginConfig cfg;
 
			cfg.setSupportMUC(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) {
 
#ifndef WIN32
 
#ifndef __FreeBSD__
 
#if !defined(__FreeBSD__) && !defined(__APPLE__)
 
		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 = boost::shared_ptr<Config>(cfg);
 
 
 
	Logging::initBackendLogging(config.get());
 
	initPurple();
 
 
backends/libyahoo2/yahoo/crypt.c
Show inline comments
 
@@ -5,48 +5,52 @@
 

	
 
   The GNU C Library is free software; you can redistribute it and/or
 
   modify it under the terms of the GNU Lesser General Public
 
   License as published by the Free Software Foundation; either
 
   version 2.1 of the License, or (at your option) any later version.
 

	
 
   The GNU C Library is distributed in the hope that it will be useful,
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
   Lesser General Public License for more details.
 

	
 
   You should have received a copy of the GNU Lesser General Public
 
   License along with the GNU C Library; if not, write to the Free
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
   02111-1307 USA.  */
 

	
 
/* warmenhoven took this file and made it work with the md5.[ch] we
 
 * already had. isn't that lovely. people should just use linux or
 
 * freebsd, crypt works properly on those systems. i hate solaris */
 

	
 
#if HAVE_CONFIG_H
 
# include <config.h>
 
#endif
 

	
 
#ifdef __APPLE__
 
#define HAVE_STRING_H 1
 
#endif
 

	
 
#if HAVE_STRING_H
 
#  include <string.h>
 
#elif HAVE_STRINGS_H
 
#  include <strings.h>
 
#endif
 

	
 
#include <stdlib.h>
 
#include "yahoo_util.h"
 

	
 
#include "md5.h"
 

	
 
/* Define our magic string to mark salt for MD5 "encryption"
 
   replacement.  This is meant to be the same as for other MD5 based
 
   encryption implementations.  */
 
static const char md5_salt_prefix[] = "$1$";
 

	
 
/* Table with characters for base64 transformation.  */
 
static const char b64t[64] =
 
	"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 

	
 
char *yahoo_crypt(char *key, char *salt)
 
{
 
	char *buffer = NULL;
 
	int buflen = 0;
backends/libyahoo2/yahoo/libyahoo2.c
Show inline comments
 
@@ -30,48 +30,52 @@
 
 *
 
 * YMSG16 authentication code based mostly on write-up at:
 
 * 	http://www.carbonize.co.uk/ymsg16.html
 
 *
 
 * This program is free software; you can redistribute it and/or modify
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation; either version 2 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 *
 
 */
 

	
 
#if HAVE_CONFIG_H
 
# include <config.h>
 
#endif
 

	
 
#if __APPLE__
 
#define STDC_HEADERS 1
 
#endif
 

	
 
#if HAVE_UNISTD_H
 
#include <unistd.h>
 
#endif
 
#include <errno.h>
 
#include <stdio.h>
 
#include <stdarg.h>
 

	
 
#if STDC_HEADERS
 
# include <string.h>
 
#else
 
# if !HAVE_STRCHR
 
#  define strchr index
 
#  define strrchr rindex
 
# endif
 
char *strchr(), *strrchr();
 
# if !HAVE_MEMCPY
 
#  define memcpy(d, s, n) bcopy ((s), (d), (n))
 
#  define memmove(d, s, n) bcopy ((s), (d), (n))
 
# endif
 
#endif
 

	
 
#include <sys/types.h>
 

	
 
#include <stdlib.h>
backends/libyahoo2/yahoo/yahoo_util.c
Show inline comments
 
@@ -2,48 +2,52 @@
 
 * libyahoo2: yahoo_util.c
 
 *
 
 * Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
 
 *
 
 * This program is free software; you can redistribute it and/or modify
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation; either version 2 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 *
 
 */
 

	
 
#if HAVE_CONFIG_H
 
# include <config.h>
 
#endif
 

	
 
#if __APPLE__
 
#define STDC_HEADERS 1
 
#endif
 

	
 
#if STDC_HEADERS
 
# include <string.h>
 
#else
 
# if !HAVE_STRCHR
 
#  define strchr index
 
#  define strrchr rindex
 
# endif
 
char *strchr(), *strrchr();
 
# if !HAVE_MEMCPY
 
#  define memcpy(d, s, n) bcopy ((s), (d), (n))
 
#  define memmove(d, s, n) bcopy ((s), (d), (n))
 
# endif
 
#endif
 

	
 
#include "yahoo_util.h"
 

	
 
char *y_string_append(char *string, char *append)
 
{
 
	int size = strlen(string) + strlen(append) + 1;
 
	char *new_string = y_renew(char, string, size);
 

	
 
	if (new_string == NULL) {
 
		new_string = y_new(char, size);
 
		strcpy(new_string, string);
backends/libyahoo2/yahoo/yahoo_util.h
Show inline comments
 
@@ -43,49 +43,49 @@
 
# endif
 
# ifndef strncasecmp
 
#  define strncasecmp	g_strncasecmp
 
#  define strcasecmp	g_strcasecmp
 
# endif
 

	
 
# define snprintf	g_snprintf
 
# define vsnprintf	g_vsnprintf
 

	
 
#else
 

	
 
# include <stdlib.h>
 
# include <stdarg.h>
 

	
 
# define FREE(x)		if(x) {free(x); x=NULL;}
 

	
 
# define y_new(type, n)		(type *)malloc(sizeof(type) * (n))
 
# define y_new0(type, n)	(type *)calloc((n), sizeof(type))
 
# define y_renew(type, mem, n)	(type *)realloc(mem, n)
 

	
 
void *y_memdup(const void *addr, int n);
 
char **y_strsplit(char *str, char *sep, int nelem);
 
void y_strfreev(char **vector);
 

	
 
#ifndef _WIN32
 
#if !defined(_WIN32) && !defined(__APPLE__)
 
int strncasecmp(const char *s1, const char *s2, size_t n);
 
int strcasecmp(const char *s1, const char *s2);
 

	
 
char *strdup(const char *s);
 

	
 
int snprintf(char *str, size_t size, const char *format, ...);
 
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
 
#endif
 

	
 
#endif
 

	
 
#ifndef TRUE
 
#define TRUE 1
 
#endif
 

	
 
#ifndef FALSE
 
#define FALSE 0
 
#endif
 

	
 
#ifndef MIN
 
#define MIN(x,y) ((x)<(y)?(x):(y))
 
#endif
 

	
 
#ifndef MAX
0 comments (0 inline, 0 general)