diff options
author | Robert Pösel <robyer@seznam.cz> | 2013-05-17 15:06:51 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2013-05-17 15:06:51 +0000 |
commit | 1c917ac3f485ffac7b4316d633a344fbafcedb78 (patch) | |
tree | 32a83a846c37fc3e3551624bf9ed1ac2e75f8165 /protocols/FacebookRM/src/proto.cpp | |
parent | df406e92b92925501b224a01962ef9e9dee84d3b (diff) |
Facebook: Ability to open links on different server (mobile, touch,...).
git-svn-id: http://svn.miranda-ng.org/main/trunk@4702 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/proto.cpp')
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index c6c0f4401b..87edd10ce4 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -454,7 +454,7 @@ int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam) HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
// TODO: why isn't wParam == 0 when is status menu moved to main menu?
- if (wParam == 0 || !IsMyContact(hContact))
+ if (wParam != 0 && !IsMyContact(hContact))
return 1;
std::string url = FACEBOOK_URL_PROFILE;
@@ -470,7 +470,7 @@ int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam) db_set_s(hContact, m_szModuleName, "Homepage", url.c_str());
}
- CallService(MS_UTILS_OPENURL, 1, reinterpret_cast<LPARAM>(url.c_str()));
+ OpenUrl(url);
return 0;
}
@@ -487,7 +487,7 @@ int FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam) url += facy.self_.user_id;
url += "&and=" + std::string(id);
- CallService(MS_UTILS_OPENURL, 1, reinterpret_cast<LPARAM>(url.c_str()));
+ OpenUrl(url);
return 0;
}
@@ -600,3 +600,39 @@ HANDLE FacebookProto::HContactFromAuthEvent(HANDLE hEvent) return DbGetAuthEventContact(&dbei);
}
+
+void FacebookProto::OpenUrl(std::string url)
+{
+ std::string facebookDomain = "facebook.com";
+ std::string::size_type pos = url.find(facebookDomain);
+ bool isFacebookUrl = (pos != std::string::npos);
+ bool isRelativeUrl = (url.substr(0, 4) != "http");
+
+ if (isFacebookUrl || isRelativeUrl) {
+
+ // Make realtive url
+ if (!isRelativeUrl) {
+ url = url.substr(pos + facebookDomain.length());
+
+ // Strip eventual port
+ pos = url.find("/");
+ if (pos != std::string::npos && pos != 0)
+ url = url.substr(pos);
+ }
+
+ // Make absolute url
+ bool useHttps = db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS, 1) > 0;
+ std::string newUrl = (useHttps ? HTTP_PROTO_SECURE : HTTP_PROTO_REGULAR);
+
+ ptrA server = db_get_sa(NULL, m_szModuleName, FACEBOOK_KEY_SERVER);
+ if (server != NULL)
+ newUrl += server;
+ else
+ newUrl += FACEBOOK_SERVER_REGULAR;
+
+ url = newUrl + url;
+ }
+
+ ptrT data = mir_utf8decodeT(url.c_str());
+ CallService(MS_UTILS_OPENURL, (WPARAM)OUF_TCHAR, (LPARAM)data);
+}
|