summaryrefslogtreecommitdiff
path: root/protocols/MRA/Mra.h
blob: b83d722fb7441c6b48ad39eee7399abc156e2050 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
#if !defined(AFX_MRA_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_)
#define AFX_MRA_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define _CRT_SECURE_NO_WARNINGS


//#define CRTDLL

#include "resource.h"
#include ".\xstatus_MRA\resource.h"
#include <SystemHeaders.h>
#include <Wincrypt.h>
#include <Ntsecapi.h>
#include <Commdlg.h>
//#include <strsafe.h>
#include <stdio.h>
#include <time.h>
#include <DebugFunctions.h>
#include <commctrl.h>
#include <uxtheme.h>
#include <SocketFunctions.h>

#define bzero(pvDst,count) memset(pvDst,0,count)
#include <timefuncs.h>

#include "../../plugins/zlib/zlib.h"

//int ZEXPORT uncompress(unsigned char*dest,uLongf *destLen,const Bytef *source,uLong sourceLen);
typedef int (*PUNCOMPRESS)(unsigned char*,DWORD*,unsigned char*,DWORD);
//int ZEXPORT compress2(Bytef *dest,uLongf *destLen,const Bytef *source,uLong sourceLen,int level);
typedef int (*PCOMPRESS2)(unsigned char*,DWORD*,unsigned char*,DWORD,int);

#define MIRANDA_VER 0x0A00

// http://miranda.svn.sourceforge.net/viewvc/miranda/trunk/miranda/include/?sortby=file
#include <newpluginapi.h>
#include <m_system.h>
#include <m_protocols.h>
#include <m_clc.h>
#include <m_clist.h>
#include <m_cluiframes.h>
#include <m_clui.h>
#include <m_genmenu.h>
#include <m_ignore.h>
#include <m_message.h>
#include <m_options.h>
#include <m_protomod.h>
#include <m_protosvc.h>
#include <m_skin.h>
#include <m_userinfo.h>
#include <m_utils.h>
#include <m_database.h>
#include <m_langpack.h>
#include <m_netlib.h>
#include <m_updater.h>
#include <m_icolib.h>
#include <win2k.h>
#include <m_popup.h>
#include <m_popup2.h>
#include <m_nudge.h>
#include <m_folders.h>
#include <m_avatars.h>
#include <m_chat.h>
#include <m_extraicons.h>
#include <m_music.h>
#include <m_proto_listeningto.h>


#include <MemoryFind.h>
#include <MemoryFindByte.h>
#include <MemoryCompare.h>
#include <MemoryReplace.h>
#include <BuffToLowerCase.h>
#include <StrToNum.h>
#include <StrToNum.h>
#include <StrHexToNum.h>
#include <Base64.h>
#include <InternetTime.h>
#include <ListMT.h>
#include <FIFOMT.h>
#include <RC4.h>
#include <SHA1.h>


// LPS
typedef struct
{
	SIZE_T	dwSize;

	union {
		LPSTR	lpszData;
		LPWSTR	lpwszData;
	};
} MRA_LPS;


// GUID
typedef struct
{
	DWORD	id[4];
} MRA_GUID;



struct MRA_ADDR_LIST_ITEM
{
	DWORD	dwPort;
	DWORD	dwAddr;
};

struct MRA_ADDR_LIST
{
	DWORD				dwAddrCount;
	MRA_ADDR_LIST_ITEM	*pmaliAddress;
};


// структура содержащая информацию по построению меню или расширеных иконок
struct GUI_DISPLAY_ITEM
{
	LPSTR			lpszName;		// имя сервиса, оно же имя в иколибе
	LPWSTR			lpwszDescr;		// текстовое описание отображаемое юзеру
	LONG			defIcon;		// иконка из ресурсов
	MIRANDASERVICE	lpFunc;			// функция вызываемая меню
};


// структура содержащая информацию о сервисах/функциях
struct SERVICE_ITEM
{
	LPSTR			lpszName;		// имя сервиса, оно же имя в иколибе
	MIRANDASERVICE	lpFunc;			// функция вызываемая
};




