Fixed spectrum2 compilation with MSVC. Thanks to Vitaly Takmazov
This commit is contained in:
parent
1b4e600948
commit
7e87208497
13 changed files with 61 additions and 36 deletions
|
@ -18,9 +18,9 @@
|
|||
#include "Swiften/TLS/OpenSSL/OpenSSLServerContext.h"
|
||||
#include "Swiften/TLS/OpenSSL/OpenSSLCertificate.h"
|
||||
#include "Swiften/TLS/PKCS12Certificate.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
|
||||
#endif
|
||||
namespace Swift {
|
||||
|
||||
static const int MAX_FINISHED_SIZE = 4096;
|
||||
|
@ -50,7 +50,7 @@ OpenSSLServerContext::OpenSSLServerContext() : state_(Start), context_(0), handl
|
|||
if (!certContext) {
|
||||
break;
|
||||
}
|
||||
ByteArray certData(certContext->pbCertEncoded, certContext->cbCertEncoded);
|
||||
ByteArray certData(createByteArray(certContext->pbCertEncoded, certContext->cbCertEncoded));
|
||||
OpenSSLCertificate cert(certData);
|
||||
if (store && cert.getInternalX509()) {
|
||||
X509_STORE_add_cert(store, cert.getInternalX509().get());
|
||||
|
|
|
@ -87,7 +87,7 @@ class Buddy {
|
|||
}
|
||||
|
||||
bool isBlocked() {
|
||||
return m_flags & BUDDY_BLOCKED;
|
||||
return (m_flags & BUDDY_BLOCKED) != 0;
|
||||
}
|
||||
|
||||
/// Sets current subscription.
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "Swiften/Swiften.h"
|
||||
#include "transport/storagebackend.h"
|
||||
#include "transport/config.h"
|
||||
#include <sqlite3.h>
|
||||
#include "sqlite3.h"
|
||||
|
||||
namespace Transport {
|
||||
|
||||
|
|
|
@ -3,12 +3,17 @@
|
|||
#include "transport/usermanager.h"
|
||||
#include "transport/logger.h"
|
||||
#include "transport/sqlite3backend.h"
|
||||
#include "transport/mysqlbackend.h"
|
||||
//#include "transport/mysqlbackend.h"
|
||||
#include "transport/userregistration.h"
|
||||
#include "transport/networkpluginserver.h"
|
||||
#include "transport/admininterface.h"
|
||||
#include "Swiften/EventLoop/SimpleEventLoop.h"
|
||||
#ifndef WIN32
|
||||
#include "sys/signal.h"
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
#include "log4cxx/logger.h"
|
||||
#include "log4cxx/patternlayout.h"
|
||||
#include "log4cxx/propertyconfigurator.h"
|
||||
|
@ -31,7 +36,7 @@ static void spectrum_sigterm_handler(int sig) {
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
Config config;
|
||||
|
||||
#ifndef WIN32
|
||||
if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) {
|
||||
std::cout << "SIGINT handler can't be set\n";
|
||||
return -1;
|
||||
|
@ -41,7 +46,7 @@ int main(int argc, char **argv)
|
|||
std::cout << "SIGTERM handler can't be set\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
boost::program_options::options_description desc("Usage: spectrum [OPTIONS] <config_file.cfg>\nAllowed options");
|
||||
desc.add_options()
|
||||
("help,h", "help")
|
||||
|
@ -82,7 +87,11 @@ int main(int argc, char **argv)
|
|||
|
||||
if (CONFIG_STRING(&config, "logging.config").empty()) {
|
||||
LoggerPtr root = log4cxx::Logger::getRootLogger();
|
||||
#ifdef WIN32
|
||||
root->addAppender(new ConsoleAppender(new PatternLayout(L"%d %-5p %c: %m%n")));
|
||||
#else
|
||||
root->addAppender(new ConsoleAppender(new PatternLayout("%d %-5p %c: %m%n")));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
log4cxx::PropertyConfigurator::configure(CONFIG_STRING(&config, "logging.config"));
|
||||
|
@ -105,6 +114,7 @@ int main(int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
else if (CONFIG_STRING(&config, "database.type") == "mysql") {
|
||||
storageBackend = new MySQLBackend(&config);
|
||||
if (!storageBackend->connect()) {
|
||||
|
@ -112,7 +122,7 @@ int main(int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
UserManager userManager(&transport, &userRegistry, storageBackend);
|
||||
UserRegistration *userRegistration = NULL;
|
||||
if (storageBackend) {
|
||||
|
|
|
@ -33,33 +33,33 @@ using namespace boost;
|
|||
namespace Transport {
|
||||
|
||||
Logger::Logger(Component *component) {
|
||||
component->onConnected.connect(bind(&Logger::handleConnected, this));
|
||||
component->onConnectionError.connect(bind(&Logger::handleConnectionError, this, _1));
|
||||
component->onXMLIn.connect(bind(&Logger::handleXMLIn, this, _1));
|
||||
component->onXMLOut.connect(bind(&Logger::handleXMLOut, this, _1));
|
||||
component->onConnected.connect(boost::bind(&Logger::handleConnected, this));
|
||||
component->onConnectionError.connect(boost::bind(&Logger::handleConnectionError, this, _1));
|
||||
component->onXMLIn.connect(boost::bind(&Logger::handleXMLIn, this, _1));
|
||||
component->onXMLOut.connect(boost::bind(&Logger::handleXMLOut, this, _1));
|
||||
}
|
||||
|
||||
Logger::~Logger(){
|
||||
}
|
||||
|
||||
void Logger::setStorageBackend(StorageBackend *storage) {
|
||||
storage->onStorageError.connect(bind(&Logger::handleStorageError, this, _1, _2));
|
||||
storage->onStorageError.connect(boost::bind(&Logger::handleStorageError, this, _1, _2));
|
||||
}
|
||||
|
||||
void Logger::setUserRegistration(UserRegistration *userRegistration) {
|
||||
userRegistration->onUserRegistered.connect(bind(&Logger::handleUserRegistered, this, _1));
|
||||
userRegistration->onUserUnregistered.connect(bind(&Logger::handleUserUnregistered, this, _1));
|
||||
userRegistration->onUserUpdated.connect(bind(&Logger::handleUserUpdated, this, _1));
|
||||
userRegistration->onUserRegistered.connect(boost::bind(&Logger::handleUserRegistered, this, _1));
|
||||
userRegistration->onUserUnregistered.connect(boost::bind(&Logger::handleUserUnregistered, this, _1));
|
||||
userRegistration->onUserUpdated.connect(boost::bind(&Logger::handleUserUpdated, this, _1));
|
||||
}
|
||||
|
||||
void Logger::setUserManager(UserManager *userManager) {
|
||||
userManager->onUserCreated.connect(bind(&Logger::handleUserCreated, this, _1));
|
||||
userManager->onUserDestroyed.connect(bind(&Logger::handleUserDestroyed, this, _1));
|
||||
userManager->onUserCreated.connect(boost::bind(&Logger::handleUserCreated, this, _1));
|
||||
userManager->onUserDestroyed.connect(boost::bind(&Logger::handleUserDestroyed, this, _1));
|
||||
}
|
||||
|
||||
void Logger::setRosterManager(RosterManager *rosterManager) {
|
||||
rosterManager->onBuddySet.connect(bind(&Logger::handleBuddySet, this, _1));
|
||||
rosterManager->onBuddyUnset.connect(bind(&Logger::handleBuddyUnset, this, _1));
|
||||
rosterManager->onBuddySet.connect(boost::bind(&Logger::handleBuddySet, this, _1));
|
||||
rosterManager->onBuddyUnset.connect(boost::bind(&Logger::handleBuddyUnset, this, _1));
|
||||
}
|
||||
|
||||
void Logger::handleConnected() {
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#ifndef WIN32
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#ifdef BSD
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
|
|
@ -60,7 +60,9 @@ NetworkPlugin::NetworkPlugin(Swift::EventLoop *loop, const std::string &host, in
|
|||
connect();
|
||||
|
||||
double shared;
|
||||
#ifndef WIN32
|
||||
process_mem_usage(shared, m_init_res);
|
||||
#endif
|
||||
}
|
||||
|
||||
NetworkPlugin::~NetworkPlugin() {
|
||||
|
@ -509,7 +511,9 @@ void NetworkPlugin::sendMemoryUsage() {
|
|||
stats.set_init_res(m_init_res);
|
||||
double res;
|
||||
double shared;
|
||||
#ifndef WIN32
|
||||
process_mem_usage(shared, res);
|
||||
#endif
|
||||
stats.set_res(res);
|
||||
stats.set_shared(shared);
|
||||
|
||||
|
|
|
@ -124,8 +124,8 @@ static unsigned long exec_(std::string path, const char *host, const char *port,
|
|||
si.cb=sizeof (si);
|
||||
|
||||
if (! CreateProcess(
|
||||
original_path.c_str(),
|
||||
path.c_str(), // command line
|
||||
NULL,
|
||||
(LPSTR)path.c_str(), // command line
|
||||
0, // process attributes
|
||||
0, // thread attributes
|
||||
0, // inherit handles
|
||||
|
@ -1078,7 +1078,7 @@ void NetworkPluginServer::handleBlockToggled(Buddy *b) {
|
|||
buddy.set_alias(b->getAlias());
|
||||
buddy.set_groups(b->getGroups().size() == 0 ? "" : b->getGroups()[0]);
|
||||
buddy.set_status(Swift::StatusShow::None);
|
||||
buddy.set_blocked(not b->isBlocked());
|
||||
buddy.set_blocked(!b->isBlocked());
|
||||
|
||||
std::string message;
|
||||
buddy.SerializeToString(&message);
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "log4cxx/logger.h"
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <iterator>
|
||||
|
||||
using namespace log4cxx;
|
||||
|
||||
namespace Transport {
|
||||
|
@ -56,7 +59,7 @@ RosterManager::~RosterManager() {
|
|||
|
||||
sendUnavailablePresences(m_user->getJID().toBare());
|
||||
|
||||
for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
Buddy *buddy = (*it).second;
|
||||
if (!buddy) {
|
||||
continue;
|
||||
|
@ -184,7 +187,7 @@ void RosterManager::sendRIE() {
|
|||
|
||||
// fallback to normal subscribe
|
||||
if (!jidWithRIE.isValid()) {
|
||||
for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
Buddy *buddy = (*it).second;
|
||||
if (!buddy) {
|
||||
continue;
|
||||
|
@ -197,7 +200,7 @@ void RosterManager::sendRIE() {
|
|||
LOG4CXX_INFO(logger, "Sending RIE stanza to " << jidWithRIE.toString());
|
||||
|
||||
Swift::RosterItemExchangePayload::ref payload = Swift::RosterItemExchangePayload::ref(new Swift::RosterItemExchangePayload());
|
||||
for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
Buddy *buddy = (*it).second;
|
||||
if (!buddy) {
|
||||
continue;
|
||||
|
@ -375,7 +378,7 @@ void RosterManager::setStorageBackend(StorageBackend *storageBackend) {
|
|||
Swift::RosterPayload::ref RosterManager::generateRosterPayload() {
|
||||
Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload());
|
||||
|
||||
for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
Buddy *buddy = (*it).second;
|
||||
if (!buddy) {
|
||||
continue;
|
||||
|
@ -391,7 +394,7 @@ Swift::RosterPayload::ref RosterManager::generateRosterPayload() {
|
|||
}
|
||||
|
||||
void RosterManager::sendCurrentPresences(const Swift::JID &to) {
|
||||
for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
Buddy *buddy = (*it).second;
|
||||
if (!buddy) {
|
||||
continue;
|
||||
|
@ -423,7 +426,7 @@ void RosterManager::sendCurrentPresence(const Swift::JID &from, const Swift::JID
|
|||
}
|
||||
|
||||
void RosterManager::sendUnavailablePresences(const Swift::JID &to) {
|
||||
for (std::map<std::string, Buddy *>::const_iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
for (std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > >::iterator it = m_buddies.begin(); it != m_buddies.end(); it++) {
|
||||
Buddy *buddy = (*it).second;
|
||||
if (!buddy) {
|
||||
continue;
|
||||
|
|
|
@ -225,7 +225,7 @@ bool SQLite3Backend::getUser(const std::string &barejid, UserInfo &user) {
|
|||
user.password = (const char *) sqlite3_column_text(m_getUser, 3);
|
||||
user.encoding = (const char *) sqlite3_column_text(m_getUser, 4);
|
||||
user.language = (const char *) sqlite3_column_text(m_getUser, 5);
|
||||
user.vip = sqlite3_column_int(m_getUser, 6);
|
||||
user.vip = sqlite3_column_int(m_getUser, 6) != 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,17 +95,17 @@ Component::Component(Swift::EventLoop *loop, Swift::NetworkFactories *factories,
|
|||
m_server->addPayloadSerializer(new Swift::BlockSerializer());
|
||||
m_server->addPayloadSerializer(new Swift::InvisibleSerializer());
|
||||
|
||||
m_server->onDataRead.connect(bind(&Component::handleDataRead, this, _1));
|
||||
m_server->onDataWritten.connect(bind(&Component::handleDataWritten, this, _1));
|
||||
m_server->onDataRead.connect(boost::bind(&Component::handleDataRead, this, _1));
|
||||
m_server->onDataWritten.connect(boost::bind(&Component::handleDataWritten, this, _1));
|
||||
}
|
||||
else {
|
||||
LOG4CXX_INFO(logger, "Creating component in gateway mode");
|
||||
m_component = new Swift::Component(loop, m_factories, m_jid, CONFIG_STRING(m_config, "service.password"));
|
||||
m_component->setSoftwareVersion("", "");
|
||||
m_component->onConnected.connect(bind(&Component::handleConnected, this));
|
||||
m_component->onError.connect(bind(&Component::handleConnectionError, this, _1));
|
||||
m_component->onDataRead.connect(bind(&Component::handleDataRead, this, _1));
|
||||
m_component->onDataWritten.connect(bind(&Component::handleDataWritten, this, _1));
|
||||
m_component->onError.connect(boost::bind(&Component::handleConnectionError, this, _1));
|
||||
m_component->onDataRead.connect(boost::bind(&Component::handleDataRead, this, _1));
|
||||
m_component->onDataWritten.connect(boost::bind(&Component::handleDataWritten, this, _1));
|
||||
m_stanzaChannel = m_component->getStanzaChannel();
|
||||
m_iqRouter = m_component->getIQRouter();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#include "Swiften/Elements/MUCPayload.h"
|
||||
#include "log4cxx/logger.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#ifndef WIN32
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -105,6 +107,7 @@ Swift::JID User::getJIDWithFeature(const std::string &feature) {
|
|||
static void
|
||||
print_trace (void)
|
||||
{
|
||||
#ifndef WIN32
|
||||
void *array[80];
|
||||
size_t size;
|
||||
char **strings;
|
||||
|
@ -119,6 +122,7 @@ for (i = 0; i < size; i++)
|
|||
printf ("%s\n", strings[i]);
|
||||
|
||||
free (strings);
|
||||
#endif
|
||||
}
|
||||
|
||||
void User::handlePresence(Swift::Presence::ref presence) {
|
||||
|
|
|
@ -99,7 +99,9 @@ void UserManager::removeUser(User *user) {
|
|||
|
||||
onUserDestroyed(user);
|
||||
delete user;
|
||||
#ifndef WIN32
|
||||
malloc_trim(0);
|
||||
#endif
|
||||
// VALGRIND_DO_LEAK_CHECK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue