diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-10-25 11:41:14 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-10-25 11:41:14 +0000 |
commit | 55dc3a99af44bb97931bdeca9122d0d62f7b183f (patch) | |
tree | 9b685ccc08282402d343bfcd131d6a77f8b038fa /protocols | |
parent | 7d5f7b0fac50a1c6972c48664797f33f180243ee (diff) |
Dummy: Support for sending messages (with option to enable it)
git-svn-id: http://svn.miranda-ng.org/main/trunk@15614 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Dummy/res/resource.aps | bin | 3476 -> 3608 bytes | |||
-rw-r--r-- | protocols/Dummy/res/resource.rc | 6 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy.h | 9 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_options.cpp | 7 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.cpp | 27 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.h | 2 | ||||
-rw-r--r-- | protocols/Dummy/src/resource.h | 3 |
7 files changed, 45 insertions, 9 deletions
diff --git a/protocols/Dummy/res/resource.aps b/protocols/Dummy/res/resource.aps Binary files differindex b342d02388..10cecfb374 100644 --- a/protocols/Dummy/res/resource.aps +++ b/protocols/Dummy/res/resource.aps diff --git a/protocols/Dummy/res/resource.rc b/protocols/Dummy/res/resource.rc index 19b1fb4949..7d7ef55679 100644 --- a/protocols/Dummy/res/resource.rc +++ b/protocols/Dummy/res/resource.rc @@ -23,7 +23,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Dialog
//
-IDD_ACCMGRUI DIALOGEX 0, 0, 186, 122
+IDD_ACCMGRUI DIALOGEX 0, 0, 186, 144
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -37,6 +37,8 @@ BEGIN EDITTEXT IDC_ID_TEXT,95,63,90,12,ES_AUTOHSCROLL
LTEXT "Visible name of unique identifier of contacts",IDC_STATIC,10,79,175,18
LTEXT "Restart is required to apply these changes.",IDC_STATIC,0,105,185,8
+ CONTROL "Allow sending messages to contacts",IDC_ALLOW_SENDING,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,121,185,10
END
@@ -79,7 +81,7 @@ BEGIN VERTGUIDE, 10
VERTGUIDE, 95
VERTGUIDE, 185
- BOTTOMMARGIN, 93
+ BOTTOMMARGIN, 138
END
END
#endif // APSTUDIO_INVOKED
diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h index 34f2ad3a7d..d9e22c2736 100644 --- a/protocols/Dummy/src/dummy.h +++ b/protocols/Dummy/src/dummy.h @@ -22,6 +22,15 @@ extern HINSTANCE hInst; #define DUMMY_ID_TEMPLATE "Template"
#define DUMMY_ID_TEXT "UniqueIdText"
#define DUMMY_ID_SETTING "UniqueIdSetting"
+#define DUMMY_KEY_ALLOW_SENDING "AllowSending"
+
+struct message_data
+{
+ message_data(MCONTACT hContact, const std::string &msg, int msgid) : hContact(hContact), msg(msg), msgid(msgid) {}
+ MCONTACT hContact;
+ std::string msg;
+ int msgid;
+};
typedef struct {
const char *name;
diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index aa6cb6d798..7f86602d08 100644 --- a/protocols/Dummy/src/dummy_options.cpp +++ b/protocols/Dummy/src/dummy_options.cpp @@ -56,6 +56,9 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM int templateId = ppro->getTemplateId();
SendDlgItemMessage(hwndDlg, IDC_TEMPLATE, CB_SETCURSEL, templateId, 0);
+ boolean allowSending = ppro->getByte(DUMMY_KEY_ALLOW_SENDING, 0);
+ CheckDlgButton(hwndDlg, IDC_ALLOW_SENDING, allowSending ? BST_CHECKED : BST_UNCHECKED);
+
onTemplateSelected(hwndDlg, ppro, templateId);
}
return TRUE;
@@ -75,6 +78,8 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
+ default:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
@@ -93,6 +98,8 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM GetDlgItemTextA(hwndDlg, IDC_ID_SETTING, str, _countof(str));
ppro->setString(DUMMY_ID_SETTING, str);
}
+
+ ppro->setByte(DUMMY_KEY_ALLOW_SENDING, IsDlgButtonChecked(hwndDlg, IDC_ALLOW_SENDING));
}
break;
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 4e9e171cb5..533b137199 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -17,11 +17,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" -void CDummyProto::SendMsgAck(void *param) +void CDummyProto::SendMsgAck(void *p) { - MCONTACT hContact = (UINT_PTR)param; + if (p == NULL) + return; + + message_data *data = static_cast<message_data*>(p); + Sleep(100); - ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)0, (LPARAM)Translate("Dummy protocol is too dumb to send messages.")); + + if (getByte(DUMMY_KEY_ALLOW_SENDING, 0)) + ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)data->msgid, 0); + else + ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)data->msgid, (LPARAM)Translate("This Dummy account has disabled sending messages. Enable it in account options.")); + + delete data; } void CDummyProto::SearchIdAckThread(void *targ) @@ -49,6 +59,8 @@ CDummyProto::CDummyProto(const char *szModuleName, const TCHAR *ptszUserName) : { CreateProtoService(PS_CREATEACCMGRUI, &CDummyProto::SvcCreateAccMgrUI); + msgid = 0; + uniqueIdText[0] = '\0'; uniqueIdSetting[0] = '\0'; @@ -116,10 +128,13 @@ DWORD_PTR CDummyProto::GetCaps(int type, MCONTACT) ////////////////////////////////////////////////////////////////////////////// -int CDummyProto::SendMsg(MCONTACT hContact, int, const char*) +int CDummyProto::SendMsg(MCONTACT hContact, int, const char *msg) { - ForkThread(&CDummyProto::SendMsgAck, (void*)hContact); - return 0; + std::string message = msg; + unsigned int id = InterlockedIncrement(&this->msgid); + + ForkThread(&CDummyProto::SendMsgAck, new message_data(hContact, message, id)); + return id; } int CDummyProto::SetStatus(int) diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index c236c31093..d2da9b0d61 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -53,4 +53,6 @@ struct CDummyProto : public PROTO<CDummyProto> char uniqueIdSetting[100]; int getTemplateId(); + + volatile unsigned int msgid; }; diff --git a/protocols/Dummy/src/resource.h b/protocols/Dummy/src/resource.h index bf5d6ff711..f9405505ad 100644 --- a/protocols/Dummy/src/resource.h +++ b/protocols/Dummy/src/resource.h @@ -6,6 +6,7 @@ #define IDC_ID_TEXT 1030
#define IDC_ID_SETTING 1031
#define IDC_TEMPLATE 1032
+#define IDC_ALLOW_SENDING 1033
// Next default values for new objects
//
@@ -14,7 +15,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1033
+#define _APS_NEXT_CONTROL_VALUE 1034
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|