#include "proto.h"
#include "MraConstans.h"
#include "MraSendCommand.h"
#include "MraMRIMProxy.h"
#include "MraSendQueue.h"
#include "MraFilesQueue.h"
#include "MraPopUp.h"
#include "MraAvatars.h"
#include "MraIcons.h"
#include "MraSelectEMail.h"
#include "MraAntiSpam.h"
#include "MraMPop.h"
#include "MraChat.h"



#ifdef MRA_EXPORTS
	#define MRA_API __declspec(dllexport)
#else
	#define MRA_API
	// __declspec(dllimport)
	#pragma comment(lib,"MRALib.lib")
#endif





/////////////////////////////////////////////////////////////////////////////////////////
//	plugin options


#define MAIN_MENU_ITEMS_COUNT		15
#define CONTACT_MENU_ITEMS_COUNT	10

typedef struct
{
	HANDLE                hHeap;
	HINSTANCE             hInstance;
	HMODULE               hDLLZLib;
	HANDLE                lpfnCompress2;
	HANDLE                lpfnUncompress;
	HMODULE               hDLLXStatusIcons;
	char                  szModuleName[MAXMODULELABELLENGTH];
	WCHAR                 wszModuleName[MAXMODULELABELLENGTH];
	SIZE_T                dwModuleNameLen;
	char                  szDisplayModuleName[MAX_PATH];
	WCHAR                 wszDisplayModuleName[MAX_PATH];
	SIZE_T                dwDisplayModuleNameLen;

	DWORD                 dwGlobalPluginRunning;
	BOOL                  bLoggedIn;
	BOOL                  bChatExist;
	DWORD                 dwStatusMode;
	DWORD                 dwXStatusMode;
	DWORD                 dwDesiredStatusMode;

	HWND                  hWndEMailPopupStatus;
	DWORD                 dwEmailMessagesTotal;
	DWORD                 dwEmailMessagesUnRead;

	BOOL                  bHideXStatusUI;
	HANDLE                hXStatusMenuItems[MRA_XSTATUS_COUNT+4];
	HANDLE                hXStatusAdvancedStatusIcons[MRA_XSTATUS_COUNT+4];
	HANDLE                hXStatusAdvancedStatusItems[MRA_XSTATUS_COUNT+4];
	HANDLE                hExtraXstatusIcon;

	HANDLE                hMainMenuIcons[MAIN_MENU_ITEMS_COUNT+4];
	HANDLE                hMainMenuItems[MAIN_MENU_ITEMS_COUNT+4];

	HANDLE                hContactMenuIcons[CONTACT_MENU_ITEMS_COUNT+4];
	HANDLE                hContactMenuItems[CONTACT_MENU_ITEMS_COUNT+4];

	HANDLE                hAdvancedStatusIcons[ADV_ICON_MAX+4];
	HANDLE                hAdvancedStatusItems[ADV_ICON_MAX+4];
	HANDLE                hExtraInfo;

	HANDLE                hThreadAPC;                // APC thread, for queue tasks
	HANDLE                hWaitEventThreadAPCHandle;
	DWORD                 dwAPCThreadRunning;
	FIFO_MT               ffmtAPCQueue;
	HANDLE                hMPopSessionQueue;
	HANDLE                hSendQueueHandle;
	HANDLE                hFilesQueueHandle;
	HANDLE                hAvatarsQueueHandle;
	
	HANDLE                hNetlibUser;
	HANDLE                hThreadWorker;
	HANDLE                hConnection;
	DWORD                 dwThreadWorkerLastPingTime;
	DWORD                 dwThreadWorkerRunning;
	DWORD                 dwCMDNum;
	CRITICAL_SECTION      csCriticalSectionSend;

	HANDLE                hHookModulesLoaded;
	HANDLE                hHookPreShutdown;
	HANDLE                hHookOptInitialize;
	HANDLE                hHookContactDeleted;
	HANDLE                hHookSettingChanged;
	HANDLE                hHookRebuildCMenu;
	HANDLE                hHookExtraIconsApply;
	HANDLE                hHookExtraIconsRebuild;
	HANDLE                hHookIconsChanged;
	HANDLE                heNudgeReceived;
	HANDLE                hHookRebuildStatusMenu;
	HANDLE                hWATrack;

	char                  szNewMailSound[MAX_PATH];

	SIZE_T                dwMirWorkDirPathLen;
	WCHAR                 szMirWorkDirPath[MAX_FILEPATH];
} MRA_SETTINGS;


