Пример #1
0
void CB_ReInitCustomButtons()
{
	for (int i = 0; i < LButtonsList.getCount(); i++) {
		CustomButtonData *cbd = LButtonsList[i];

		if (cbd->opFlags & BBSF_NTBSWAPED || cbd->opFlags & BBSF_NTBDESTRUCT) {
			cbd->opFlags ^= BBSF_NTBSWAPED;

			if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
				RButtonsList.insert(cbd);

			LButtonsList.remove(i);
			i--;
		}
	}

	for (int i = 0; i < RButtonsList.getCount(); i++) {
		CustomButtonData* cbd = RButtonsList[i];
		if (cbd->opFlags & BBSF_NTBSWAPED || cbd->opFlags & BBSF_NTBDESTRUCT) {
			cbd->opFlags ^= BBSF_NTBSWAPED;

			if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
				LButtonsList.insert(cbd);

			RButtonsList.remove(i);
			i--;
		}
	}
	M.BroadcastMessage(DM_BBNEEDUPDATE, 0, 0);
	M.BroadcastMessage(DM_LOADBUTTONBARICONS, 0, 0);
}
Пример #2
0
void ScheduleThread(void*)
{
	time_t waitTime = INFINITE;

	while (true)
	{
wait:	WaitForSingleObject(hScheduleEvent, waitTime);

		while (ScheduleTask *task = tasks[0])
		{
			if (Miranda_Terminated())
				return;

			mir_cslock lock(threadLock);

			time_t timestamp = time(NULL);
			if (task->timestamp > timestamp)
			{
				waitTime = (task->timestamp - timestamp - 1) * 1000;
				goto wait;
			}

			tasks.remove(task);

			mir_forkthread(ExecuteTaskThread, task);
		}

		waitTime = INFINITE;
	}
}
Пример #3
0
/**
* Protocols àcknowledgement
*/
int ProtoAck(WPARAM wparam,LPARAM lparam)
{
	ACKDATA *pAck = (ACKDATA *)lparam;
	if (pAck->type != ACKTYPE_MESSAGE || pAck->result != ACKRESULT_SUCCESS)
		return 0;

	MESSAGE_PROC* p = arMessageProcs.find((MESSAGE_PROC*)&pAck->hProcess);
	if (p == NULL)
		return 0;

	if (iSendAndHistory > 0){
		time_t ltime;
		time(&ltime);

		DBEVENTINFO dbei = { sizeof(dbei) };
		dbei.szModule = "yaRelay";
		dbei.timestamp = ltime;
		dbei.flags = DBEF_SENT | DBEF_UTF;
		dbei.eventType = EVENTTYPE_MESSAGE;
		dbei.cbBlob = (DWORD)strlen(p->msgText) + 1;
		dbei.pBlob = (PBYTE)p->msgText;
		db_event_add(hForwardTo, &dbei);
	}

	mir_free(p->msgText);
	arMessageProcs.remove(p);
	mir_free(p);
	return 0;
}
Пример #4
0
MIR_CORE_DLL(INT_PTR) Thread_Pop()
{
	if (WaitForSingleObject(hStackMutex, INFINITE) == WAIT_OBJECT_0) {
		DWORD dwThreadId = GetCurrentThreadId();
		for (int j = 0; j < threads.getCount(); j++) {
			THREAD_WAIT_ENTRY *p = threads[j];
			if (p->dwThreadId == dwThreadId) {
				SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
				CloseHandle(p->hThread);
				threads.remove(j);
				mir_free(p);

				if (!threads.getCount()) {
					threads.destroy();
					ReleaseMutex(hStackMutex);
					SetEvent(hThreadQueueEmpty); // thread list is empty now
					return 0;
				}

				ReleaseMutex(hStackMutex);
				return 0;
			}
		}
		ReleaseMutex(hStackMutex);
	}
	return 1;
}
Пример #5
0
static void wipeList(LIST<CustomButtonData> &list)
{
	for (int i = list.getCount()-1; i >= 0; i--) {
		delete list[i];
		list.remove(i);
	}
}
Пример #6
0
static int sametime_proto_uninit(PROTO_INTERFACE* ppro)
{
	CSametimeProto* proto = (CSametimeProto*)ppro;
	g_Instances.remove(proto);
	delete proto;
	return 0;
}
Пример #7
0
static int yahooProtoUninit( CYahooProto* ppro )
{
	g_instances.remove( ppro );
	delete ppro;
	
	return 0;
}
Пример #8
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;
}
Пример #9
0
void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char* szErr)
{
	MCONTACT hMeta = db_mc_getMeta(hContact);

	mir_cslockfull lck(csMsgQueue);
	for (int i = 0; i < msgQueue.getCount(); i++) {
		TMsgQueue *item = msgQueue[i];
		if ((item->hContact == hContact || item->hContact == hMeta) && item->id == id) {
			msgQueue.remove(i); i--;

			if (!msgQueue.getCount() && timerId) {
				KillTimer(NULL, timerId);
				timerId = 0;
			}
			lck.unlock();

			if (success) {
				mir_free(item->szMsg);
				mir_free(item);
			}
			else MessageFailureProcess(item, szErr);
			break;
		}
	}
}
Пример #10
0
static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PopupWnd2 *wnd = NULL;
	if (message == UTM_ADD_WINDOW || message == UTM_UPDATE_WINDOW || message == UTM_REMOVE_WINDOW || message == UTM_REQUEST_REMOVE)
		if (!(wnd = (PopupWnd2 *)lParam))
			return 0;

	switch (message) {
	case UTM_STOP_THREAD:
		gTerminating = true;
		if (db_get_b(NULL, MODULNAME, "FastExit", 0))
			for (int i = 0; i < popupList.getCount(); ++i)
				PUDeletePopup(popupList[i]->getHwnd());
		PostQuitMessage(0);
		break;

	case UTM_ADD_WINDOW:
		if (gTerminating)
			break;
		UpdatePopupPosition(popupList.getCount() ? popupList[popupList.getCount() - 1] : 0, wnd);
		popupList.insert(wnd);
		++nPopups;
		wnd->callMethodAsync(&PopupWnd2::m_show, 0);
		break;

	case UTM_UPDATE_WINDOW:
		RepositionPopups();
		break;

	case UTM_REQUEST_REMOVE:
		if ((PopupOptions.LeaveHovered && gLockCount) || (wnd && wnd->isLocked()))
			wnd->updateTimer();
		else
			PostMessage(wnd->getHwnd(), WM_CLOSE, 0, 0);
		break;

	case UTM_REMOVE_WINDOW:
	{
		for (int i = popupList.getCount() - 1; i >= 0; i--)
			if (popupList[i] == wnd)
				popupList.remove(i);
	}
	RepositionPopups();
	--nPopups;
	delete wnd;
	break;

	case UTM_LOCK_QUEUE:
		++gLockCount;
		break;

	case UTM_UNLOCK_QUEUE:
		if (--gLockCount < 0)
			gLockCount = 0;
		break;

	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}
