summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/res/facebook.rc66
-rw-r--r--protocols/FacebookRM/src/constants.h6
-rw-r--r--protocols/FacebookRM/src/db.h20
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp69
-rw-r--r--protocols/FacebookRM/src/events.cpp98
-rw-r--r--protocols/FacebookRM/src/messages.cpp2
-rw-r--r--protocols/FacebookRM/src/proto.cpp171
-rw-r--r--protocols/FacebookRM/src/proto.h7
-rw-r--r--protocols/FacebookRM/src/resource.h20
9 files changed, 186 insertions, 273 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc
index 35d5aa98e1..58bbd8c9d5 100644
--- a/protocols/FacebookRM/res/facebook.rc
+++ b/protocols/FacebookRM/res/facebook.rc
@@ -123,41 +123,16 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- GROUPBOX "Event notifications",IDC_STATIC,6,7,293,115
- CTEXT "Colors",IDC_STATIC,106,14,68,8
- RTEXT "Back",IDC_STATIC,106,24,31,8
- LTEXT "Text",IDC_STATIC,143,24,31,8
- CONTROL "Notifications",IDC_NOTIFICATIONS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,37,84,8
- CONTROL "",IDC_COLBACK,"ColourPicker",WS_TABSTOP,113,35,24,13
- CONTROL "",IDC_COLTEXT,"ColourPicker",WS_TABSTOP,143,35,24,13
- CONTROL "Default",IDC_NOTIFICATIONS_DEFAULT,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,174,37,63,8
- CONTROL "News feeds",IDC_FEEDS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,57,84,8
- CONTROL "",IDC_COLBACK2,"ColourPicker",WS_TABSTOP,113,55,24,13
- CONTROL "",IDC_COLTEXT2,"ColourPicker",WS_TABSTOP,143,55,24,13
- CONTROL "Default",IDC_FEEDS_DEFAULT,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,174,57,63,8
- CONTROL "Other events",IDC_OTHER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,77,84,8
- CONTROL "",IDC_COLBACK3,"ColourPicker",WS_TABSTOP,113,75,24,13
- CONTROL "",IDC_COLTEXT3,"ColourPicker",WS_TABSTOP,143,75,24,13
- CONTROL "Default",IDC_OTHER_DEFAULT,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,174,77,63,8
- CONTROL "Client notifications",IDC_CLIENT_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,97,84,8
- CONTROL "",IDC_COLBACK4,"ColourPicker",WS_TABSTOP,113,95,24,13
- CONTROL "",IDC_COLTEXT4,"ColourPicker",WS_TABSTOP,143,95,24,13
- CONTROL "Default",IDC_CLIENT_DEFAULT,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,174,97,63,8
- RTEXT "Timeout (sec.)",IDC_STATIC,174,14,113,8
- RTEXT "(0 = default, -1 = infinite)",IDC_STATIC,174,24,118,8
- EDITTEXT IDC_TIMEOUT,243,35,34,14,ES_AUTOHSCROLL
- CONTROL "",IDC_TIMEOUT_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,35,11,14
- EDITTEXT IDC_TIMEOUT2,243,55,34,14,ES_AUTOHSCROLL
- CONTROL "",IDC_TIMEOUT_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,55,11,14
- EDITTEXT IDC_TIMEOUT3,243,75,34,14,ES_AUTOHSCROLL
- CONTROL "",IDC_TIMEOUT_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,75,11,14
- EDITTEXT IDC_TIMEOUT4,243,95,34,14,ES_AUTOHSCROLL
- CONTROL "",IDC_TIMEOUT_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,95,11,14
- PUSHBUTTON "Preview",IDC_PREVIEW,118,182,68,14
+ GROUPBOX "Event notifications",IDC_STATIC,6,7,292,106
+ CONTROL "Notifications",IDC_NOTIFICATIONS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,23,84,8
+ 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 "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,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,49,132,228,8
- LTEXT "News Feed types to notify:",IDC_STATIC,51,155,112,8
- COMBOBOX IDC_FEED_TYPE,169,153,96,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,47,121,228,8
END
IDD_OPTIONS_ADVANCED DIALOGEX 0, 0, 305, 210
@@ -230,26 +205,10 @@ BEGIN
IDD_OPTIONS_EVENTS, DIALOG
BEGIN
LEFTMARGIN, 6
- RIGHTMARGIN, 299
+ RIGHTMARGIN, 298
VERTGUIDE, 22
- VERTGUIDE, 106
- VERTGUIDE, 113
- VERTGUIDE, 137
- VERTGUIDE, 143
- VERTGUIDE, 167
- VERTGUIDE, 174
- VERTGUIDE, 237
- VERTGUIDE, 277
TOPMARGIN, 7
- BOTTOMMARGIN, 203
- HORZGUIDE, 35
- HORZGUIDE, 37
- HORZGUIDE, 55
- HORZGUIDE, 57
- HORZGUIDE, 75
- HORZGUIDE, 77
- HORZGUIDE, 95
- HORZGUIDE, 97
+ BOTTOMMARGIN, 202
END
IDD_OPTIONS_ADVANCED, DIALOG
@@ -277,7 +236,8 @@ END
//
// Generated from the TEXTINCLUDE 3 resource.
//
-
+
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index e5af79d6db..7334ddf262 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_URL_NOTIFICATIONS "http://www.facebook.com/n/?notifications.php"
#define FACEBOOK_URL_PROFILE "http://www.facebook.com/profile.php?id="
#define FACEBOOK_URL_GROUP "http://www.facebook.com/n/?home.php&sk=group_"
+#define FACEBOOK_URL_PICTURE "http://graph.facebook.com/%s/picture"
// Connection
#define FACEBOOK_SERVER_REGULAR "www.facebook.com"
@@ -38,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_SERVER_CHAT "%s-%s.facebook.com"
#define FACEBOOK_SERVER_LOGIN "login.facebook.com"
#define FACEBOOK_SERVER_APPS "apps.facebook.com"
+#define FACEBOOK_SERVER_DOMAIN "facebook.com"
// Limits
#define FACEBOOK_MESSAGE_LIMIT 200000 // this is guessed limit, in reality it is bigger
@@ -70,10 +72,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_EVENT_FEEDS_ENABLE 1
#define DEFAULT_EVENT_OTHER_ENABLE 1
#define DEFAULT_EVENT_CLIENT_ENABLE 1
-#define DEFAULT_EVENT_COLBACK 0x00ffffff
-#define DEFAULT_EVENT_COLTEXT 0x00000000
-#define DEFAULT_EVENT_TIMEOUT_TYPE 0
-#define DEFAULT_EVENT_TIMEOUT 20
// Event flags
#define FACEBOOK_EVENT_CLIENT 0x10000000 // Facebook error or info message
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index 7d8d07fde6..df5877abf7 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -65,23 +65,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_EVENT_OTHER_ENABLE "EventOtherEnable"
#define FACEBOOK_KEY_EVENT_CLIENT_ENABLE "EventClientEnable"
#define FACEBOOK_KEY_FEED_TYPE "EventFeedsType"
-
-#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLBACK "PopupNotificationsColorBack"
-#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLTEXT "PopupNotificationsColorText"
-#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_TIMEOUT "PopupNotificationsTimeout"
-#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_DEFAULT "PopupNotificationsColorDefault"
-
-#define FACEBOOK_KEY_EVENT_FEEDS_COLBACK "PopupFeedsColorBack"
-#define FACEBOOK_KEY_EVENT_FEEDS_COLTEXT "PopupFeedsColorText"
-#define FACEBOOK_KEY_EVENT_FEEDS_TIMEOUT "PopupFeedsTimeout"
-#define FACEBOOK_KEY_EVENT_FEEDS_DEFAULT "PopupFeedsColorDefault"
-
-#define FACEBOOK_KEY_EVENT_OTHER_COLBACK "PopupOtherColorBack"
-#define FACEBOOK_KEY_EVENT_OTHER_COLTEXT "PopupOtherColorText"
-#define FACEBOOK_KEY_EVENT_OTHER_TIMEOUT "PopupOtherTimeout"
-#define FACEBOOK_KEY_EVENT_OTHER_DEFAULT "PopupOtherColorDefault"
-
-#define FACEBOOK_KEY_EVENT_CLIENT_COLBACK "PopupClientColorBack"
-#define FACEBOOK_KEY_EVENT_CLIENT_COLTEXT "PopupClientColorText"
-#define FACEBOOK_KEY_EVENT_CLIENT_TIMEOUT "PopupClientTimeout"
-#define FACEBOOK_KEY_EVENT_CLIENT_DEFAULT "PopupClientColorDefault"
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 113c08175e..fa29e6bc2f 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -456,36 +456,10 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa
LoadDBCheckState(proto, hwnd, IDC_CLIENT_ENABLE, FACEBOOK_KEY_EVENT_CLIENT_ENABLE, DEFAULT_EVENT_CLIENT_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE, DEFAULT_EVENT_OTHER_ENABLE);
- SendDlgItemMessage(hwnd, IDC_COLBACK, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLBACK,DEFAULT_EVENT_COLBACK));
- SendDlgItemMessage(hwnd, IDC_COLTEXT, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLTEXT,DEFAULT_EVENT_COLTEXT));
- SetDlgItemInt(hwnd, IDC_TIMEOUT, proto->getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_TIMEOUT, 0),TRUE);
- SendDlgItemMessage(hwnd, IDC_COLBACK2, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_FEEDS_COLBACK,DEFAULT_EVENT_COLBACK));
- SendDlgItemMessage(hwnd, IDC_COLTEXT2, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_FEEDS_COLTEXT,DEFAULT_EVENT_COLTEXT));
- SetDlgItemInt(hwnd, IDC_TIMEOUT2, proto->getDword(FACEBOOK_KEY_EVENT_FEEDS_TIMEOUT, 0),TRUE);
- SendDlgItemMessage(hwnd, IDC_COLBACK3, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_OTHER_COLBACK,DEFAULT_EVENT_COLBACK));
- SendDlgItemMessage(hwnd, IDC_COLTEXT3, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_OTHER_COLTEXT,DEFAULT_EVENT_COLTEXT));
- SetDlgItemInt(hwnd, IDC_TIMEOUT3, proto->getDword(FACEBOOK_KEY_EVENT_OTHER_TIMEOUT, 0),TRUE);
- SendDlgItemMessage(hwnd, IDC_COLBACK4, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_CLIENT_COLBACK,DEFAULT_EVENT_COLBACK));
- SendDlgItemMessage(hwnd, IDC_COLTEXT4, CPM_SETCOLOUR, 0, proto->getDword(FACEBOOK_KEY_EVENT_CLIENT_COLTEXT,DEFAULT_EVENT_COLTEXT));
- SetDlgItemInt(hwnd, IDC_TIMEOUT4, proto->getDword(FACEBOOK_KEY_EVENT_CLIENT_TIMEOUT, 0),TRUE);
-
- LoadDBCheckState(proto, hwnd, IDC_NOTIFICATIONS_DEFAULT, FACEBOOK_KEY_EVENT_NOTIFICATIONS_DEFAULT, 0);
- LoadDBCheckState(proto, hwnd, IDC_FEEDS_DEFAULT, FACEBOOK_KEY_EVENT_FEEDS_DEFAULT, 0);
- LoadDBCheckState(proto, hwnd, IDC_CLIENT_DEFAULT, FACEBOOK_KEY_EVENT_CLIENT_DEFAULT, 0);
- LoadDBCheckState(proto, hwnd, IDC_OTHER_DEFAULT, FACEBOOK_KEY_EVENT_OTHER_DEFAULT, 0);
-
- SendDlgItemMessage(hwnd, IDC_TIMEOUT, EM_LIMITTEXT, 4, 0);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE32, -1, 100);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT2, EM_LIMITTEXT, 4, 0);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN2, UDM_SETRANGE32, -1, 100);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT3, EM_LIMITTEXT, 4, 0);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN3, UDM_SETRANGE32, -1, 100);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT4, EM_LIMITTEXT, 4, 0);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN4, UDM_SETRANGE32, -1, 100);
-
} return TRUE;
- case WM_COMMAND: {
+ case WM_COMMAND:
+ {
switch (LOWORD(wparam))
{
case IDC_PREVIEW:
@@ -497,25 +471,14 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa
proto->NotifyEvent(protoName, TranslateT("Sample newsfeed"), NULL, FACEBOOK_EVENT_NEWSFEED);
proto->NotifyEvent(protoName, TranslateT("Sample notification"), NULL, FACEBOOK_EVENT_NOTIFICATION);
} break;
-
- case IDC_COLTEXT:
- case IDC_COLBACK:
- case IDC_COLTEXT2:
- case IDC_COLBACK2:
- case IDC_COLTEXT3:
- case IDC_COLBACK3:
- case IDC_COLTEXT4:
- case IDC_COLBACK4:
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- // TODO: Required? There's a catching clause below
}
if ((LOWORD(wparam)==IDC_PREVIEW || (HWND)lparam!=GetFocus()))
return 0;
else
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0); }
+ SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- return TRUE;
+ } return TRUE;
case WM_NOTIFY:
{
@@ -529,30 +492,8 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa
StoreDBCheckState(proto, hwnd, IDC_FEEDS_ENABLE, FACEBOOK_KEY_EVENT_FEEDS_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_CLIENT_ENABLE, FACEBOOK_KEY_EVENT_CLIENT_ENABLE);
-
- StoreDBCheckState(proto, hwnd, IDC_NOTIFICATIONS_DEFAULT, FACEBOOK_KEY_EVENT_NOTIFICATIONS_DEFAULT);
- StoreDBCheckState(proto, hwnd, IDC_FEEDS_DEFAULT, FACEBOOK_KEY_EVENT_FEEDS_DEFAULT);
- StoreDBCheckState(proto, hwnd, IDC_OTHER_DEFAULT, FACEBOOK_KEY_EVENT_OTHER_DEFAULT);
- StoreDBCheckState(proto, hwnd, IDC_CLIENT_DEFAULT, FACEBOOK_KEY_EVENT_CLIENT_DEFAULT);
-
- proto->setDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLBACK, SendDlgItemMessage(hwnd,IDC_COLBACK,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLTEXT, SendDlgItemMessage(hwnd,IDC_COLTEXT,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_TIMEOUT, GetDlgItemInt(hwnd,IDC_TIMEOUT,NULL,TRUE));
-
- proto->setDword(FACEBOOK_KEY_EVENT_FEEDS_COLBACK, SendDlgItemMessage(hwnd,IDC_COLBACK2,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_FEEDS_COLTEXT, SendDlgItemMessage(hwnd,IDC_COLTEXT2,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_FEEDS_TIMEOUT, GetDlgItemInt(hwnd,IDC_TIMEOUT2,NULL,TRUE));
-
- proto->setDword(FACEBOOK_KEY_EVENT_OTHER_COLBACK, SendDlgItemMessage(hwnd,IDC_COLBACK3,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_OTHER_COLTEXT, SendDlgItemMessage(hwnd,IDC_COLTEXT3,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_OTHER_TIMEOUT, GetDlgItemInt(hwnd,IDC_TIMEOUT3,NULL,TRUE));
-
- proto->setDword(FACEBOOK_KEY_EVENT_CLIENT_COLBACK, SendDlgItemMessage(hwnd,IDC_COLBACK4,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_CLIENT_COLTEXT, SendDlgItemMessage(hwnd,IDC_COLTEXT4,CPM_GETCOLOUR,0,0));
- proto->setDword(FACEBOOK_KEY_EVENT_CLIENT_TIMEOUT, GetDlgItemInt(hwnd,IDC_TIMEOUT4,NULL,TRUE));
}
- }
- return TRUE;
+ } return TRUE;
}
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp
index bbab7df928..826a0a55ef 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -42,72 +42,23 @@ int FacebookProto::Log(const char *fmt,...)
return utils::debug::log(m_szModuleName, text);
}
-LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case WM_COMMAND:
- case WM_CONTEXTMENU:
- {
- // Get the plugin data (we need the Popup service to do it)
- popup_data *data = (popup_data *)PUGetPluginData(hwnd);
- if (data != NULL) {
- if (!data->notification_id.empty())
- data->proto->ForkThread(&FacebookProto::ReadNotificationWorker, new std::string(data->notification_id));
-
- if (message == WM_COMMAND && !data->url.empty())
- data->proto->OpenUrl(data->url);
- }
-
- // After a click, destroy popup
- PUDeletePopup(hwnd);
- } break;
-
- case UM_FREEPLUGINDATA:
- {
- // After close, free
- popup_data *data = (popup_data *)PUGetPluginData(hwnd);
- if (data != NULL)
- mir_free(data);
- } return FALSE;
-
- default:
- break;
- }
-
- return DefWindowProc(hwnd, message, wParam, lParam);
-};
-
void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD flags, std::string *url, std::string *notification_id)
{
- int ret, timeout;
- COLORREF colorBack = 0, colorText = 0;
- HICON icon = Skin_GetIconByHandle(m_hProtoIcon);
+ char name[256];
switch (flags)
{
case FACEBOOK_EVENT_CLIENT:
if (!getByte(FACEBOOK_KEY_EVENT_CLIENT_ENABLE, DEFAULT_EVENT_CLIENT_ENABLE))
return;
- if (!getByte(FACEBOOK_KEY_EVENT_CLIENT_DEFAULT, 0))
- {
- colorBack = getDword(FACEBOOK_KEY_EVENT_CLIENT_COLBACK, DEFAULT_EVENT_COLBACK);
- colorText = getDword(FACEBOOK_KEY_EVENT_CLIENT_COLTEXT, DEFAULT_EVENT_COLTEXT);
- }
- timeout = getDword(FACEBOOK_KEY_EVENT_CLIENT_TIMEOUT, 0);
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Client");
flags |= NIIF_WARNING;
break;
case FACEBOOK_EVENT_NEWSFEED:
if (!getByte(FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE))
return;
- if (!getByte(FACEBOOK_KEY_EVENT_FEEDS_DEFAULT, 0))
- {
- colorBack = getDword(FACEBOOK_KEY_EVENT_FEEDS_COLBACK, DEFAULT_EVENT_COLBACK);
- colorText = getDword(FACEBOOK_KEY_EVENT_FEEDS_COLTEXT, DEFAULT_EVENT_COLTEXT);
- }
- timeout = getDword(FACEBOOK_KEY_EVENT_FEEDS_TIMEOUT, 0);
- icon = Skin_GetIconByHandle(GetIconHandle("newsfeed"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Newsfeed");
SkinPlaySound("NewsFeed");
flags |= NIIF_INFO;
break;
@@ -115,13 +66,7 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD
case FACEBOOK_EVENT_NOTIFICATION:
if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
return;
- if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_DEFAULT, 0))
- {
- colorBack = getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLBACK, DEFAULT_EVENT_COLBACK);
- colorText = getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_COLTEXT, DEFAULT_EVENT_COLTEXT);
- }
- timeout = getDword(FACEBOOK_KEY_EVENT_NOTIFICATIONS_TIMEOUT, 0);
- icon = Skin_GetIconByHandle(GetIconHandle("notification"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Notification");
SkinPlaySound("Notification");
flags |= NIIF_INFO;
break;
@@ -129,12 +74,7 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD
case FACEBOOK_EVENT_OTHER:
if (!getByte(FACEBOOK_KEY_EVENT_OTHER_ENABLE, DEFAULT_EVENT_OTHER_ENABLE))
return;
- if (!getByte(FACEBOOK_KEY_EVENT_OTHER_DEFAULT, 0))
- {
- colorBack = getDword(FACEBOOK_KEY_EVENT_OTHER_COLBACK, DEFAULT_EVENT_COLBACK);
- colorText = getDword(FACEBOOK_KEY_EVENT_OTHER_COLTEXT, DEFAULT_EVENT_COLTEXT);
- }
- timeout = getDword(FACEBOOK_KEY_EVENT_OTHER_TIMEOUT, 0);
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Other");
SkinPlaySound("OtherEvent");
flags |= NIIF_INFO;
break;
@@ -142,14 +82,13 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD
if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY,DEFAULT_SYSTRAY_NOTIFY))
{
- if (ServiceExists(MS_POPUP_ADDPOPUP))
- {
- POPUPDATAT pd = {0};
- pd.colorBack = colorBack;
- pd.colorText = colorText;
- pd.iSeconds = timeout;
- pd.lchContact = contact;
- pd.lchIcon = icon;
+ if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
+ POPUPDATACLASS pd = { sizeof(pd) };
+ pd.ptszTitle = title;
+ pd.ptszText = info;
+ pd.pszClassName = name;
+ pd.hContact = contact;
+
if (url != NULL || notification_id != NULL) {
popup_data *data = new popup_data(this);
if (url != NULL)
@@ -159,12 +98,7 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD
pd.PluginData = data;
}
- pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
- lstrcpy(pd.lptzContactName, title);
- lstrcpy(pd.lptzText, info);
- ret = PUAddPopupT(&pd);
-
- if (ret == 0)
+ if (CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&pd) == 0)
return;
}
} else {
@@ -181,10 +115,8 @@ void FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, HANDLE contact, DWORD
err.dwInfoFlags = NIIF_INTERN_TCHAR | niif_flags;
err.tszInfoTitle = title;
err.tszInfo = info;
- err.uTimeout = 1000 * timeout;
- ret = CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & err);
-
- if (ret == 0)
+ err.uTimeout = 10000;
+ if (CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & err) == 0)
return;
}
}
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index b5fd264f95..09b3b14ce8 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -197,7 +197,7 @@ void FacebookProto::ParseSmileys(std::string message, HANDLE hContact)
std::string smiley = message.substr(pos, pos2+2-pos);
pos = pos2;
- std::string url = "http://graph.facebook.com/%s/picture";
+ std::string url = FACEBOOK_URL_PICTURE;
utils::text::replace_first(&url, "%s", smiley.substr(2, smiley.length()-4));
std::string b64 = ptrA( mir_base64_encode((PBYTE)smiley.c_str(), (unsigned)smiley.length()));
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 42e675e9c1..cf12dea71e 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -52,20 +52,13 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged);
HookProtoEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit);
- char module[512];
- mir_snprintf(module, sizeof(module), "%s/Mind", m_szModuleName);
-
- HOTKEYDESC hkd = { sizeof(hkd) };
- hkd.dwFlags = HKD_TCHAR;
- hkd.ptszDescription = LPGENT("Show 'Share status' window");
- hkd.pszName = "ShowMindWnd";
- hkd.ptszSection = m_tszUserName;
- hkd.pszService = module;
- hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT|HOTKEYF_EXT, 'F');
- Hotkey_Register(&hkd);
+ InitHotkeys();
+ InitPopups();
+ InitSounds();
// Create standard network connection
TCHAR descr[512];
+ char module[512];
NETLIBUSER nlu = {sizeof(nlu)};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
nlu.szSettingsModule = m_szModuleName;
@@ -77,11 +70,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
if (m_hNetlibUser == NULL)
MessageBox(NULL, TranslateT("Unable to get Netlib connection for Facebook"), m_tszUserName, MB_OK);
- facy.set_handle(m_hNetlibUser);
-
- SkinAddNewSoundExT("Notification", m_tszUserName, LPGENT("Notification"));
- SkinAddNewSoundExT("NewsFeed", m_tszUserName, LPGENT("News Feed"));
- SkinAddNewSoundExT("OtherEvent", m_tszUserName, LPGENT("Other Event"));
+ facy.set_handle(m_hNetlibUser);
mir_sntprintf(descr, SIZEOF(descr), _T("%%miranda_avatarcache%%\\%s"), m_tszUserName);
hAvatarFolder_ = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, descr, m_tszUserName);
@@ -92,6 +81,11 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
FacebookProto::~FacebookProto()
{
+ // Uninit popup classes
+ for (std::vector<HANDLE>::size_type i = 0; i < popupClasses.size(); i++)
+ Popup_UnregisterClass(popupClasses[i]);
+ popupClasses.clear();
+
Netlib_CloseHandle(m_hNetlibUser);
WaitForSingleObject(signon_lock_, IGNORE);
@@ -423,19 +417,17 @@ int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
Options_AddPage(wParam, &odp);
odp.position = 271829;
- odp.ptszTab = LPGENT("Advanced");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_ADVANCED);
- odp.pfnDlgProc = FBOptionsAdvancedProc;
- Options_AddPage(wParam, &odp);
-
- odp.position = 271830;
- if (ServiceExists(MS_POPUP_ADDPOPUPT))
- odp.ptszGroup = LPGENT("Popups");
odp.ptszTab = LPGENT("Events");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_EVENTS);
odp.pfnDlgProc = FBEventsProc;
Options_AddPage(wParam, &odp);
+ odp.position = 271830;
+ odp.ptszTab = LPGENT("Advanced");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_ADVANCED);
+ odp.pfnDlgProc = FBOptionsAdvancedProc;
+ Options_AddPage(wParam, &odp);
+
return 0;
}
@@ -669,8 +661,7 @@ HANDLE FacebookProto::HContactFromAuthEvent(HANDLE hEvent)
void FacebookProto::OpenUrl(std::string url)
{
- std::string facebookDomain = "facebook.com";
- std::string::size_type pos = url.find(facebookDomain);
+ std::string::size_type pos = url.find(FACEBOOK_SERVER_DOMAIN);
bool isFacebookUrl = (pos != std::string::npos);
bool isRelativeUrl = (url.substr(0, 4) != "http");
@@ -678,7 +669,7 @@ void FacebookProto::OpenUrl(std::string url)
// Make realtive url
if (!isRelativeUrl) {
- url = url.substr(pos + facebookDomain.length());
+ url = url.substr(pos + strlen(FACEBOOK_SERVER_DOMAIN));
// Strip eventual port
pos = url.find("/");
@@ -709,4 +700,128 @@ void FacebookProto::ReadNotificationWorker(void *p)
facy.flap(REQUEST_NOTIFICATIONS_READ, NULL, &data);
delete p;
-} \ No newline at end of file
+}
+
+/**
+ * Popup processing callback
+ */
+LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case WM_COMMAND:
+ case WM_CONTEXTMENU:
+ {
+ // Get the plugin data (we need the Popup service to do it)
+ popup_data *data = (popup_data *)PUGetPluginData(hwnd);
+ if (data != NULL) {
+ if (!data->notification_id.empty())
+ data->proto->ForkThread(&FacebookProto::ReadNotificationWorker, new std::string(data->notification_id));
+
+ if (message == WM_COMMAND && !data->url.empty())
+ data->proto->OpenUrl(data->url);
+ }
+
+ // After a click, destroy popup
+ PUDeletePopup(hwnd);
+ } break;
+
+ case UM_FREEPLUGINDATA:
+ {
+ // After close, free
+ popup_data *data = (popup_data *)PUGetPluginData(hwnd);
+ if (data != NULL)
+ mir_free(data);
+ } return FALSE;
+
+ default:
+ break;
+ }
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+};
+
+/**
+ * Popup classes initialization
+ */
+void FacebookProto::InitPopups()
+{
+ POPUPCLASS ppc = { sizeof(ppc) };
+ ppc.flags = PCF_TCHAR;
+ ppc.PluginWindowProc = (WNDPROC)PopupDlgProc;
+
+ TCHAR desc[256];
+ char name[256];
+
+ // Client
+ mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Client notifications"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Client");
+ ppc.ptszDescription = desc;
+ ppc.pszName = name;
+ ppc.hIcon = Skin_GetIconByHandle(GetIconHandle("facebook"));
+ ppc.colorBack = RGB(191, 0, 0); // red
+ ppc.colorText = RGB(255, 255, 255); // white
+ ppc.iSeconds = 0;
+ popupClasses.push_back(Popup_RegisterClass(&ppc));
+
+ // Newsfeeds
+ mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("News feeds"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Newsfeed");
+ ppc.ptszDescription = desc;
+ ppc.pszName = name;
+ ppc.hIcon = Skin_GetIconByHandle(GetIconHandle("newsfeed"));
+ ppc.colorBack = RGB(255, 255, 255); // white
+ ppc.colorText = RGB(0, 0, 0); // black
+ ppc.iSeconds = 0;
+ popupClasses.push_back(Popup_RegisterClass(&ppc));
+
+ // Notifications
+ mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Notifications"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Notification");
+ ppc.ptszDescription = desc;
+ ppc.pszName = name;
+ ppc.hIcon = Skin_GetIconByHandle(GetIconHandle("notification"));
+ ppc.colorBack = RGB(59, 89, 152); // Facebook's blue
+ ppc.colorText = RGB(255, 255, 255); // white
+ ppc.iSeconds = 0;
+ popupClasses.push_back(Popup_RegisterClass(&ppc));
+
+ // Others
+ mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Other events"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Other");
+ ppc.ptszDescription = desc;
+ ppc.pszName = name;
+ ppc.hIcon = Skin_GetIconByHandle(GetIconHandle("facebook"));
+ ppc.colorBack = RGB(255, 255, 255); // white
+ ppc.colorText = RGB(0, 0, 0); // black
+ ppc.iSeconds = 0;
+ popupClasses.push_back(Popup_RegisterClass(&ppc));
+}
+
+/**
+ * Hotkeys initialiation
+ */
+void FacebookProto::InitHotkeys()
+{
+ char module[512];
+ mir_snprintf(module, sizeof(module), "%s/Mind", m_szModuleName);
+
+ HOTKEYDESC hkd = { sizeof(hkd) };
+ hkd.dwFlags = HKD_TCHAR;
+ hkd.ptszDescription = LPGENT("Show 'Share status' window");
+ hkd.pszName = "ShowMindWnd";
+ hkd.ptszSection = m_tszUserName;
+ hkd.pszService = module;
+ hkd.DefHotKey = HOTKEYCODE(HOTKEYF_ALT|HOTKEYF_EXT, 'F');
+ Hotkey_Register(&hkd);
+}
+
+/**
+ * Sounds initialization
+ */
+void FacebookProto::InitSounds()
+{
+ SkinAddNewSoundExT("Notification", m_tszUserName, LPGENT("Notification"));
+ SkinAddNewSoundExT("NewsFeed", m_tszUserName, LPGENT("News Feed"));
+ SkinAddNewSoundExT("OtherEvent", m_tszUserName, LPGENT("Other Event"));
+}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 0352945043..40c03e6450 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -123,6 +123,11 @@ public:
INT_PTR __cdecl OnMind(WPARAM,LPARAM);
+ // Initialiation
+ void InitPopups();
+ void InitHotkeys();
+ void InitSounds();
+
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
@@ -207,6 +212,8 @@ public:
HANDLE m_hNetlibUser;
+ std::vector<HANDLE> popupClasses;
+
std::string last_status_msg_;
HANDLE hAvatarFolder_;
HANDLE hSmileysFolder_;
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 444c7c7699..85ae3cca47 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -33,26 +33,6 @@
#define IDC_FEEDS_ENABLE 1042
#define IDC_OTHER_ENABLE 1043
#define IDC_CLIENT_ENABLE 1044
-#define IDC_COLBACK 1051
-#define IDC_COLTEXT 1052
-#define IDC_COLBACK2 1053
-#define IDC_COLTEXT2 1054
-#define IDC_COLBACK3 1055
-#define IDC_COLTEXT3 1056
-#define IDC_COLBACK4 1057
-#define IDC_COLTEXT4 1058
-#define IDC_NOTIFICATIONS_DEFAULT 1071
-#define IDC_FEEDS_DEFAULT 1072
-#define IDC_OTHER_DEFAULT 1073
-#define IDC_CLIENT_DEFAULT 1074
-#define IDC_TIMEOUT 1081
-#define IDC_TIMEOUT_SPIN 1082
-#define IDC_TIMEOUT2 1083
-#define IDC_TIMEOUT_SPIN2 1084
-#define IDC_TIMEOUT3 1085
-#define IDC_TIMEOUT_SPIN3 1086
-#define IDC_TIMEOUT4 1087
-#define IDC_TIMEOUT_SPIN4 1088
#define IDC_SYSTRAY_NOTIFY 1098
#define IDC_PREVIEW 1099
#define IDC_SET_STATUS 1126