diff options
Diffstat (limited to 'protocols/Dummy/src')
-rw-r--r-- | protocols/Dummy/src/dummy.h | 1 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_options.cpp | 5 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.cpp | 7 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.h | 3 | ||||
-rw-r--r-- | protocols/Dummy/src/main.cpp | 15 |
5 files changed, 16 insertions, 15 deletions
diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h index e06e8d81ac..69d250ca03 100644 --- a/protocols/Dummy/src/dummy.h +++ b/protocols/Dummy/src/dummy.h @@ -22,7 +22,6 @@ struct CDummyProto; #define DUMMY_ID_TEMPLATE "Template"
#define DUMMY_ID_TEXT "UniqueIdText"
#define DUMMY_ID_SETTING "UniqueIdSetting"
-#define DUMMY_KEY_ALLOW_SENDING "AllowSending"
struct ttemplate
{
diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index 226b1825ca..205a74814d 100644 --- a/protocols/Dummy/src/dummy_options.cpp +++ b/protocols/Dummy/src/dummy_options.cpp @@ -38,8 +38,7 @@ 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);
+ CheckDlgButton(hwndDlg, IDC_ALLOW_SENDING, ppro->bAllowSending ? BST_CHECKED : BST_UNCHECKED);
ppro->selectTemplate(hwndDlg, templateId);
}
@@ -81,7 +80,7 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM ppro->setString(DUMMY_ID_SETTING, str);
}
- ppro->setByte(DUMMY_KEY_ALLOW_SENDING, IsDlgButtonChecked(hwndDlg, IDC_ALLOW_SENDING));
+ ppro->bAllowSending = IsDlgButtonChecked(hwndDlg, IDC_ALLOW_SENDING);
}
break;
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 295872252a..db82416df5 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -81,7 +81,8 @@ static int sttCompareProtocols(const CDummyProto *p1, const CDummyProto *p2) }
CDummyProto::CDummyProto(const char *szModuleName, const wchar_t *ptszUserName) :
- PROTO<CDummyProto>(szModuleName, ptszUserName)
+ PROTO<CDummyProto>(szModuleName, ptszUserName),
+ bAllowSending(szModuleName, "AllowSending", false)
{
msgid = 0;
@@ -139,7 +140,7 @@ INT_PTR CDummyProto::GetCaps(int type, MCONTACT) {
switch(type) {
case PFLAGNUM_1:
- return PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES;
+ return PF1_BASICSEARCH | PF1_ADDSEARCHRES | (bAllowSending ? PF1_IM : 0);
case PFLAGNUM_4:
return PF4_AVATARS | PF4_NOAUTHDENYREASON | PF4_NOCUSTOMAUTH;
@@ -191,7 +192,7 @@ int CDummyProto::SendMsg(MCONTACT hContact, MEVENT, const char *msg) std::string message = msg;
unsigned int id = InterlockedIncrement(&msgid);
- if (getByte(DUMMY_KEY_ALLOW_SENDING, 0))
+ if (bAllowSending)
ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id);
else
ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)TranslateT("This Dummy account has disabled sending messages. Enable it in account options."));
diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index adbfd643b4..573d24cc0e 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -38,7 +38,7 @@ struct CDummyProto : public PROTO<CDummyProto> MCONTACT AddToList(int flags, PROTOSEARCHRESULT* psr) override;
- //==== Events ==========================================================================
+ //======================================================================================
MWindow OnCreateAccMgrUI(MWindow) override;
@@ -50,5 +50,6 @@ struct CDummyProto : public PROTO<CDummyProto> int getTemplateId();
void selectTemplate(HWND, int templateId);
+ CMOption<bool> bAllowSending;
volatile unsigned int msgid;
};
diff --git a/protocols/Dummy/src/main.cpp b/protocols/Dummy/src/main.cpp index 034231f0b5..23c47005a4 100644 --- a/protocols/Dummy/src/main.cpp +++ b/protocols/Dummy/src/main.cpp @@ -54,13 +54,14 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC static int OnDummyDoubleClicked(WPARAM hContact, LPARAM)
{
if (auto *pa = Proto_GetContactAccount(hContact))
- if (pa->ppro && pa->ppro->GetCaps(1000)) {
- if (Contact::IsGroupChat(hContact))
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
- else
- CallService(MS_MSG_SENDMESSAGE, hContact, 0);
- return 1;
- }
+ if (auto *ppro = (CDummyProto*)pa->ppro)
+ if (ppro->GetCaps(1000)) {
+ if (Contact::IsGroupChat(hContact) || !ppro->bAllowSending)
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
+ else
+ CallService(MS_MSG_SENDMESSAGE, hContact, 0);
+ return 1;
+ }
return 0;
}
|