Пример #11
0
int
main() {
  LIST<int> list;
  
  print_list(list);
  
  list.append(10);
  print_list(list);

  list.append(20);
  print_list(list);

  list.prepend(30);
  print_list(list);

  list.prepend(20);
  print_list(list);

  list.append(40);
  print_list(list);
  
  LIST<int>::ITERATOR i(list);
  
  while(!i.done()) {
    LIST<int>::NODE* node = (*i);
    i++;
    if(node->data() == 20) {      
      list.remove(node);
    }
  }
  
  print_list(list);

  i = LIST<int>::ITERATOR(list);
  
  while(!i.done()) {
    LIST<int>::NODE* node = (*i);
    i++;
    list.remove(node);
  }

  print_list(list);
  
  return 0;
}
Пример #12
0
void KillModuleTTBButton()
{
	while (TBButtons.getCount())
	{
		HANDLE hTTButton = TBButtons[0];
		::CallService(MS_TTB_REMOVEBUTTON, (WPARAM)hTTButton, 0);
		TBButtons.remove(0);
	}
}
Пример #13
0
HRESULT ISmileyBase::Close(DWORD /* dwSaveOption */)
{
	regSmileys.remove(this);

	if (m_spAdviseSink) m_spAdviseSink->Release();
	m_spAdviseSink = NULL;

	return S_OK;
}
Пример #14
0
/*
*	Gets handle from queue for request
*/
static MCONTACT amGetCurrentChain()
{
	mir_cslock lck(amCS);
	if (amItems.getCount() == 0)
		return NULL;

	MCONTACT res = (MCONTACT)amItems[0];
	amItems.remove(0);
	return res;
}
Пример #15
0
void KillModuleScheduleTasks()
{
	mir_cslock lock(threadLock);

	while (ScheduleTask *task = tasks[0])
	{
		tasks.remove(task);
		DestroyTask(task);
	}
}
Пример #16
0
void KillModuleHotkeys(int hLangpack)
{
	for (int i = hotkeys.getCount() - 1; i >= 0; i--) {
		THotkeyItem *item = hotkeys[i];
		if (item->hLangpack == hLangpack) {
			FreeHotkey(item);
			hotkeys.remove(i);
		}
	}
}
Пример #17
0
	void UnloadSmiley(void)
	{
		regAniSmileys.remove(this);

		if (timerId && (timerId+1) && regAniSmileys.getCount() == 0) {
			KillTimer(NULL, timerId);
			timerId = 0;
		}
		if (m_img) m_img->Release();
		m_img = NULL;
	}
