Changeset - deaa8e8dca9b
[Not reviewed]
0 1 0
HanzZ - 12 years ago 2013-02-24 10:50:24
hanzz.k@gmail.com
Load skype buddies from database if it's possible
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
backends/skype/skype.cpp
Show inline comments
 
@@ -83,48 +83,49 @@ static pbnetwork::StatusType getStatus(const std::string &st) {
 
	}
 
	return status;
 
}
 

	
 
DBusHandlerResult skype_notify_handler(DBusConnection *connection, DBusMessage *message, gpointer data) {
 
	Skype *skype = (Skype *) data;
 
	return skype->dbusMessageReceived(connection, message);
 
}
 

	
 
void Skype::login() {
 
	// Do not allow usernames with unsecure symbols
 
	if (m_username.find("..") == 0 || m_username.find("/") != std::string::npos) {
 
		m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Invalid username");
 
		return;
 
	}
 

	
 
	m_db = createSkypeDirectory();
 

	
 
	bool spawned = spawnSkype(m_db);
 
	if (!spawned) {
 
		m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Error spawning the Skype instance.");
 
		return;
 
	}
 

	
 
	m_db += "/" + getUsername() + "/main.db";
 

	
 
	if (m_connection == NULL) {
 
		LOG4CXX_INFO(logger, "Creating DBUS connection.");
 
		GError *error = NULL;
 
		m_connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
 
		if (m_connection == NULL && error != NULL)
 
		{
 
			LOG4CXX_INFO(logger,  m_username << ": Creating DBUS Connection error: " << error->message);
 
			g_error_free(error);
 
			return;
 
		}
 
	}
 

	
 
	m_timer = g_timeout_add_seconds(1, create_dbus_proxy, this);
 
}
 

	
 
bool Skype::createDBusProxy() {
 
	if (m_proxy == NULL) {
 
		LOG4CXX_INFO(logger, "Creating DBus proxy for com.Skype.Api.");
 
		m_counter++;
 

	
 
		GError *error = NULL;
 
		m_proxy = dbus_g_proxy_new_for_name_owner(m_connection, "com.Skype.API", "/com/Skype", "com.Skype.API", &error);
 
		if (m_proxy == NULL && error != NULL) {
0 comments (0 inline, 0 general)