From 4cd528271c09dd3def2a01aa1399f97d313c1ffc Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Wed, 14 Mar 2012 09:00:19 +0100 Subject: [PATCH 1/3] send info about missed calls + probably fixed Incorrect Password notification --- backends/skype/main.cpp | 49 +++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/backends/skype/main.cpp b/backends/skype/main.cpp index dd8031d4..fbc765d1 100644 --- a/backends/skype/main.cpp +++ b/backends/skype/main.cpp @@ -485,15 +485,20 @@ 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; + std::string b(buffer); + LOG4CXX_WARN(logger, "Skype wrote this on stdout '" << b << "'"); + if (b.find("Incorrect Password") != std::string::npos) { + LOG4CXX_INFO(logger, "Incorrect password, logging out") + np->handleDisconnected(m_user, 0, "Incorrect password"); + close(fd_output); + logout(); + return FALSE; + } + } std::string re = send_command("NAME Spectrum"); if (m_counter++ > 15) { @@ -710,6 +715,32 @@ static void handle_skype_message(std::string &message, Skype *sk) { np->handleMessage(sk->getUser(), from, body); } } + else if (cmd[0] == "CALL") { + // CALL 884 STATUS RINGING + if (cmd[2] == "STATUS") { + if (cmd[3] == "RINGING" || cmd[3] == "MISSED") { + // handle only incoming calls + std::string type = sk->send_command("GET CALL " + cmd[1] + " TYPE"); + type = type.substr(type.find("TYPE") + 5); + if (type.find("INCOMING") != 0) { + return; + } + + std::string from = sk->send_command("GET CALL " + cmd[1] + " PARTNER_HANDLE"); + from = from.substr(from.find("PARTNER_HANDLE") + 15); + + std::string dispname = sk->send_command("GET CALL " + cmd[1] + " PARTNER_DISPNAME"); + dispname = dispname.substr(dispname.find("PARTNER_DISPNAME") + 17); + + if (cmd[3] == "RINGING") { + np->handleMessage(sk->getUser(), from, "User " + dispname + " is calling you."); + } + else { + np->handleMessage(sk->getUser(), from, "You have missed call from user " + dispname + "."); + } + } + } + } } DBusHandlerResult skype_notify_handler(DBusConnection *connection, DBusMessage *message, gpointer user_data) { From 55c27481103e63e8cd18bb8cebf01bd4f9606955 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Wed, 14 Mar 2012 09:22:29 +0100 Subject: [PATCH 2/3] Removed unrecognized commands --- backends/skype/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/skype/main.cpp b/backends/skype/main.cpp index fbc765d1..4622f464 100644 --- a/backends/skype/main.cpp +++ b/backends/skype/main.cpp @@ -437,7 +437,7 @@ void Skype::login() { char *db = (char *) malloc(db_path.size() + 1); strcpy(db, db_path.c_str()); LOG4CXX_INFO(logger, m_username << ": Spawning new Skype instance dbpath=" << db); - gchar* argv[8] = {"skype", "--enable-dbus", "--use-session-dbus", "--disable-cleanlooks", "--pipelogin", "--dbpath", db, 0}; + gchar* argv[6] = {"skype", "--disable-cleanlooks", "--pipelogin", "--dbpath", db, 0}; int fd; g_spawn_async_with_pipes(NULL, From 0e01945c9839eaeec61af49db1920cb5cf8fe628 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Wed, 14 Mar 2012 14:48:24 +0100 Subject: [PATCH 3/3] Forward proper errors to XMPP user instead of Internal Server Error --- backends/skype/main.cpp | 10 +++++----- spectrum/src/sample.cfg | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backends/skype/main.cpp b/backends/skype/main.cpp index 4622f464..137c7b8a 100644 --- a/backends/skype/main.cpp +++ b/backends/skype/main.cpp @@ -363,7 +363,7 @@ bool Skype::createDBusProxy() { if (m_counter == 15) { LOG4CXX_ERROR(logger, "Logging out, proxy couldn't be created"); - np->handleDisconnected(m_user, 0, error->message); + np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, error->message); logout(); g_error_free(error); return FALSE; @@ -393,7 +393,7 @@ static gboolean create_dbus_proxy(gpointer data) { void Skype::login() { if (m_username.find("..") == 0 || m_username.find("/") != std::string::npos) { - np->handleDisconnected(m_user, 0, "Invalid username"); + np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Invalid username"); return; } boost::filesystem::remove_all(std::string("/tmp/skype/") + m_username); @@ -493,7 +493,7 @@ bool Skype::loadSkypeBuddies() { LOG4CXX_WARN(logger, "Skype wrote this on stdout '" << b << "'"); if (b.find("Incorrect Password") != std::string::npos) { LOG4CXX_INFO(logger, "Incorrect password, logging out") - np->handleDisconnected(m_user, 0, "Incorrect password"); + np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_FAILED, "Incorrect password"); close(fd_output); logout(); return FALSE; @@ -503,7 +503,7 @@ bool Skype::loadSkypeBuddies() { 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, ""); + np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Skype is not read."); close(fd_output); logout(); return FALSE; @@ -517,7 +517,7 @@ bool Skype::loadSkypeBuddies() { if (send_command("PROTOCOL 7") != "PROTOCOL 7") { LOG4CXX_ERROR(logger, "PROTOCOL 7 failed, logging out"); - np->handleDisconnected(m_user, 0, "Skype is not ready"); + np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Skype is not ready"); logout(); return FALSE; } diff --git a/spectrum/src/sample.cfg b/spectrum/src/sample.cfg index d0e234e9..57e601eb 100644 --- a/spectrum/src/sample.cfg +++ b/spectrum/src/sample.cfg @@ -13,11 +13,12 @@ admin_password=test #cert=server.pfx #patch to PKCS#12 certificate #cert_password=test #password to that certificate if any users_per_backend=10 -backend=/home/hanzz/code/libtransport/backends/libpurple/spectrum2_libpurple_backend +#backend=/home/hanzz/code/libtransport/backends/libpurple/spectrum2_libpurple_backend #backend=/home/hanzz/code/libtransport/backends/smstools3/spectrum2_smstools3_backend #backend=/usr/bin/mono /home/hanzz/code/networkplugin-csharp/msnp-sharp-backend/bin/Debug/msnp-sharp-backend.exe #backend=/home/hanzz/code/libtransport/backends/frotz/spectrum2_frotz_backend #backend=/home/hanzz/code/libtransport/backends/libircclient-qt/spectrum2_libircclient-qt_backend +backend=/usr/bin/xvfb-run -n BACKEND_ID -s "-screen 0 10x10x8" -f /tmp/x-skype-gw /home/hanzz/code/libtransport/backends/skype/spectrum2_skype_backend #protocol=prpl-msn protocol=any #protocol=prpl-icq