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; }
static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam) { int i; char *pszName = (char *)lParam; char pszNamePrefix[MAXMODULELABELLENGTH]; size_t cbNamePrefix; mir_snprintf(pszNamePrefix, _countof(pszNamePrefix), "%s$", pszName); cbNamePrefix = mir_strlen(pszNamePrefix); for (i = 0; i < hotkeys.getCount(); i++) { char *pszCurrentName = hotkeys[i]->rootHotkey ? hotkeys[i]->rootHotkey->pszName : hotkeys[i]->pszName; if (!pszCurrentName) continue; hotkeys[i]->UnregisterHotkey = !mir_strcmp(pszCurrentName, pszName) || !strncmp(pszCurrentName, pszNamePrefix, cbNamePrefix); } if (g_hwndHkOptions) SendMessage(g_hwndHkOptions, WM_HOTKEYUNREGISTERED, 0, 0); for (i = 0; i < hotkeys.getCount(); i++) if (hotkeys[i]->UnregisterHotkey) { FreeHotkey(hotkeys[i]); List_Remove((SortedList *)&hotkeys, i); --i; } return 0; }
void UnloadNewPluginsModule(void) { int i; if ( !bModuleInitialized ) return; // unload everything but the DB for ( i = pluginList.getCount()-1; i >= 0; i-- ) { pluginEntry* p = pluginList[i]; if ( !(p->pclass & PCLASS_DB) && p != pluginList_crshdmp ) Plugin_Uninit( p ); } if ( pluginList_crshdmp ) Plugin_Uninit( pluginList_crshdmp ); // unload the DB for ( i = pluginList.getCount()-1; i >= 0; i-- ) { pluginEntry* p = pluginList[i]; Plugin_Uninit( p ); } if ( hPluginListHeap ) HeapDestroy(hPluginListHeap); hPluginListHeap=0; pluginList.destroy(); pluginListAddr.destroy(); UninitIni(); }
void BB_UpdateIcons(HWND hdlg, TWindowData *dat) { HWND hwndBtn = NULL; for (int i = 0; i < LButtonsList.getCount(); i++) { CustomButtonData *cbd = LButtonsList[i]; if (cbd) { if (!cbd->bSeparator) hwndBtn = GetDlgItem(hdlg, cbd->dwButtonCID); if (hwndBtn && cbd->hIcon) SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon)); } } hwndBtn = NULL; for (int i = 0; i < RButtonsList.getCount(); i++) { CustomButtonData *cbd = RButtonsList[i]; if (cbd) { if (!cbd->bSeparator) hwndBtn = GetDlgItem(hdlg, cbd->dwButtonCID); if (hwndBtn && cbd->hIcon) SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon)); } } }
MIR_CORE_DLL(int) TimeZone_SelectListItem(MCONTACT hContact, LPCSTR szModule, HWND hWnd, DWORD dwFlags) { const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags); if (lstMsg == NULL) return -1; if (szModule == NULL) szModule = "UserInfo"; int iSelection = 0; ptrT tszName(db_get_tsa(hContact, szModule, "TzName")); if (tszName != NULL) { unsigned hash = mir_hashstrT(tszName); for (int i = 0; i < g_timezonesBias.getCount(); i++) { if (hash == g_timezonesBias[i]->hash) { iSelection = i + 1; break; } } } else { signed char cBias = db_get_b(hContact, szModule, "Timezone", -100); if (cBias != -100) { int iBias = cBias * 30; for (int i = 0; i < g_timezonesBias.getCount(); i++) { if (iBias == g_timezonesBias[i]->tzi.Bias) { iSelection = i + 1; break; } } } } SendMessage(hWnd, lstMsg->setSel, iSelection, 0); return iSelection; }
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); }
void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups) { extraIconsByHandle.destroy(); for (int i=0; i < registeredExtraIcons.getCount(); i++) extraIconsByHandle.insert(registeredExtraIcons[i]); for (int k=0; k < extraIconsBySlot.getCount(); k++) { ExtraIcon *extra = extraIconsBySlot[k]; if (extra->getType() == EXTRAICON_TYPE_GROUP) delete extra; } extraIconsBySlot.destroy(); for (int i=0; i < groups.getCount(); i++) { ExtraIconGroup *group = groups[i]; for (int j = 0; j < group->m_items.getCount(); j++) extraIconsByHandle.put(group->m_items[j]->getID()-1, group); extraIconsBySlot.insert(group); } for (int k=0; k < extraIconsByHandle.getCount(); k++) { ExtraIcon *extra = extraIconsByHandle[k]; if (extra->getType() != EXTRAICON_TYPE_GROUP) extraIconsBySlot.insert(extra); } }
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; } } }
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); }
~TTreeList_ItemInfo() { for (int i = text.getCount(); i--;) mir_free(text[i]); for (int k = subItems.getCount(); k--;) delete subItems[k]; }
~TTreeList_ItemInfo() { int i; for (i = text.getCount(); i--; ) mir_free(text[i]); text.destroy(); for (i = subItems.getCount(); i--; ) delete subItems[i]; subItems.destroy(); }
static INT_PTR CB_ModifyButton(WPARAM, LPARAM lParam) { BBButton *bbdi = (BBButton *)lParam; if (!bbdi) return 1; bool bFound = 1; CustomButtonData *cbd = NULL; { mir_cslock lck(ToolBarCS); for (int i = 0; i < LButtonsList.getCount(); i++) { cbd = LButtonsList[i]; if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) { bFound = true; break; } } if (!bFound) { for (int i = 0; i < RButtonsList.getCount(); i++) { cbd = RButtonsList[i]; if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) { bFound = true; break; } } } if (bFound) { if (bbdi->pszTooltip) { mir_free(cbd->ptszTooltip); if (bbdi->bbbFlags & BBBF_ANSITOOLTIP) cbd->ptszTooltip = mir_a2u(bbdi->pszTooltip); else cbd->ptszTooltip = mir_tstrdup(bbdi->ptszTooltip); } if (bbdi->hIcon) cbd->hIcon = bbdi->hIcon; if (bbdi->bbbFlags) { cbd->bHidden = (bbdi->bbbFlags & BBBF_HIDDEN) != 0; cbd->bLSided = (bbdi->bbbFlags & BBBF_ISLSIDEBUTTON) != 0; cbd->bRSided = (bbdi->bbbFlags & BBBF_ISRSIDEBUTTON) != 0; cbd->bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0; cbd->bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0; cbd->bIMButton = (bbdi->bbbFlags & BBBF_ISIMBUTTON) != 0; cbd->bDisabled = (bbdi->bbbFlags & BBBF_DISABLED) != 0; } } } if (bFound) M.BroadcastMessage(DM_BBNEEDUPDATE, 0, (LPARAM)cbd); return 0; }
void UnloadExtraIconsModule(void) { for (int k = 0; k < extraIconsBySlot.getCount(); k++) { ExtraIcon *extra = extraIconsBySlot[k]; if (extra->getType() == EXTRAICON_TYPE_GROUP) delete extra; } for (int i = 0; i < registeredExtraIcons.getCount(); i++) delete registeredExtraIcons[i]; }
void RichEditData_Destroy(void) { int i; for (i=g_RichEditList.getCount()-1; i >= 0; i--) CloseRichCallback(g_RichEditList[i]->hwnd); g_RichEditList.destroy(); for (i=g_RichEditOwnerList.getCount()-1; i >= 0; i--) CloseRichOwnerCallback(g_RichEditOwnerList[i]->hwnd); g_RichEditOwnerList.destroy(); }
void BB_RefreshTheme(const TWindowData *dat) { for (int i = 0; i < RButtonsList.getCount(); i++) { CustomButtonData* cbd = RButtonsList[i]; SendMessage(GetDlgItem(dat->hwnd, cbd->dwButtonCID), WM_THEMECHANGED, 0, 0); } for (int i = 0; i < LButtonsList.getCount(); i++) { CustomButtonData* cbd = LButtonsList[i]; SendMessage(GetDlgItem(dat->hwnd, cbd->dwButtonCID), WM_THEMECHANGED, 0, 0); } }
char * GetPluginNameByInstance( HINSTANCE hInstance ) { int i = 0; if ( pluginList.getCount() == 0) return NULL; for (i = 0; i < pluginList.getCount(); i++) { pluginEntry* pe = pluginList[i]; if (pe->bpi.pluginInfo && pe->bpi.hInst == hInstance) return pe->bpi.pluginInfo->shortName; } return NULL; }
void FreeResidentSettings() { for (int i = 0; i < m_lResidentSettings.getCount(); i++) { mir_free(m_lResidentSettings[i]); } m_lResidentSettings.destroy(); for (int i = 0; i < m_lResidentModules.getCount(); i++) { mir_free(m_lResidentModules[i]); } m_lResidentModules.destroy(); }
static void wipeList(LIST<CustomButtonData> &list) { for (int i = list.getCount()-1; i >= 0; i--) { delete list[i]; list.remove(i); } }
static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam) { if (code == HC_ACTION && !(HIWORD(lParam) & KF_UP)) { BYTE mod = 0, vk = wParam; if (vk) { if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL; if (GetAsyncKeyState(VK_MENU)) mod |= MOD_ALT; if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT; if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN; for (int i = 0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; if (item->type != HKT_LOCAL || !item->Enabled) continue; BYTE hkMod, hkVk; sttWordToModAndVk(item->Hotkey, &hkMod, &hkVk); if (!hkVk) continue; if (item->pszService && vk == hkVk && mod == hkMod) { CallService(item->pszService, 0, item->lParam); return TRUE; } } } } return CallNextHookEx(hhkKeyboard, code, wParam, lParam); }
static INT_PTR svcHotkeyCheck(WPARAM wParam, LPARAM lParam) { MSG *msg = (MSG *)wParam; TCHAR *pszSection = mir_a2t((char *)lParam); if ((msg->message == WM_KEYDOWN) || (msg->message == WM_SYSKEYDOWN)) { int i; BYTE mod = 0, vk = msg->wParam; if (vk) { if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL; if (GetAsyncKeyState(VK_MENU)) mod |= MOD_ALT; if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT; if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN; for (i = 0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; BYTE hkMod, hkVk; if ((item->type != HKT_MANUAL) || mir_tstrcmp(pszSection, item->ptszSection)) continue; sttWordToModAndVk(item->Hotkey, &hkMod, &hkVk); if (!hkVk) continue; if (!item->Enabled) continue; if ((vk == hkVk) && (mod == hkMod)) { mir_free(pszSection); return item->lParam; } } } } mir_free(pszSection); return 0; }
static int timeapiSelectListItem(HANDLE hContact, HWND hWnd, DWORD dwFlags) { if (hWnd == NULL) // nothing to do return -1; const ListMessages *lstMsg = GetListMessages(hWnd, dwFlags); if (lstMsg == NULL) return -1; int iSelection = 0; if (hContact) { DBVARIANT dbv; if (!DBGetContactSettingTString(hContact, "UserInfo", "TzName", &dbv)) { unsigned hash = hashstr(dbv.ptszVal); for (int i = 0; i < g_timezonesBias.getCount(); ++i) { if (hash == g_timezonesBias[i]->hash) { iSelection = i + 1; break; } } DBFreeVariant(&dbv); } } SendMessage(hWnd, lstMsg->setSel, iSelection, 0); return iSelection; }
int MO_RemoveAllObjects() { for (int i = 0; i < g_menus.getCount(); i++) delete g_menus[i]; g_menus.destroy(); return 0; }
void UnloadNetlibModule(void) { if (!bModuleInitialized) return; if (hConnectionHeaderMutex != NULL) { int i; NetlibUnloadIeProxy(); NetlibSecurityDestroy(); NetlibUPnPDestroy(); NetlibLogShutdown(); DestroyHookableEvent(hRecvEvent); hRecvEvent = NULL; DestroyHookableEvent(hSendEvent); hSendEvent = NULL; for (i = netlibUser.getCount(); i > 0; i--) NetlibCloseHandle((WPARAM)netlibUser[i-1], 0); netlibUser.destroy(); CloseHandle(hConnectionHeaderMutex); if (hConnectionOpenMutex) CloseHandle(hConnectionOpenMutex); DeleteCriticalSection(&csNetlibUser); WSACleanup(); } }
INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam) { CCSDATA *ccs = (CCSDATA*)lParam; INT_PTR ret; if (wParam == (WPARAM)(-1)) return 1; for (int i = wParam; i < filters.getCount(); i++) { if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) { //chain was started, exit return ret; } } char szProto[40]; if (GetProtocolP((MCONTACT)ccs->hContact, szProto, sizeof(szProto))) return 1; PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa == NULL || pa->ppro == NULL) return 1; if (pa->bOldProto) ret = CallProtoServiceInt(ccs->hContact, szProto, ccs->szProtoService, (WPARAM)(-1), (LPARAM)ccs); else ret = CallProtoServiceInt(ccs->hContact, szProto, ccs->szProtoService, ccs->wParam, ccs->lParam); if (ret == CALLSERVICE_NOTFOUND) ret = 1; return ret; }
int EnumResidentModules(ModuleSettingLL *msll) { msll->first = 0; msll->last = 0; if (!m_lResidentModules.getCount()) return 0; int cnt = 0; for (int i = 0; i < m_lResidentModules.getCount(); i++) { enumModulesSettingsProc(m_lResidentModules[i], 0, (LPARAM)msll); cnt++; } return cnt; }
void CloseSmileys(void) { for (int i=regSmileys.getCount()-1; i >= 0; i--) { regSmileys[i]->OnClose(); regSmileys[i]->Close(OLECLOSE_NOSAVE); } }
INT_PTR CallContactService(MCONTACT hContact, const char *szProtoService, WPARAM wParam, LPARAM lParam) { INT_PTR ret; CCSDATA ccs = { hContact, szProtoService, wParam, lParam }; for (int i=0; i < filters.getCount(); i++) { if ((ret = CallProtoServiceInt(hContact, filters[i]->szName, szProtoService, i+1, (LPARAM)&ccs)) != CALLSERVICE_NOTFOUND) { //chain was started, exit return ret; } } char szProto[40]; if ( GetProtocolP((MCONTACT)hContact, szProto, sizeof(szProto))) return 1; PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa == NULL || pa->ppro == NULL) return 1; if (pa->bOldProto) ret = CallProtoServiceInt(hContact, szProto, szProtoService, (WPARAM)(-1), (LPARAM)&ccs); else ret = CallProtoServiceInt(hContact, szProto, szProtoService, wParam, lParam); if (ret == CALLSERVICE_NOTFOUND) ret = 1; return ret; }
void FreeTypes() { // Destroy services int i; for(i = 0; i < MAX_REGS(hServices); ++i) DestroyServiceFunction(hServices[i]); // Free internal structs for(i = 0; i < types.getCount(); i++) { SPEAK_TYPE *type = types[i]; mir_free((void *) type->module); mir_free((void *) type->name); mir_free((void *) type->icon); if (type->numTemplates > 0) { for(int i = 0; i < type->numTemplates; i++) mir_free((void *) type->templates[i]); mir_free(type->templates); } mir_free(type); } types.destroy(); }
int OnIconChange(WPARAM, LPARAM) { mir_cslock lck(csButtonsHook); for (int i = 0; i < Buttons.getCount(); i++) { TopButtonInt *b = Buttons[i]; if (!b->hIconHandleUp && !b->hIconHandleDn) continue; if (b->hIconHandleUp) { IcoLib_ReleaseIcon(b->hIconUp); b->hIconUp = IcoLib_GetIconByHandle(b->hIconHandleUp); } if (b->hIconHandleDn) { IcoLib_ReleaseIcon(b->hIconDn); b->hIconDn = IcoLib_GetIconByHandle(b->hIconHandleDn); } DestroyWindow(b->hwnd); b->CreateWnd(); } if (g_ctrl->hWnd) { g_ctrl->bOrderChanged = true; PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); } return 0; }
void UnloadLangPackModule() { if (!bModuleInitialized) return; int i; for (i = 0; i < lMuuids.getCount(); i++) mir_free(lMuuids[i]); lMuuids.destroy(); LangPackEntry *p = g_pEntries; for (i = 0; i < g_entryCount; i++, p++) { if (p->pNext != NULL) { for (LangPackEntry *p1 = p->pNext; p1 != NULL;) { LangPackEntry *p2 = p1; p1 = p1->pNext; mir_free(p2->szLocal); mir_free(p2->wszLocal); mir_free(p2); } } mir_free(p->szLocal); mir_free(p->wszLocal); } if (g_entryCount) { mir_free(g_pEntries); g_pEntries = 0; g_entryCount = g_entriesAlloced = 0; } langPack.tszFileName[0] = langPack.tszFullPath[0] = 0; }