Changeset - bdafc260c0ee
[Not reviewed]
0 2 0
HanzZ - 13 years ago 2012-05-23 18:18:37
hanzz.k@gmail.com
more tweaks
2 files changed with 15 insertions and 13 deletions:
0 comments (0 inline, 0 general)
backends/libyahoo2/main.cpp
Show inline comments
 
@@ -178,56 +178,57 @@ class YahooPlugin : public NetworkPlugin {
 
		}
 

	
 
		void _yahoo_data_written(yahoo_local_account *account, int conn_tag) {
 
			LOG4CXX_INFO(logger, "data written");
 
			currently_writting_account = account;
 
			for (std::map<int, yahoo_handler *>::iterator it = account->handlers_per_conn[conn_tag].begin(); it != account->handlers_per_conn[conn_tag].end(); it++) {
 
				if (it->second->cond == YAHOO_INPUT_WRITE) {
 
					yahoo_write_ready(account->id, (void *) conn_tag, it->second->data);
 
				}
 
			}
 
		}
 

	
 
		void _yahoo_disconnected(yahoo_local_account *account, int conn_tag, const boost::optional<Swift::Connection::Error> &error) {
 
			LOG4CXX_INFO(logger, "Disconnected " << error);
 
		}
 

	
 
		int _yahoo_connect_async(int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl) {
 
			yahoo_local_account *account = getAccount(id);
 
			if (!account) {
 
				LOG4CXX_ERROR(logger, "Unknown account id=" << id);
 
				return -1;
 
			}
 

	
 
// boost::asio::io_service io_service;
 
// boost::asio::ip::tcp::resolver resolver(io_service);
 
// boost::asio::ip::tcp::resolver::query query(values[1], "");
 
// for(boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);
 
//                             i != boost::asio::ip::tcp::resolver::iterator();
 
//                             ++i)
 
// {
 
//     boost::asio::ip::tcp::endpoint end = *i;
 
//     std::cout << end.address() << ' ';
 
// }
 
// std::cout << '\n';
 

	
 
			boost::asio::ip::tcp::resolver resolver(*m_boostIOServiceThread.getIOService());
 
			boost::asio::ip::tcp::resolver::query query(host, "");
 
			boost::asio::ip::address address;
 
			for(boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query); i != boost::asio::ip::tcp::resolver::iterator(); ++i) {
 
				boost::asio::ip::tcp::endpoint end = *i;
 
				address = end.address();
 
				break;
 
			}
 

	
 
			LOG4CXX_INFO(logger, m_ids[id] << ": Connecting " << host << ":" << port);
 
			int tag = account->conn_tag++;
 
			if (use_ssl) {
 
				account->conns[tag] = m_tlsFactory->createConnection();
 
			}
 
			else {
 
				account->conns[tag] = m_factories->getConnectionFactory()->createConnection();
 
			}
 
			account->conns[tag]->onConnectFinished.connect(boost::bind(&YahooPlugin::_yahoo_connect_finished, this, account, callback, data, tag, _1));
 
			account->conns[tag]->onDisconnected.connect(boost::bind(&YahooPlugin::_yahoo_disconnected, this, account, tag, _1));
 
			account->conns[tag]->onDataRead.connect(boost::bind(&YahooPlugin::_yahoo_data_read, this, account, tag, _1));
 
			account->conns[tag]->onDataWritten.connect(boost::bind(&YahooPlugin::_yahoo_data_written, this, account, tag));
 
			account->conns[tag]->connect(Swift::HostAddressPort(Swift::HostAddress("67.195.187.249"), port));
 
			account->conns[tag]->connect(Swift::HostAddressPort(Swift::HostAddress(address), port));
 
			return tag;
 
		}
 

	
 
	private:
 
		Config *config;
 
		std::map<std::string, yahoo_local_account *> m_users;
 
		std::map<int, std::string> m_ids;
 
};
 

	
 
static void spectrum_sigchld_handler(int sig)
 
{
 
	int status;
backends/swiften/main.cpp
Show inline comments
 
@@ -101,24 +101,25 @@ class SwiftenPlugin : public NetworkPlugin {
 
				client->onDisconnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftDisconnected, this, user, _1));
 
				client->onMessageReceived.disconnect(boost::bind(&SwiftenPlugin::handleSwiftMessageReceived, this, user, _1));
 
				m_users.erase(user);
 
			}
 

	
 
#ifndef WIN32
 
			// force returning of memory chunks allocated by libxml2 to kernel
 
			malloc_trim(0);
 
#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;
0 comments (0 inline, 0 general)