diff --git a/backends/skype/main.cpp b/backends/skype/main.cpp index aa237178261657a5c1c42d07762d90ec8bec1ba9..838d9231d1bea354b681332ab961cc6d4ca1b5ea 100644 --- a/backends/skype/main.cpp +++ b/backends/skype/main.cpp @@ -165,6 +165,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin { if (skype) { LOG4CXX_INFO(logger, "User wants to logout, logging out"); skype->logout(); + Logging::shutdownLogging(); exit(1); } } @@ -366,7 +367,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"); + LOG4CXX_ERROR(logger, "Logging out, proxy couldn't be created: " << error->message); np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, error->message); logout(); g_error_free(error); @@ -444,7 +445,8 @@ void Skype::login() { gchar* argv[6] = {"skype", "--disable-cleanlooks", "--pipelogin", "--dbpath", db, 0}; int fd; - g_spawn_async_with_pipes(NULL, + GError *error = NULL; + bool spawned = g_spawn_async_with_pipes(NULL, argv, NULL /*envp*/, G_SPAWN_SEARCH_PATH, @@ -454,9 +456,16 @@ void Skype::login() { &fd, NULL, &fd_output, - NULL /*error*/); + &error); + + if (!spawned) { + LOG4CXX_ERROR(logger, "Error spawning the Skype instance: " << error->message) + np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Error spawning the Skype instance."); + return; + } + std::string login_data = std::string(m_username + " " + m_password + "\n"); - LOG4CXX_INFO(logger, m_username << ": Login data=" << login_data); + LOG4CXX_INFO(logger, m_username << ": Login data=" << m_username); write(fd, login_data.c_str(), login_data.size()); close(fd); @@ -469,12 +478,12 @@ void Skype::login() { if (m_connection == NULL) { - LOG4CXX_INFO(logger, "Creating DBus connection."); + 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 << ": DBUS Error: " << error->message); + LOG4CXX_INFO(logger, m_username << ": Creating DBUS Connection error: " << error->message); g_error_free(error); return; } @@ -793,6 +802,7 @@ static int create_socket(char *host, int portno) { if ((hos = gethostbyname(host)) == NULL) { // strerror() will not work for gethostbyname() and hstrerror() // is supposedly obsolete + Logging::shutdownLogging(); exit(1); } serv_addr.sin_addr.s_addr = *((unsigned long *) hos->h_addr_list[0]); @@ -815,6 +825,7 @@ static gboolean transportDataReceived(GIOChannel *source, GIOCondition condition ssize_t n = read(m_sock, ptr, sizeof(buffer)); if (n <= 0) { LOG4CXX_INFO(logger, "Diconnecting from spectrum2 server"); + Logging::shutdownLogging(); exit(errno); } std::string d = std::string(buffer, n); @@ -823,6 +834,7 @@ static gboolean transportDataReceived(GIOChannel *source, GIOCondition condition } static void io_destroy(gpointer data) { + Logging::shutdownLogging(); exit(1); }