/////////////////////////////////////////////////////////////////////////////////////////
//	External variables
extern MRA_SETTINGS masMraSettings;


INT_PTR          LoadServices    ();
INT_PTR          LoadModules        ();
void             UnloadModules    ();
void             UnloadServices    ();
void             InitExtraIcons    ();
void             SetExtraIcons    (HANDLE hContact);
DWORD            MraSetXStatusInternal    (DWORD dwXStatus);
DWORD            MraGetXStatusInternal    ();

int              OptInit            (WPARAM wParam,LPARAM lParam);


INT_PTR CALLBACK AdvancedSearchDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam);
DWORD            AdvancedSearchFromDlg(HWND hWndDlg);


DWORD            MraRecvCommand_Message            (DWORD dwTime,DWORD dwFlags,MRA_LPS *plpsFrom,MRA_LPS *plpsText,MRA_LPS *plpsRFTText,MRA_LPS *plpsMultiChatData);


DWORD            MraGetSelfVersionString        (LPSTR lpszSelfVersion,SIZE_T dwSelfVersionSize,SIZE_T *pdwSelfVersionSizeRet);

DWORD            MraAddrListGetFromBuff        (LPSTR lpszAddreses,SIZE_T dwAddresesSize,MRA_ADDR_LIST *pmalAddrList);
DWORD            MraAddrListGetToBuff        (MRA_ADDR_LIST *pmalAddrList,LPSTR lpszBuff,SIZE_T dwBuffSize,SIZE_T *pdwBuffSizeRet);
void             MraAddrListStoreToContact    (HANDLE hContact,MRA_ADDR_LIST *pmalAddrList);
void             MraAddrListFree                (MRA_ADDR_LIST *pmalAddrList);



#define GetContactNameA(Contact) (LPSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)Contact,0)
#define GetContactNameW(Contact) (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)Contact,GCDNF_UNICODE)

#define GetStatusModeDescriptionA(Status) (LPSTR)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)Status,0)
#define GetStatusModeDescriptionW(Status) (LPWSTR)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)Status,GSMDF_UNICODE)

#define DB_Mra_DeleteValue(Contact,valueName) DBDeleteContactSetting(Contact,PROTOCOL_NAMEA,valueName)

#define DB_Mra_GetDword(Contact,valueName,parDefltValue) DBGetContactSettingDword(Contact,PROTOCOL_NAMEA,valueName,parDefltValue)
#define DB_Mra_SetDword(Contact,valueName,parValue) DBWriteContactSettingDword(Contact,PROTOCOL_NAMEA,valueName,parValue)

#define DB_Mra_GetWord(Contact,valueName,parDefltValue) DBGetContactSettingWord(Contact,PROTOCOL_NAMEA,valueName,parDefltValue)
#define DB_Mra_SetWord(Contact,valueName,parValue) DBWriteContactSettingWord(Contact,PROTOCOL_NAMEA,valueName,parValue)

#define DB_Mra_GetByte(Contact,valueName,parDefltValue) DBGetContactSettingByte(Contact,PROTOCOL_NAMEA,valueName,parDefltValue)
#define DB_Mra_SetByte(Contact,valueName,parValue) DBWriteContactSettingByte(Contact,PROTOCOL_NAMEA,valueName,parValue)

void	DB_Mra_CreateResidentSetting(LPSTR lpszValueName);

