summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/src/communication.cpp23
-rw-r--r--protocols/FacebookRM/src/constants.h9
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp49
-rw-r--r--protocols/FacebookRM/src/entities.h15
-rw-r--r--protocols/FacebookRM/src/proto.cpp1
5 files changed, 61 insertions, 36 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index ae677ed30e..0e040c31d7 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -1294,10 +1294,10 @@ bool facebook_client::send_message(std::string message_recipient, std::string me
bool facebook_client::post_status(status_data *status)
{
- handle_entry("post_status");
+ if (status == NULL || (status->text.empty() && status->url.empty()))
+ return false;
- if (status == NULL || status->text.empty())
- return handle_success("post_status");
+ handle_entry("post_status");
if (status->isPage) {
std::string data = "fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
@@ -1341,6 +1341,14 @@ bool facebook_client::post_status(status_data *status)
data += "&composertags_place_name=";
data += utils::url::encode(status->place);
}
+ for(std::vector<facebook_user*>::size_type i = 0; i < status->users.size(); i++) {
+ data += "&composertags_with[" + utils::conversion::to_string(&i, UTILS_CONV_UNSIGNED_NUMBER);
+ data += "]=" + status->users[i]->user_id;
+ data += "&text_composertags_with[" + utils::conversion::to_string(&i, UTILS_CONV_UNSIGNED_NUMBER);
+ data += "]=" + status->users[i]->real_name;
+ delete status->users[i];
+ }
+ status->users.clear();
data += "&xhpc_context=profile&xhpc_ismeta=1&xhpc_timeline=1&xhpc_composerid=u_0_2y&is_explicit_place=&composertags_place=&composertags_city=";
@@ -1354,14 +1362,15 @@ bool facebook_client::post_status(status_data *status)
}
validate_response(&resp);
- if (resp.error_number != 0 && !resp.error_text.empty())
- client_notify(ptrT(mir_utf8decodeT(resp.error_text.c_str())));
switch (resp.code)
{
case HTTP_CODE_OK:
- return handle_success("post_status");
-
+ if (resp.error_number != 0 && !resp.error_text.empty())
+ client_notify(ptrT(mir_utf8decodeT(resp.error_text.c_str())));
+ else
+ parent->NotifyEvent(parent->m_tszUserName, TranslateT("Status update was successful."), NULL, FACEBOOK_EVENT_OTHER);
+ return handle_success("post_status");
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index 628e5e6895..3ce1fdb01a 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -159,8 +159,9 @@ static const ttype server_types[] = {
// Status privacy types
static const ttype privacy_types[] = {
- { LPGEN("For everyone"), "80" },
- { LPGEN("For friends of friends"), "111&audience[0][custom_value]=50" },
- { LPGEN("For friends"), "40" },
- { LPGEN("Only for me"), "10" },
+ { LPGEN("Public"), "80" },
+ { LPGEN("Friends of friends"), "111&audience[0][custom_value]=50" },
+ { LPGEN("Friends"), "40" },
+ { LPGEN("Friends except acquaintances"), "127" },
+ { LPGEN("Only me"), "10" },
}; \ No newline at end of file
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 36534465a5..f57ece0da7 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -172,23 +172,14 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
{
data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
RefreshPrivacy(hwnd, data);
-
- // remember last choice, only when there are more options
- if (SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCOUNT, 0, 0) > 1)
- data->proto->setByte(FACEBOOK_KEY_LAST_WALL, SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0));
- }
- if (LOWORD(wparam) == IDC_PRIVACY && HIWORD(wparam) == CBN_SELCHANGE) {
- data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
-
- // remember last choice, only when there are more options
- if (SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCOUNT, 0, 0) > 1)
- data->proto->setByte(FACEBOOK_KEY_PRIVACY_TYPE, SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0));
}
- else if (LOWORD(wparam) == IDC_MINDMSG && HIWORD(wparam) == EN_CHANGE)
+ else if ((LOWORD(wparam) == IDC_MINDMSG || LOWORD(wparam) == IDC_URL) && HIWORD(wparam) == EN_CHANGE)
{
- size_t len = SendDlgItemMessage(hwnd,IDC_MINDMSG,WM_GETTEXTLENGTH,0,0);
- EnableWindow(GetDlgItem(hwnd, IDOK), len > 0);
+ bool ok = SendDlgItemMessage(hwnd, IDC_MINDMSG, WM_GETTEXTLENGTH, 0, 0) > 0;
+ if (!ok && SendDlgItemMessage(hwnd, IDC_URL, WM_GETTEXTLENGTH, 0, 0) > 0)
+ ok = true;
+ EnableWindow(GetDlgItem(hwnd, IDOK), ok);
return TRUE;
}
else if (LOWORD(wparam) == IDOK)
@@ -204,26 +195,38 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
GetDlgItemText(hwnd, IDC_URL, urlT, SIZEOF(urlT));
ShowWindow(hwnd, SW_HIDE);
- ptrA place(mir_utf8encodeT(placeT));
- data->proto->setString(FACEBOOK_KEY_PLACE, place);
-
int wall_id = SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0);
+ int privacy_id = SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0);
+
+ data->proto->setTString(FACEBOOK_KEY_PLACE, placeT);
+
+ // remember last wall, only when there are more options
+ if (SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCOUNT, 0, 0) > 1)
+ data->proto->setByte(FACEBOOK_KEY_LAST_WALL, wall_id);
+
+ // remember last privacy, only when there are more options
+ if (SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCOUNT, 0, 0) > 1)
+ data->proto->setByte(FACEBOOK_KEY_PRIVACY_TYPE, privacy_id);
status_data *status = new status_data();
status->user_id = data->walls[wall_id]->user_id;
status->isPage = data->walls[wall_id]->isPage;
- status->privacy = privacy_types[SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0)].id;
- status->place = place;
+ status->privacy = privacy_types[privacy_id].id;
+ status->place = ptrA(mir_utf8encodeT(placeT));
status->url = _T2A(urlT);
- char *narrow = mir_utf8encodeT(mindMessageT);
+ // TODO: add support for tagging friends
+ /*facebook_user *fu = new facebook_user();
+ fu->user_id = ...;
+ fu->real_name = ...;
+ status->users.insert(fu);*/
+
+ ptrA narrow = mir_utf8encodeT(mindMessageT);
status->text = narrow;
- if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != narrow)
+ if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char *)narrow)
data->proto->last_status_msg_ = narrow;
- mir_free(narrow);
-
data->proto->ForkThread(&FacebookProto::SetAwayMsgWorker, status);
EndDialog(hwnd, wparam);
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h
index d1f1a48dcc..20008b2f21 100644
--- a/protocols/FacebookRM/src/entities.h
+++ b/protocols/FacebookRM/src/entities.h
@@ -147,17 +147,26 @@ struct popup_data
struct status_data
{
+ status_data() {
+ this->user_id = this->text = this->url = this->place = this->privacy = "";
+ this->isPage = false;
+ }
std::string user_id;
std::string text;
std::string url;
std::string place;
std::string privacy;
bool isPage;
+ std::vector<facebook_user*> users;
};
struct wall_data
{
- wall_data() {}
+ wall_data() {
+ this->user_id = "";
+ this->title = NULL;
+ this->isPage = false;
+ }
wall_data(std::string user_id, TCHAR *title, bool isPage = false) : user_id(user_id), title(title), isPage(isPage) {}
std::string user_id;
TCHAR *title;
@@ -166,7 +175,9 @@ struct wall_data
struct post_status_data {
post_status_data(FacebookProto *proto) : proto(proto) {}
- post_status_data(FacebookProto *proto, wall_data *wall) : proto(proto) { walls.push_back(wall); }
+ post_status_data(FacebookProto *proto, wall_data *wall) : proto(proto) {
+ this->walls.push_back(wall);
+ }
FacebookProto *proto;
std::vector<wall_data*> walls;
};
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 117bb2c03c..71e99a2e88 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -460,6 +460,7 @@ INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam)
wall_data *wall = new wall_data();
wall->user_id = ptrA(getStringA(hContact, FACEBOOK_KEY_ID));
+ wall->isPage = false;
if (wall->user_id == facy.self_.user_id) {
wall->title = _tcsdup(TranslateT("Own wall"));
} else