1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
/*
Facebook plugin for Miranda Instant Messenger
_____________________________________________
Copyright © 2009-11 Michal Zelinka, 2011-13 Robert Pösel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common.h"
int FacebookProto::Log(const char *fmt,...)
{
if (!getByte(FACEBOOK_KEY_LOGGING_ENABLE, 0))
return EXIT_SUCCESS;
va_list va;
char text[65535];
ScopedLock s(log_lock_);
va_start(va,fmt);
mir_vsnprintf(text,sizeof(text),fmt,va);
va_end(va);
// Write into network log
CallService(MS_NETLIB_LOG, (WPARAM)m_hNetlibUser, (LPARAM)text);
// Write into log file
return utils::debug::log(m_szModuleName, text);
}
LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
{
//Get the plugin data (we need the Popup service to do it)
popup_data *data = (popup_data *)PUGetPluginData(hwnd);
if (data != NULL)
data->proto->OpenUrl(data->url);
// After a click, destroy popup
PUDeletePopup(hwnd);
} break;
case WM_CONTEXTMENU:
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)
{
int ret; int timeout; COLORREF colorBack = 0; COLORREF colorText = 0;
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);
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);
SkinPlaySound("NewsFeed");
flags |= NIIF_INFO;
break;
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);
SkinPlaySound("Notification");
flags |= NIIF_INFO;
break;
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);
SkinPlaySound("OtherEvent");
flags |= NIIF_INFO;
break;
}
if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY,DEFAULT_SYSTRAY_NOTIFY))
{
if (ServiceExists(MS_POPUP_ADDPOPUP))
{
POPUPDATAT pd;
pd.colorBack = colorBack;
pd.colorText = colorText;
pd.iSeconds = timeout;
pd.lchContact = contact;
pd.lchIcon = Skin_GetIconByHandle(m_hProtoIcon); // TODO: Icon test
if (url != NULL)
pd.PluginData = new popup_data(this, *url);
pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
lstrcpy(pd.lptzContactName, title);
lstrcpy(pd.lptzText, info);
ret = PUAddPopupT(&pd);
if (ret == 0)
return;
}
} else {
if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY))
{
MIRANDASYSTRAYNOTIFY err;
int niif_flags = flags;
REMOVE_FLAG(niif_flags, FACEBOOK_EVENT_CLIENT |
FACEBOOK_EVENT_NEWSFEED |
FACEBOOK_EVENT_NOTIFICATION |
FACEBOOK_EVENT_OTHER);
err.szProto = m_szModuleName;
err.cbSize = sizeof(err);
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)
return;
}
}
if (FLAG_CONTAINS(flags, FACEBOOK_EVENT_CLIENT))
MessageBox(NULL, info, title, MB_OK | MB_ICONINFORMATION);
}
|