BOOL	DB_GetStaticStringA(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPSTR lpszRetBuff,SIZE_T dwRetBuffSize,SIZE_T *pdwRetBuffSize);
BOOL	DB_GetStaticStringW(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPWSTR lpszRetBuff,SIZE_T dwRetBuffSize,SIZE_T *pdwRetBuffSize);
#define DB_Mra_GetStaticStringA(Contact,ValueName,Ret,RetBuffSize,pRetBuffSize) DB_GetStaticStringA(Contact,PROTOCOL_NAMEA,ValueName,Ret,RetBuffSize,pRetBuffSize)
#define DB_Mra_GetStaticStringW(Contact,ValueName,Ret,RetBuffSize,pRetBuffSize) DB_GetStaticStringW(Contact,PROTOCOL_NAMEA,ValueName,Ret,RetBuffSize,pRetBuffSize)

BOOL	DB_SetStringExA(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPSTR lpszValue,SIZE_T dwValueSize);
BOOL	DB_SetStringExW(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPWSTR lpwszValue,SIZE_T dwValueSize);
#define DB_SetStringA(Contact,Module,valueName,parValue) DB_SetStringExA(Contact,Module,valueName,parValue,lstrlenA(parValue))
#define DB_SetStringW(Contact,Module,valueName,parValue) DBWriteContactSettingWString(Contact,Module,valueName,parValue)
#define DB_SetLPSStringA(Contact,Module,valueName,parValue) if ((parValue)) DB_SetStringExA(Contact,Module,valueName,(parValue)->lpszData,(parValue)->dwSize)
#define DB_SetLPSStringW(Contact,Module,valueName,parValue) if ((parValue)) DB_SetStringExW(Contact,Module,valueName,(parValue)->lpwszData,((parValue)->dwSize/sizeof(WCHAR)))
#define DB_Mra_SetStringA(Contact,valueName,parValue) DB_SetStringExA(Contact,PROTOCOL_NAMEA,valueName,parValue,lstrlenA(parValue))
#define DB_Mra_SetStringW(Contact,valueName,parValue) DBWriteContactSettingWString(Contact,PROTOCOL_NAMEA,valueName,parValue)
#define DB_Mra_SetLPSStringA(Contact,valueName,parValue) DB_SetLPSStringA(Contact,PROTOCOL_NAMEA,valueName,parValue)
#define DB_Mra_SetLPSStringW(Contact,valueName,parValue) DB_SetLPSStringW(Contact,PROTOCOL_NAMEA,valueName,parValue)
#define DB_Mra_SetStringExA(Contact,valueName,parValue,parValueSize) DB_SetStringExA(Contact,PROTOCOL_NAMEA,valueName,parValue,parValueSize)
#define DB_Mra_SetStringExW(Contact,valueName,parValue,parValueSize) DB_SetStringExW(Contact,PROTOCOL_NAMEA,valueName,parValue,parValueSize)

int DB_WriteContactSettingBlob(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPVOID lpValue,SIZE_T dwValueSize);
#define DB_Mra_WriteContactSettingBlob(hContact,lpszValueName,lpbValue,dwValueSize) DB_WriteContactSettingBlob(hContact,PROTOCOL_NAMEA,lpszValueName,lpbValue,dwValueSize)
BOOL DB_GetContactSettingBlob(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPVOID lpRet,SIZE_T dwRetBuffSize,SIZE_T *pdwRetBuffSize);
#define DB_Mra_GetContactSettingBlob(hContact,lpszValueName,lpbRet,dwRetBuffSize,pdwRetBuffSize) DB_GetContactSettingBlob(hContact,PROTOCOL_NAMEA,lpszValueName,lpbRet,dwRetBuffSize,pdwRetBuffSize)

#define MEMALLOC(Size)			HeapAlloc(masMraSettings.hHeap,HEAP_ZERO_MEMORY,((Size)+sizeof(void*)))
#define MEMREALLOC(Mem,Size)	HeapReAlloc(masMraSettings.hHeap,(HEAP_ZERO_MEMORY),(void*)(Mem),((Size)+sizeof(void*)))
#define MEMFREE(Mem)			if ((Mem)) {HeapFree(masMraSettings.hHeap,0,(void*)(Mem));(Mem)=NULL;}

#define SetBit(bytes,bitpos) bytes|=(1<<bitpos)
#define GetBit(bytes,bitpos) ((bytes&(1<<bitpos))? TRUE:FALSE)


