summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-07-31 10:38:07 +0000
committerRobert Pösel <robyer@seznam.cz>2013-07-31 10:38:07 +0000
commitfb112ace5822634a51dbf06a42d57e048981519d (patch)
tree85af7a2bc9f4d5a9993d2fe2ed7bf728fa3c8af4 /protocols/FacebookRM/src
parent3de73f4e34db0c8119f9424558ba724a2b793506 (diff)
Facebook: Added ability to post status with tagged friends
git-svn-id: http://svn.miranda-ng.org/main/trunk@5535 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp126
-rw-r--r--protocols/FacebookRM/src/resource.h5
2 files changed, 109 insertions, 22 deletions
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index f57ece0da7..4fff2ef9d6 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -123,6 +123,60 @@ void RefreshPrivacy(HWND hwnd, post_status_data *data)
SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_SETCURSEL, data->proto->getByte(FACEBOOK_KEY_PRIVACY_TYPE, 0), 0);
}
+void ClistPrepare(FacebookProto *proto, HANDLE hItem, HWND hwndList)
+{
+ if (hItem == NULL)
+ hItem = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
+
+ while (hItem)
+ {
+ HANDLE hItemN = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
+
+ if (IsHContactGroup(hItem)) {
+ HANDLE hItemT = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
+ if (hItemT)
+ ClistPrepare(proto, hItemT, hwndList);
+ } else if (IsHContactContact(hItem)) {
+ if (!proto->IsMyContact(hItem) || ptrA(proto->getStringA(hItem, FACEBOOK_KEY_ID)) == NULL)
+ SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
+ }
+
+ hItem = hItemN;
+ }
+}
+
+void GetSelectedContacts(FacebookProto *proto, HANDLE hItem, HWND hwndList, std::vector<facebook_user*> *contacts)
+{
+ if (hItem == NULL)
+ hItem = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
+
+ while (hItem) {
+ if (IsHContactGroup(hItem)) {
+ HANDLE hItemT = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
+ if (hItemT)
+ GetSelectedContacts(proto, hItemT, hwndList, contacts);
+ } else {
+ if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
+ facebook_user *fu = new facebook_user();
+ fu->user_id = ptrA(proto->getStringA(hItem, FACEBOOK_KEY_ID));
+ fu->real_name = _T2A(ptrT(proto->getTStringA(hItem, FACEBOOK_KEY_NAME)));
+ contacts->push_back(fu);
+ }
+ }
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
+ }
+}
+
+void ResizeHorizontal(HWND hwnd, bool wide) {
+ RECT r = { 0, 0, wide ? 422 : 271, 116 };
+ MapDialogRect(hwnd, &r);
+ r.bottom += GetSystemMetrics(SM_CYSMCAPTION);
+ SetWindowPos(hwnd, 0, 0, 0, r.right, r.bottom, SWP_NOMOVE | SWP_NOZORDER);
+ SetDlgItemText(hwnd, IDC_EXPAND, (wide ? _T("<<") : _T(">>")));
+}
+
+static bool bShowContacts;
+
INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
post_status_data *data;
@@ -145,6 +199,12 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
ptrT place = data->proto->getTStringA(FACEBOOK_KEY_PLACE);
SetDlgItemText(hwnd, IDC_PLACE, place != NULL ? place : _T("Miranda NG"));
+ bShowContacts = data->proto->getByte("PostStatusExpand", 0);
+ ResizeHorizontal(hwnd, bShowContacts);
+
+ HWND hwndClist = GetDlgItem(hwnd, IDC_CCLIST);
+ SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);
+
for (std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++)
SendDlgItemMessage(hwnd, IDC_WALL, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(data->walls[i]->title));
SendDlgItemMessage(hwnd, IDC_WALL, CB_SETCURSEL, 0, 0);
@@ -167,22 +227,48 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
return TRUE;
- case WM_COMMAND:
- if (LOWORD(wparam) == IDC_WALL && HIWORD(wparam) == CBN_SELCHANGE)
+ case WM_NOTIFY:
{
- data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- RefreshPrivacy(hwnd, data);
+ NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lparam;
+ if (nmc->hdr.idFrom == IDC_CCLIST) {
+ switch (nmc->hdr.code) {
+ case CLN_LISTREBUILT:
+ data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ ClistPrepare(data->proto, NULL, nmc->hdr.hwndFrom);
+ break;
+ }
+ }
}
- else if ((LOWORD(wparam) == IDC_MINDMSG || LOWORD(wparam) == IDC_URL) && HIWORD(wparam) == EN_CHANGE)
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wparam))
{
- bool ok = SendDlgItemMessage(hwnd, IDC_MINDMSG, WM_GETTEXTLENGTH, 0, 0) > 0;
- if (!ok && SendDlgItemMessage(hwnd, IDC_URL, WM_GETTEXTLENGTH, 0, 0) > 0)
- ok = true;
+ case IDC_WALL:
+ if (HIWORD(wparam) == CBN_SELCHANGE) {
+ data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ RefreshPrivacy(hwnd, data);
+ }
+ break;
- EnableWindow(GetDlgItem(hwnd, IDOK), ok);
- return TRUE;
- }
- else if (LOWORD(wparam) == IDOK)
+ case IDC_MINDMSG:
+ case IDC_URL:
+ if (HIWORD(wparam) == EN_CHANGE) {
+ 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;
+ }
+ break;
+
+ case IDC_EXPAND:
+ bShowContacts = !bShowContacts;
+ ResizeHorizontal(hwnd, bShowContacts);
+ break;
+
+ case IDOK:
{
data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
@@ -199,6 +285,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
int privacy_id = SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0);
data->proto->setTString(FACEBOOK_KEY_PLACE, placeT);
+ data->proto->setByte("PostStatusExpand", bShowContacts);
// remember last wall, only when there are more options
if (SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCOUNT, 0, 0) > 1)
@@ -215,11 +302,8 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
status->place = ptrA(mir_utf8encodeT(placeT));
status->url = _T2A(urlT);
- // TODO: add support for tagging friends
- /*facebook_user *fu = new facebook_user();
- fu->user_id = ...;
- fu->real_name = ...;
- status->users.insert(fu);*/
+ HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST);
+ GetSelectedContacts(data->proto, NULL, hwndList, &status->users);
ptrA narrow = mir_utf8encodeT(mindMessageT);
status->text = narrow;
@@ -232,12 +316,12 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
EndDialog(hwnd, wparam);
return TRUE;
}
- else if (LOWORD(wparam) == IDCANCEL)
- {
+
+ case IDCANCEL:
EndDialog(hwnd, wparam);
return TRUE;
- }
- break;
+
+ } break;
case WM_DESTROY:
data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 85ae3cca47..4fcbcffdda 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -2,6 +2,8 @@
// Microsoft Visual C++ generated include file.
// Used by D:\Development\Miranda NG\protocols\FacebookRM\res\facebook.rc
//
+#define IDCANCEL2 3
+#define IDC_EXPAND 3
#define IDI_FACEBOOK 101
#define IDI_MIND 102
#define IDD_FACEBOOKACCOUNT 111
@@ -42,6 +44,7 @@
#define IDC_PRIVACY 1204
#define IDC_WALL 1205
#define IDC_URL 1206
+#define IDC_CCLIST 1207
// Next default values for new objects
//
@@ -49,7 +52,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1205
+#define _APS_NEXT_CONTROL_VALUE 1208
#define _APS_NEXT_SYMED_VALUE 131
#endif
#endif