diff options
author | Robert Pösel <robyer@seznam.cz> | 2013-07-31 10:38:07 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2013-07-31 10:38:07 +0000 |
commit | fb112ace5822634a51dbf06a42d57e048981519d (patch) | |
tree | 85af7a2bc9f4d5a9993d2fe2ed7bf728fa3c8af4 /protocols | |
parent | 3de73f4e34db0c8119f9424558ba724a2b793506 (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')
-rw-r--r-- | protocols/FacebookRM/res/facebook.rc | 23 | ||||
-rw-r--r-- | protocols/FacebookRM/src/dialogs.cpp | 126 | ||||
-rw-r--r-- | protocols/FacebookRM/src/resource.h | 5 |
3 files changed, 124 insertions, 30 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index 58bbd8c9d5..f78670aec5 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -76,7 +76,7 @@ BEGIN "Hyperlink",WS_TABSTOP,0,40,174,12
END
-IDD_MIND DIALOGEX 0, 0, 267, 112
+IDD_MIND DIALOGEX 0, 0, 418, 113
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?"
@@ -92,8 +92,11 @@ BEGIN EDITTEXT IDC_URL,53,60,210,14,ES_AUTOHSCROLL
LTEXT "Place:",IDC_STATIC,4,80,44,8,0,WS_EX_RIGHT
EDITTEXT IDC_PLACE,53,77,210,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "Share",IDOK,214,93,50,15
- PUSHBUTTON "Cancel",IDCANCEL,160,93,50,15
+ CONTROL "",IDC_CCLIST,"CListControl",WS_TABSTOP | 0x16f,267,21,147,88,WS_EX_CLIENTEDGE
+ DEFPUSHBUTTON "Share",IDOK,53,94,54,15
+ PUSHBUTTON "Cancel",IDCANCEL,110,94,44,15
+ PUSHBUTTON ">>",IDC_EXPAND,239,94,24,15
+ LTEXT "Attach contacts:",IDC_STATIC,271,6,143,8
END
IDD_OPTIONS DIALOGEX 0, 0, 305, 210
@@ -128,7 +131,7 @@ BEGIN CONTROL "News feeds",IDC_FEEDS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,43,84,8
LTEXT "News Feed types to notify:",IDC_STATIC,33,59,112,8
COMBOBOX IDC_FEED_TYPE,151,57,96,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "Other events",IDC_OTHER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,75,84,8
+ CONTROL "Other events",IDC_OTHER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,75,84,8
CONTROL "Client notifications",IDC_CLIENT_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,95,84,8
PUSHBUTTON "Preview",IDC_PREVIEW,117,137,68,14
CONTROL "Use balloon notifications in system tray instead of popups",IDC_SYSTRAY_NOTIFY,
@@ -177,16 +180,21 @@ BEGIN IDD_MIND, DIALOG
BEGIN
LEFTMARGIN, 4
- RIGHTMARGIN, 263
+ RIGHTMARGIN, 414
VERTGUIDE, 48
VERTGUIDE, 53
VERTGUIDE, 132
VERTGUIDE, 160
VERTGUIDE, 210
VERTGUIDE, 214
+ VERTGUIDE, 263
TOPMARGIN, 4
- BOTTOMMARGIN, 108
+ BOTTOMMARGIN, 109
+ HORZGUIDE, 21
HORZGUIDE, 40
+ HORZGUIDE, 57
+ HORZGUIDE, 94
+ HORZGUIDE, 109
END
IDD_OPTIONS, DIALOG
@@ -236,8 +244,7 @@ END //
// Generated from the TEXTINCLUDE 3 resource.
//
-
-
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
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
|