summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/res/facebook.rc23
-rw-r--r--protocols/FacebookRM/src/client.h1
-rw-r--r--protocols/FacebookRM/src/common.h1
-rw-r--r--protocols/FacebookRM/src/communication.cpp23
-rw-r--r--protocols/FacebookRM/src/constants.h27
-rw-r--r--protocols/FacebookRM/src/db.h2
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp36
-rw-r--r--protocols/FacebookRM/src/proto.cpp41
-rw-r--r--protocols/FacebookRM/src/proto.h1
-rw-r--r--protocols/FacebookRM/src/resource.h4
-rw-r--r--protocols/FacebookRM/src/theme.cpp2
-rw-r--r--protocols/FacebookRM/src/version.h4
12 files changed, 121 insertions, 44 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc
index 1d602b3fe4..c784d3564f 100644
--- a/protocols/FacebookRM/res/facebook.rc
+++ b/protocols/FacebookRM/res/facebook.rc
@@ -79,16 +79,21 @@ BEGIN
"Hyperlink",WS_TABSTOP,0,40,174,12
END
-IDD_MIND DIALOGEX 0, 0, 267, 62
+IDD_MIND DIALOGEX 0, 0, 267, 79
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOPMOST
CAPTION "What's on your mind?"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- EDITTEXT IDC_MINDMSG,4,4,259,36,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
- LTEXT "420",IDC_CHARACTERS,4,48,19,10
- DEFPUSHBUTTON "Share",IDOK,213,44,50,14
- PUSHBUTTON "Cancel",IDCANCEL,159,44,50,14
+ LTEXT "Text:",IDC_STATIC,4,6,44,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_MINDMSG,53,4,210,36,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
+ LTEXT "420",IDC_CHARACTERS,4,30,43,10,0,WS_EX_RIGHT
+ LTEXT "Place:",IDC_STATIC,4,46,44,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_PLACE,53,43,210,14,ES_AUTOHSCROLL
+ LTEXT "Visibility:",IDC_STATIC,4,62,44,8,0,WS_EX_RIGHT
+ COMBOBOX IDC_PRIVACY,53,60,96,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Share",IDOK,213,59,50,15
+ PUSHBUTTON "Cancel",IDCANCEL,159,59,50,15
END
IDD_OPTIONS DIALOGEX 0, 0, 305, 210
@@ -198,12 +203,13 @@ BEGIN
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 263
+ VERTGUIDE, 48
+ VERTGUIDE, 53
VERTGUIDE, 209
VERTGUIDE, 213
TOPMARGIN, 4
- BOTTOMMARGIN, 58
+ BOTTOMMARGIN, 75
HORZGUIDE, 40
- HORZGUIDE, 44
END
IDD_OPTIONS, DIALOG
@@ -269,7 +275,8 @@ END
//
// Generated from the TEXTINCLUDE 3 resource.
//
-
+
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 9a531825d5..9f51ebe2f6 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -94,6 +94,7 @@ public:
std::string get_newsfeed_type();
std::string get_server_type();
+ std::string get_privacy_type();
char* load_cookies();
void store_headers(http::response* resp, NETLIBHTTPHEADER* headers, int headers_count);
diff --git a/protocols/FacebookRM/src/common.h b/protocols/FacebookRM/src/common.h
index ee7cefc903..3f91242fa7 100644
--- a/protocols/FacebookRM/src/common.h
+++ b/protocols/FacebookRM/src/common.h
@@ -77,6 +77,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <m_hotkeys.h>
#include <m_folders.h>
#include <m_smileyadd.h>
+#include <m_toptoolbar.h>
#include "version.h"
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index c92a1c7b5b..5cfd9fab99 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -567,6 +567,15 @@ std::string facebook_client::get_server_type()
return server_types[server_type].id;
}
+std::string facebook_client::get_privacy_type()
+{
+ BYTE privacy_type = db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_PRIVACY_TYPE, 0);
+ if (privacy_type < 0 || privacy_type >= SIZEOF(privacy_types))
+ privacy_type = 0;
+ return privacy_types[privacy_type].id;
+}
+
+
char* facebook_client::load_cookies()
{
ScopedLock s(cookies_lock_);
@@ -1200,12 +1209,18 @@ bool facebook_client::set_status(const std::string &status_text)
if (status_text.empty())
return handle_success("set_status");
- // TODO: use also privacy options
- std::string data = "&fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
+ std::string text = utils::url::encode(status_text);
+ ptrA place = db_get_sa(NULL, parent->m_szModuleName, FACEBOOK_KEY_PLACE);
+
+ std::string data = "fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
+ data += "&xhpc_context=home&xhpc_ismeta=1&xhpc_timeline=&xhpc_composerid=u_jsonp_2_0&is_explicit_place=&composertags_place=&composer_session_id=0&composertags_city=&disable_location_sharing=false&composer_predicted_city=&nctr[_mod]=pagelet_composer&__a=1&__dyn=&__req=1f&phstamp=0";
data += "&xhpc_targetid=" + this->self_.user_id;
data += "&__user=" + this->self_.user_id;
- data += "nctr[_mod]=pagelet_composer&__a=1&__req=b&phstamp=&composertags_place_name=Miranda+NG";
- data += "&xhpc_message=" + utils::url::encode(status_text);
+ data += "&xhpc_message=" + text;
+ data += "&xhpc_message_text=" + text;
+ data += "&audience[0][value]=" + get_privacy_type();
+ data += "&composertags_place_name=";
+ data += ptrA(mir_urlEncode(place));
http::response resp = flap(FACEBOOK_REQUEST_STATUS_SET, &data);
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index 34940132e1..b66bf6aaac 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -121,11 +121,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_CONTACT_REQUEST 3 // contact that we asked for friendship
#define FACEBOOK_CONTACT_APPROVE 4 // contact that is asking us for approval of friendship
-// News Feed types
-static const struct {
+typedef struct {
const char *name;
const char *id;
-} feed_types[] = {
+} ttype;
+
+// News Feed types
+static const ttype feed_types[] = {
{ LPGEN("Most Recent"), "lf_" }, //h_chr?
{ LPGEN("Wall Posts"), "app_2915120374" },
{ LPGEN("Top News"), "h_nor" }, //h
@@ -134,11 +136,16 @@ static const struct {
{ LPGEN("Apps and Games"), "appsandgames" },
};
-static const struct {
- const char *id;
- const char *name;
-} server_types[] = {
- { "www.facebook.com", LPGEN("Classic website") },
- { "m.facebook.com", LPGEN("Mobile website") },
- { "touch.facebook.com", LPGEN("Smartphone website") },
+// Server types
+static const ttype server_types[] = {
+ { LPGEN("Classic website"), "www.facebook.com" },
+ { LPGEN("Mobile website"), "m.facebook.com" },
+ { LPGEN("Smartphone website"), "touch.facebook.com" },
+};
+
+// Status privacy types
+static const ttype privacy_types[] = {
+ { LPGEN("For everyone"), "80" },
+ { LPGEN("For friends"), "40" },
+ { LPGEN("Only for me"), "10" },
}; \ No newline at end of file
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index ab249b213d..a5f46e33f8 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -65,6 +65,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_SERVER_TYPE "ServerType"
#define FACEBOOK_KEY_MARK_READ "MarkRead"
#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp"
+#define FACEBOOK_KEY_PRIVACY_TYPE "PrivacyType"
+#define FACEBOOK_KEY_PLACE "Place"
#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN]
#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN]
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 830bea22bb..9d8dfaae53 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -120,16 +120,29 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
{
TranslateDialogDefault(hwnd);
+ SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(GetIconHandle("mind")));
+
proto = reinterpret_cast<FacebookProto*>(lparam);
SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam);
SendDlgItemMessage(hwnd,IDC_MINDMSG,EM_LIMITTEXT,FACEBOOK_MIND_LIMIT,0);
- DBVARIANT dbv = { DBVT_TCHAR };
+ ptrT place = db_get_tsa(NULL, proto->m_szModuleName, FACEBOOK_KEY_PLACE);
+ SetDlgItemText(hwnd, IDC_PLACE, place != NULL ? place : _T("Miranda NG"));
- if (!db_get_ts(NULL,proto->m_szModuleName,FACEBOOK_KEY_NAME,&dbv))
- {
- SetWindowText(hwnd, dbv.ptszVal);
- db_free(&dbv);
+ for(size_t i=0; i<SIZEOF(privacy_types); i++)
+ SendDlgItemMessageA(hwnd, IDC_PRIVACY, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(privacy_types[i].name)));
+ SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_SETCURSEL, db_get_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_PRIVACY_TYPE, 0), 0);
+
+ ptrA name = db_get_sa(NULL, proto->m_szModuleName, FACEBOOK_KEY_NAME);
+ if (name != NULL) {
+ std::string firstname = name;
+ std::string::size_type pos = firstname.find(" ");
+ if (pos != std::string::npos)
+ firstname = firstname.substr(0, pos);
+
+ char title[100];
+ mir_snprintf(title, SIZEOF(title), Translate("What's on your mind, %s?"), firstname.c_str());
+ SetWindowTextA(hwnd, title);
}
}
@@ -150,13 +163,20 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
}
else if (LOWORD(wparam) == IDOK)
{
- TCHAR mindMessage[FACEBOOK_MIND_LIMIT+1];
+ TCHAR mindMessageT[FACEBOOK_MIND_LIMIT+1];
+ TCHAR placeT[100];
proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- GetDlgItemText(hwnd,IDC_MINDMSG,mindMessage,SIZEOF(mindMessage));
+ GetDlgItemText(hwnd,IDC_MINDMSG, mindMessageT, SIZEOF(mindMessageT));
+ GetDlgItemText(hwnd,IDC_PLACE, placeT, SIZEOF(placeT));
ShowWindow(hwnd,SW_HIDE);
- char *narrow = mir_utf8encodeT(mindMessage);
+ ptrA place = mir_utf8encodeT(placeT);
+ db_set_s(NULL, proto->m_szModuleName, FACEBOOK_KEY_PLACE, place);
+
+ db_set_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_PRIVACY_TYPE, SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0));
+
+ char *narrow = mir_utf8encodeT(mindMessageT);
if (proto->last_status_msg_ != narrow)
proto->last_status_msg_ = narrow;
utils::mem::detract(narrow);
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 03fd9c722e..582b7309c2 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -45,10 +45,13 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username)
CreateProtoService(m_szModuleName, PS_JOINCHAT, &FacebookProto::OnJoinChat, this);
CreateProtoService(m_szModuleName, PS_LEAVECHAT, &FacebookProto::OnLeaveChat, this);
+ CreateProtoService(m_szModuleName, "/Mind", &FacebookProto::OnMind, this);
+
HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu, this);
HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit, this);
HookProtoEvent(ME_GC_EVENT, &FacebookProto::OnChatOutgoing, this);
HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged, this);
+ HookProtoEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit, this);
// Create standard network connection
TCHAR descr[512];
@@ -331,7 +334,7 @@ int FacebookProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
-int FacebookProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
+int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
{
switch(event)
{
@@ -354,13 +357,13 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
// EVENTS
-int FacebookProto::SvcCreateAccMgrUI(WPARAM wParam,LPARAM lParam)
+int FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
(HWND)lParam, FBAccountProc, (LPARAM)this);
}
-int FacebookProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam)
+int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
// Register group chat
GCREGISTER gcr = {sizeof(gcr)};
@@ -375,13 +378,13 @@ int FacebookProto::OnModulesLoaded(WPARAM wParam,LPARAM lParam)
return 0;
}
-int FacebookProto::OnPreShutdown(WPARAM wParam,LPARAM lParam)
+int FacebookProto::OnPreShutdown(WPARAM wParam, LPARAM lParam)
{
SetStatus(ID_STATUS_OFFLINE);
return 0;
}
-int FacebookProto::OnOptionsInit(WPARAM wParam,LPARAM lParam)
+int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = {sizeof(odp)};
odp.hInstance = g_hInstance;
@@ -413,12 +416,30 @@ int FacebookProto::OnOptionsInit(WPARAM wParam,LPARAM lParam)
return 0;
}
-int FacebookProto::OnMind(WPARAM,LPARAM)
+int FacebookProto::OnToolbarInit(WPARAM, LPARAM)
{
- HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND),
- (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(this));
- ShowWindow(hDlg, SW_SHOW);
- return FALSE;
+ TTBButton ttb = { sizeof(ttb) };
+ ttb.dwFlags = TTBBF_SHOWTOOLTIP | TTBBF_VISIBLE;
+
+ char service[100];
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, "/Mind");
+
+ ttb.pszService = service;
+ ttb.pszTooltipUp = ttb.name = LPGEN("What's on your mind?");
+ ttb.hIconHandleUp = Skin_GetIconByHandle(GetIconHandle("mind"));
+ TopToolbar_AddButton(&ttb);
+
+ return 0;
+}
+
+int FacebookProto::OnMind(WPARAM, LPARAM)
+{
+ if (isOnline()) {
+ HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(this));
+ ShowWindow(hDlg, SW_SHOW);
+ }
+
+ return 0;
}
int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 69a62ac96c..8fb316366f 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -119,6 +119,7 @@ public:
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
+ int __cdecl OnToolbarInit(WPARAM, LPARAM);
int __cdecl OnBuildStatusMenu(WPARAM,LPARAM);
int __cdecl OnContactDeleted(WPARAM,LPARAM);
int __cdecl OnMind(WPARAM,LPARAM);
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 6c58cea147..46290bcfaf 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -62,6 +62,8 @@
#define IDC_SET_STATUS 1126
#define IDC_FEED_TYPE 1201
#define IDC_URL_SERVER 1202
+#define IDC_PLACE 1203
+#define IDC_PRIVACY 1204
// Next default values for new objects
//
@@ -69,7 +71,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1203
+#define _APS_NEXT_CONTROL_VALUE 1205
#define _APS_NEXT_SYMED_VALUE 131
#endif
#endif
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 938defeee3..1468400c18 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -210,7 +210,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED);
mi.position = 201001;
- CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
+ //CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
strcpy(tDest,"/Mind");
mi.hParentMenu = hRoot;
mi.pszName = LPGEN("Mind...");
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 8a192eb9fc..c35c72fd48 100644
--- a/protocols/FacebookRM/src/version.h
+++ b/protocols/FacebookRM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM