diff --git a/backends/skype/main.cpp b/backends/skype/main.cpp index 54e7025e..dd8031d4 100644 --- a/backends/skype/main.cpp +++ b/backends/skype/main.cpp @@ -82,7 +82,7 @@ static pbnetwork::StatusType getStatus(const std::string &st) { class Skype { public: Skype(const std::string &user, const std::string &username, const std::string &password); - ~Skype() { logout(); } + ~Skype() { LOG4CXX_INFO(logger, "Skype instance desctuctor"); logout(); } void login(); void logout(); std::string send_command(const std::string &message); @@ -159,6 +159,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin { void handleLogoutRequest(const std::string &user, const std::string &legacyName) { Skype *skype = m_sessions[user]; if (skype) { + LOG4CXX_INFO(logger, "User wants to logout, logging out"); skype->logout(); exit(1); } @@ -361,6 +362,7 @@ bool Skype::createDBusProxy() { LOG4CXX_INFO(logger, m_username << ":" << error->message); if (m_counter == 15) { + LOG4CXX_ERROR(logger, "Logging out, proxy couldn't be created"); np->handleDisconnected(m_user, 0, error->message); logout(); g_error_free(error); @@ -430,6 +432,7 @@ void Skype::login() { "\n"; g_file_set_contents(std::string(std::string("/tmp/skype/") + m_username + "/" + m_username +"/config.xml").c_str(), config_xml.c_str(), -1, NULL); + sleep(1); std::string db_path = std::string("/tmp/skype/") + m_username; char *db = (char *) malloc(db_path.size() + 1); strcpy(db, db_path.c_str()); @@ -473,6 +476,7 @@ void Skype::login() { } } + sleep(1); m_timer = g_timeout_add_seconds(1, create_dbus_proxy, this); } @@ -481,31 +485,33 @@ bool Skype::loadSkypeBuddies() { // while (re == "CONNSTATUS OFFLINE" || re.empty()) { // sleep(1); - gchar buffer[1024]; - int bytes_read = read(fd_output, buffer, 1023); - if (bytes_read > 0) { - buffer[bytes_read] = 0; - np->handleDisconnected(m_user, 0, buffer); - close(fd_output); - logout(); - return FALSE; - } +// gchar buffer[1024]; +// int bytes_read = read(fd_output, buffer, 1023); +// if (bytes_read > 0) { +// buffer[bytes_read] = 0; +// np->handleDisconnected(m_user, 0, buffer); +// close(fd_output); +// logout(); +// return FALSE; +// } std::string re = send_command("NAME Spectrum"); if (m_counter++ > 15) { + LOG4CXX_ERROR(logger, "Logging out, because we tried to connect the Skype over DBUS 15 times without success"); np->handleDisconnected(m_user, 0, ""); close(fd_output); logout(); return FALSE; } - if (re.empty() || re == "CONNSTATUS OFFLINE") { + if (re.empty() || re == "CONNSTATUS OFFLINE" || re == "ERROR 68") { return TRUE; } close(fd_output); if (send_command("PROTOCOL 7") != "PROTOCOL 7") { + LOG4CXX_ERROR(logger, "PROTOCOL 7 failed, logging out"); np->handleDisconnected(m_user, 0, "Skype is not ready"); logout(); return FALSE; @@ -601,6 +607,7 @@ std::string Skype::send_command(const std::string &message) { // int message_num; // gchar error_return[30]; + LOG4CXX_INFO(logger, "Sending: " << message); if (!dbus_g_proxy_call (m_proxy, "Invoke", &error, G_TYPE_STRING, message.c_str(), G_TYPE_INVALID, G_TYPE_STRING, &str, G_TYPE_INVALID)) {