#define IsXStatusValid(XStatus) (((XStatus) && (XStatus)<MRA_XSTATUS_COUNT))


#define SEND_DLG_ITEM_MESSAGEW(hDlg,nIDDlgItem,Msg,wParam,lParam)	SendMessageW(GetDlgItem(hDlg,nIDDlgItem),Msg,wParam,lParam)
#define SEND_DLG_ITEM_MESSAGEA(hDlg,nIDDlgItem,Msg,wParam,lParam)	SendMessageA(GetDlgItem(hDlg,nIDDlgItem),Msg,wParam,lParam)
#define SEND_DLG_ITEM_MESSAGE(hDlg,nIDDlgItem,Msg,wParam,lParam)	SendMessage(GetDlgItem(hDlg,nIDDlgItem),Msg,wParam,lParam)

#define IS_DLG_BUTTON_CHECKED(hDlg,nIDDlgItem)						SEND_DLG_ITEM_MESSAGE(hDlg,nIDDlgItem,BM_GETCHECK,NULL,NULL)
#define CHECK_DLG_BUTTON(hDlg,nIDDlgItem,uCheck)					SEND_DLG_ITEM_MESSAGE(hDlg,nIDDlgItem,BM_SETCHECK,(WPARAM)uCheck,NULL)

#define SET_DLG_ITEM_TEXTW(hDlg,nIDDlgItem,lpString)				SEND_DLG_ITEM_MESSAGEW(hDlg,nIDDlgItem,WM_SETTEXT,0,(LPARAM)lpString)
#define SET_DLG_ITEM_TEXTA(hDlg,nIDDlgItem,lpString)				SEND_DLG_ITEM_MESSAGEA(hDlg,nIDDlgItem,WM_SETTEXT,0,(LPARAM)lpString)
#define SET_DLG_ITEM_TEXT(hDlg,nIDDlgItem,lpString)					SEND_DLG_ITEM_MESSAGE(hDlg,nIDDlgItem,WM_SETTEXT,0,(LPARAM)lpString)

#define GET_DLG_ITEM_TEXTW(hDlg,nIDDlgItem,lpString,nMaxCount)		SEND_DLG_ITEM_MESSAGEW(hDlg,nIDDlgItem,WM_GETTEXT,(WPARAM)nMaxCount,(LPARAM)lpString)
#define GET_DLG_ITEM_TEXTA(hDlg,nIDDlgItem,lpString,nMaxCount)		SEND_DLG_ITEM_MESSAGEA(hDlg,nIDDlgItem,WM_GETTEXT,(WPARAM)nMaxCount,(LPARAM)lpString)
#define GET_DLG_ITEM_TEXT(hDlg,nIDDlgItem,lpString,nMaxCount)		SEND_DLG_ITEM_MESSAGE(hDlg,nIDDlgItem,WM_GETTEXT,(WPARAM)nMaxCount,(LPARAM)lpString)

#define GET_DLG_ITEM_TEXT_LENGTH(hDlg,nIDDlgItem)					SEND_DLG_ITEM_MESSAGE(hDlg,nIDDlgItem,WM_GETTEXTLENGTH,NULL,NULL)
#define GET_WINDOW_TEXT_LENGTH(hDlg)								SendMessage(hDlg,WM_GETTEXTLENGTH,NULL,NULL)

#define GET_CURRENT_COMBO_DATA(hWndDlg,ControlID)					SEND_DLG_ITEM_MESSAGE(hWndDlg,ControlID,CB_GETITEMDATA,SEND_DLG_ITEM_MESSAGE(hWndDlg,ControlID,CB_GETCURSEL,0,0),0)


#define IsFileExist(FileName) (GetFileAttributes(FileName)!=INVALID_FILE_ATTRIBUTES)
#define IsFileExistA(FileName) (GetFileAttributesA(FileName)!=INVALID_FILE_ATTRIBUTES)
#define IsFileExistW(FileName) (GetFileAttributesW(FileName)!=INVALID_FILE_ATTRIBUTES)