Пример #18
0
// delete contact from the list of secureIM users
void delContact(HANDLE hContact)
{
	pUinKey p = arClist.find((pUinKey)&hContact);
	if (p) {
		arClist.remove(p);

		cpp_delete_context(p->cntx); p->cntx = 0;
		mir_free(p->tmp);
		mir_free(p->msgSplitted);
		mir_free(p);
	}
}
Пример #19
0
static int lua_RemoveButton(lua_State *L)
{
	HANDLE hTTButton = (HANDLE)lua_touserdata(L, 1);

	INT_PTR res = ::CallService(MS_TTB_REMOVEBUTTON, (WPARAM)hTTButton, 0);
	lua_pushinteger(L, res);

	if (!res)
		TBButtons.remove(hTTButton);

	return 1;
}
Пример #20
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);
}
Пример #21
0
// perform any API related tasks to freeing
static void Plugin_Uninit(pluginEntry * p)
{
	// if it was an installed database plugin, call its unload
	if ( p->pclass & PCLASS_DB )
		p->bpi.dblink->Unload( p->pclass & PCLASS_OK );

	// if the basic API check had passed, call Unload if Load() was ever called
	if ( p->pclass & PCLASS_LOADED )
		p->bpi.Unload();

	// release the library
	if ( p->bpi.hInst != NULL ) {
		// we need to kill all resources which belong to that DLL before calling FreeLibrary
		KillModuleEventHooks( p->bpi.hInst );
		KillModuleServices( p->bpi.hInst );

		FreeLibrary( p->bpi.hInst );
		ZeroMemory( &p->bpi, sizeof( p->bpi ));
	}
	pluginList.remove( p );
	pluginListAddr.remove( p );
}
Пример #22
0
void SvcFlagsUnloadModule()
{
	//Uninit message winsow
	for (int i = 0; i < gMsgWndList.getCount(); i++) {
		//this should not happen
		delete gMsgWndList[i];
		gMsgWndList.remove(i);
	}
	gMsgWndList.destroy();

	// Uninit misc
	UninitIcons();
}
Пример #23
0
MIR_APP_DLL(int) Menu_RemoveObject(int hMenuObject)
{
	if (!bIsGenMenuInited || hMenuObject == 0)
		return -1;

	mir_cslock lck(csMenuHook);
	TIntMenuObject *pmo = GetMenuObjbyId(hMenuObject);
	if (pmo == NULL)
		return -1;

	g_menus.remove(pmo);
	delete pmo;
	return 0;
}
Пример #24
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);
}
Пример #25
0
static INT_PTR CB_RemoveButton(WPARAM, LPARAM lParam)
{
	BBButton *bbdi = (BBButton *)lParam;
	if (!bbdi)
		return 1;

	DWORD tempCID = 0;
	DWORD dwFlags = 0;
	{
		mir_cslock lck(ToolBarCS);

		for (int i = LButtonsList.getCount()-1; i >= 0; i--) {
			CustomButtonData *cbd = LButtonsList[i];
			if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && cbd->dwButtonOrigID == bbdi->dwButtonID) {
				tempCID = cbd->dwButtonCID;
				dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
				LButtonsList.remove(i);
			}
		}

		if (!tempCID) {
			for (int i = RButtonsList.getCount()-1; i >= 0; i--) {
				CustomButtonData *cbd = RButtonsList[i];
				if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && cbd->dwButtonOrigID == bbdi->dwButtonID) {
					tempCID = cbd->dwButtonCID;
					dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
					RButtonsList.remove(i);
				}
			}
		}
	}

	if (tempCID)
		M.BroadcastMessage(DM_CBDESTROY, (WPARAM)tempCID, (LPARAM)dwFlags);
	return 0;
}
Пример #26
0
CVkProto::~CVkProto()
{
	debugLogA("CVkProto::~CVkProto");
	Netlib_CloseHandle(m_hNetlibUser); 
	m_hNetlibUser = NULL;
	UninitQueue();
	UnInitMenus();
	if (m_hPopupClassError)
		Popup_UnregisterClass(m_hPopupClassError);
	if (m_hPopupClassNotification)
		Popup_UnregisterClass(m_hPopupClassNotification);
	{
		mir_cslock lck(csInstances);
		vk_Instances.remove(this);
	}
}
Пример #27
0
static VOID CALLBACK MsgTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
	LIST<TMsgQueue> arTimedOut(1);
	{
		mir_cslock lck(csMsgQueue);
		for (int i = msgQueue.getCount() - 1; i >= 0; i--) {
			TMsgQueue *item = msgQueue[i];
			if (dwTime - item->ts > g_dat.msgTimeout) {
				arTimedOut.insert(item);
				msgQueue.remove(i);
			}
		}
	}

	for (int i = 0; i < arTimedOut.getCount(); ++i)
		MessageFailureProcess(arTimedOut[i], LPGEN("The message send timed out."));
}
Пример #28
0
//wparam=MenuObjectHandle
INT_PTR MO_RemoveMenuObject(WPARAM wParam, LPARAM)
{
	int objidx;

	if ( !bIsGenMenuInited) return -1;
	EnterCriticalSection( &csMenuHook );

	objidx = GetMenuObjbyId(( int )wParam );
	if ( objidx == -1 ) {
		LeaveCriticalSection( &csMenuHook );
		return -1;
	}

	delete g_menus[ objidx ];
	g_menus.remove( objidx );
	LeaveCriticalSection( &csMenuHook );
	return 0;
}
Пример #29
0
// wparam = (HANDLE)hTTButton
// lparam = 0
INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM)
{
	mir_cslock lck(csButtonsHook);

	int idx;
	TopButtonInt *b = idtopos(wParam, &idx);
	if (b == NULL)
		return -1;

	RemoveFromOptions(b->id);

	Buttons.remove(idx);
	delete b;

	g_ctrl->bOrderChanged = TRUE;
	ArrangeButtons();
	return 0;
}
Пример #30
0
static INT_PTR destroyAvatar(WPARAM wParam, LPARAM)
{
	flash_avatar_item key(((FLASHAVATAR*)wParam)->hContact, *(FLASHAVATAR*)wParam, NULL);

	Lock l(cs);

	flash_avatar_item *item = FlashList.find(&key);
	if (item) {
		if (item->pFlash)
			item->pFlash->Release();
		if (item->hFA.hWindow)
			DestroyWindow(item->hFA.hWindow);
		mir_free(item->hFA.cUrl);
		FlashList.remove(item);
		delete item;
	}
	return 0;
}