Exemple #1
0
int IsResidentSetting(const char *module, const char *setting)
{
	if (!m_lResidentSettings.getCount()) return 0;

	if (m_lResidentModules.getIndex((char*)module) == -1) return 0; 
	if (!setting) return 1;

	char str[2*FLD_SIZE];
    mir_strncpy(str, module, _countof(str)-1);
    mir_strcat(str, "/");
    mir_strncat(str, setting, _countof(str));
	return m_lResidentSettings.getIndex(str) != -1;
}
Exemple #2
0
static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam)
{
	DBEVENTTYPEDESCR* et = (DBEVENTTYPEDESCR*)lParam;
	if (eventTypes.getIndex(et) == -1) {
		DBEVENTTYPEDESCR* p = (DBEVENTTYPEDESCR*)mir_calloc(sizeof(DBEVENTTYPEDESCR));
		p->cbSize = DBEVENTTYPEDESCR_SIZE;
		p->module = mir_strdup(et->module);
		p->eventType = et->eventType;
		p->descr = mir_strdup(et->descr);
		if (et->cbSize == DBEVENTTYPEDESCR_SIZE) {
			if (et->textService)
				p->textService = mir_strdup(et->textService);
			if (et->iconService)
				p->iconService = mir_strdup(et->iconService);
			p->eventIcon = et->eventIcon;
			p->flags = et->flags;
		}
		if (!p->textService) {
			char szServiceName[100];
			mir_snprintf(szServiceName, sizeof(szServiceName), "%s/GetEventText%d", p->module, p->eventType);
			p->textService = mir_strdup(szServiceName);
		}
		if (!p->iconService) {
			char szServiceName[100];
			mir_snprintf(szServiceName, sizeof(szServiceName), "%s/GetEventIcon%d", p->module, p->eventType);
			p->iconService = mir_strdup(szServiceName);
		}
		eventTypes.insert(p);
	}

	return 0;
}
Exemple #3
0
//hookProc ME_MSG_WINDOWEVENT
static int OnMsgWndEvent(WPARAM, LPARAM lParam)
{
	MsgWndData *msgwnd;
	MessageWindowEventData *msgwe = (MessageWindowEventData*)lParam;
	/* sanity check */
	if (msgwe->hContact == NULL)
		return 0;

	switch (msgwe->uType) {
	case MSG_WINDOW_EVT_OPENING:
		msgwnd = gMsgWndList.find((MsgWndData*)&msgwe->hContact);
		if (msgwnd == NULL) {
			msgwnd = new MsgWndData(msgwe->hwndWindow, msgwe->hContact);
			gMsgWndList.insert(msgwnd);
		}
		break;

	case MSG_WINDOW_EVT_CLOSE:
		int i = gMsgWndList.getIndex((MsgWndData*)&msgwe->hContact);
		if (i != -1) {
			delete gMsgWndList[i];
			gMsgWndList.remove(i);
		}
		break;
	}
	return 0;
}
Exemple #4
0
MIR_CORE_DLL(int) Langpack_MarkPluginLoaded(PLUGININFOEX *pInfo)
{
	int idx = lMuuids.getIndex(&pInfo->uuid);
	if (idx == -1)
		return 0;

	return (idx + 1) << 16;
}
Exemple #5
0
static HANDLE timeapiGetInfoByContact(HANDLE hContact, DWORD dwFlags)
{
	if (hContact == NULL)
		return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;

	DBVARIANT dbv;
	if (!DBGetContactSettingTString(hContact, "UserInfo", "TzName", &dbv)) 
	{
		HANDLE res = timeapiGetInfoByName(dbv.ptszVal, dwFlags);  
		DBFreeVariant(&dbv);
		if (res) return res;
	} 

	signed char timezone = (signed char)DBGetContactSettingByte(hContact, "UserInfo", "Timezone", -1);
	if (timezone == -1)
	{
		char* szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
		if (!DBGetContactSettingTString(hContact, szProto, "TzName", &dbv)) 
		{
			HANDLE res = timeapiGetInfoByName(dbv.ptszVal, dwFlags);  
			DBFreeVariant(&dbv);
			if (res) return res;
		}
		timezone = (signed char)DBGetContactSettingByte(hContact, szProto, "Timezone", -1);
	}

	if (timezone != -1) 
	{
		MIM_TIMEZONE tzsearch;
		tzsearch.tzi.Bias = timezone * 30;
		if (myInfo.myTZ.tzi.Bias == tzsearch.tzi.Bias)
		{
			if (dwFlags & TZF_DIFONLY) return NULL;
			return &myInfo.myTZ;
		}

		int i = g_timezonesBias.getIndex(&tzsearch);
		while (i >= 0 && g_timezonesBias[i]->tzi.Bias == tzsearch.tzi.Bias) --i; 
		
		int delta = LONG_MAX;
		for (int j = ++i; j < g_timezonesBias.getCount() && g_timezonesBias[j]->tzi.Bias == tzsearch.tzi.Bias; ++j)
		{
			int delta1 = abs(g_timezonesBias[j]->tzi.DaylightDate.wMonth - myInfo.myTZ.tzi.DaylightDate.wMonth);
			if (delta1 <= delta)
			{
				delta = delta1;
				i = j;
			}
		}

		if (i >= 0)
		{
			MIM_TIMEZONE *tz = g_timezonesBias[i];
			return ((dwFlags & TZF_DIFONLY) && IsSameTime(tz)) ? NULL : tz;
		}
	}
	return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
}
Exemple #6
0
bool IsActionEnabled(POPUPACTION *action)
{
	if (!(action->flags & PAF_ENABLED))
		return false;

	int index;
	if ((index = gActions.getIndex(action)) >= 0)
		if (!(gActions[index]->flags & PAF_ENABLED))
			return false;

	return true;
}
Exemple #7
0
MIR_CORE_DLL(HANDLE) TimeZone_CreateByContact(MCONTACT hContact, LPCSTR szModule, DWORD dwFlags)
{
	if (hContact == NULL && szModule == NULL)
		return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;

	if (szModule == NULL) szModule = "UserInfo";

	DBVARIANT dbv;
	if (!db_get_ts(hContact, szModule, "TzName", &dbv)) {
		HANDLE res = TimeZone_CreateByName(dbv.ptszVal, dwFlags);
		db_free(&dbv);
		if (res) return res;
	}

	signed char timezone = (signed char)db_get_b(hContact, szModule, "Timezone", -1);
	if (timezone == -1) {
		char *szProto = GetContactProto(hContact);
		if (!db_get_ts(hContact, szProto, "TzName", &dbv)) {
			HANDLE res = TimeZone_CreateByName(dbv.ptszVal, dwFlags);
			db_free(&dbv);
			if (res) return res;
		}
		timezone = (signed char)db_get_b(hContact, szProto, "Timezone", -1);
	}

	if (timezone != -1) {
		MIM_TIMEZONE tzsearch;
		tzsearch.tzi.Bias = timezone * 30;
		if (myInfo.myTZ.tzi.Bias == tzsearch.tzi.Bias) {
			if (dwFlags & TZF_DIFONLY) return NULL;
			return &myInfo.myTZ;
		}

		int i = g_timezonesBias.getIndex(&tzsearch);
		while (i >= 0 && g_timezonesBias[i]->tzi.Bias == tzsearch.tzi.Bias) --i;

		int delta = LONG_MAX;
		for (int j = ++i; j < g_timezonesBias.getCount() && g_timezonesBias[j]->tzi.Bias == tzsearch.tzi.Bias; ++j) {
			int delta1 = abs(g_timezonesBias[j]->tzi.DaylightDate.wMonth - myInfo.myTZ.tzi.DaylightDate.wMonth);
			if (delta1 <= delta) {
				delta = delta1;
				i = j;
			}
		}

		if (i >= 0) {
			MIM_TIMEZONE *tz = g_timezonesBias[i];
			return ((dwFlags & TZF_DIFONLY) && IsSameTime(tz)) ? NULL : tz;
		}
	}
	return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
}
Exemple #8
0
void CloseRichCallback(HWND hwnd)
{
	int ind = g_RichEditList.getIndex((RichEditData*)&hwnd);
	if (ind == -1 )
		return;

	RichEditData* rdt = g_RichEditList[ind];
	if (rdt->hToolTip)
		DestroyWindow(rdt->hToolTip);
	delete rdt;
	g_RichEditList.remove(ind);
	mir_unsubclassWindow(hwnd, RichEditSubclass);
}
Exemple #9
0
int enumResidentProc(const char *setting, DWORD, LPARAM)
{
	m_lResidentSettings.insert(mir_strdup(setting));

	char str[FLD_SIZE];
	const char *end = strstr(setting, "/");
	if (end && (end - setting) < _countof(str)) {
		mir_strncpy(str, setting, end - setting + 1);
		if (m_lResidentModules.getIndex(str) == -1)
				m_lResidentModules.insert(mir_strdup(str));
	}
	return 0;
}
Exemple #10
0
void CloseRichOwnerCallback(HWND hwnd)
{
	int ind = g_RichEditOwnerList.getIndex((RichEditOwnerData*)&hwnd);
	if (ind == -1)
		return;

	RichEditOwnerData* rdto = g_RichEditOwnerList[ind];
	CloseRichCallback(rdto->hwndInput);
	CloseRichCallback(rdto->hwndLog);
	delete rdto;

	g_RichEditOwnerList.remove(ind);

	mir_unsubclassWindow(hwnd, RichEditOwnerSubclass);
}
Exemple #11
0
void RegisterAction(POPUPACTION *action)
{
    int index;
    if ((index = gActions.getIndex(action)) >= 0) {
        DWORD flags = gActions[index]->flags;
        *gActions[index] = *action;
        gActions[index]->flags = flags;
    }
    else {
        POPUPACTION *actionCopy = new POPUPACTION;
        *actionCopy = *action;
        actionCopy->flags = db_get_b(NULL, "PopupActions", actionCopy->lpzTitle, actionCopy->flags & PAF_ENABLED) ? PAF_ENABLED : 0;
        gActions.insert(actionCopy);
    }
}
Exemple #12
0
void RegisterAction(POPUPACTION *action)
{
	int index;
	if ((index = gActions.getIndex(action)) >= 0)
	{
		DWORD flags = gActions[index]->flags;
		*gActions[index] = *action;
		gActions[index]->flags = flags;
	} else
	{
		POPUPACTION *actionCopy = (POPUPACTION *)mir_alloc(sizeof(POPUPACTION));
		*actionCopy = *action;
		actionCopy->flags =
			DBGetContactSettingByte(NULL, "PopUpActions", actionCopy->lpzTitle, actionCopy->flags & PAF_ENABLED) ?
				PAF_ENABLED : 0;
		gActions.insert(actionCopy);
	}
}
Exemple #13
0
int __fastcall ApplyFingerprintImage(MCONTACT hContact, LPTSTR szMirVer)
{
	if (hContact == NULL)
		return 0;

	HANDLE hImage = INVALID_HANDLE_VALUE;
	if (szMirVer)
		hImage = GetIconIndexFromFI(szMirVer);

	ExtraIcon_SetIcon(hExtraIcon, hContact, hImage);

	if (arMonitoredWindows.getIndex((HANDLE)hContact) != -1)
		SetSrmmIcon(hContact, szMirVer);

	MCONTACT hMeta = db_mc_getMeta(hContact);
	if (hMeta && db_mc_getMostOnline(hMeta) == hContact)
		db_set_ts(hMeta, META_PROTO, "MirVer", szMirVer);

	return 0;
}
Exemple #14
0
int EnumResidentSettings(const char *module, ModuleSettingLL *msll)
{
	msll->first = 0;
	msll->last = 0;

	if (!module) return 0;
	if (!m_lResidentSettings.getCount()) return 0;
	if (m_lResidentModules.getIndex((char*)module) == -1) return 0; 

	int len = (int)mir_strlen(module);
	int cnt = 0;

	for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
		if (strncmp(module, m_lResidentSettings[i], len))
			continue;

		if (m_lResidentSettings[i][len] != '/' || m_lResidentSettings[i][len+1] == 0) continue;

		enumModulesSettingsProc(&m_lResidentSettings[i][len+1], 0, (LPARAM)msll);
		cnt++;
	}
	return cnt;
}
Exemple #15
0
static int OnContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
	if (hContact == NULL)
		return 0;

	/* user details update */
	DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
	if (!strcmp(dbcws->szSetting, SET_CONTACT_COUNTRY) ||
		 !strcmp(dbcws->szSetting, SET_CONTACT_ORIGIN_COUNTRY) ||
		 !strcmp(dbcws->szSetting, SET_CONTACT_COMPANY_COUNTRY))
	{
		/* Extra Image */
		SetExtraImage(hContact);

		/* Status Icon */
		int i = gMsgWndList.getIndex((MsgWndData*)&hContact);
		if (i != -1) {
			gMsgWndList[i]->ContryIDchange((int)ServiceDetectContactOriginCountry(hContact, 0));
			gMsgWndList[i]->FlagsIconSet();
		}
	}
	return 0;
}
//global subclass function for all dialogs
static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	MsgWndData* dat = IsMsgWnd(hwnd);
	if (dat == NULL)
		return 0;

	switch(uMsg) {
	case DM_OPTIONSAPPLIED:
		dat->clear();
		dat->CreateSmileyButton();
		break;

	case DM_APPENDTOLOG:
		if (opt.PluginSupportEnabled) {
			//get length of text now before things can get added...
			GETTEXTLENGTHEX gtl;
			gtl.codepage = 1200;
			gtl.flags = GTL_PRECISE | GTL_NUMCHARS;
			dat->idxLastChar = (int)SendMessage(dat->REdit, EM_GETTEXTLENGTHEX, (WPARAM) &gtl, 0);
		}
		break;
	}

	LRESULT result = mir_callNextSubclass(hwnd, MessageDlgSubclass, uMsg, wParam, lParam); 
	if (!opt.PluginSupportEnabled)
		return result;

	switch(uMsg) {
	case WM_DESTROY:
		WaitForSingleObject(g_hMutex, 2000);
		{
			int ind = g_MsgWndList.getIndex((MsgWndData*)&hwnd);
			if ( ind != -1 ) {
				delete g_MsgWndList[ind];
				g_MsgWndList.remove(ind);
			}
		}
		ReleaseMutex(g_hMutex);
		break;

	case WM_SIZE:
		if (dat->doSmileyButton) {
			RECT rect = dat->CalcSmileyButtonPos();
			SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top, 
				0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
		}
		break;

	case DM_APPENDTOLOG:
		if (dat->doSmileyReplace) {
			SmileyPackCType* smcp;
			SmileyPackType* SmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact, &smcp);
			if (SmileyPack != NULL) {
				const CHARRANGE sel = { dat->idxLastChar, LONG_MAX };
				ReplaceSmileys(dat->REdit, SmileyPack, smcp, sel, false, false, false);
			}
		}
		break;

	case DM_REMAKELOG:
		if (dat->doSmileyReplace) {
			SmileyPackCType* smcp;
			SmileyPackType* SmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact, &smcp);
			if (SmileyPack != NULL) {
				static const CHARRANGE sel = { 0, LONG_MAX };
				ReplaceSmileys(dat->REdit, SmileyPack, smcp, sel, false, false, false);
			}
		}
		break;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDC_SMLBUTTON && HIWORD(wParam) == BN_CLICKED) {
			SmileyToolWindowParam *stwp = new SmileyToolWindowParam;
			stwp->pSmileyPack = GetSmileyPack(dat->ProtocolName, dat->hContact);

			stwp->hWndParent = hwnd;
			stwp->hWndTarget = dat->MEdit;
			stwp->targetMessage = EM_REPLACESEL;
			stwp->targetWParam = TRUE;

			RECT rect;
			GetWindowRect(dat->hSmlButton, &rect);

			if (dat->OldButtonPlace) {
				stwp->direction = 3;
				stwp->xPosition = rect.left;
				stwp->yPosition = rect.top + 4;
			}
			else {
				stwp->direction = 0;
				stwp->xPosition = rect.left;
				stwp->yPosition = rect.top + 24;
			}

			mir_forkthread(SmileyToolThread, stwp);
		}

		if (LOWORD(wParam) == MI_IDC_ADD && HIWORD(wParam) == BN_CLICKED && dat->doSmileyButton) {
			RECT rect = dat->CalcSmileyButtonPos();
			SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top, 
				0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
		}
		break;
	}

	return result;
}
Exemple #17
0
static INT_PTR NetlibRegisterUser(WPARAM,LPARAM lParam)
{
	NETLIBUSER *nlu=(NETLIBUSER*)lParam;
	struct NetlibUser *thisUser;

	if(nlu==NULL || nlu->cbSize!=sizeof(NETLIBUSER) || nlu->szSettingsModule==NULL
	   || (!(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName==NULL)
	   || (nlu->flags&NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit==NULL))) {
		SetLastError(ERROR_INVALID_PARAMETER);
		return 0;
	}

	thisUser = (struct NetlibUser*)mir_calloc(sizeof(struct NetlibUser));
	thisUser->handleType = NLH_USER;
	thisUser->user = *nlu;

	EnterCriticalSection(&csNetlibUser);
	if (netlibUser.getIndex(thisUser) >= 0) 
	{
		LeaveCriticalSection(&csNetlibUser);
		mir_free(thisUser);
		SetLastError(ERROR_DUP_NAME);
		return 0;
	}
	LeaveCriticalSection(&csNetlibUser);

	if (nlu->szDescriptiveName) {
		thisUser->user.ptszDescriptiveName = (thisUser->user.flags&NUF_UNICODE ? mir_u2t((WCHAR*)nlu->ptszDescriptiveName) : mir_a2t(nlu->szDescriptiveName));
	}
	if((thisUser->user.szSettingsModule=mir_strdup(nlu->szSettingsModule))==NULL
	   || (nlu->szDescriptiveName && thisUser->user.ptszDescriptiveName ==NULL)
	   || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent=mir_strdup(nlu->szHttpGatewayUserAgent))==NULL)) 
	{
		mir_free(thisUser);
		SetLastError(ERROR_OUTOFMEMORY);
		return 0;
	}
	if (nlu->szHttpGatewayHello)
		thisUser->user.szHttpGatewayHello=mir_strdup(nlu->szHttpGatewayHello);
	else
		thisUser->user.szHttpGatewayHello=NULL;

	thisUser->settings.cbSize=sizeof(NETLIBUSERSETTINGS);
	thisUser->settings.useProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLUseProxy",0);
	thisUser->settings.proxyType=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLProxyType",PROXYTYPE_SOCKS5);
	if(thisUser->user.flags&NUF_NOHTTPSOPTION && thisUser->settings.proxyType==PROXYTYPE_HTTPS)
		thisUser->settings.proxyType=PROXYTYPE_HTTP;
	if(!(thisUser->user.flags&(NUF_HTTPCONNS|NUF_HTTPGATEWAY)) && thisUser->settings.proxyType==PROXYTYPE_HTTP) {
		thisUser->settings.useProxy=0;
		thisUser->settings.proxyType=PROXYTYPE_SOCKS5;
	}
	thisUser->settings.szProxyServer=GetNetlibUserSettingString(thisUser->user.szSettingsModule,"NLProxyServer",0);
	thisUser->settings.wProxyPort=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLProxyPort",1080);
	thisUser->settings.useProxyAuth=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLUseProxyAuth",0);
	thisUser->settings.szProxyAuthUser=GetNetlibUserSettingString(thisUser->user.szSettingsModule,"NLProxyAuthUser",0);
	thisUser->settings.szProxyAuthPassword=GetNetlibUserSettingString(thisUser->user.szSettingsModule,"NLProxyAuthPassword",1);
	thisUser->settings.dnsThroughProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLDnsThroughProxy",1);
	thisUser->settings.specifyIncomingPorts=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLSpecifyIncomingPorts",0);
	thisUser->settings.szIncomingPorts=GetNetlibUserSettingString(thisUser->user.szSettingsModule,"NLIncomingPorts",0);
	thisUser->settings.specifyOutgoingPorts=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLSpecifyOutgoingPorts",0);
	thisUser->settings.szOutgoingPorts=GetNetlibUserSettingString(thisUser->user.szSettingsModule,"NLOutgoingPorts",0);
	thisUser->settings.enableUPnP=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLEnableUPnP",1); //default to on
	thisUser->settings.validateSSL=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLValidateSSL",0);

	thisUser->toLog=GetNetlibUserSettingInt(thisUser->user.szSettingsModule,"NLlog",1);

	EnterCriticalSection(&csNetlibUser);
	netlibUser.insert(thisUser);
	LeaveCriticalSection(&csNetlibUser);
	return (INT_PTR)thisUser;
}
Exemple #18
0
INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
{
	switch(GetNetlibHandleType(wParam)) {
		case NLH_USER:
		{	struct NetlibUser *nlu=(struct NetlibUser*)wParam;
			int i;
			
			EnterCriticalSection(&csNetlibUser);
			i = netlibUser.getIndex(nlu);
			if (i >= 0) netlibUser.remove(i);
			LeaveCriticalSection(&csNetlibUser);

			NetlibFreeUserSettingsStruct(&nlu->settings);
			mir_free(nlu->user.szSettingsModule);
			mir_free(nlu->user.szDescriptiveName);
			mir_free(nlu->user.szHttpGatewayHello);
			mir_free(nlu->user.szHttpGatewayUserAgent);
			mir_free(nlu->szStickyHeaders);
			break;
		}
		case NLH_CONNECTION:
		{	struct NetlibConnection *nlc=(struct NetlibConnection*)wParam;
			HANDLE waitHandles[4];
			DWORD waitResult;

			WaitForSingleObject(hConnectionHeaderMutex,INFINITE);
			if (nlc->usingHttpGateway)
			{
				HttpGatewayRemovePacket(nlc, -1);
			}
			else
			{
				if(nlc->s != INVALID_SOCKET) {
					NetlibDoClose(nlc);
				}
				if (nlc->s2 != INVALID_SOCKET) closesocket(nlc->s2);
				nlc->s2 = INVALID_SOCKET;
			}
			ReleaseMutex(hConnectionHeaderMutex);

			waitHandles[0]=hConnectionHeaderMutex;
			waitHandles[1]=nlc->hOkToCloseEvent;
			waitHandles[2]=nlc->ncsRecv.hMutex;
			waitHandles[3]=nlc->ncsSend.hMutex;
			waitResult=WaitForMultipleObjects( SIZEOF(waitHandles),waitHandles,TRUE,INFINITE);
			if(waitResult<WAIT_OBJECT_0 || waitResult >= WAIT_OBJECT_0 + SIZEOF(waitHandles)) {
				ReleaseMutex(hConnectionHeaderMutex);
				SetLastError(ERROR_INVALID_PARAMETER);	  //already been closed
				return 0;
			}
			nlc->handleType=0;
			mir_free(nlc->nlhpi.szHttpPostUrl);
			mir_free(nlc->nlhpi.szHttpGetUrl);
			mir_free(nlc->dataBuffer);
			mir_free((char*)nlc->nloc.szHost);
			mir_free(nlc->szNewUrl);
			mir_free(nlc->szProxyServer);
			NetlibDeleteNestedCS(&nlc->ncsRecv);
			NetlibDeleteNestedCS(&nlc->ncsSend);
			CloseHandle(nlc->hOkToCloseEvent);
			DeleteCriticalSection(&nlc->csHttpSequenceNums);
			ReleaseMutex(hConnectionHeaderMutex);
			NetlibLogf(nlc->nlu,"(%p:%u) Connection closed",nlc,nlc->s);
			break;
		}
		case NLH_BOUNDPORT:
			return NetlibFreeBoundPort((struct NetlibBoundPort*)wParam);
		case NLH_PACKETRECVER:
		{	struct NetlibPacketRecver *nlpr=(struct NetlibPacketRecver*)wParam;
			mir_free(nlpr->packetRecver.buffer);
			break;
		}
		default:
			SetLastError(ERROR_INVALID_PARAMETER);
			return 0;
	}
	mir_free((void*)wParam);
	return 1;
}
Exemple #19
0
// previously saved in DB resident settings are unaccessible. 
// so let's find them and delete from DB
int fixResidentSettings()
{
	if (!m_lResidentSettings.getCount() || fixing) return 0;

	ModuleSettingLL ModuleList, SettingList;
	ModSetLinkLinkItem *module, *setting;
	MCONTACT hContact = 0;
	int NULLContactDone = 0;
	char str[2*FLD_SIZE];
	int cnt = 0;

	if (!EnumModules(&ModuleList)) return 0;

	fixing = 1;

	while (hwnd2mainWindow) {

		if (!hContact) {
			if (NULLContactDone) 
				break;
			else {
				NULLContactDone = 1;
				hContact = db_find_first();
			}
		}
		else 
			hContact = db_find_next(hContact);

		for (module = ModuleList.first; module; module = module->next) {

			if (IsModuleEmpty(hContact, module->name) || m_lResidentModules.getIndex(module->name) == -1) 
				continue;
	
			if (!EnumSettings(hContact, module->name, &SettingList))
			 	continue;

			for (setting = SettingList.first; setting; setting = setting->next) {

			    mir_strncpy(str, module->name, _countof(str)-1);
			    mir_strcat(str, "/");
			    mir_strncat(str, setting->name, _countof(str));
				int idx = m_lResidentSettings.getIndex(str);

				if (idx == -1)
					continue;

				g_db->SetSettingResident(0, str);
				db_unset(hContact, module->name, setting->name);
				g_db->SetSettingResident(1, str);

				cnt++;

			} // for(setting)

			FreeModuleSettingLL(&SettingList);

		} // for(module)
	}

	FreeModuleSettingLL(&ModuleList);

	fixing = 0;

	return cnt;
}