summaryrefslogtreecommitdiff
path: root/plugins/MirFox/src/MirandaUtils.h
blob: 2c6e04afcc5f28552a201a221d76261484bf4bda (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
115
116
117
118
119
120
#ifndef _MIRANDAUTILS_INC
#define _MIRANDAUTILS_INC

#include "MirfoxData.h"



class MirandaUtils;


struct ActionThreadArgStruct {
	wchar_t* userActionSelection;
	HANDLE targetHandle;
	char* accountSzModuleName;
	char userActionType;
	char menuItemType;
	char userButton;
	MirandaUtils* instancePtr;
	MirfoxData* mirfoxDataPtr;
};




class MirandaUtils
{

public:

	static MirandaUtils *
	getInstance()
	{
		if (m_pOnlyOneInstance == NULL) {
			if (m_pOnlyOneInstance == NULL) {
				m_pOnlyOneInstance = new MirandaUtils();
			}
		}
	return m_pOnlyOneInstance;
	}


	void netlibRegister(void);
	void netlibUnregister(void);
	void netlibLog_int(const wchar_t* szText);
	static void netlibLog(const wchar_t* szText);


	std::wstring& getProfileName();

	std::wstring& getDisplayName();

	static void userActionThread(void* threadArg);

	static int onProtoAck(WPARAM wParam, LPARAM lParam);

	void translateOldDBNames();

	struct OnHookOpenMvStruct {
		HANDLE targetHandle;
		std::wstring* msgBuffer;
	};

	static int on_hook_OpenMW(WPARAM wParam, LPARAM lParam);


private:


	static MirandaUtils * m_pOnlyOneInstance;

	// private constructor
	MirandaUtils();




	void sendMessageToContact(ActionThreadArgStruct* args);

	void sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE mode);

	int getMirandaSendModeFlag(char* targetHandleSzProto);

	HANDLE sendMessageMiranda(HCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer);

	void addMessageToDB(HCONTACT hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto);

	void setStatusOnAccount(ActionThreadArgStruct* args);

	void onProtoAckOnInstance(ACKDATA* ack);

	static void ForceForegroundWindow(HWND hWnd);


	HANDLE netlibHandle;

	std::wstring profileName;
	std::wstring displayName;



	typedef struct {
		const char* szModule;
		HCONTACT hContact;
		int result;
		const char* errorDesc;
	} MIRFOXACKDATA;

	std::map<HANDLE, MIRFOXACKDATA*> ackMap;
	std::map<HANDLE, MIRFOXACKDATA*>::iterator ackMapIt;
	CRITICAL_SECTION ackMapCs;


	MFLogger* logger;


};



#endif //#IFNDEF _MIRANDAUTILS_INC