diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-05-28 17:21:42 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-05-28 17:21:42 +0000 |
commit | 142db72b8b10178a262b4508fd8d06249c1ea728 (patch) | |
tree | e602017d4bdf355fd92299098cd4a79579388d14 /protocols/Twitter/src/connection.cpp | |
parent | 4d556a607649ff90b846f0c6e1b033d365d3b744 (diff) |
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
Diffstat (limited to 'protocols/Twitter/src/connection.cpp')
-rw-r--r-- | protocols/Twitter/src/connection.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
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 <http://www.gnu.org/licenses/>. #include "proto.h"
//#include "tc2.h"
#include "twitter.h"
+#include <sstream>
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<LPARAM>(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_);
|