From 142db72b8b10178a262b4508fd8d06249c1ea728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 28 May 2014 17:21:42 +0000 Subject: Twitter: When clicked on popup, open tweet detail in browser; Version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@9336 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Twitter/src/connection.cpp | 47 +++++++++++++++++++++++++++++++++--- protocols/Twitter/src/proto.h | 2 +- protocols/Twitter/src/version.h | 2 +- 3 files changed, 46 insertions(+), 5 deletions(-) (limited to 'protocols/Twitter') diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index a9ed828887..7786e1d0a2 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . #include "proto.h" //#include "tc2.h" #include "twitter.h" +#include void CALLBACK TwitterProto::APC_callback(ULONG_PTR p) { @@ -516,7 +517,39 @@ void TwitterProto::UpdateFriends() } -void TwitterProto::ShowContactPopup(MCONTACT hContact,const std::string &text) + +LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + { + // Get the plugin data (we need the Popup service to do it) + std::string *url = (std::string *)PUGetPluginData(hwnd); + if (url != NULL) { + //std::string url = profile_base_url("https://twitter.com/") + http::url_encode(dbv.pszVal); + CallService(MS_UTILS_OPENURL, 1, reinterpret_cast(url->c_str())); + } + + // After a click, destroy popup + PUDeletePopup(hwnd); + } break; + + case UM_FREEPLUGINDATA: + { + // After close, free + std::string *url = (std::string *)PUGetPluginData(hwnd); + delete url; + } return FALSE; + + default: + break; + } + + return DefWindowProc(hwnd, message, wParam, lParam); +}; + +void TwitterProto::ShowContactPopup(MCONTACT hContact,const std::string &text,const std::string *url) { if(!ServiceExists(MS_POPUP_ADDPOPUPT) || db_get_b(0,m_szModuleName,TWITTER_KEY_POPUP_SHOW,0) == 0) { @@ -541,6 +574,11 @@ void TwitterProto::ShowContactPopup(MCONTACT hContact,const std::string &text) db_free(&dbv); } + if (url != NULL) { + popup.PluginWindowProc = PopupWindowProc; + popup.PluginData = (void *)url; + } + mbcs_to_tcs(CP_UTF8,text.c_str(),popup.lptzText,MAX_SECONDLINE); PUAddPopupT(&popup); } @@ -582,8 +620,11 @@ void TwitterProto::UpdateStatuses(bool pre_read, bool popups, bool tweetToMsg) db_set_utf(hContact,"CList","StatusMsg",i->status.text.c_str()); - if(!pre_read && popups) - ShowContactPopup(hContact,i->status.text); + if (!pre_read && popups) { + std::stringstream url; + url << std::string("https://twitter.com/") << i->username << std::string("/status/") << i->status.id; + ShowContactPopup(hContact, i->status.text, new std::string(url.str())); + } } db_pod_set(0,m_szModuleName,TWITTER_KEY_SINCEID,since_id_); diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 659e2b41d5..7c0207d78b 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -126,7 +126,7 @@ private: int ShowPinDialog(); void ShowPopup(const wchar_t *, int Error = 0); void ShowPopup(const char *, int Error = 0); - void ShowContactPopup(MCONTACT, const std::string &); + void ShowContactPopup(MCONTACT, const std::string &, const std::string *); bool IsMyContact(MCONTACT, bool include_chat = false); MCONTACT UsernameToHContact(const char *); diff --git a/protocols/Twitter/src/version.h b/protocols/Twitter/src/version.h index 7fe85d41a9..28503b3ce5 100644 --- a/protocols/Twitter/src/version.h +++ b/protocols/Twitter/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3