diff options
author | Mataes <mataes2007@gmail.com> | 2018-05-16 19:12:38 +0300 |
---|---|---|
committer | Mataes <mataes2007@gmail.com> | 2018-05-16 19:12:38 +0300 |
commit | b12321b9897b511e94301b73c1c48c533412d739 (patch) | |
tree | aeec4c481dc82376e22879e76a81fd2abb7138f5 /plugins/BuddyPounce/src | |
parent | 3c4beeb99d4324fb453e928421c9b13d70ab4923 (diff) |
BossKey, BuddyExpectator, BuddyPounce, ChangeKeyboardLayout, ClientChangeNotify, Cln_skinedit, CmdLine: cmplugin adaptation
Diffstat (limited to 'plugins/BuddyPounce/src')
-rw-r--r-- | plugins/BuddyPounce/src/dialog.cpp | 214 | ||||
-rw-r--r-- | plugins/BuddyPounce/src/main.cpp | 125 | ||||
-rw-r--r-- | plugins/BuddyPounce/src/stdafx.h | 11 |
3 files changed, 172 insertions, 178 deletions
diff --git a/plugins/BuddyPounce/src/dialog.cpp b/plugins/BuddyPounce/src/dialog.cpp index 724d740347..714a392324 100644 --- a/plugins/BuddyPounce/src/dialog.cpp +++ b/plugins/BuddyPounce/src/dialog.cpp @@ -77,30 +77,30 @@ void getDefaultMessage(HWND hwnd, UINT control, MCONTACT hContact) INT_PTR CALLBACK StatusModesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); // windowInfo*
TranslateDialogDefault(hwnd);
return FALSE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
- windowInfo *wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ windowInfo * wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
wchar_t type[32];
GetDlgItemText(hwnd, IDC_CHECK1, type, _countof(type));
WORD flag = (IsDlgButtonChecked(hwnd, IDC_CHECK1))
- |(IsDlgButtonChecked(hwnd, IDC_CHECK2)<<1)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK3)<<2)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK4)<<3)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK5)<<4)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK6)<<5)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK7)<<6)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK8)<<7)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK9)<<8)
- |(IsDlgButtonChecked(hwnd, IDC_CHECK10)<<9);
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK2) << 1)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK3) << 2)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK4) << 3)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK5) << 4)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK6) << 5)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK7) << 6)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK8) << 7)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK9) << 8)
+ | (IsDlgButtonChecked(hwnd, IDC_CHECK10) << 9);
if (!mir_wstrcmp(type, L"Any")) {
if (LOWORD(wParam) == IDOK)
@@ -111,7 +111,7 @@ INT_PTR CALLBACK StatusModesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l if (LOWORD(wParam) == IDOK)
db_set_w(wi->hContact, modname, "SendIfTheirStatusIsFLAG", flag);
wi->SendWhenThey = nullptr;
- }
+ }
DestroyWindow(hwnd);
}
break;
@@ -129,7 +129,7 @@ void statusModes(windowInfo *wi, int myStatusMode) // myStatusMode=1 sendIfMySta return;
}
else {
- hwnd = wi->SendIfMy = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_STATUSMODES), nullptr, StatusModesDlgProc, (LPARAM)wi);
+ hwnd = wi->SendIfMy = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_STATUSMODES), nullptr, StatusModesDlgProc, (LPARAM)wi);
statusFlag = db_get_w(wi->hContact, modname, "SendIfMyStatusIsFLAG", 0);
SetWindowText(hwnd, TranslateT("Send If My Status Is"));
SetDlgItemText(hwnd, IDC_CHECK1, TranslateT("Any"));
@@ -150,7 +150,7 @@ void statusModes(windowInfo *wi, int myStatusMode) // myStatusMode=1 sendIfMySta return;
}
else {
- hwnd = wi->SendWhenThey = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_STATUSMODES),nullptr,StatusModesDlgProc, (LPARAM)wi);
+ hwnd = wi->SendWhenThey = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_STATUSMODES), nullptr, StatusModesDlgProc, (LPARAM)wi);
statusFlag = db_get_w(wi->hContact, modname, "SendIfTheirStatusIsFLAG", 0);
SetWindowText(hwnd, TranslateT("Send If Their Status changes"));
SetDlgItemText(hwnd, IDC_CHECK1, TranslateT("From Offline"));
@@ -166,23 +166,23 @@ void statusModes(windowInfo *wi, int myStatusMode) // myStatusMode=1 sendIfMySta }
}
CheckDlgButton(hwnd, IDC_CHECK1, statusFlag&ANY ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK2, (statusFlag&ONLINE)>>1 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK3, (statusFlag&AWAY)>>2 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK4, (statusFlag&NA)>>3 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK5, (statusFlag&OCCUPIED)>>4 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK6, (statusFlag&DND)>>5 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK7, (statusFlag&FFC)>>6 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK8, (statusFlag&INVISIBLE)>>7 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK9, (statusFlag&PHONE)>>8 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, IDC_CHECK10, (statusFlag&LUNCH)>>9 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK2, (statusFlag&ONLINE) >> 1 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK3, (statusFlag&AWAY) >> 2 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK4, (statusFlag&NA) >> 3 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK5, (statusFlag&OCCUPIED) >> 4 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK6, (statusFlag&DND) >> 5 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK7, (statusFlag&FFC) >> 6 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK8, (statusFlag&INVISIBLE) >> 7 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK9, (statusFlag&PHONE) >> 8 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECK10, (statusFlag&LUNCH) >> 9 ? BST_CHECKED : BST_UNCHECKED);
}
void deletePounce(MCONTACT hContact)
{
- db_unset(hContact,modname, "PounceMsg");
- db_unset(hContact,modname, "SendIfMyStatusIsFLAG");
- db_unset(hContact,modname, "SendIfTheirStatusIsFLAG");
- db_unset(hContact,modname, "Reuse");
+ db_unset(hContact, modname, "PounceMsg");
+ db_unset(hContact, modname, "SendIfMyStatusIsFLAG");
+ db_unset(hContact, modname, "SendIfTheirStatusIsFLAG");
+ db_unset(hContact, modname, "Reuse");
db_unset(hContact, modname, "GiveUpDays");
db_unset(hContact, modname, "GiveUpDate");
db_unset(hContact, modname, "ConfirmTimeout");
@@ -194,7 +194,7 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, L MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
wchar_t msg[1024];
- switch(uMsg) {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
hContact = lParam;
@@ -202,11 +202,11 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, L getDefaultMessage(hwnd, IDC_MESSAGE, hContact);
mir_snwprintf(msg, TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)));
- SetDlgItemText(hwnd, GRP_MSG, msg);
+ SetDlgItemText(hwnd, GRP_MSG, msg);
return FALSE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_MESSAGE:
if (HIWORD(wParam) == EN_CHANGE) {
int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE));
@@ -219,19 +219,19 @@ INT_PTR CALLBACK BuddyPounceSimpleDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, L // fall through
case IDOK:
- {
- int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1;
- if (length>1) {
- wchar_t *text = (wchar_t*)_alloca(length*sizeof(wchar_t));
- GetDlgItemText(hwnd, IDC_MESSAGE, text, length);
- db_set_ws(hContact, modname, "PounceMsg", text);
- }
- else db_unset(hContact, modname, "PounceMsg");
+ {
+ int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1;
+ if (length > 1) {
+ wchar_t *text = (wchar_t*)_alloca(length * sizeof(wchar_t));
+ GetDlgItemText(hwnd, IDC_MESSAGE, text, length);
+ db_set_ws(hContact, modname, "PounceMsg", text);
}
- // fall through
+ else db_unset(hContact, modname, "PounceMsg");
+ }
+ // fall through
case IDCANCEL:
if (LOWORD(wParam) == IDC_ADVANCED)
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_POUNCE), nullptr, BuddyPounceDlgProc, GetWindowLongPtr(hwnd, GWLP_USERDATA));
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POUNCE), nullptr, BuddyPounceDlgProc, GetWindowLongPtr(hwnd, GWLP_USERDATA));
DestroyWindow(hwnd);
}
break;
@@ -244,7 +244,7 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM windowInfo *wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
wchar_t msg[1024];
- switch(uMsg) {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
wi = (windowInfo *)mir_alloc(sizeof(windowInfo));
@@ -259,7 +259,7 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM getDefaultMessage(hwnd, IDC_MESSAGE, wi->hContact);
mir_snwprintf(msg, TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)));
- SetDlgItemText(hwnd, GRP_MSG, msg);
+ SetDlgItemText(hwnd, GRP_MSG, msg);
populateSettingsList(GetDlgItem(hwnd, IDC_SETTINGS));
populateContacts(wi->hContact, GetDlgItem(hwnd, IDC_CONTACTS));
@@ -268,7 +268,7 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM return FALSE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_MESSAGE:
if (HIWORD(wParam) == EN_CHANGE) {
int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE));
@@ -279,25 +279,25 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM case IDC_SIMPLE:
case IDOK:
- {
- MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETITEMDATA, SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETCURSEL, 0, 0), 0);
- int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))+1;
- if (length>1) {
- wchar_t *text = (wchar_t*)mir_alloc(length*sizeof(wchar_t));
- if (!text) {
- msg(TranslateT("Couldn't allocate enough memory"), L"");
- break;
- }
- GetDlgItemText(hwnd, IDC_MESSAGE, text, length);
- db_set_ws(hContact, modname, "PounceMsg", text);
- mir_free(text);
+ {
+ MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETITEMDATA, SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETCURSEL, 0, 0), 0);
+ int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1;
+ if (length > 1) {
+ wchar_t *text = (wchar_t*)mir_alloc(length * sizeof(wchar_t));
+ if (!text) {
+ msg(TranslateT("Couldn't allocate enough memory"), L"");
+ break;
}
- else db_unset(hContact, modname, "PounceMsg");
- saveLastSetting(hContact, hwnd);
- } // fall through
- if (LOWORD(wParam) == IDC_SIMPLE)
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_POUNCE_SIMPLE), nullptr, BuddyPounceSimpleDlgProc, (LPARAM)((windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact);
- // fall through
+ GetDlgItemText(hwnd, IDC_MESSAGE, text, length);
+ db_set_ws(hContact, modname, "PounceMsg", text);
+ mir_free(text);
+ }
+ else db_unset(hContact, modname, "PounceMsg");
+ saveLastSetting(hContact, hwnd);
+ } // fall through
+ if (LOWORD(wParam) == IDC_SIMPLE)
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POUNCE_SIMPLE), nullptr, BuddyPounceSimpleDlgProc, (LPARAM)((windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact);
+ // fall through
case IDCANCEL:
if (wi->SendIfMy) DestroyWindow(wi->SendIfMy);
@@ -318,16 +318,16 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM mir_snwprintf(msg, TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)));
SetDlgItemText(hwnd, GRP_MSG, msg);
- db_set_w(wi->hContact, modname, "SendIfMyStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfMyStatusIsFLAG",0));
- db_set_w(wi->hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfTheirStatusIsFLAG",0));
- db_set_b(wi->hContact, modname, "Reuse",(BYTE)db_get_b(NULL, modname, "Reuse",0));
- db_set_b(wi->hContact, modname, "GiveUpDays", (BYTE)db_get_b(NULL, modname, "GiveUpDays",0));
- db_set_dw(wi->hContact, modname, "GiveUpDate", (DWORD)db_get_dw(NULL, modname, "GiveUpDate",0));
- db_set_w(wi->hContact, modname, "ConfirmTimeout", (WORD)db_get_w(NULL, modname, "ConfirmTimeout",0));
+ db_set_w(wi->hContact, modname, "SendIfMyStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfMyStatusIsFLAG", 0));
+ db_set_w(wi->hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfTheirStatusIsFLAG", 0));
+ db_set_b(wi->hContact, modname, "Reuse", (BYTE)db_get_b(NULL, modname, "Reuse", 0));
+ db_set_b(wi->hContact, modname, "GiveUpDays", (BYTE)db_get_b(NULL, modname, "GiveUpDays", 0));
+ db_set_dw(wi->hContact, modname, "GiveUpDate", (DWORD)db_get_dw(NULL, modname, "GiveUpDate", 0));
+ db_set_w(wi->hContact, modname, "ConfirmTimeout", (WORD)db_get_w(NULL, modname, "ConfirmTimeout", 0));
break;
case IDC_SETTINGS:
- if (HIWORD(wParam) == LBN_SELCHANGE) {
+ if (HIWORD(wParam) == LBN_SELCHANGE) {
int item = SendDlgItemMessage(hwnd, IDC_SETTINGS, LB_GETCURSEL, 0, 0);
wchar_t temp[5];
saveLastSetting(wi->hContact, hwnd);
@@ -379,7 +379,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, {
wchar_t msg[1024];
- switch(uMsg) {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
{
@@ -391,7 +391,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, getDefaultMessage(hwnd, IDC_MESSAGE, wi->hContact);
mir_snwprintf(msg, TranslateT("The Message (%d Characters)"), GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)));
- SetDlgItemText(hwnd, GRP_MSG, msg);
+ SetDlgItemText(hwnd, GRP_MSG, msg);
populateSettingsList(GetDlgItem(hwnd, IDC_SETTINGS));
SendDlgItemMessage(hwnd, IDC_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG((short)1024, (short)0));
CheckDlgButton(hwnd, IDC_USEADVANCED, db_get_b(NULL, modname, "UseAdvanced", 0) ? BST_CHECKED : BST_UNCHECKED);
@@ -401,15 +401,15 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, return FALSE;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- windowInfo *wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ windowInfo * wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
MCONTACT hContact = ((windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact;
- int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE))+1;
+ int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1;
if (length > 1) {
- wchar_t *text = (wchar_t*)mir_alloc(length*sizeof(wchar_t));
+ wchar_t *text = (wchar_t*)mir_alloc(length * sizeof(wchar_t));
if (!text) {
msg(TranslateT("Couldn't allocate enough memory"), L"");
break;
@@ -429,7 +429,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_MESSAGE:
if (HIWORD(wParam) == EN_CHANGE) {
int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE));
@@ -445,7 +445,7 @@ INT_PTR CALLBACK BuddyPounceOptionsDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, break;
case IDC_SETTINGS:
- if (HIWORD(wParam) == LBN_SELCHANGE) {
+ if (HIWORD(wParam) == LBN_SELCHANGE) {
windowInfo *wi = (windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
int item = SendDlgItemMessage(hwnd, IDC_SETTINGS, LB_GETCURSEL, 0, 0);
wchar_t temp[5];
@@ -499,7 +499,7 @@ INT_PTR CALLBACK SendPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP {
SendPounceDlgProcStruct *spdps = (SendPounceDlgProcStruct *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
spdps = (SendPounceDlgProcStruct*)lParam;
@@ -513,36 +513,36 @@ INT_PTR CALLBACK SendPounceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP if (db_get_ws(spdps->hContact, modname, "PounceMsg", &dbv))
DestroyWindow(hwnd);
else {
- SetDlgItemText(hwnd,IDC_MESSAGE, dbv.ptszVal);
+ SetDlgItemText(hwnd, IDC_MESSAGE, dbv.ptszVal);
db_free(&dbv);
}
}
- SetTimer(hwnd,1,1000,nullptr);
- SendMessage(hwnd,WM_TIMER,0,0);
+ SetTimer(hwnd, 1, 1000, nullptr);
+ SendMessage(hwnd, WM_TIMER, 0, 0);
break;
case WM_TIMER:
- {
- wchar_t message[1024];
- mir_snwprintf(message, TranslateT("Pounce being sent to %s in %d seconds"), Clist_GetContactDisplayName(spdps->hContact), spdps->timer);
- SetDlgItemText(hwnd, LBL_CONTACT, message);
- }
- spdps->timer--;
- if (spdps->timer < 0) {
- KillTimer(hwnd,1);
- SendPounce(spdps->message, spdps->hContact);
- DestroyWindow(hwnd);
- }
- break;
+ {
+ wchar_t message[1024];
+ mir_snwprintf(message, TranslateT("Pounce being sent to %s in %d seconds"), Clist_GetContactDisplayName(spdps->hContact), spdps->timer);
+ SetDlgItemText(hwnd, LBL_CONTACT, message);
+ }
+ spdps->timer--;
+ if (spdps->timer < 0) {
+ KillTimer(hwnd, 1);
+ SendPounce(spdps->message, spdps->hContact);
+ DestroyWindow(hwnd);
+ }
+ break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
- KillTimer(hwnd,1);
+ KillTimer(hwnd, 1);
SendPounce(spdps->message, spdps->hContact);
// fall through
case IDCANCEL:
- KillTimer(hwnd,1);
+ KillTimer(hwnd, 1);
DestroyWindow(hwnd);
break;
}
@@ -560,7 +560,7 @@ INT_PTR CALLBACK PounceSentDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP {
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
TranslateDialogDefault(hwnd);
@@ -577,17 +577,17 @@ INT_PTR CALLBACK PounceSentDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
- {
- wchar_t text[2048];
- GetDlgItemText(hwnd, IDOK, text, _countof(text));
- if (!mir_wstrcmp(text, TranslateT("Retry"))) {
- GetDlgItemText(hwnd, IDC_MESSAGE, text, _countof(text));
- SendPounce(text, hContact);
- }
+ {
+ wchar_t text[2048];
+ GetDlgItemText(hwnd, IDOK, text, _countof(text));
+ if (!mir_wstrcmp(text, TranslateT("Retry"))) {
+ GetDlgItemText(hwnd, IDC_MESSAGE, text, _countof(text));
+ SendPounce(text, hContact);
}
- // fall through
+ }
+ // fall through
case IDCANCEL:
DestroyWindow(hwnd);
}
@@ -598,7 +598,7 @@ INT_PTR CALLBACK PounceSentDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP void CreateMessageAcknowlegedWindow(MCONTACT hContact, int SentSuccess)
{
- HWND hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMSEND), nullptr, PounceSentDlgProc, hContact);
+ HWND hwnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONFIRMSEND), nullptr, PounceSentDlgProc, hContact);
wchar_t msg[256];
if (SentSuccess) {
mir_snwprintf(msg, TranslateT("Message successfully sent to %s"), Clist_GetContactDisplayName(hContact));
diff --git a/plugins/BuddyPounce/src/main.cpp b/plugins/BuddyPounce/src/main.cpp index e2c5bd5ec9..daa4c73022 100644 --- a/plugins/BuddyPounce/src/main.cpp +++ b/plugins/BuddyPounce/src/main.cpp @@ -1,10 +1,10 @@ #include "stdafx.h"
+CMPlugin g_plugin;
int hLangpack;
-HINSTANCE hInst;
MWindowList hWindowList;
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -18,15 +18,6 @@ PLUGININFOEX pluginInfo={ };
//========================
-// WINAPI DllMain
-//========================
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-//========================
// MirandaPluginInfo
//========================
@@ -45,26 +36,26 @@ int MainInit(WPARAM, LPARAM) CMenuItem mi;
SET_UID(mi, 0x719c1596, 0xb0fd, 0x4c74, 0xb7, 0xe4, 0xeb, 0x22, 0xf4, 0x99, 0xd7, 0x68);
mi.position = 10;
- mi.hIcolibItem = LoadIcon(hInst,MAKEINTRESOURCE(IDI_POUNCE));
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POUNCE));
mi.name.a = LPGEN("&Buddy Pounce");
mi.pszService = "BuddyPounce/MenuCommand";
Menu_AddContactMenuItem(&mi);
return 0;
}
-int MsgAck(WPARAM, LPARAM lParam)
-{
- ACKDATA *ack=(ACKDATA*)lParam;
+int MsgAck(WPARAM, LPARAM lParam)
+{
+ ACKDATA *ack = (ACKDATA*)lParam;
if (ack && ack->type == ACKTYPE_MESSAGE) {
- if (ack->hProcess == (HANDLE)WindowList_Find(hWindowList,ack->hContact)) {
+ if (ack->hProcess == (HANDLE)WindowList_Find(hWindowList, ack->hContact)) {
if (db_get_b(NULL, modname, "ShowDeliveryMessages", 1))
- CreateMessageAcknowlegedWindow(ack->hContact,ack->result == ACKRESULT_SUCCESS);
+ CreateMessageAcknowlegedWindow(ack->hContact, ack->result == ACKRESULT_SUCCESS);
if (ack->result == ACKRESULT_SUCCESS) {
// wrtie it to the DB
DBEVENTINFO dbei = {};
DBVARIANT dbv;
- int reuse = db_get_b(ack->hContact,modname, "Reuse", 0);
+ int reuse = db_get_b(ack->hContact, modname, "Reuse", 0);
if (!db_get_ws(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) {
T2Utf pszUtf(dbv.ptszVal);
dbei.eventType = EVENTTYPE_MESSAGE;
@@ -77,23 +68,23 @@ int MsgAck(WPARAM, LPARAM lParam) }
// check to reuse
if (reuse > 1)
- db_set_b(ack->hContact, modname, "Reuse", (BYTE)(reuse-1));
+ db_set_b(ack->hContact, modname, "Reuse", (BYTE)(reuse - 1));
else {
- db_set_b(ack->hContact,modname, "Reuse", 0);
+ db_set_b(ack->hContact, modname, "Reuse", 0);
db_set_ws(ack->hContact, modname, "PounceMsg", L"");
}
}
- WindowList_Remove(hWindowList,(HWND)ack->hProcess);
+ WindowList_Remove(hWindowList, (HWND)ack->hProcess);
}
- }
- return 0;
-}
+ }
+ return 0;
+}
int BuddyPounceOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szGroup.w = LPGENW("Message sessions");
odp.szTitle.w = LPGENW("Buddy Pounce");
@@ -105,63 +96,63 @@ int BuddyPounceOptInit(WPARAM wParam, LPARAM) int statusCheck(int statusFlag, int status)
{
if (statusFlag == ANY || !statusFlag) return 1;
- switch(status) {
- case ID_STATUS_OFFLINE:
- return 0;
- case ID_STATUS_ONLINE:
- return (statusFlag & ONLINE);
- case ID_STATUS_AWAY:
- return (statusFlag & AWAY);
- case ID_STATUS_NA:
- return (statusFlag & NA);
- case ID_STATUS_OCCUPIED:
- return (statusFlag & OCCUPIED);
- case ID_STATUS_DND:
- return (statusFlag & DND);
- case ID_STATUS_FREECHAT:
- return (statusFlag & FFC);
- case ID_STATUS_INVISIBLE:
- return (statusFlag & INVISIBLE);
- case ID_STATUS_OUTTOLUNCH:
- return (statusFlag & LUNCH);
- case ID_STATUS_ONTHEPHONE:
- return (statusFlag & PHONE);
+ switch (status) {
+ case ID_STATUS_OFFLINE:
+ return 0;
+ case ID_STATUS_ONLINE:
+ return (statusFlag & ONLINE);
+ case ID_STATUS_AWAY:
+ return (statusFlag & AWAY);
+ case ID_STATUS_NA:
+ return (statusFlag & NA);
+ case ID_STATUS_OCCUPIED:
+ return (statusFlag & OCCUPIED);
+ case ID_STATUS_DND:
+ return (statusFlag & DND);
+ case ID_STATUS_FREECHAT:
+ return (statusFlag & FFC);
+ case ID_STATUS_INVISIBLE:
+ return (statusFlag & INVISIBLE);
+ case ID_STATUS_OUTTOLUNCH:
+ return (statusFlag & LUNCH);
+ case ID_STATUS_ONTHEPHONE:
+ return (statusFlag & PHONE);
}
return 0;
}
int CheckDate(MCONTACT hContact)
{
- time_t curtime = time (nullptr);
- if(!db_get_b(hContact,modname,"GiveUpDays",0))
+ time_t curtime = time(nullptr);
+ if (!db_get_b(hContact, modname, "GiveUpDays", 0))
return 1;
- if(db_get_b(hContact,modname,"GiveUpDays",0) && ( abs((time_t)db_get_dw(hContact,modname,"GiveUpDate",0)) > curtime))
+ if (db_get_b(hContact, modname, "GiveUpDays", 0) && (abs((time_t)db_get_dw(hContact, modname, "GiveUpDate", 0)) > curtime))
return 1;
return 0;
}
void SendPounce(wchar_t *text, MCONTACT hContact)
{
- if (HANDLE hSendId = (HANDLE)ProtoChainSend(hContact, PSS_MESSAGE, 0, T2Utf(text)))
+ if (HANDLE hSendId = (HANDLE)ProtoChainSend(hContact, PSS_MESSAGE, 0, T2Utf(text)))
WindowList_Add(hWindowList, (HWND)hSendId, hContact);
}
int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam)
{
- DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
char *szProto = GetContactProto(hContact);
- if(hContact == NULL || strcmp(cws->szSetting,"Status")) return 0;
+ if (hContact == NULL || strcmp(cws->szSetting, "Status")) return 0;
if (szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) {
int newStatus = cws->value.wVal;
- int oldStatus = db_get_w(hContact,"UserOnline","OldStatus",ID_STATUS_OFFLINE);
-
+ int oldStatus = db_get_w(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE);
+
if (newStatus != oldStatus && hContact != NULL && newStatus != ID_STATUS_OFFLINE) {
DBVARIANT dbv;
if (!db_get_ws(hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) {
// check my status
if (statusCheck(db_get_w(hContact, modname, "SendIfMyStatusIsFLAG", 0), Proto_GetStatus(szProto))
- // check the contacts status
- && statusCheck(db_get_w(hContact, modname, "SendIfTheirStatusIsFLAG", 0), newStatus)) {
+ // check the contacts status
+ && statusCheck(db_get_w(hContact, modname, "SendIfTheirStatusIsFLAG", 0), newStatus)) {
// check if we r giving up after x days
if (CheckDate(hContact)) {
if (db_get_w(hContact, modname, "ConfirmTimeout", 0)) {
@@ -169,7 +160,7 @@ int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) wchar_t *message = mir_wstrdup(dbv.ptszVal); // will get free()ed in the send confirm window proc
spdps->hContact = hContact;
spdps->message = message;
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMSEND), nullptr, SendPounceDlgProc, (LPARAM)spdps);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONFIRMSEND), nullptr, SendPounceDlgProc, (LPARAM)spdps);
// set the confirmation window to send the msg when the timeout is done
mir_free(message);
}
@@ -186,9 +177,9 @@ int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) INT_PTR BuddyPounceMenuCommand(WPARAM hContact, LPARAM)
{
if (db_get_b(NULL, modname, "UseAdvanced", 0) || db_get_b(hContact, modname, "UseAdvanced", 0))
- CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_POUNCE),nullptr,BuddyPounceDlgProc, hContact);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POUNCE), nullptr, BuddyPounceDlgProc, hContact);
else
- CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_POUNCE_SIMPLE),nullptr,BuddyPounceSimpleDlgProc, hContact);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POUNCE_SIMPLE), nullptr, BuddyPounceSimpleDlgProc, hContact);
return 0;
}
@@ -197,11 +188,11 @@ INT_PTR AddSimpleMessage(WPARAM wParam, LPARAM lParam) MCONTACT hContact = wParam;
wchar_t* message = (wchar_t*)lParam;
db_set_ws(hContact, modname, "PounceMsg", message);
- db_set_w(hContact, modname, "SendIfMyStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfMyStatusIsFLAG",1));
- db_set_w(hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfTheirStatusIsFLAG",1));
- db_set_b(hContact, modname, "Reuse", (BYTE)db_get_b(NULL, modname, "Reuse",0));
- db_set_b(hContact, modname, "GiveUpDays", (BYTE)db_get_b(NULL, modname, "GiveUpDays",0));
- db_set_dw(hContact, modname, "GiveUpDate", (DWORD)(db_get_b(hContact, modname, "GiveUpDays",0)*SECONDSINADAY));
+ db_set_w(hContact, modname, "SendIfMyStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfMyStatusIsFLAG", 1));
+ db_set_w(hContact, modname, "SendIfTheirStatusIsFLAG", (WORD)db_get_w(NULL, modname, "SendIfTheirStatusIsFLAG", 1));
+ db_set_b(hContact, modname, "Reuse", (BYTE)db_get_b(NULL, modname, "Reuse", 0));
+ db_set_b(hContact, modname, "GiveUpDays", (BYTE)db_get_b(NULL, modname, "GiveUpDays", 0));
+ db_set_dw(hContact, modname, "GiveUpDate", (DWORD)(db_get_b(hContact, modname, "GiveUpDays", 0)*SECONDSINADAY));
return 0;
}
@@ -210,7 +201,7 @@ INT_PTR AddToPounce(WPARAM wParam, LPARAM lParam) MCONTACT hContact = wParam;
wchar_t* message = (wchar_t*)lParam;
DBVARIANT dbv;
- if (!db_get_ws(hContact, modname, "PounceMsg",&dbv))
+ if (!db_get_ws(hContact, modname, "PounceMsg", &dbv))
{
wchar_t* newPounce = (wchar_t*)mir_alloc(mir_wstrlen(dbv.ptszVal) + mir_wstrlen(message) + 1);
if (!newPounce) return 1;
@@ -232,7 +223,7 @@ extern "C" __declspec(dllexport) int Load(void) mir_getLP(&pluginInfo);
HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
- HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UserOnlineSettingChanged);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UserOnlineSettingChanged);
HookEvent(ME_OPT_INITIALISE, BuddyPounceOptInit);
HookEvent(ME_PROTO_ACK, MsgAck);
@@ -243,7 +234,7 @@ extern "C" __declspec(dllexport) int Load(void) /* service funcitons for other devs... */
CreateServiceFunction("BuddyPounce/AddSimplePounce", AddSimpleMessage); // add a simple pounce to a contact
CreateServiceFunction("BuddyPounce/AddToPounce", AddToPounce); // add to the exsisitng pounce, if there isnt 1 then add a new simple pounce.
- return 0;
+ return 0;
}
diff --git a/plugins/BuddyPounce/src/stdafx.h b/plugins/BuddyPounce/src/stdafx.h index f69b5981ba..50f8e76057 100644 --- a/plugins/BuddyPounce/src/stdafx.h +++ b/plugins/BuddyPounce/src/stdafx.h @@ -8,8 +8,6 @@ #include <time.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_langpack.h>
@@ -29,6 +27,13 @@ #define modFullname "Buddy Pounce"
#define msg(a,b) MessageBox(0,a,b,MB_OK)
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(modname)
+ {}
+};
+
#define SECONDSINADAY 86400
/* flags for the sending and recieving.... */
@@ -61,8 +66,6 @@ struct SendPounceDlgProcStruct wchar_t *message;
};
-extern HINSTANCE hInst;
-
//=======================================================
// Functions
//=======================================================
|