Hi, Boiko, here is the first pile of libmsn fixes.
The 4th patch was not included intentionally. Regards, Roman
>From 46cbbfd9fb4248575eb401220a61d49f90e7c411 Mon Sep 17 00:00:00 2001 From: kedge <ke...@kedge.(none)> Date: Sat, 2 Jan 2010 11:42:26 +0100 Subject: [PATCH 1/5] Set isConnected to false during disconnection. --- msn/connection.cpp | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/msn/connection.cpp b/msn/connection.cpp index 48abdcd..602f0c1 100644 --- a/msn/connection.cpp +++ b/msn/connection.cpp @@ -114,6 +114,7 @@ namespace MSN void Connection::disconnect() { + this->connected = false; this->myNotificationServer()->externalCallbacks.unregisterSocket(this->sock); this->myNotificationServer()->externalCallbacks.closeSocket(this->sock); -- 1.6.5.4
>From df41cf1a67cbae6dfc78408096349aa3a2551bf3 Mon Sep 17 00:00:00 2001 From: kedge <ke...@kedge.(none)> Date: Sat, 2 Jan 2010 11:44:01 +0100 Subject: [PATCH 2/5] Don't assert in connectionWithSocket because we need this for error handling (KDE BUG 199755). Don't assert in disconnect if we are already disconnected. --- msn/notificationserver.cpp | 5 ++--- msn/switchboardserver.cpp | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/msn/notificationserver.cpp b/msn/notificationserver.cpp index 9ff8edf..963686a 100644 --- a/msn/notificationserver.cpp +++ b/msn/notificationserver.cpp @@ -69,8 +69,6 @@ namespace MSN Connection *NotificationServerConnection::connectionWithSocket(void *sock) { - this->assertConnectionStateIsNot(NS_DISCONNECTED); - if (this->sock == sock) return this; @@ -1208,7 +1206,8 @@ public: void NotificationServerConnection::disconnect() { - this->assertConnectionStateIsNot(NS_DISCONNECTED); + if (this->connectionState() == NS_DISCONNECTED) + return; std::vector<SwitchboardServerConnection *> list = _switchboardConnections; std::vector<SwitchboardServerConnection *>::iterator i = list.begin(); diff --git a/msn/switchboardserver.cpp b/msn/switchboardserver.cpp index a71a46a..fa2f4c2 100644 --- a/msn/switchboardserver.cpp +++ b/msn/switchboardserver.cpp @@ -55,8 +55,6 @@ namespace MSN Connection *SwitchboardServerConnection::connectionWithSocket(void * sock) { - this->assertConnectionStateIsAtLeast(SB_CONNECTING); - if (this->sock == sock) return this; @@ -572,7 +570,9 @@ public: void SwitchboardServerConnection::disconnect() { - this->assertConnectionStateIsNot(SB_DISCONNECTED); + if (this->connectionState() == SB_DISCONNECTED) + return; + notificationServer.removeSwitchboardConnection(this); this->myNotificationServer()->externalCallbacks.closingConnection(this); -- 1.6.5.4
>From 2f8f8df10d40a72aa15fb7e78997f3c53fd36a74 Mon Sep 17 00:00:00 2001 From: kedge <ke...@kedge.(none)> Date: Sat, 2 Jan 2010 11:56:39 +0100 Subject: [PATCH 3/5] Objects created with "new" should be freed with "delete" not "free". --- msn/p2p.cpp | 21 +++++++++++---------- msn/switchboardserver.cpp | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/msn/p2p.cpp b/msn/p2p.cpp index 0b6d106..0e826fa 100644 --- a/msn/p2p.cpp +++ b/msn/p2p.cpp @@ -68,7 +68,7 @@ namespace MSN { header.read(c, packet.p2pHeader.messageLength); std::string content(c, packet.p2pHeader.messageLength); packet.body = content; - free(c); + delete [] c; header.read((char*)&packet.p2pFooter.appID, sizeof(packet.p2pFooter.appID)); if(packet.p2pHeader.flag==FLAG_ACK) @@ -113,10 +113,10 @@ namespace MSN { std::string d2(c); std::string d3(g); - free(a); - free(c); - free(d1); - free(g); + delete [] a; + delete [] c; + delete [] d1; + delete [] g; conn.message_ink(args, d2, d3); return; @@ -701,8 +701,8 @@ namespace MSN { context.read((char*)filenameutf16, 520); _ucs2_utf8(filenameutf8, filenameutf16, 520); std::string filename((char*)filenameutf8); - free(filenameutf16); - free(filenameutf8); + delete [] filenameutf16; + delete [] filenameutf8; unsigned long long filesize; context.seekg(8); @@ -715,7 +715,7 @@ namespace MSN { char *a = new char[size2]; context.read((char*)a, size2); preview = b64_encode(a,size2); - free(a); + delete [] a; } fileTransferInvite ft; ft.type = type; @@ -1316,8 +1316,9 @@ namespace MSN { context.write((char*)&unknown2, sizeof(unsigned int)); context.write((char*)&unknown3, 64); - free(--filenameutf16); - free(filenameutf8); + filenameutf16--; + delete [] filenameutf16; + delete [] filenameutf8; if(ft.type == FILE_TRANSFER_WITH_PREVIEW && ft.preview.size()) context.write((char*)b64_decode(ft.preview.c_str()).c_str(), b64_decode(ft.preview.c_str()).size()); diff --git a/msn/switchboardserver.cpp b/msn/switchboardserver.cpp index fa2f4c2..7ea1bea 100644 --- a/msn/switchboardserver.cpp +++ b/msn/switchboardserver.cpp @@ -474,7 +474,7 @@ public: body_stream.read((char*)part, 1202); std::string part1(part); chunks.push_back(part1); - free(part); + delete [] part; } // sending the first one -- 1.6.5.4
>From 2a4908e194ad44781af4f8d4714e88aeea274080 Mon Sep 17 00:00:00 2001 From: kedge <ke...@kedge.(none)> Date: Sat, 2 Jan 2010 12:43:55 +0100 Subject: [PATCH 5/5] Remove ifdef LIBMSN_INBOX_URL_ENABLED and make pure virtual function gotInboxUrl only virtual. Bump version. Should fix all crashes which were caused by API/ABI change. --- CMakeLists.txt | 1 - msn/CMakeLists.txt | 4 ++-- msn/config.h.cmake | 2 -- msn/externals.h | 5 ++--- msn/notificationserver.cpp | 2 -- msntest/msntest.cpp | 4 ---- 6 files changed, 4 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac93435..c71881b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) project(libmsn) -option( LIBMSN_INBOX_URL_ENABLED "Check if you want to enable the inbox feature. This will break API." TRUE ) option( ENABLE_DEBUG "Enable debug flags" FALSE) if (ENABLE_DEBUG) diff --git a/msn/CMakeLists.txt b/msn/CMakeLists.txt index 6bb32f7..6a8f197 100644 --- a/msn/CMakeLists.txt +++ b/msn/CMakeLists.txt @@ -62,8 +62,8 @@ set(siren_HEADERS libsiren/siren7.h ) add_library(msn SHARED ${msn_STAT_SRCS} ${siren_STAT_SRCS}) -set_target_properties(msn PROPERTIES VERSION 0.2.0 - SOVERSION 0.2 +set_target_properties(msn PROPERTIES VERSION 0.3.0 + SOVERSION 0.3 ) if(NOT WIN32) diff --git a/msn/config.h.cmake b/msn/config.h.cmake index 5f8f59a..426ee69 100644 --- a/msn/config.h.cmake +++ b/msn/config.h.cmake @@ -1,6 +1,4 @@ #ifndef LIBMSN_CONFIG_H #define LIBMSN_CONFIG_H -#cmakedefine LIBMSN_INBOX_URL_ENABLED - #endif diff --git a/msn/externals.h b/msn/externals.h index bc4a917..f9c79a3 100644 --- a/msn/externals.h +++ b/msn/externals.h @@ -326,9 +326,8 @@ namespace MSN * It must return the real size written to *sock */ virtual size_t writeDataToSocket (void *sock, char *data, size_t size) = 0; -#ifdef LIBMSN_INBOX_URL_ENABLED - virtual void gotInboxUrl (MSN::NotificationServerConnection *conn, MSN::hotmailInfo info) = 0; -#endif + + virtual void gotInboxUrl (MSN::NotificationServerConnection * /*conn*/, MSN::hotmailInfo /*info*/) {}; }; } #endif diff --git a/msn/notificationserver.cpp b/msn/notificationserver.cpp index 963686a..84ec74b 100644 --- a/msn/notificationserver.cpp +++ b/msn/notificationserver.cpp @@ -385,9 +385,7 @@ namespace MSN std::string creds(b); info.creds = creds; -#ifdef LIBMSN_INBOX_URL_ENABLED this->myNotificationServer()->externalCallbacks.gotInboxUrl(this, info); -#endif } void NotificationServerConnection::handle_MSG(std::vector<std::string> & args) diff --git a/msntest/msntest.cpp b/msntest/msntest.cpp index 67641c5..219947c 100644 --- a/msntest/msntest.cpp +++ b/msntest/msntest.cpp @@ -167,9 +167,7 @@ class Callbacks : public MSN::Callbacks virtual size_t writeDataToSocket (void *sock, char *data, size_t size); virtual std::string getSecureHTTPProxy(); -#ifdef LIBMSN_INBOX_URL_ENABLED virtual void gotInboxUrl (MSN::NotificationServerConnection *conn, MSN::hotmailInfo info); -#endif }; struct pollfd mySockets[21]; @@ -1363,7 +1361,6 @@ void Callbacks::gotWinkFile(MSN::SwitchboardServerConnection * conn, unsigned in printf("--- Voice Wink file '%s'\n", file.c_str()); } -#ifdef LIBMSN_INBOX_URL_ENABLED void Callbacks::gotInboxUrl(MSN::NotificationServerConnection *conn, MSN::hotmailInfo info) { std::vector<std::string>::const_iterator i; @@ -1377,4 +1374,3 @@ void Callbacks::gotInboxUrl(MSN::NotificationServerConnection *conn, MSN::hotmai std::cout << "auth: " << info.MSPAuth << std::endl; std::cout << "creds: " << info.creds << std::endl; } -#endif -- 1.6.5.4
_______________________________________________ kopete-devel mailing list kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel