summaryrefslogtreecommitdiff
path: root/plugins/Toaster/src/stdafx.h
blob: a0b2a3509e682b34359756601c7c817db0ac3137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef _COMMON_H_
#define _COMMON_H_

#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#include <wrl\implements.h>
#include <windows.ui.notifications.h>
#include <ShObjIdl.h>
#include <propvarutil.h>
#include <memory>
#include <map>
#include <newpluginapi.h>
#include <m_system_cpp.h>
#include <m_langpack.h>
#include <m_avatars.h>
#include <m_protocols.h>
#include <m_popup.h>
#include <m_message.h>
#include <m_chat.h>
#include <m_skin.h>
#include <m_imgsrvc.h>
#include <m_netlib.h>
#include <m_xml.h>

#include "version.h"
#include "resource.h"

__forceinline bool isChatRoom(MCONTACT hContact)
{
	return (db_get_b(hContact, GetContactProto(hContact), "ChatRoom", 0) == 1);
}

typedef void(__cdecl *pEventHandler)(void*);
const wchar_t AppUserModelID[] = _T("MirandaNG");
DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5);

#define MODULE "Toaster"

#define CHECKHR(x) if (FAILED(x)) return x;

class ToastNotification;

#include "string_reference_wrapper.h"
#include "toast_event_handler.h"
#include "toast_notification.h"
#include "add_to_start_menu.h"
#include "images.h"

extern HINSTANCE g_hInstance;
extern mir_cs csNotifications;
extern OBJLIST<ToastNotification> lstNotifications;
extern wchar_t wszTempDir[MAX_PATH];

struct callbackArg
{
	MCONTACT hContact;
	ToastNotification* notification;
};

struct ToastData
{
	MCONTACT hContact;
	TCHAR *tszTitle;
	TCHAR *tszText;
	union
	{
		HICON hIcon;
		HBITMAP hBitmap;
	};
	int iType; // 0 = none, 1 = hBitmap, 2 = hIcon

	WNDPROC pPopupProc;
	void *vPopupData;

	ToastData(MCONTACT _hContact, const TCHAR *_tszTitle, const TCHAR *_tszText, HICON _hIcon = NULL) : 
		hContact(_hContact),
		tszTitle(mir_tstrdup(_tszTitle)), 
		tszText(mir_tstrdup(_tszText)), 
		hIcon(_hIcon), 
		iType(_hIcon ? 2 : 0) 
	{}
	ToastData(MCONTACT _hContact, const TCHAR *_tszTitle, const TCHAR *_tszText, HBITMAP bmp = NULL) :
		hContact(_hContact),
		tszTitle(mir_tstrdup(_tszTitle)),
		tszText(mir_tstrdup(_tszText)),
		hBitmap(bmp),
		iType(bmp ? 1 : 0)
	{}
	~ToastData()
	{
		mir_free(tszTitle);
		mir_free(tszText);
	}
};

struct ClassData
{
	int iFlags;
	HICON hIcon;
	HANDLE handle;

	WNDPROC pPopupProc;

	ClassData(int f, HICON h = NULL) : iFlags(f), hIcon(h) 
	{
		Utils_GetRandom(&handle, sizeof(handle));
	}
};

void CleanupClasses();
void InitServices();
int OnPreShutdown(WPARAM, LPARAM);
void __stdcall HideAllToasts(void*);
#endif //_COMMON_H_