diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-10-25 11:41:11 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-10-25 11:41:11 +0000 |
commit | 7d5f7b0fac50a1c6972c48664797f33f180243ee (patch) | |
tree | 6a9d0055d2bc67393ebfcdd3c0056ef4be62e31a /protocols/Dummy | |
parent | bf40980c0484f7c0639a040b5abc80f181084283 (diff) |
Dummy: Allow searching (by id) and adding new contacts
git-svn-id: http://svn.miranda-ng.org/main/trunk@15613 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Dummy')
-rw-r--r-- | protocols/Dummy/src/dummy_proto.cpp | 55 | ||||
-rw-r--r-- | protocols/Dummy/src/dummy_proto.h | 5 |
2 files changed, 58 insertions, 2 deletions
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 531cf9d627..4e9e171cb5 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -24,6 +24,19 @@ void CDummyProto::SendMsgAck(void *param) ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)0, (LPARAM)Translate("Dummy protocol is too dumb to send messages.")); } +void CDummyProto::SearchIdAckThread(void *targ) +{ + PROTOSEARCHRESULT psr = { 0 }; + psr.cbSize = sizeof(psr); + psr.flags = PSR_TCHAR; + psr.id.t = (TCHAR*)targ; + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, targ, (LPARAM)&psr); + + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0); + + mir_free(targ); +} + static int sttCompareProtocols(const CDummyProto *p1, const CDummyProto *p2) { return mir_tstrcmp(p1->m_tszUserName, p2->m_tszUserName); @@ -63,7 +76,7 @@ DWORD_PTR CDummyProto::GetCaps(int type, MCONTACT) { switch(type) { case PFLAGNUM_1: - return PF1_IM; + return PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES; case PFLAGNUM_2: return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; @@ -72,7 +85,7 @@ DWORD_PTR CDummyProto::GetCaps(int type, MCONTACT) return 0; case PFLAGNUM_4: - return 0; + return PF4_AVATARS | PF4_NOAUTHDENYREASON | PF4_NOCUSTOMAUTH; case PFLAGNUM_5: return PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; @@ -113,3 +126,41 @@ int CDummyProto::SetStatus(int) { return 0; } + +HANDLE CDummyProto::SearchBasic(const TCHAR* id) +{ + if (uniqueIdSetting[0] == '\0') + return 0; + + TCHAR *tid = mir_tstrdup(id); + ForkThread(&CDummyProto::SearchIdAckThread, tid); + return tid; +} + +MCONTACT CDummyProto::AddToList(int flags, PROTOSEARCHRESULT* psr) +{ + if (psr->id.t == NULL) + return NULL; + + MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD); + + if (hContact && Proto_AddToContact(hContact, m_szModuleName) != 0) { + CallService(MS_DB_CONTACT_DELETE, hContact); + hContact = NULL; + } + + if (hContact) { + if (flags & PALF_TEMPORARY) { + db_set_b(hContact, "CList", "Hidden", 1); + db_set_b(hContact, "CList", "NotOnList", 1); + } + else if (db_get_b(hContact, "CList", "NotOnList", 0)) { + db_unset(hContact, "CList", "Hidden"); + db_unset(hContact, "CList", "NotOnList"); + } + setTString(hContact, uniqueIdSetting, psr->id.t); + setTString(hContact, "Nick", psr->id.t); + } + + return hContact; +} diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index 61292aa366..c236c31093 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -32,6 +32,10 @@ struct CDummyProto : public PROTO<CDummyProto> virtual int __cdecl SetStatus(int iNewStatus); + virtual HANDLE __cdecl SearchBasic(const TCHAR* id); + + virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr); + //==== Events ======================================================================== int __cdecl OnModulesLoaded(WPARAM, LPARAM); @@ -43,6 +47,7 @@ struct CDummyProto : public PROTO<CDummyProto> INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); void __cdecl SendMsgAck(void *param); + void __cdecl SearchIdAckThread(void*); char uniqueIdText[100]; char uniqueIdSetting[100]; |