summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_events.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-04-14 20:32:40 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-04-14 20:32:40 +0000
commit4d0735ab834be6c541e7e577fbe76c888bf4d09f (patch)
tree8e290ade50e86e7b5f53a2b66bb0f1f2a2119982 /protocols/Tox/src/tox_events.cpp
parent31ba819bd0994a0a48a174cba37b5985522ff3f8 (diff)
Tox: second approach for audio support
git-svn-id: http://svn.miranda-ng.org/main/trunk@12827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_events.cpp')
-rw-r--r--protocols/Tox/src/tox_events.cpp76
1 files changed, 54 insertions, 22 deletions
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp
index 406999549a..255358d687 100644
--- a/protocols/Tox/src/tox_events.cpp
+++ b/protocols/Tox/src/tox_events.cpp
@@ -2,37 +2,69 @@
int CToxProto::OnModulesLoaded(WPARAM, LPARAM)
{
+ CToxProto::InitIcons();
+ CToxProto::InitMenus();
+ CToxProto::InitCustomDbEvents();
+
hProfileFolderPath = FoldersRegisterCustomPathT("Tox", Translate("Profiles folder"), MIRANDA_USERDATAT);
return 0;
}
-int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM)
+void CToxProto::InitCustomDbEvents()
{
- if (!IsOnline())
- {
- return -1;
- }
+ DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
+ dbEventType.module = MODULE;
+ dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW;
+
+ dbEventType.eventType = DB_EVENT_ACTION;
+ dbEventType.descr = Translate("Action");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
+ dbEventType.eventType = DB_EVENT_AUDIO_CALL;
+ dbEventType.descr = Translate("Audio call");
+ dbEventType.eventIcon = GetIconHandle("audio_call");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+}
+
+int CToxProto::OnDbEventAdded(WPARAM hContact, LPARAM hEvent)
+{
+ DWORD dwSignature;
- if (!isChatRoom(hContact))
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = sizeof(DWORD);
+ dbei.pBlob = (PBYTE)&dwSignature;
+ db_event_get(hEvent, &dbei);
+ if (dbei.flags & (DBEF_SENT | DBEF_READ) || dbei.eventType <= DB_EVENT_ACTION || dwSignature == 0)
+ return 0;
+
+ DBEVENTTYPEDESCR *dbEventType = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)MODULE, dbei.eventType);
+ if (dbEventType == NULL)
+ return 0;
+
+ CLISTEVENT cle = { sizeof(cle) };
+ cle.flags |= CLEF_TCHAR;
+ cle.hContact = hContact;
+ cle.hDbEvent = hEvent;
+ cle.hIcon = Skin_GetIconByHandle(dbEventType->eventIcon);
+
+ TCHAR szTooltip[256];
+ mir_sntprintf(szTooltip, SIZEOF(szTooltip), _T("%s %s %s"), _A2T(dbEventType->descr), TranslateT("from"), pcli->pfnGetContactDisplayName(hContact, 0));
+ cle.ptszTooltip = szTooltip;
+
+ char szService[256];
+ switch (dbei.eventType)
{
- int32_t friendNumber = GetToxFriendNumber(hContact);
- TOX_ERR_FRIEND_DELETE error;
- if (!tox_friend_delete(tox, friendNumber, &error))
- {
- debugLogA(__FUNCTION__": failed to delete friend (%d)", error);
- return error;
- }
+ case DB_EVENT_AUDIO_CALL:
+ mir_snprintf(szService, SIZEOF(szService), "%s/AudioCall", GetContactProto(hContact));
+ break;
+
+ default:
+ return 0;
}
- /*else
- {
- OnLeaveChatRoom(hContact, 0);
- int groupNumber = 0; // ???
- if (groupNumber == TOX_ERROR || tox_del_groupchat(tox, groupNumber) == TOX_ERROR)
- {
- return 1;
- }
- }*/
+ cle.pszService = szService;
+
+ CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
return 0;
} \ No newline at end of file