Changeset - 2836f390b953
[Not reviewed]
0 2 0
HanzZ - 14 years ago 2011-06-19 20:40:27
hanzz.k@gmail.com
Receive VCard from PurpleAccount and fixed crash on disconnect
2 files changed with 14 insertions and 2 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -674,55 +674,65 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
 
				lastName = purple_notify_user_info_entry_get_value(vcardEntry);
 
			}
 
			else if (label=="Nickname" || label == "Nick") {
 
				nickname = purple_notify_user_info_entry_get_value(vcardEntry);
 
			}
 
			else if (label=="Full Name") {
 
				fullName = purple_notify_user_info_entry_get_value(vcardEntry);
 
			}
 
			else {
 
				std::cout << "UNHANDLED VCARD LABEL '" << purple_notify_user_info_entry_get_label(vcardEntry) << "' " << purple_notify_user_info_entry_get_value(vcardEntry) << "\n";
 
			}
 
		}
 
		vcardEntries = vcardEntries->next;
 
	}
 

	
 
	if (name == purple_account_get_username(account)) {
 
		const gchar *displayname = purple_connection_get_display_name(gc);
 
		if (!displayname) {
 
			displayname = purple_account_get_name_for_display(account);
 
		}
 

	
 
		if (displayname) {
 
			nickname = displayname;
 
		}
 

	
 
		// avatar
 
		PurpleStoredImage *avatar = purple_buddy_icons_find_account_icon(account);
 
		if (avatar) {
 
			const gchar * data = (const gchar *) purple_imgstore_get_data(avatar);
 
			size_t len = purple_imgstore_get_size(avatar);
 
			if (len < 300000 && data) {
 
				photo = Swift::createByteArray(data, len);
 
			}
 
		}
 
	}
 

	
 
	if ((!firstName.empty() || !lastName.empty()) && fullName.empty())
 
		fullName = firstName + " " + lastName;
 

	
 
	PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(gc), who);
 
	if (buddy) {
 
	if (buddy && photo.size() == 0) {
 
		gsize len;
 
		PurpleBuddyIcon *icon = NULL;
 
		icon = purple_buddy_icons_find(purple_connection_get_account(gc), name.c_str());
 
		if (icon) {
 
			const gchar * data = (gchar*)purple_buddy_icon_get_data(icon, &len);
 
			// Sometimes libpurple returns really broken pointers here
 
			// They weren't able to do anything with that and I don't know what to do too,
 
			// so it's better to hack through it by not trying to forward really broken things...
 
			if (len < 300000 && data) {
 
				photo = Swift::createByteArray(data, len);
 
// 				const gchar *ext = (gchar*)purple_buddy_icon_get_extension(icon);
 
// 				if (ext) {
 
// 					std::string extension(ext);
 
// 					if (extension != "icon") {
 
// 						if (extension == "jpg") {
 
// 							extension = "jpeg";
 
// 						}
 
// 						photo->addChild( new Tag("TYPE", "image/" + extension) );
 
// 					}
 
// 				}
 
			}
 
		}
 
	}
 

	
include/Swiften/Server/Server.cpp
Show inline comments
 
@@ -36,49 +36,51 @@ Server::Server(
 
		EventLoop* eventLoop,
 
		NetworkFactories* networkFactories,
 
		UserRegistry *userRegistry,
 
		const JID& jid,
 
		int port) :
 
			userRegistry_(userRegistry),
 
			port_(port),
 
			eventLoop(eventLoop),
 
			networkFactories_(networkFactories),
 
			stopping(false),
 
			selfJID(jid),
 
			stanzaChannel_(){
 
	stanzaChannel_ = new ServerStanzaChannel();
 
	iqRouter_ = new IQRouter(stanzaChannel_);
 
	tlsFactory = NULL;
 
}
 

	
 
Server::~Server() {
 
	stop();
 
	delete iqRouter_;
 
	delete stanzaChannel_;
 
}
 

	
 
void Server::start() {
 
	assert(!serverFromClientConnectionServer);
 
	if (serverFromClientConnectionServer) {
 
		return;
 
	}
 
	serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(port_);
 
	serverFromClientConnectionServerSignalConnections.push_back(
 
		serverFromClientConnectionServer->onNewConnection.connect(
 
				boost::bind(&Server::handleNewClientConnection, this, _1)));
 
// 	serverFromClientConnectionServerSignalConnections.push_back(
 
// 		serverFromClientConnectionServer->onStopped.connect(
 
// 				boost::bind(&Server::handleClientConnectionServerStopped, this, _1)));
 

	
 
	serverFromClientConnectionServer->start();
 
}
 

	
 
void Server::stop() {
 
	if (stopping) {
 
		return;
 
	}
 

	
 
	stopping = true;
 

	
 
	foreach(boost::shared_ptr<ServerFromClientSession> session, serverFromClientSessions) {
 
		session->finishSession();
 
	}
 
	serverFromClientSessions.clear();
 

	
 
	if (serverFromClientConnectionServer) {
0 comments (0 inline, 0 general)