#define IsThreadAlive(hThread) (GetThreadPriority(hThread)!=THREAD_PRIORITY_ERROR_RETURN)



DWORD           MraGetVersionStringFromFormated (LPSTR lpszUserAgentFormated,SIZE_T dwUserAgentFormatedSize,LPSTR lpszVersion,SIZE_T dwVersionSize,SIZE_T *pdwVersionSizeRet);
HANDLE          MraHContactFromEmail            (LPSTR lpszEMail,SIZE_T dwEMailSize,BOOL bAddIfNeeded,BOOL bTemporary,BOOL *pbAdded);
BOOL            MraUpdateContactInfo            (HANDLE hContact);
DWORD           MraContactCapabilitiesGet       (HANDLE hContact);
void            MraContactCapabilitiesSet       (HANDLE hContact,DWORD dwFutureFlags);
DWORD           MraGetContactStatus             (HANDLE hContact);
DWORD           MraSetContactStatus             (HANDLE hContact,DWORD dwNewStatus);
void            MraUpdateEmailStatus            (LPSTR lpszFrom,SIZE_T dwFromSize,LPSTR lpszSubject,SIZE_T dwSubjectSize,DWORD dwDate,DWORD dwUIDL);
BOOL            IsUnicodeEnv                    ();
BOOL            IsHTTPSProxyUsed                (HANDLE hNetlibUser);
BOOL            IsContactMra                    (HANDLE hContact);
BOOL            IsContactMraProto               (HANDLE hContact);
BOOL            IsEMailMy                       (LPSTR lpszEMail,SIZE_T dwEMailSize);
BOOL            IsEMailChatAgent                (LPSTR lpszEMail,SIZE_T dwEMailSize);
BOOL            IsContactChatAgent              (HANDLE hContact);
BOOL            IsEMailMR                       (LPSTR lpszEMail,SIZE_T dwEMailSize);
BOOL            GetEMailFromString              (LPSTR lpszBuff,SIZE_T dwBuffSize,LPSTR *plpszEMail,SIZE_T *pdwEMailSize);
DWORD           GetContactEMailCount            (HANDLE hContact,BOOL bMRAOnly);
BOOL            GetContactFirstEMail            (HANDLE hContact,BOOL bMRAOnly,LPSTR lpszRetBuff,SIZE_T dwRetBuffSize,SIZE_T *pdwRetBuffSize);
DWORD           MraAPCQueueAdd                  (PAPCFUNC pfnAPC,PFIFO_MT pffmtAPCQueue,ULONG_PTR dwData);
void            MraAPCQueueDestroy              (PFIFO_MT pffmtAPCQueue);
void            ShowFormatedErrorMessage        (LPWSTR lpwszErrText,DWORD dwErrorCode);
DWORD           ProtoBroadcastAckAsynchEx       (const char *szModule,HANDLE hContact,int type,int result,HANDLE hProcess,LPARAM lParam,SIZE_T dwLparamSize);
void            MraUserAPCThreadProc            (LPVOID lpParameter);

