Changeset - 10cef3dd0995
[Not reviewed]
Merge
0 4 0
Vitaly Takmazov - 12 years ago 2013-05-28 16:48:29
vitalyster@gmail.com
Merge branch 'master' of https://github.com/hanzz/libtransport
4 files changed with 43 insertions and 4 deletions:
0 comments (0 inline, 0 general)
backends/twitter/TwitterPlugin.cpp
Show inline comments
 
@@ -348,7 +348,7 @@ void TwitterPlugin::pollForDirectMessages()
 
	std::set<std::string>::iterator it = onlineUsers.begin();
 
	while(it != onlineUsers.end()) {
 
		std::string user = *it;
 
		tp->runAsThread(new DirectMessageRequest(userdb[user].sessions, user, "", userdb[user].mostRecentDirectMessageID,
 
		tp->runAsThread(new DirectMessageRequest(userdb[user].sessions, user, "", getMostRecentDMIDUnsafe(user),
 
											boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4)));
 
		it++;
 
	}
 
@@ -569,14 +569,37 @@ void TwitterPlugin::updateLastDMID(const std::string user, const std::string ID)
 
{
 
	boost::mutex::scoped_lock lock(userlock);	
 
	userdb[user].mostRecentDirectMessageID = ID;
 

	
 
	UserInfo info;
 
	if(storagebackend->getUser(user, info) == false) {
 
		LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
 
		return;
 
	}
 

	
 
	storagebackend->updateUserSetting((long)info.id, "twitter_last_dm", ID);
 
}
 

	
 
std::string TwitterPlugin::getMostRecentDMIDUnsafe(const std::string user) {
 
	std::string ID = "";
 
	if(onlineUsers.count(user)) {
 
		ID = userdb[user].mostRecentDirectMessageID;
 
		if (ID.empty()) {
 
			int type;
 
			UserInfo info;
 
			if(storagebackend->getUser(user, info) == false) {
 
				LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
 
			}
 
			else {
 
				storagebackend->getUserSetting(info.id, "twitter_last_dm", type, ID);
 
			}
 
		}
 
	}
 
}
 

	
 
std::string TwitterPlugin::getMostRecentDMID(const std::string user)
 
{
 
	boost::mutex::scoped_lock lock(userlock);	
 
	std::string ID = "";
 
	if(onlineUsers.count(user)) ID = userdb[user].mostRecentDirectMessageID;
 
	return ID;
 
	return getMostRecentDMIDUnsafe(user);
 
}
 

	
 
/************************************** Twitter response functions **********************************/
backends/twitter/TwitterPlugin.h
Show inline comments
 
@@ -136,6 +136,7 @@ class TwitterPlugin : public NetworkPlugin {
 

	
 
	private:
 
		std::string getMostRecentTweetIDUnsafe(const std::string user);
 
		std::string getMostRecentDMIDUnsafe(const std::string user);
 

	
 
		enum status {NEW, WAITING_FOR_PIN, CONNECTED, DISCONNECTED};
 
		enum mode {SINGLECONTACT, MULTIPLECONTACT, CHATROOM};
include/Swiften/Network/DummyNetworkFactories.cpp
Show inline comments
 
@@ -15,8 +15,12 @@ namespace Swift {
 
DummyNetworkFactories::DummyNetworkFactories(EventLoop* eventLoop) {
 
	timerFactory = new DummyTimerFactory();
 
	connectionFactory = new DummyConnectionFactory(eventLoop);
 
#if HAVE_SWIFTEN_3
 
	idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
 
	domainNameResolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop);
 
#else
 
	domainNameResolver = new PlatformDomainNameResolver(eventLoop);
 
#endif
 
	connectionServerFactory = new DummyConnectionServerFactory(eventLoop);
 
	m_platformXMLParserFactory =  new PlatformXMLParserFactory();
 
	this->eventLoop = eventLoop;
include/Swiften/Network/DummyNetworkFactories.h
Show inline comments
 
@@ -6,10 +6,17 @@
 

	
 
#pragma once
 

	
 
#include <Swiften/Version.h>
 
//#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
// Swiften 3 was not released yet and these changes are not in 3.0alpha
 
#define HAVE_SWIFTEN_3 0
 

	
 
#include <Swiften/Network/NetworkFactories.h>
 
#include <Swiften/Parser/PlatformXMLParserFactory.h>
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/IDN/IDNConverter.h>
 
#include <Swiften/IDN/PlatformIDNConverter.h>
 
#endif
 

	
 
namespace Swift {
 
	class EventLoop;
 
@@ -27,9 +34,11 @@ namespace Swift {
 
				return connectionFactory;
 
			}
 

	
 
#if HAVE_SWIFTEN_3
 
			IDNConverter* getIDNConverter() const {
 
				return idnConverter.get();
 
			}
 
#endif
 

	
 
			DomainNameResolver* getDomainNameResolver() const {
 
				return domainNameResolver;
 
@@ -63,7 +72,9 @@ namespace Swift {
 
			PlatformXMLParserFactory *m_platformXMLParserFactory;
 
			TimerFactory* timerFactory;
 
			ConnectionFactory* connectionFactory;
 
#if HAVE_SWIFTEN_3
 
			boost::shared_ptr<IDNConverter> idnConverter;
 
#endif
 
			DomainNameResolver* domainNameResolver;
 
			ConnectionServerFactory* connectionServerFactory;
 
			EventLoop *eventLoop;
0 comments (0 inline, 0 general)