DWORD           CreateBlobFromContact           (HANDLE hContact,LPWSTR lpwszRequestReason,SIZE_T dwRequestReasonSize,LPBYTE lpbBuff,SIZE_T dwBuffSize,SIZE_T *pdwBuffSizeRet);
void            CListCreateMenu                 (LONG lPosition,LONG lPopupPosition,HICON hMainIcon,LPSTR pszContactOwner,BOOL bIsStatus,const GUI_DISPLAY_ITEM *pgdiItems,HANDLE *hIcoLibIcons,SIZE_T dwCount,HANDLE *hResult);
void            CListDestroyMenu                (const GUI_DISPLAY_ITEM *pgdiItems,SIZE_T dwCount);
void            CListShowMenuItem               (HANDLE hMenuItem,BOOL bShow);
int             ExtraSetIcon                    (HANDLE hExtraIcon,HANDLE hContact,HANDLE hImage,int iColumnType);
SIZE_T          CopyNumber                      (LPCVOID lpcOutBuff,LPCVOID lpcBuff,SIZE_T dwLen);
BOOL            IsPhone                         (LPSTR lpszString,SIZE_T dwStringSize);
BOOL            IsContactPhone                  (HANDLE hContact,LPSTR lpszPhone,SIZE_T dwPhoneSize);
HANDLE          MraHContactFromPhone            (LPSTR lpszPhone,SIZE_T dwPhoneSize,BOOL bAddIfNeeded,BOOL bTemporary,BOOL *pbAdded);
void            EnableControlsArray             (HWND hWndDlg,WORD *pwControlsList,SIZE_T dwControlsListCount,BOOL bEnabled);
BOOL            MraRequestXStatusDetails        (DWORD dwXStatus);
BOOL            MraSendReplyBlogStatus          (HANDLE hContact);
DWORD           GetYears                        (CONST PSYSTEMTIME pcstSystemTime);
DWORD           FindFile                        (LPWSTR lpszFolder,DWORD dwFolderLen,LPWSTR lpszFileName,DWORD dwFileNameLen,LPWSTR lpszRetFilePathName,DWORD dwRetFilePathLen,DWORD *pdwRetFilePathLen);
DWORD           MemFillRandom                   (LPVOID lpBuff,SIZE_T dwBuffSize);
BOOL            SetPassDB                       (LPSTR lpszBuff,SIZE_T dwBuffSize);
BOOL            GetPassDB                       (LPSTR lpszBuff,SIZE_T dwBuffSize,SIZE_T *pdwBuffSize);
DWORD           DecodeXML                       (LPTSTR lptszMessage,SIZE_T dwMessageSize,LPTSTR lptszMessageConverted,SIZE_T dwMessageConvertedBuffSize,SIZE_T *pdwMessageConvertedSize);
DWORD           EncodeXML                       (LPTSTR lptszMessage,SIZE_T dwMessageSize,LPTSTR lptszMessageConverted,SIZE_T dwMessageConvertedBuffSize,SIZE_T *pdwMessageConvertedSize);


DWORD           StartConnect                    ();
void            MraThreadClean                  ();

DWORD           GetMraStatusFromMiradaStatus    (DWORD dwMirandaStatus,DWORD dwXStatusMir,DWORD *pdwXStatusMra);
DWORD           GetMiradaStatusFromMraStatus    (DWORD dwMraStatus,DWORD dwXStatusMra,DWORD *pdwXStatusMir);
DWORD           GetMraXStatusIDFromMraUriStatus (LPSTR lpszStatusUri,SIZE_T dwStatusUriSize);

DWORD           GetContactFlags                 (HANDLE hContact);
DWORD           SetContactFlags                 (HANDLE hContact,DWORD dwContactFlag);

DWORD           GetContactBasicInfoW            (HANDLE hContact,DWORD *pdwID,DWORD *pdwGroupID,DWORD *pdwContactFlag,DWORD *pdwContactSeverFlags,DWORD *pdwStatus,LPSTR lpszEMail,SIZE_T dwEMailSize,SIZE_T *pdwEMailSize,LPWSTR lpwszNick,SIZE_T dwNickSize,SIZE_T *pdwNickSize,LPSTR lpszPhones,SIZE_T dwPhonesSize,SIZE_T *pdwPhonesSize);

#define SCBIFSI_LOCK_CHANGES_EVENTS	1
#define SCBIF_ID			1
#define SCBIF_GROUP_ID		2
#define SCBIF_FLAG			4
#define SCBIF_SERVER_FLAG	8
#define SCBIF_STATUS		16
#define SCBIF_EMAIL			32
#define SCBIF_NICK			64
#define SCBIF_PHONES		128
DWORD			SetContactBasicInfoW			(HANDLE hContact,DWORD dwSetInfoFlags,DWORD dwFlags,DWORD dwID,DWORD dwGroupID,DWORD dwContactFlag,DWORD dwContactSeverFlags,DWORD dwStatus,LPSTR lpszEMail,SIZE_T dwEMailSize,LPWSTR lpwszNick,SIZE_T dwNickSize,LPSTR lpszPhones,SIZE_T dwPhonesSize);




#endif // !defined(AFX_MRA_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_)