Example #1
0
/// \todo Make some assertion about # of constit. labels, and/or that
/// they are the lowest numbered ones?
void read_labels(const string filename) {
	assert(!open_label_list);

	ifstream fin(filename.c_str());
	assert(fin.is_open());

	_all_labels.clear();
	_all_constituent_labels.clear();
	_all_terminal_labels.clear();
	_max_label = 0;

	label_list.clear();
	label_map.clear();
	terminal_set.clear();
	constituent_set.clear();

	unsigned i, is_terminal, cnt;
	string label;
	while(!fin.eof()) {
		fin >> i >> ws >> is_terminal >> ws >> cnt >> label >> ws;

		if (i == NO_LABEL)
			label = "";

		label_list.push_back(label);
		assert(label_list.at(i) == label);
		label_map[label] = i;	// FIXME: Don't use [] operator

		if (i != NO_LABEL) {
			_all_labels.push_back(i);
			if (is_terminal) {
				terminal_set.insert(i, true);
				_all_terminal_labels.push_back(i);
			} else {
				constituent_set.insert(i, true);
				_all_constituent_labels.push_back(i);
			}
			if (i > _max_label) _max_label = i+1;
		}
	}
	assert(label_list.at(NO_LABEL) == "");
	assert(label_map[""] == NO_LABEL);	// FIXME: Don't use [] operator
	assert(label_list.size() == label_map.size());
//	assert(label_map.size() == terminal_set.size() + constituent_set.size() + 1);
	terminal_set.lock();
	constituent_set.lock();

/*
	Debug::log(1) << "Read " << constituent_set.size() << " constituents, " << \
			terminal_set.size() << " terminals from '" << filename << "'\n";
*/

	fin.close();
	open_label_list = true;

	if (is_label_string("ADJP")) _Label_ADJP = string_to_label("ADJP");
	if (is_label_string("ADVP")) _Label_ADVP = string_to_label("ADVP");
	if (is_label_string("AUX")) _Label_AUX = string_to_label("AUX");
	if (is_label_string("AUXG")) _Label_AUXG = string_to_label("AUXG");
	if (is_label_string("CC")) _Label_CC = string_to_label("CC");
	if (is_label_string("CD")) _Label_CD = string_to_label("CD");
	if (is_label_string("COLON")) _Label_COLON = string_to_label(":");
	if (is_label_string("COMMA")) _Label_COMMA = string_to_label(",");
	if (is_label_string("CONJP")) _Label_CONJP = string_to_label("CONJP");
	if (is_label_string("DOLLAR")) _Label_DOLLAR = string_to_label("$");
	if (is_label_string("DT")) _Label_DT = string_to_label("DT");
	if (is_label_string("EX")) _Label_EX = string_to_label("EX");
	if (is_label_string("FRAG")) _Label_FRAG = string_to_label("FRAG");
	if (is_label_string("FW")) _Label_FW = string_to_label("FW");
	if (is_label_string("HASH")) _Label_HASH = string_to_label("#");
	if (is_label_string("IN")) _Label_IN = string_to_label("IN");
	if (is_label_string("INTJ")) _Label_INTJ = string_to_label("INTJ");
	if (is_label_string("JJ")) _Label_JJ = string_to_label("JJ");
	if (is_label_string("JJR")) _Label_JJR = string_to_label("JJR");
	if (is_label_string("JJS")) _Label_JJS = string_to_label("JJS");
	if (is_label_string("LS")) _Label_LS = string_to_label("LS");
	if (is_label_string("LST")) _Label_LST = string_to_label("LST");
	if (is_label_string("MD")) _Label_MD = string_to_label("MD");
	if (is_label_string("NAC")) _Label_NAC = string_to_label("NAC");
	if (is_label_string("NN")) _Label_NN = string_to_label("NN");
	if (is_label_string("NNP")) _Label_NNP = string_to_label("NNP");
	if (is_label_string("NNPS")) _Label_NNPS = string_to_label("NNPS");
	if (is_label_string("NNS")) _Label_NNS = string_to_label("NNS");
	if (is_label_string("NP")) _Label_NP = string_to_label("NP");
	if (is_label_string("NPB")) _Label_NPB = string_to_label("NPB");
	if (is_label_string("NX")) _Label_NX = string_to_label("NX");
	if (is_label_string("POS")) _Label_POS = string_to_label("POS");
	if (is_label_string("PP")) _Label_PP = string_to_label("PP");
	if (is_label_string("PRN")) _Label_PRN = string_to_label("PRN");
	if (is_label_string("PRP")) _Label_PRP = string_to_label("PRP");
	if (is_label_string("PRPP")) _Label_PRPP = string_to_label("PRP$");
	if (is_label_string("PRT")) _Label_PRT = string_to_label("PRT");
	if (is_label_string("QP")) _Label_QP = string_to_label("QP");
	if (is_label_string("RB")) _Label_RB = string_to_label("RB");
	if (is_label_string("RBR")) _Label_RBR = string_to_label("RBR");
	if (is_label_string("RBS")) _Label_RBS = string_to_label("RBS");
	if (is_label_string("RP")) _Label_RP = string_to_label("RP");
	if (is_label_string("RRC")) _Label_RRC = string_to_label("RRC");
	if (is_label_string("S")) _Label_S = string_to_label("S");
	if (is_label_string("SBAR")) _Label_SBAR = string_to_label("SBAR");
	if (is_label_string("SBARQ")) _Label_SBARQ = string_to_label("SBARQ");
	if (is_label_string("SINV")) _Label_SINV = string_to_label("SINV");
	if (is_label_string("SQ")) _Label_SQ = string_to_label("SQ");
	if (is_label_string("SYM")) _Label_SYM = string_to_label("SYM");
	if (is_label_string("TO")) _Label_TO = string_to_label("TO");
	if (is_label_string("TOP")) _Label_TOP = string_to_label("TOP");
	if (is_label_string("UCP")) _Label_UCP = string_to_label("UCP");
	if (is_label_string("UH")) _Label_UH = string_to_label("UH");
	if (is_label_string("VB")) _Label_VB = string_to_label("VB");
	if (is_label_string("VBD")) _Label_VBD = string_to_label("VBD");
	if (is_label_string("VBG")) _Label_VBG = string_to_label("VBG");
	if (is_label_string("VBN")) _Label_VBN = string_to_label("VBN");
	if (is_label_string("VBP")) _Label_VBP = string_to_label("VBP");
	if (is_label_string("VBZ")) _Label_VBZ = string_to_label("VBZ");
	if (is_label_string("VP")) _Label_VP = string_to_label("VP");
	if (is_label_string("WDT")) _Label_WDT = string_to_label("WDT");
	if (is_label_string("WHADJP")) _Label_WHADJP = string_to_label("WHADJP");
	if (is_label_string("WHADVP")) _Label_WHADVP = string_to_label("WHADVP");
	if (is_label_string("WHNP")) _Label_WHNP = string_to_label("WHNP");
	if (is_label_string("WHPP")) _Label_WHPP = string_to_label("WHPP");
	if (is_label_string("WP")) _Label_WP = string_to_label("WP");
	if (is_label_string("X")) _Label_X = string_to_label("X");
}
Example #2
0
int LoadNewPluginsModule(void)
{
	TCHAR exe[MAX_PATH];
	TCHAR* slice;
	pluginEntry* p;
	pluginEntry* clist = NULL;
	int useWhiteList, i;
	bool msgModule = false;

	// make full path to the plugin
	GetModuleFileName(NULL, exe, SIZEOF(exe));
	slice = _tcsrchr(exe, '\\');
	if (slice) *slice = 0;

	// remember some useful options
	askAboutIgnoredPlugins=(UINT) GetPrivateProfileInt( _T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini);

	// if Crash Dumper is present, load it to provide Crash Reports
	if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname)) 
    {
		if ( pluginList_crshdmp->bpi.Load(&pluginCoreLink) == 0 )
			pluginList_crshdmp->pclass |= PCLASS_LOADED | PCLASS_LAST;
		else
			Plugin_Uninit( pluginList_crshdmp );
    }

	// if freeimage is present, load it to provide the basic core functions
	if ( pluginList_freeimg != NULL ) {
		BASIC_PLUGIN_INFO bpi;
		mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), pluginList_freeimg->pluginname);
		if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) {
			pluginList_freeimg->bpi = bpi;
			pluginList_freeimg->pclass |= PCLASS_OK | PCLASS_BASICAPI;
			if ( bpi.Load(&pluginCoreLink) == 0 )
				pluginList_freeimg->pclass |= PCLASS_LOADED;
			else
				Plugin_Uninit( pluginList_freeimg );
	}	}

	// first load the clist cos alot of plugins need that to be present at Load()
	for ( useWhiteList = 1; useWhiteList >= 0 && clist == NULL; useWhiteList-- )
		clist=getCListModule(exe, slice, useWhiteList);
	/* the loop above will try and get one clist DLL to work, if all fail then just bail now */
	if ( clist == NULL ) {
		// result = 0, no clist_* can be found
		if ( pluginListUI )
			MessageBox(NULL, TranslateT("Unable to start any of the installed contact list plugins, I even ignored your preferences for which contact list couldn't load any."), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION);
		else
			MessageBox(NULL, TranslateT("Can't find a contact list plugin! you need clist_classic or any other clist plugin.") , _T("Miranda IM"), MB_OK | MB_ICONINFORMATION);
		return 1;
	}

	/* enable and disable as needed  */
	p = pluginListUI;
	while ( p != NULL ) {
		SetPluginOnWhiteList(p->pluginname, clist != p ? 0 : 1 );
		p = p->nextclass;
	}
	/* now loop thru and load all the other plugins, do this in one pass */

	for ( i=0; i < pluginList.getCount(); i++ ) {
		p = pluginList[i];
		CharLower(p->pluginname);
		if (!(p->pclass & (PCLASS_LOADED | PCLASS_DB | PCLASS_CLIST))) 
		{
			if (isPluginOnWhiteList(p->pluginname))
			{
				BASIC_PLUGIN_INFO bpi;
				mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), p->pluginname);
				if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) {
					int rm = bpi.pluginInfo->replacesDefaultModule;
					p->bpi = bpi;
					p->pclass |= PCLASS_OK | PCLASS_BASICAPI;

					if ( pluginDefModList[rm] == NULL ) {
						pluginListAddr.insert( p );
						if ( bpi.Load(&pluginCoreLink) == 0 ) {
							p->pclass |= PCLASS_LOADED;
							msgModule |= (bpi.pluginInfo->replacesDefaultModule == DEFMOD_SRMESSAGE);
						}
						else {
							Plugin_Uninit( p );
							i--;
						}
						if ( rm ) pluginDefModList[rm]=p;
					} //if
					else {
						SetPluginOnWhiteList( p->pluginname, 0 );
						Plugin_Uninit( p );
						i--;
					}
				}
				else p->pclass |= PCLASS_FAILED;
			}
			else {
				Plugin_Uninit( p );
				i--;
			}
		}
		else if ( p->bpi.hInst != NULL )
		{
			pluginListAddr.insert( p );
			p->pclass |= PCLASS_LOADED;
		}
	}
	if (!msgModule)
		MessageBox(NULL, TranslateT("No messaging plugins loaded. Please install/enable one of the messaging plugins, for instance, \"srmm.dll\""), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION);

	HookEvent(ME_OPT_INITIALISE, PluginOptionsInit);
	return 0;
}
Example #3
0
INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
{
	if (wParam == 0)
		return 0;

	EXTRAICON_INFO *ei = (EXTRAICON_INFO *)wParam;
	if (ei->cbSize < (int)sizeof(EXTRAICON_INFO))
		return 0;
	if (ei->type != EXTRAICON_TYPE_CALLBACK && ei->type != EXTRAICON_TYPE_ICOLIB)
		return 0;
	if (IsEmpty(ei->name) || IsEmpty(ei->description))
		return 0;
	if (ei->type == EXTRAICON_TYPE_CALLBACK && (ei->ApplyIcon == NULL || ei->RebuildIcons == NULL))
		return 0;

	ptrT tszDesc(mir_a2t(ei->description));
	TCHAR *desc = TranslateTH(lParam, tszDesc);

	BaseExtraIcon *extra = GetExtraIconByName(ei->name);
	if (extra != NULL) {
		if (ei->type != extra->getType() || ei->type != EXTRAICON_TYPE_ICOLIB)
			return 0;

		// Found one, now merge it
		if (_tcsicmp(extra->getDescription(), desc)) {
			CMString newDesc = extra->getDescription();
			newDesc += _T(" / ");
			newDesc += desc;
			extra->setDescription(newDesc.c_str());
		}

		if (!IsEmpty(ei->descIcon))
			extra->setDescIcon(ei->descIcon);

		if (ei->OnClick != NULL)
			extra->setOnClick(ei->OnClick, ei->onClickParam);

		if (extra->getSlot() > 0) {
			if (clistRebuildAlreadyCalled)
				extra->rebuildIcons();
			if (clistApplyAlreadyCalled)
				extraIconsByHandle[extra->getID() - 1]->applyIcons();
		}

		return extra->getID();
	}

	int id = registeredExtraIcons.getCount() + 1;

	switch (ei->type) {
	case EXTRAICON_TYPE_CALLBACK:
		extra = new CallbackExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon,
			ei->RebuildIcons, ei->ApplyIcon, ei->OnClick, ei->onClickParam);
		break;
	case EXTRAICON_TYPE_ICOLIB:
		extra = new IcolibExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick,
			ei->onClickParam);
		break;
	default:
		return 0;
	}

	char setting[512];
	mir_snprintf(setting, SIZEOF(setting), "Position_%s", ei->name);
	extra->setPosition(db_get_w(NULL, MODULE_NAME, setting, 1000));

	mir_snprintf(setting, SIZEOF(setting), "Slot_%s", ei->name);
	int slot = db_get_w(NULL, MODULE_NAME, setting, 1);
	if (slot == (WORD)-1)
		slot = -1;
	extra->setSlot(slot);

	extra->hLangpack = (int)lParam;

	registeredExtraIcons.insert(extra);
	extraIconsByHandle.insert(extra);

	LIST<ExtraIconGroup> groups(1);
	LoadGroups(groups);

	ExtraIconGroup *group = IsInGroup(groups, extra);
	if (group != NULL)
		RebuildListsBasedOnGroups(groups);
	else {
		for (int i = 0; i < groups.getCount(); i++)
			delete groups[i];

		extraIconsBySlot.insert(extra);
	}

	if (slot >= 0 || group != NULL) {
		if (clistRebuildAlreadyCalled)
			extra->rebuildIcons();

		slot = 0;
		for (int i = 0; i < extraIconsBySlot.getCount(); i++) {
			ExtraIcon *ex = extraIconsBySlot[i];
			if (ex->getSlot() < 0)
				continue;

			int oldSlot = ex->getSlot();
			ex->setSlot(slot++);

			if (clistApplyAlreadyCalled && (ex == group || ex == extra || oldSlot != slot))
				extra->applyIcons();
		}
	}

	return id;
}
Example #4
0
// find user in the list of secureIM users and add him, if unknow
pUinKey findUinKey(HANDLE hContact)
{
	return arClist.find((pUinKey)&hContact);
}
Example #5
0
INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static bool windowInitialized = false;
	int i;

	switch (msg) {
	case WM_INITDIALOG:
		windowInitialized = false;

		TranslateDialogDefault(hwnd);

		SendMessage(GetDlgItem(hwnd, IDC_ICO_INFO), STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_MISC_NOTIFY,0), 0);

		CheckDlgButton(hwnd, IDC_CHK_ENABLEACTIONS, PopupOptions.actions&ACT_ENABLE ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_CHK_IMCONTACTSONLY, PopupOptions.actions&ACT_DEF_IMONLY ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_CHK_CONTACTSONLY, PopupOptions.actions&ACT_DEF_NOGLOBAL ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_CHK_DONTCLOSE, PopupOptions.actions&ACT_DEF_KEEPWND ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_CHK_LARGEICONS, PopupOptions.actions&ACT_LARGE ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_RD_TEXT, PopupOptions.actions&ACT_TEXT ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_RD_LEFTICONS, PopupOptions.actions&ACT_LEFTICONS ? TRUE : FALSE);
		CheckDlgButton(hwnd, IDC_RD_RIGHTICONS, PopupOptions.actions&ACT_RIGHTICONS ? TRUE : FALSE);

		{
			DWORD dwActiveItem = 0;
			HWND hCombo = GetDlgItem(hwnd, IDC_CB_LEFT);
			dwActiveItem = MouseOverride(hCombo, PopupOptions.overrideLeft);
			SendDlgItemMessage(hwnd, IDC_CB_LEFT, CB_SETCURSEL, dwActiveItem, 0);

			dwActiveItem = 0;
			hCombo = GetDlgItem(hwnd, IDC_CB_MIDDLE);
			dwActiveItem = MouseOverride(hCombo, PopupOptions.overrideMiddle);
			SendDlgItemMessage(hwnd, IDC_CB_MIDDLE, CB_SETCURSEL, dwActiveItem, 0);

			dwActiveItem = 0;
			hCombo = GetDlgItem(hwnd, IDC_CB_RIGHT);
			dwActiveItem = MouseOverride(hCombo, PopupOptions.overrideRight);
			SendDlgItemMessage(hwnd, IDC_CB_RIGHT, CB_SETCURSEL, dwActiveItem, 0);

			HWND hwndList = GetDlgItem(hwnd, IDC_ACTIONS);
			ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES|LVS_EX_LABELTIP);
			HIMAGELIST hImgList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 10, 1);
			ListView_SetImageList(hwndList, hImgList, LVSIL_SMALL);

			LVCOLUMN column = {0};
			column.mask = LVCF_TEXT|LVCF_WIDTH;
			column.pszText = TranslateT("Action");
			column.cx = 175;
			ListView_InsertColumn(hwndList, 0, &column);

			ListView_EnableGroupView(hwndList, TRUE);

			LIST<char> groups(1, strcmp);

			for (i = 0; i < gActions.getCount(); ++i) {
				char szGroup[64];
				char *szName = strchr(gActions[i]->lpzTitle, '/');
				if (!szName) szName = gActions[i]->lpzTitle;
				else ++szName;
				lstrcpynA(szGroup, gActions[i]->lpzTitle, szName - gActions[i]->lpzTitle);

				int grpId = 0;

				if ((grpId = groups.getIndex(szGroup)) < 0)
				{
					LVGROUP group = {0};
					group.cbSize = sizeof(group);
					group.mask = LVGF_HEADER|LVGF_GROUPID;
					LPWSTR wszGroup = mir_a2u(szGroup);
					group.pszHeader = TranslateW(wszGroup);
					group.cchHeader = lstrlenW(wszGroup);
					grpId = group.iGroupId = groups.getCount();
					int grpId = ListView_InsertGroup(hwndList, -1, &group);
					mir_free(wszGroup);
					groups.insert(mir_strdup(szGroup), groups.getCount());
				}

				LVITEM item = {0};
				item.mask = LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT|LVIF_STATE|LVIF_INDENT;
				item.iItem = i;
				ptrT tszName( mir_a2t(szName));
				item.pszText = TranslateTS(tszName);
				item.iImage = ImageList_AddIcon(hImgList, gActions[i]->lchIcon);
				item.lParam = i;
				item.mask |= LVIF_GROUPID;
				item.iGroupId = grpId;
				item.iIndent = 0;
				ListView_InsertItemW(hwndList, &item);

				ListView_SetItemState(hwndList, i, (gActions[i]->flags & PAF_ENABLED) ? 0x2000 : 0x1000, LVIS_STATEIMAGEMASK);
			}

			BOOL enabled = (PopupOptions.actions&ACT_ENABLE) ? TRUE : FALSE;
			for (i = 0; i < SIZEOF(controls); ++i)
				EnableWindow(GetDlgItem(hwnd, controls[i]), enabled);
		}
		windowInitialized = true;
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CHK_ENABLEACTIONS:
			PopupOptions.actions &= ~ACT_ENABLE;
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_CHK_ENABLEACTIONS) ? ACT_ENABLE : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			{
				BOOL enabled = (PopupOptions.actions & ACT_ENABLE) ? TRUE : FALSE;
				for (i=0; i < SIZEOF(controls); ++i)
					EnableWindow(GetDlgItem(hwnd, controls[i]), enabled);
			}
			break;

		case IDC_CHK_IMCONTACTSONLY:
			PopupOptions.actions &= ~ACT_DEF_IMONLY;
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_CHK_IMCONTACTSONLY) ? ACT_DEF_IMONLY : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_CHK_CONTACTSONLY:
			PopupOptions.actions &= ~ACT_DEF_NOGLOBAL;
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_CHK_CONTACTSONLY) ? ACT_DEF_NOGLOBAL : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_CHK_DONTCLOSE:
			PopupOptions.actions &= ~ACT_DEF_KEEPWND;
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_CHK_DONTCLOSE) ? ACT_DEF_KEEPWND : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_CHK_LARGEICONS:
			PopupOptions.actions &= ~ACT_LARGE;
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_CHK_LARGEICONS) ? ACT_LARGE : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_RD_TEXT:
			PopupOptions.actions &= ~(ACT_TEXT|ACT_LEFTICONS|ACT_RIGHTICONS);
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_CHK_ENABLEACTIONS) ? ACT_TEXT : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_RD_LEFTICONS:
			PopupOptions.actions &= ~(ACT_TEXT|ACT_LEFTICONS|ACT_RIGHTICONS);
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_RD_LEFTICONS) ? ACT_LEFTICONS : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_RD_RIGHTICONS:
			PopupOptions.actions &= ~(ACT_TEXT|ACT_LEFTICONS|ACT_RIGHTICONS);
			PopupOptions.actions |= IsDlgButtonChecked(hwnd, IDC_RD_RIGHTICONS) ? ACT_RIGHTICONS : 0;
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
			break;
		case IDC_PREVIEW:
			PopupPreview();
			break;
		case IDC_CB_LEFT:
		case IDC_CB_MIDDLE:
		case IDC_CB_RIGHT:
			PopupOptions.overrideLeft = SendDlgItemMessage(hwnd, IDC_CB_LEFT, CB_GETITEMDATA,
				SendDlgItemMessage(hwnd, IDC_CB_LEFT, CB_GETCURSEL,0,0),0);
			PopupOptions.overrideMiddle = SendDlgItemMessage(hwnd, IDC_CB_MIDDLE, CB_GETITEMDATA,
				SendDlgItemMessage(hwnd, IDC_CB_MIDDLE, CB_GETCURSEL,0,0),0);
			PopupOptions.overrideRight = SendDlgItemMessage(hwnd, IDC_CB_RIGHT, CB_GETITEMDATA,
				SendDlgItemMessage(hwnd, IDC_CB_RIGHT, CB_GETCURSEL,0,0),0);
			SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				LoadOption_Actions();
				break;

			case PSN_APPLY:
				db_set_dw(NULL, MODULNAME, "Actions", PopupOptions.actions);
				HWND hwndList = GetDlgItem(hwnd, IDC_ACTIONS);

				for (i=0; i < gActions.getCount(); ++i) {
					gActions[i]->flags = (ListView_GetItemState(hwndList, i, LVIS_STATEIMAGEMASK) == 0x2000) ? PAF_ENABLED : 0;
					db_set_b(NULL, "PopupActions", gActions[i]->lpzTitle, (gActions[i]->flags&PAF_ENABLED) ? 1 : 0);
				}

				//overrideActions
				db_set_dw(NULL, MODULNAME, "OverrideLeft", PopupOptions.overrideLeft);
				db_set_dw(NULL, MODULNAME, "OverrideMiddle", PopupOptions.overrideMiddle);
				db_set_dw(NULL, MODULNAME, "OverrideRight", PopupOptions.overrideRight);
			}
		break;

		case IDC_ACTIONS:
			NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
			if (windowInitialized && nmlv && nmlv->hdr.code == LVN_ITEMCHANGED && nmlv->uOldState != 0 && (nmlv->uNewState == 0x1000 || nmlv->uNewState == 0x2000))
				SendMessage(GetParent(hwnd), PSM_CHANGED,0,0);
		}
	}
	return FALSE;
}
Example #6
0
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hwndDlg, IDC_MODULES);
	CDbxMmapSA *p_Db = (CDbxMmapSA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	LVITEM item;
	int i, iRow, iIndex;
	NMLISTVIEW * hdr = (NMLISTVIEW *)lParam;
	WORD uid;

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
		p_Db = (CDbxMmapSA*)lParam;
		{
			HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 2, 0);
			ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_OTHER_LOADED));
			ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_OTHER_NOTLOADED));
			ListView_SetImageList(hwndList, hIml, LVSIL_SMALL);

			LVCOLUMN col;
			col.pszText = NULL;
			col.mask = LVCF_TEXT | LVCF_WIDTH;
			col.fmt = LVCFMT_LEFT;
			col.cx = 50;
			ListView_InsertColumn(hwndList, 1, &col);

			col.pszText = TranslateT("Dll");
			col.mask = LVCF_TEXT | LVCF_WIDTH;
			col.fmt = LVCFMT_LEFT;
			col.cx = 1000;
			ListView_InsertColumn(hwndList, 2, &col);

			col.pszText = TranslateT("Name");
			col.cx = 1000;
			ListView_InsertColumn(hwndList, 3, &col);

			col.pszText = TranslateT("Version");
			col.cx = 1000;
			ListView_InsertColumn(hwndList, 4, &col);
		}

		ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);

		uid = db_get_w(NULL, "SecureMMAP", "CryptoModule", 0);

		for (i = 0; i < arCryptors.getCount(); i++) {
			TCHAR buf[100];

			item.mask = LVIF_TEXT;
			item.iItem = i;
			item.iSubItem = 0;
			item.pszText = NULL;
			iRow = ListView_InsertItem(hwndList, &item);

			ListView_SetItemText(hwndList, iRow, 1, arCryptors[i]->dllname);
			_tcsncpy(buf, _A2T(arCryptors[i]->cryptor->Name), SIZEOF(buf));
			ListView_SetItemText(hwndList, iRow, 2, buf);
			mir_sntprintf(buf, SIZEOF(buf), _T("%d.%d.%d.%d"), HIBYTE(HIWORD(arCryptors[i]->cryptor->Version)), LOBYTE(HIWORD(arCryptors[i]->cryptor->Version)), HIBYTE(LOWORD(arCryptors[i]->cryptor->Version)), LOBYTE(LOWORD(arCryptors[i]->cryptor->Version)));
			ListView_SetItemText(hwndList, iRow, 3, buf);

			if (uid == arCryptors[i]->cryptor->uid && p_Db->m_bEncoding)
				ListView_SetCheckState(hwndList, i, 1);

			item.mask = LVIF_IMAGE;
			item.iItem = iRow;
			item.iSubItem = 0;
			item.iImage = (CryptoEngine == arCryptors[i]->cryptor && p_Db->m_bEncoding) ? 0 : 1;
			ListView_SetItem(hwndList, &item);
		}

		ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
		ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE);
		ListView_SetColumnWidth(hwndList, 2, LVSCW_AUTOSIZE);
		ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE);
		return TRUE;

	case WM_COMMAND:
		if (HIWORD(wParam) == STN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDC_EMAIL:
			case IDC_SITE:
				char buf[512];
				char *p = &buf[7];
				lstrcpyA(buf, "mailto:");
				if (GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7))
					CallService(MS_UTILS_OPENURL, 0, (LPARAM)(LOWORD(wParam) == IDC_EMAIL ? buf : p));
				break;
			}
		}
		break;

	case WM_NOTIFY:
		if (hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != (-1)) {
			iIndex = hdr->iItem;
			if (hdr->uNewState & 0x2000) {
				for (i = 0; i < arCryptors.getCount(); i++)
					if (i != iIndex)
						ListView_SetCheckState(hwndList, i, 0);

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}
			if (hdr->uNewState & 0x1000) {
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}
			if (hdr->uNewState & LVIS_SELECTED) {
				SetDlgItemTextA(hwndDlg, IDC_AUTHOR, arCryptors[iIndex]->cryptor->Author);
				{
					TCHAR *info_t = mir_a2t((char*)(arCryptors[iIndex]->cryptor->Info));
					SetDlgItemText(hwndDlg, IDC_INFO, TranslateTS(info_t));
					mir_free(info_t);
				}
				SetDlgItemTextA(hwndDlg, IDC_SITE, arCryptors[iIndex]->cryptor->Site);
				SetDlgItemTextA(hwndDlg, IDC_EMAIL, arCryptors[iIndex]->cryptor->Email);
				SetDlgItemTextA(hwndDlg, IDC_ENC, arCryptors[iIndex]->cryptor->Name);
				SetDlgItemInt(hwndDlg, IDC_UID, arCryptors[iIndex]->cryptor->uid, 0);
			}
			else {
				SetDlgItemTextA(hwndDlg, IDC_AUTHOR, "");
				SetDlgItemTextA(hwndDlg, IDC_INFO, "");
				SetDlgItemTextA(hwndDlg, IDC_SITE, "");
				SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
				SetDlgItemTextA(hwndDlg, IDC_ENC, "");
				SetDlgItemTextA(hwndDlg, IDC_UID, "");
			}

			break;
		}
		if (((LPNMHDR)lParam)->code == PSN_APPLY) {
			int alg = -1;
			for (i = 0; i < arCryptors.getCount(); i++) {
				if (ListView_GetCheckState(hwndList, i)) {
					alg = i;
					break;
				}
			}

			if (alg > -1) {
				if (!p_Db->m_bEncoding) {
					db_set_w(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
					p_Db->EncryptDB();
				}
				else {
					if (arCryptors[alg]->cryptor->uid != db_get_w(NULL, "SecureMMAP", "CryptoModule", -1)) {
						db_set_w(NULL, "SecureMMAP", "CryptoModule", arCryptors[alg]->cryptor->uid);
						p_Db->RecryptDB();
					}
				}
			}
			else if (p_Db->m_bEncoding)
				p_Db->DecryptDB();

			uid = db_get_w(NULL, "SecureMMAP", "CryptoModule", 0);

			for (i = 0; i < arCryptors.getCount(); i++) {
				if (uid == arCryptors[i]->cryptor->uid && p_Db->m_bEncoding)
					ListView_SetCheckState(hwndList, i, 1);

				item.mask = LVIF_IMAGE;
				item.iItem = i;
				item.iSubItem = 0;
				item.iImage = (CryptoEngine == arCryptors[i]->cryptor && p_Db->m_bEncoding) ? 0 : 1;

				ListView_SetItem(hwndList, &item);
			}

			return TRUE;

		}
		break;
	}

	return FALSE;
}
Example #7
0
static int UnloadDatabase(MIDatabase *db)
{
	g_Dbs.remove((CDbxKyoto*)db);
	delete (CDbxKyoto*)db;
	return 0;
}
Example #8
0
extern "C" int __declspec(dllexport) Unload()
{
	g_Instances.destroy();
	return 0;
}
Example #9
0
//******************************************************************************
PLAYER* Player_GetFirst()
{
    return PlayerList.GetFirst();
}
Example #10
0
//============ MANAGE THE ITEMS STORED IN DB ============
// get single setting that is found
// szSetting = the setting name
// lparam = the counter
int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam)
{
	LIST<char> *pList = (LIST<char>*)lparam;
	pList->insert(mir_strdup(szSetting));
	return 0;
}
Example #11
0
static CSametimeProto* sametime_proto_init(const char* pszProtoName, const TCHAR* tszUserName)
{
	CSametimeProto* proto = new CSametimeProto(pszProtoName, tszUserName);
	g_Instances.insert(proto);
	return proto;
}
Example #12
0
MIR_APP_DLL(void) Proto_EnumProtocols(int *nProtos, PROTOCOLDESCRIPTOR ***pProtos)
{
	if (nProtos) *nProtos = protos.getCount();
	if (pProtos) *pProtos = protos.getArray();
}
Example #13
0
INT_PTR CALLBACK CSWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	CSWindow* csw = (CSWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA);

	switch (message) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwnd);

		csw = (CSWindow*)lparam;
		arWindows.insert(csw);
		SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);

		csw->m_handle = hwnd;
		csw->initIcons();
		csw->initButtons();
		csw->m_listview = new CSListView(GetDlgItem(hwnd, IDC_CSLIST), csw);
		csw->m_listview->initItems(csw->m_itemslist->m_list->getListHead());
		csw->toggleButtons();
		csw->toggleEmptyListMessage();
		csw->loadWindowPosition();
		SetWindowText(hwnd, MODULENAME);
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wparam)) {
		case IDC_MODIFY:
		case IDC_ADD:
			csw->m_addModifyDlg = new CSAMWindow(LOWORD(wparam), csw);
			csw->m_addModifyDlg->exec();
			if (csw->m_addModifyDlg->m_bChanged) {
				if (LOWORD(wparam) == IDC_MODIFY)
					csw->m_itemslist->m_list->remove(csw->m_listview->getPositionInList());

				int selection = csw->m_itemslist->m_list->add(csw->m_addModifyDlg->m_item);
				csw->m_bSomethingChanged = TRUE;
				csw->m_listview->reinitItems(csw->m_itemslist->m_list->getListHead());
				csw->m_listview->setFullFocusedSelection(selection);
				csw->toggleButtons();
				csw->toggleEmptyListMessage();
			}
			delete csw->m_addModifyDlg;
			break;

		case IDC_REMOVE:
			if (getByte("ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION))
				if (MessageBox(hwnd, TranslateT("Do you really want to delete selected item?"), TranslateW(MODULENAME), MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION) == IDNO)
					break;

			csw->m_itemslist->m_list->remove(csw->m_listview->getPositionInList());
			csw->m_bSomethingChanged = TRUE;
			csw->m_listview->reinitItems(csw->m_itemslist->m_list->getListHead());
			csw->toggleButtons();
			csw->toggleEmptyListMessage();
			break;

		case IDC_FAVOURITE:
		{
			int selection = csw->m_listview->getPositionInList();
			StatusItem* f = new StatusItem(*csw->m_itemslist->m_list->get(selection));
			f->m_bFavourite = !f->m_bFavourite;
			csw->m_itemslist->m_list->remove(selection);
			selection = csw->m_itemslist->m_list->add(f);
			csw->m_bSomethingChanged = TRUE;
			csw->m_listview->reinitItems(csw->m_itemslist->m_list->getListHead());
			csw->m_listview->setFullFocusedSelection(selection);
			csw->toggleButtons();
		}
		break;

		case IDC_UNDO:
			csw->m_itemslist->m_list->destroy();
			csw->m_itemslist->loadItems(csw->m_protoName);
			csw->m_bSomethingChanged = FALSE;
			csw->m_listview->reinitItems(csw->m_itemslist->m_list->getListHead());
			csw->toggleButtons();
			csw->toggleEmptyListMessage();
			break;

		case IDC_IMPORT:
		{
			int result = getByte("DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT);
			if (result == TRUE)
				result = IDYES;
			else {
				result = MessageBox(hwnd,
					TranslateT("Do you want old database entries to be deleted after Import?"),
					TranslateW(MODULENAME), MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_ICONQUESTION);
				if (result == IDCANCEL)
					break;
			}

			importCustomStatuses(csw, result);
			csw->m_bSomethingChanged = TRUE;
			csw->toggleButtons();
			csw->toggleEmptyListMessage();
		}
		break;

		case IDC_FILTER:
			csw->toggleFilter();
			csw->toggleButtons();
			break;

		case IDC_FILTER_FIELD:
			if (HIWORD(wparam) == EN_CHANGE)
				csw->m_listview->reinitItems(csw->m_itemslist->m_list->getListHead());
			break;

		case IDCLOSE:    // close and save, no custom status
		case IDCANCEL:   // close and save, no custom status
		case IDC_CANCEL:   // close and save, cancel custom status
		case IDOK:       // close and save, set selected custom status
			if (LOWORD(wparam) == IDOK && csw->toggleButtons())
				SetStatus(IDOK, csw->m_itemslist->m_list->get(csw->m_listview->getPositionInList()), csw->m_protoName);
			if (LOWORD(wparam) == IDC_CANCEL)
				SetStatus(IDC_CANCEL, nullptr, csw->m_protoName);
			if (csw->m_bSomethingChanged)
				csw->m_itemslist->saveItems(csw->m_protoName);
			csw->saveWindowPosition(csw->m_handle);
			EndDialog(hwnd, FALSE);
			break;
		}
		return FALSE;

	case WM_NOTIFY:
		if (wparam == IDC_CSLIST) {
			NMHDR* pnmh = (NMHDR*)lparam;
			switch (pnmh->code) {
			case NM_DBLCLK:
				PostMessage(hwnd, WM_COMMAND, IDOK, 0L);
				break;

			case LVN_ITEMCHANGED:
			case NM_CLICK:
				csw->toggleButtons();
				break;
			}
		}
		return FALSE;

	case WM_CTLCOLORSTATIC:
		SetTextColor((HDC)wparam, RGB(174, 174, 174));
		if (((HWND)lparam == GetDlgItem(hwnd, IDC_NO_ITEMS)) || ((HWND)lparam == GetDlgItem(hwnd, IDC_ADD_SAMPLE)))
			return (INT_PTR)GetStockObject(WHITE_BRUSH);
		return NULL;

	case WM_DESTROY:
		SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
		arWindows.remove(csw);
		delete csw->m_listview;
		csw->deinitIcons();
		delete csw;
		break;
	}
	return FALSE;
}
Example #14
0
static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD) 
{
	for (int i=0; i < regAniSmileys.getCount(); i++)
		regAniSmileys[i]->ProcessTimerTick();
}
Example #15
0
void CJabberProto::SearchReturnResults(HANDLE  id, void * pvUsersInfo, U_TCHAR_MAP * pmAllFields)
{
	LIST<TCHAR> ListOfNonEmptyFields(20,(LIST<TCHAR>::FTSortFunc)TCharKeyCmp);
	LIST<TCHAR> ListOfFields(20);
	LIST<void>* plUsersInfo = (LIST<void>*)pvUsersInfo;
	int i, nUsersFound = plUsersInfo->getCount();

	// lets fill the ListOfNonEmptyFields but in users order
	for (i=0; i < nUsersFound; i++) {
		U_TCHAR_MAP* pmUserData = (U_TCHAR_MAP*)plUsersInfo->operator [](i);
		int nUserFields = pmUserData->getCount();
		for (int j=0; j < nUserFields; j++) {
			TCHAR *var = pmUserData->getKeyName(j);
			if (var && ListOfNonEmptyFields.getIndex(var) < 0)
					ListOfNonEmptyFields.insert(var);
	}	}

	// now fill the ListOfFields but order is from pmAllFields
	int nAllCount = pmAllFields->getCount();
	for (i=0; i < nAllCount; i++) {
		TCHAR * var=pmAllFields->getUnOrderedKeyName(i);
		if (var && ListOfNonEmptyFields.getIndex(var) < 0)
			continue;
		ListOfFields.insert(var);
	}

	// now lets transfer field names
	int nFieldCount = ListOfFields.getCount();

	JABBER_CUSTOMSEARCHRESULTS Results={0};
	Results.nSize=sizeof(Results);
	Results.pszFields=(TCHAR**)mir_alloc(sizeof(TCHAR*)*nFieldCount);
	Results.nFieldCount=nFieldCount;

	/* Sending Columns Titles */
	for (i=0; i < nFieldCount; i++) {
		TCHAR *var = ListOfFields[i];
		if (var)
			Results.pszFields[i] = pmAllFields->operator [](var);
	}

	Results.jsr.hdr.cbSize = 0; // sending column names
	ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results);

	/* Sending Users Data */
	Results.jsr.hdr.cbSize = sizeof(Results.jsr); // sending user data

	for (i=0; i < nUsersFound; i++) {
	   TCHAR buff[200]=_T("");
	   Results.jsr.jid[0]=0;
	   U_TCHAR_MAP * pmUserData = (U_TCHAR_MAP *) plUsersInfo->operator [](i);
	   for (int j=0; j < nFieldCount; j++) {
		   TCHAR* var = ListOfFields[j];
		   TCHAR* value = pmUserData->operator [](var);
		   Results.pszFields[j] = value ? value : (TCHAR *)_T(" ");
		   if (!_tcsicmp(var,_T("jid")) && value)
			   _tcsncpy(Results.jsr.jid, value, SIZEOF(Results.jsr.jid));
	   }
	   {
		   TCHAR * nickfields[]={ _T("nick"),		_T("nickname"),
								  _T("fullname"),	_T("name"),
								  _T("given"),		_T("first"),
								  _T("jid"), NULL };
		   TCHAR * nick=NULL;
		   int k=0;
		   while (nickfields[k] && !nick)   nick=pmUserData->operator [](nickfields[k++]);
		   if (_tcsicmp(nick, Results.jsr.jid))
			   mir_sntprintf(buff, SIZEOF(buff), _T("%s (%s)"), nick, Results.jsr.jid);
		   else
				_tcsncpy(buff, nick, SIZEOF(buff));
		   Results.jsr.hdr.nick = nick ? buff : NULL;
		   Results.jsr.hdr.flags = PSR_TCHAR;
	   }
	   ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results);
	   Results.jsr.hdr.nick=NULL;

	}
	mir_free(Results.pszFields);
}
Example #16
0
//******************************************************************************
PLAYER* Player_GetNext(PLAYER* Player)
{
    return PlayerList.GetNext( Player );
}
Example #17
0
void UnloadTreeData()
{
	for (int i = 0; i < gTreeData.getCount(); ++i)
		FreePopupClass(gTreeData[i]);
	gTreeData.destroy();
}
Example #18
0
//******************************************************************************
PLAYER::~PLAYER()
{
    PlayerList.Remove( this );
}
Example #19
0
static int CopyChatSetting(const char *szSetting, LPARAM param)
{
	LIST<char> *szSettings = (LIST<char>*)param;
	szSettings->insert(mir_strdup(szSetting));
	return 0;
}
Example #20
0
static int BuildMenuObjectsTree(HWND hToolBarTree)
{
	HTREEITEM hti;
	int iImage = 0;

	TVINSERTSTRUCT tvis;
	tvis.hParent = NULL;
	tvis.hInsertAfter = TVI_LAST;
	tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE;

	TreeView_DeleteAllItems(hToolBarTree);

	himgl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
	ImageList_AddIcon(himgl, LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT));
	ImageList_Destroy(TreeView_GetImageList(hToolBarTree, TVSIL_NORMAL));
	TreeView_SetImageList(hToolBarTree, himgl, TVSIL_NORMAL);

	if ((RButtonsList.getCount() + LButtonsList.getCount()) == 0)
		return FALSE;

	mir_cslock lck(ToolBarCS);

	for (int i = 0; i < LButtonsList.getCount(); i++) {
		CustomButtonData *cbd = LButtonsList[i];
		tvis.item.lParam = (LPARAM)cbd;

		if (cbd->bSeparator) {
			tvis.item.pszText = TranslateT("<Separator>");
			tvis.item.iImage = tvis.item.iSelectedImage = 0;
		}
		else {
			tvis.item.pszText = TranslateTS(cbd->ptszTooltip);
			iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->hIcon));
			tvis.item.iImage = tvis.item.iSelectedImage = iImage;
		}
		cbd->opFlags = 0;
		hti = TreeView_InsertItem(hToolBarTree, &tvis);

		TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
	}

	tvis.item.lParam = 0;
	tvis.item.mask |= TVIF_STATE;
	tvis.item.pszText = MIDDLE_SEPARATOR;
	tvis.item.stateMask = TVIS_BOLD;
	tvis.item.state = TVIS_BOLD;
	tvis.item.iImage = tvis.item.iSelectedImage = -1;
	hti = TreeView_InsertItem(hToolBarTree, &tvis);
	TreeView_SetCheckState(hToolBarTree, hti, 1);

	for (int i = RButtonsList.getCount()-1; i >= 0; i--) {
		CustomButtonData *cbd = RButtonsList[i];
		tvis.item.lParam = (LPARAM)cbd;

		if (cbd->bSeparator) {
			tvis.item.pszText = TranslateT("<Separator>");
			tvis.item.iImage = tvis.item.iSelectedImage = -1;
		}
		else {
			tvis.item.pszText = TranslateTS(cbd->ptszTooltip);
			iImage = ImageList_AddIcon(himgl, Skin_GetIconByHandle(cbd->hIcon));
			tvis.item.iImage = tvis.item.iSelectedImage = iImage;
		}
		tvis.item.state = 0;
		cbd->opFlags = 0;
		hti = TreeView_InsertItem(hToolBarTree, &tvis);
		TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
	}

	return 1;
}
Example #21
0
	/*!
	\brief 递归逐维分组碰撞算法

	当分组到达最小组数量的时候,将最小组作为参数调用
	SBC::SimpleColl
	\param group 参与碰撞检测的BOX组
	\param fData 帧数据指针
	\param minGroupSize 最小分组
	\param freeBlockList 空闲块链表
	\param axis1 当前检测的坐标轴
	\param axis2 下个递归检测的坐标轴
	*/
	void 
		RDCColl(LIST<BOX*> &group, const FRAMEDATA *fData, size_t minGroupSize, BUFFER *freeBlockList, AXIS axis1, AXIS axis2)
	{
		if(axis1 == AXIS_INVALID || group.SizeIfLessThan(minGroupSize))
		{
			SimpleColl(group, fData);
		}
		else
		{
			LIST<OPENCLOSEBOUNDARY> openCloseBoundaryList(&freeBlockList->m_collInfoBuffer);
			_FindOpenCloseBoundaryList(axis1, 
				group, openCloseBoundaryList);

			LIST<BOX*> subGroup(group.GetFreeBlockList());
			unsigned int count = 0;
			AXIS newAxis1 = axis2;
			AXIS newAxis2 = AXIS_INVALID;
			bool groupSubdivided = false;
			OPENCLOSEBOUNDARY *thisBoundaryPtr;
			for(LIST<OPENCLOSEBOUNDARY>::NOTE 
				*thisNote = openCloseBoundaryList.QSort();
				thisNote; thisNote = thisNote->GetNext())
			{
				thisBoundaryPtr = &thisNote->Get();
				if(thisBoundaryPtr->type == TYPE_OPEN)
				{
					++count;
					subGroup.Create(thisBoundaryPtr->pBox);
				}
				else
				{
					--count;
					if(count == 0)
					{
						if(thisNote != openCloseBoundaryList.GetLast())
						{
							groupSubdivided = true;
						}
						if(groupSubdivided)
						{
							if(newAxis1 == AXIS_X)
							{
								newAxis1 = AXIS_Y;
								newAxis2 = AXIS_X;
							}
							if(newAxis1 == AXIS_Y)
							{
								newAxis1 = AXIS_X;
								newAxis2 = AXIS_Y;
							}
						}
						RDCColl(subGroup,
							fData,
							minGroupSize,
							freeBlockList,
							newAxis1, 
							newAxis2);
						subGroup.Clear();
					}
				}
			} // for loop - end
		} // if - end
	} // RDCColl - end
Example #22
0
INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HTREEITEM hti;

	switch (uMsg) {
	case WM_INITDIALOG:
		hToolBarTree = GetDlgItem(hwndDlg, IDC_TOOLBARTREE);
		{
			LONG_PTR style = GetWindowLongPtr(hToolBarTree, GWL_STYLE);
			style ^= TVS_CHECKBOXES;
			SetWindowLongPtr(hToolBarTree, GWL_STYLE, style);
			style |= TVS_CHECKBOXES;
			style |= TVS_NOHSCROLL;
			SetWindowLongPtr(hToolBarTree, GWL_STYLE, style);
		}
		{
			mir_cslock lck(ToolBarCS);
			BuildMenuObjectsTree(hToolBarTree);
		}

		Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
		Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
		Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);

		SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 0));
		SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETPOS, 0, MAKELONG(PluginConfig.g_iButtonsBarGap, 0));
		TranslateDialogDefault(hwndDlg);
		bOptionsInit = FALSE;
		break;

	case WM_LBUTTONUP:
		if (drag) {
			TreeView_SetInsertMark(hToolBarTree, NULL, 0);
			drag = 0;
			ReleaseCapture();

			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hToolBarTree, &hti.pt);
			hti.pt.y -= TreeView_GetItemHeight(hToolBarTree) / 2;
			TreeView_HitTest(hToolBarTree, &hti);
			if (hDragItem == hti.hItem) break;
			if (hti.flags & TVHT_ABOVE)
				hti.hItem = TVI_FIRST;

			TVITEM tvi;
			tvi.mask = TVIF_HANDLE | TVIF_PARAM;
			tvi.hItem = (HTREEITEM)hDragItem;
			TreeView_GetItem(hToolBarTree, &tvi);
			if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
				TVINSERTSTRUCT tvis;
				TCHAR strbuf[128];
				tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
				tvis.item.stateMask = 0xFFFFFFFF;
				tvis.item.pszText = strbuf;
				tvis.item.cchTextMax = sizeof(strbuf);
				tvis.item.hItem = (HTREEITEM)hDragItem;
				TreeView_GetItem(hToolBarTree, &tvis.item);
				TreeView_DeleteItem(hToolBarTree, hDragItem);
				tvis.hParent = NULL;
				tvis.hInsertAfter = hti.hItem;
				TreeView_SelectItem(hToolBarTree, TreeView_InsertItem(hToolBarTree, &tvis));
				SendMessage((GetParent(hwndDlg)), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_MOUSEMOVE:
		if (drag) {
			TVHITTESTINFO hti;
			hti.pt.x = (short)LOWORD(lParam);
			hti.pt.y = (short)HIWORD(lParam);
			ClientToScreen(hwndDlg, &hti.pt);
			ScreenToClient(hToolBarTree, &hti.pt);
			TreeView_HitTest(hToolBarTree, &hti);
			if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
				HTREEITEM it = hti.hItem;
				hti.pt.y -= TreeView_GetItemHeight(hToolBarTree) / 2;
				TreeView_HitTest(hToolBarTree, &hti);
				if (!(hti.flags & TVHT_ABOVE))
					TreeView_SetInsertMark(hToolBarTree, hti.hItem, 1);
				else
					TreeView_SetInsertMark(hToolBarTree, it, 0);
			}
			else {
				if (hti.flags & TVHT_ABOVE) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
				if (hti.flags & TVHT_BELOW) SendMessage(hToolBarTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
				TreeView_SetInsertMark(hToolBarTree, NULL, 0);
			}
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam && (HWND)lParam != hToolBarTree)
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		if ((HIWORD(wParam) == EN_CHANGE) && ((HWND)lParam == GetFocus()))
			if (!bOptionsInit)
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

		switch (LOWORD(wParam)) {
		case IDC_BBRESET:
			CallService(MS_DB_MODULE_DELETE, NULL, LPARAM("TabSRMM_Toolbar"));
			CB_HardReInit();
			BuildMenuObjectsTree(hToolBarTree);
			break;

		case IDC_SEPARATOR:
			hti = TreeView_GetSelection(hToolBarTree);
			if (!hti)
				hti = TVI_FIRST;

			CustomButtonData *cbd = new CustomButtonData();
			cbd->bSeparator = cbd->bHidden = cbd->bIMButton = cbd->bLSided = true;
			cbd->dwButtonOrigID = ++dwSepCount;
			cbd->pszModuleName = "Tabsrmm_sep";
			cbd->iButtonWidth = 22;
			cbd->opFlags = BBSF_NTBDESTRUCT;
			LButtonsList.insert(cbd);

			TVINSERTSTRUCT tvis;
			tvis.hParent = NULL;
			tvis.hInsertAfter = hti;
			tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;

			tvis.item.pszText = TranslateT("<Separator>");
			tvis.item.iImage = tvis.item.iSelectedImage = -1;
			tvis.item.lParam = (LPARAM)cbd;
			hti = TreeView_InsertItem(hToolBarTree, &tvis);

			TreeView_SetCheckState(hToolBarTree, hti, (cbd->bIMButton || cbd->bChatButton));
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				CB_ReInitCustomButtons();
				dwSepCount = M.GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0);
				return 1;

			case PSN_APPLY:
				hti = TreeView_GetSelection(hToolBarTree);
				if (hti) {
					TVITEM tvi;
					tvi.mask = TVIF_HANDLE | TVIF_PARAM;
					tvi.hItem = hti;
					TreeView_GetItem(hToolBarTree, &tvi);

					if (tvi.lParam) {
						CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
						if (cbd) {
							cbd->bIMButton = IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) != 0;
							cbd->bChatButton = IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) != 0;
							cbd->bCanBeHidden = IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) != 0;
						}
					}
				}

				SaveTree(hToolBarTree);
				CB_ReInitCustomButtons();
				PluginConfig.g_iButtonsBarGap = (BYTE)SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_GETPOS, 0, 0);

				if (PluginConfig.g_iButtonsBarGap != M.GetByte("ButtonsBarGap", 1))
					M.BroadcastMessageAsync(WM_SIZE, 0, 0);

				db_set_b(0, SRMSGMOD_T, "ButtonsBarGap", PluginConfig.g_iButtonsBarGap);

				BuildMenuObjectsTree((HWND)hToolBarTree);
				Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
				Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
				Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
				return 1;
			}
			break;

		case IDC_TOOLBARTREE:
			switch (((LPNMHDR)lParam)->code) {
			case TVN_BEGINDRAGA:
			case TVN_BEGINDRAGW:
				SetCapture(hwndDlg);
				drag = 1;
				hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
				TreeView_SelectItem(hToolBarTree, hDragItem);
				break;

			case TVN_SELCHANGINGA:
			case TVN_SELCHANGINGW:
				hti = TreeView_GetSelection(hToolBarTree);
				if (hti != NULL) {
					TCHAR strbuf[128];

					TVITEM tvi;
					tvi.hItem = hti;
					tvi.pszText = strbuf;
					tvi.cchTextMax = sizeof(strbuf);
					tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM;
					TreeView_GetItem(hToolBarTree, &tvi);

					if (tvi.lParam == 0 || !TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !_tcscmp(tvi.pszText, MIDDLE_SEPARATOR))
						break;

					CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
					if (cbd) {
						cbd->opFlags = (IsDlgButtonChecked(hwndDlg, IDC_IMCHECK)) ? BBSF_IMBUTTON : 0;
						cbd->opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK)) ? BBSF_CHATBUTTON : 0;
						cbd->opFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN)) ? BBSF_CANBEHIDDEN : 0;

						cbd->bIMButton = (IsDlgButtonChecked(hwndDlg, IDC_IMCHECK) ? TRUE : FALSE);
						cbd->bChatButton = (IsDlgButtonChecked(hwndDlg, IDC_CHATCHECK) ? TRUE : FALSE);
						cbd->bCanBeHidden = (IsDlgButtonChecked(hwndDlg, IDC_CANBEHIDDEN) ? TRUE : FALSE);
					}
				}
				break;

			case TVN_SELCHANGEDW:
			case TVN_SELCHANGEDA:
				hti = TreeView_GetSelection(hToolBarTree);
				if (hti != NULL) {
					TCHAR strbuf[128];

					TVITEM tvi;
					tvi.pszText = strbuf;
					tvi.cchTextMax = sizeof(strbuf);
					tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM;
					tvi.hItem = hti;
					TreeView_GetItem(hToolBarTree, &tvi);

					if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !_tcscmp(tvi.pszText, MIDDLE_SEPARATOR)) {
						Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
						Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
						Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
						break;
					}

					if (tvi.lParam == 0)
						break;

					CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
					if (cbd) {
						Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, TRUE);
						Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, TRUE);
						Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, TRUE);
						CheckDlgButton(hwndDlg, IDC_IMCHECK, (cbd->bIMButton) ? 1 : 0);
						CheckDlgButton(hwndDlg, IDC_CHATCHECK, (cbd->bChatButton) ? 1 : 0);
						CheckDlgButton(hwndDlg, IDC_CANBEHIDDEN, (cbd->bCanBeHidden) ? 1 : 0);
					}
				}
				break;

			case NM_CLICK:
				TVHITTESTINFO hti = { 0 };
				GetCursorPos(&hti.pt);
				ScreenToClient(hToolBarTree, &hti.pt);
				if (TreeView_HitTest(hToolBarTree, &hti)) {
					if (hti.flags&TVHT_ONITEMSTATEICON) {
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
						if (TreeView_GetCheckState(hToolBarTree, hti.hItem)) {
							Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, FALSE);
							Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, FALSE);
							Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, FALSE);
							CheckDlgButton(hwndDlg, IDC_IMCHECK, 1);
						}
						else {
							Utils::enableDlgControl(hwndDlg, IDC_IMCHECK, TRUE);
							Utils::enableDlgControl(hwndDlg, IDC_CHATCHECK, TRUE);
							Utils::enableDlgControl(hwndDlg, IDC_CANBEHIDDEN, TRUE);
						}
						TreeView_SelectItem(hToolBarTree, hti.hItem);
					}
				}
			}
		}
		break;

	case WM_DESTROY:
		HIMAGELIST hIml = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TOOLBARTREE), TVSIL_NORMAL);
		ImageList_Destroy(hIml);
		hIml = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TOOLBARTREE), TVSIL_STATE);
		ImageList_Destroy(hIml);
		break;
	}

	return FALSE;
}
Example #23
0
pUinKey getUinKey(HANDLE hContact)
{
	pUinKey p = arClist.find((pUinKey)&hContact);
	return (p) ? p : addContact(hContact);
}
Example #24
0
void TSAPI BB_InitDlgButtons(TWindowData *dat)
{
	RECT rect;
	int i;
	int lwidth = 0, rwidth = 0;
	RECT rcSplitter;
	POINT ptSplitter;
	int splitterY;
	BYTE gap = DPISCALEX_S(PluginConfig.g_iButtonsBarGap);
	BOOL isThemed = TRUE;
	int cx = 0, cy = 0;
	int lcount = LButtonsList.getCount();
	int rcount = RButtonsList.getCount();
	HWND hdlg = dat->hwnd;

	if (dat == 0 || hdlg == 0) { return; }
	if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED &&
		 !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED) {
		isThemed = FALSE;
	}

	GetWindowRect(GetDlgItem(hdlg, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);
	ptSplitter.x = 0;
	ptSplitter.y = rcSplitter.top;
	ScreenToClient(hdlg, &ptSplitter);

	GetClientRect(hdlg, &rect);
	splitterY = ptSplitter.y - DPISCALEY_S(1);

	HWND hwndBtn = NULL;

	for (i = 0; i < RButtonsList.getCount(); i++) {
		CustomButtonData *cbd = RButtonsList[i];
		if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) {
			if (!cbd->bHidden)
				rwidth += cbd->iButtonWidth + gap;
			if (!cbd->bHidden && !cbd->bCanBeHidden)
				dat->iButtonBarReallyNeeds += cbd->iButtonWidth + gap;
			if (!cbd->bSeparator && !GetDlgItem(hdlg, cbd->dwButtonCID)) {
				hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, rect.right - rwidth + gap, splitterY, cbd->iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->dwButtonCID, g_hInst, NULL);
				CustomizeButton(hwndBtn);
			}
			if (!cbd->bSeparator && hwndBtn) {
				SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
				SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0);
				if (cbd->hIcon)
					SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
				if (cbd->ptszTooltip)
					SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(cbd->ptszTooltip), BATF_TCHAR);
				SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
				SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);

				if (hwndBtn && cbd->dwArrowCID)
					SendMessage(hwndBtn, BUTTONSETARROW, cbd->dwArrowCID, 0);
				if (hwndBtn && cbd->bPushButton)
					SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
			}
		}
		else if (GetDlgItem(hdlg, cbd->dwButtonCID))
			DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID));

		if (cbd->bDisabled)
			EnableWindow(hwndBtn, 0);
		if (cbd->bHidden)
			ShowWindow(hwndBtn, SW_HIDE);

	}

	hwndBtn = NULL;

	for (i = 0; i < LButtonsList.getCount(); i++) {
		CustomButtonData *cbd = LButtonsList[i];
		if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) {
			if (!cbd->bSeparator && !GetDlgItem(hdlg, cbd->dwButtonCID)) {
				hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, 2 + lwidth, splitterY,
												 cbd->iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->dwButtonCID, g_hInst, NULL);
				CustomizeButton(hwndBtn);
			}
			if (!cbd->bHidden)
				lwidth += cbd->iButtonWidth + gap;
			if (!cbd->bHidden && !cbd->bCanBeHidden)
				dat->iButtonBarReallyNeeds += cbd->iButtonWidth + gap;
			if (!cbd->bSeparator && hwndBtn) {
				SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0);
				SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0);
				if (cbd->hIcon)
					SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon));
				if (cbd->ptszTooltip)
					SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(cbd->ptszTooltip), BATF_TCHAR);
				SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0);
				SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0);

				if (hwndBtn && cbd->dwArrowCID)
					SendMessage(hwndBtn, BUTTONSETARROW, cbd->dwArrowCID, 0);
				if (hwndBtn && cbd->bPushButton)
					SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0);
			}
		}
		else if (GetDlgItem(hdlg, cbd->dwButtonCID))
			DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID));

		if (cbd->bDisabled)
			EnableWindow(hwndBtn, 0);
		if (cbd->bHidden)
			ShowWindow(hwndBtn, SW_HIDE);
	}

	dat->bbLSideWidth = lwidth;
	dat->bbRSideWidth = rwidth;
}
Example #25
0
void UnloadActions()
{
	for (int i=0; i < gActions.getCount(); ++i)
		delete gActions[i];
	gActions.destroy();
}
Example #26
0
BOOL TSAPI BB_SetButtonsPos(TWindowData *dat)
{
	HWND hwnd = dat->hwnd;
	if (!dat || !IsWindowVisible(hwnd))
		return 0;

	RECT rect;
	int  i;
	HWND hwndBtn = 0;

	BYTE gap = DPISCALEX_S(PluginConfig.g_iButtonsBarGap);
	bool showToolbar = !(dat->pContainer->dwFlags & CNT_HIDETOOLBAR);
	bool bBottomToolbar = (dat->pContainer->dwFlags & CNT_BOTTOMTOOLBAR) != 0;

	HDWP hdwp = BeginDeferWindowPos(LButtonsList.getCount() + RButtonsList.getCount() + 1);

	HWND hwndToggleSideBar = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_TOGGLESIDEBAR : IDC_CHAT_TOGGLESIDEBAR);
	ShowWindow(hwndToggleSideBar, (showToolbar && dat->pContainer->SideBar->isActive()) ? SW_SHOW : SW_HIDE);

	mir_cslock lck(ToolBarCS);

	RECT rcSplitter;
	GetWindowRect(GetDlgItem(hwnd, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter);

	POINT ptSplitter = { 0, rcSplitter.top };
	ScreenToClient(hwnd, &ptSplitter);

	GetClientRect(hwnd, &rect);

	int splitterY = (!bBottomToolbar) ? ptSplitter.y - DPISCALEY_S(1) : rect.bottom;
	int tempL = dat->bbLSideWidth, tempR = dat->bbRSideWidth;
	int lwidth = 0, rwidth = 0;
	int iOff = DPISCALEY_S((PluginConfig.g_DPIscaleY > 1.0) ? (dat->bType == SESSIONTYPE_IM ? 22 : 23) : 22);

	int foravatar = 0;
	if ((rect.bottom - ptSplitter.y - (rcSplitter.bottom - rcSplitter.top) /*- DPISCALEY(2)*/ - (bBottomToolbar ? DPISCALEY_S(24) : 0) < dat->pic.cy - DPISCALEY_S(2)) && dat->showPic && !PluginConfig.m_AlwaysFullToolbarWidth)
		foravatar = dat->pic.cx + gap;

	if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT)) {
		DeferWindowPos(hdwp, hwndToggleSideBar, NULL, 4, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
		lwidth += 10;
		tempL -= 10;
	}

	for (i = 0; i < LButtonsList.getCount(); i++) {
		CustomButtonData *cbd = LButtonsList[i];
		if (((dat->bType == SESSIONTYPE_IM) && cbd->bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->bChatButton)) {
			hwndBtn = GetDlgItem(hwnd, cbd->dwButtonCID);

			if (!showToolbar) {
				ShowWindow(hwndBtn, SW_HIDE);
				DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
				if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
					lwidth += cbd->iButtonWidth + gap;
				if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->bAutoHidden)
					cbd->bAutoHidden = 1;
				continue;
			}
			if (!cbd->bCanBeHidden && !cbd->bHidden && !(!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->bAutoHidden)) {
				ShowWindow(hwndBtn, SW_SHOW);
				cbd->bAutoHidden = 0;
			}

			if (!cbd->bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
				tempL -= cbd->iButtonWidth + gap;

			if (cbd->bCanBeHidden && !cbd->bHidden && (cbd->bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden))) {
				if (tempL + tempR > (rect.right - foravatar)) {
					ShowWindow(hwndBtn, SW_HIDE);
					cbd->bAutoHidden = 1;
					tempL -= cbd->iButtonWidth + gap;
				}
				else if (cbd->bAutoHidden) {
					ShowWindow(hwndBtn, SW_SHOW);
					cbd->bAutoHidden = 0;
				}
			}
			DeferWindowPos(hdwp, hwndBtn, NULL, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);// SWP_NOCOPYBITS);
			if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
				lwidth += cbd->iButtonWidth + gap;
		}
	}

	if ((dat->pContainer->dwFlags & CNT_SIDEBAR) && (dat->pContainer->SideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT)) {
		DeferWindowPos(hdwp, hwndToggleSideBar, NULL, rect.right - foravatar - 10, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
		rwidth += 12;
		tempR -= 12;
	}

	for (i = 0; i < RButtonsList.getCount(); i++) {
		CustomButtonData *cbd = RButtonsList[i];
		if (((dat->bType == SESSIONTYPE_IM) && cbd->bIMButton) || ((dat->bType == SESSIONTYPE_CHAT) && cbd->bChatButton)) {
			hwndBtn = GetDlgItem(hwnd, cbd->dwButtonCID);

			if (!showToolbar) {
				ShowWindow(hwndBtn, SW_HIDE);
				if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
					rwidth += cbd->iButtonWidth + gap;
				DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
				if (!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn) && !cbd->bAutoHidden)
					cbd->bAutoHidden = 1;
				continue;
			}
			if (!cbd->bCanBeHidden && !cbd->bHidden && !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden)) {
				ShowWindow(hwndBtn, SW_SHOW);
				cbd->bAutoHidden = 0;
			}

			if (!cbd->bSeparator && !IsWindowVisible(hwndBtn) && !IsWindowEnabled(hwndBtn) && !cbd->bAutoHidden)
				tempR -= cbd->iButtonWidth + gap;

			if (cbd->bCanBeHidden && !cbd->bHidden && (cbd->bSeparator || !((!IsWindowEnabled(hwndBtn) && !IsWindowVisible(hwndBtn)) && !cbd->bAutoHidden))) {
				if (tempL + tempR > (rect.right - foravatar)) {
					ShowWindow(hwndBtn, SW_HIDE);
					cbd->bAutoHidden = 1;
					tempR -= cbd->iButtonWidth + gap;
				}
				else if (cbd->bAutoHidden) {
					ShowWindow(hwndBtn, SW_SHOW);
					cbd->bAutoHidden = 0;
				}
			}

			if (IsWindowVisible(hwndBtn) || (cbd->bSeparator && !(cbd->bAutoHidden || cbd->bHidden)))
				rwidth += cbd->iButtonWidth + gap;
			DeferWindowPos(hdwp, hwndBtn, NULL, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
		}
	}

	return EndDeferWindowPos(hdwp);
}
Example #27
0
// called in the first pass to create pluginEntry* structures and validate database plugins
static BOOL scanPluginsDir (WIN32_FIND_DATA * fd, TCHAR * path, WPARAM, LPARAM)
{
	int isdb = validguess_db_name(fd->cFileName);
	BASIC_PLUGIN_INFO bpi;
	pluginEntry* p = (pluginEntry*)HeapAlloc(hPluginListHeap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, sizeof(pluginEntry));
	_tcsncpy(p->pluginname, fd->cFileName, SIZEOF(p->pluginname));
	// plugin name suggests its a db module, load it right now
	if ( isdb ) 
	{
		TCHAR buf[MAX_PATH];
		mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName);
		if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_DB, NULL)) 
		{
			// db plugin is valid
			p->pclass |= (PCLASS_DB | PCLASS_BASICAPI);
			// copy the dblink stuff
			p->bpi=bpi;
			// keep a faster list.
			if ( pluginListDb != NULL ) p->nextclass = pluginListDb;
			pluginListDb=p;
		}
		else
			// didn't have basic APIs or DB exports - failed.
			p->pclass |= PCLASS_FAILED;
	}
	else if (validguess_clist_name(fd->cFileName)) 
	{
		// keep a note of this plugin for later
		if ( pluginListUI != NULL ) p->nextclass=pluginListUI;
		pluginListUI=p;
		p->pclass |= PCLASS_CLIST;
	}
	else if (validguess_servicemode_name(fd->cFileName))
	{
		TCHAR buf[MAX_PATH];
		mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, fd->cFileName);
		if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_NONE, NULL)) 
		{
			p->pclass |= (PCLASS_OK | PCLASS_BASICAPI);
			p->bpi = bpi;
			if (bpi.Interfaces) 
			{
				int i = 0;
				MUUID *piface = bpi.Interfaces();
				while (!equalUUID(miid_last, piface[i])) 
				{
					if (!equalUUID(miid_servicemode, piface[i++]))
						continue;
					p->pclass |= (PCLASS_SERVICE);
					if ( pluginListSM != NULL ) p->nextclass = pluginListSM;
					pluginListSM=p;
	                if (pluginList_crshdmp == NULL &&  lstrcmpi(fd->cFileName, _T("svc_crshdmp.dll")) == 0)
					{
		                pluginList_crshdmp = p;
						p->pclass |= PCLASS_LAST;
					}
					break;
				}
			}
		}
		else
			// didn't have basic APIs or DB exports - failed.
			p->pclass |= PCLASS_FAILED;
	}
	else if (pluginList_freeimg == NULL && lstrcmpi(fd->cFileName, _T("advaimg.dll")) == 0)
		pluginList_freeimg = p;

	// add it to the list
	pluginList.insert( p );
	return TRUE;
}
Example #28
0
static int SaveTree(HWND hToolBarTree)
{
	bool RSide = false;
	int count = 10;
	DWORD loc_sepcout = 0;
	TCHAR strbuf[128];

	TVITEM tvi;
	tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE;
	tvi.hItem = TreeView_GetRoot(hToolBarTree);
	tvi.pszText = strbuf;
	tvi.cchTextMax = sizeof(strbuf);
	{
		mir_cslock lck(ToolBarCS);

		while (tvi.hItem != NULL) {
			TreeView_GetItem(hToolBarTree, &tvi);

			if (_tcscmp(tvi.pszText, MIDDLE_SEPARATOR) == 0) {
				RSide = true;
				count = TreeView_GetCount(hToolBarTree) * 10 - count;
				tvi.hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
				continue;
			}
			CustomButtonData *cbd = (CustomButtonData*)tvi.lParam;
			if (cbd) {
				if (cbd->opFlags) {
					cbd->bIMButton = (cbd->opFlags & BBSF_IMBUTTON) != 0;
					cbd->bChatButton = (cbd->opFlags & BBSF_CHATBUTTON) != 0;
					cbd->bCanBeHidden = (cbd->opFlags & BBSF_CANBEHIDDEN) != 0;
				}
				if (RSide && cbd->bLSided) {
					cbd->bLSided = false;
					cbd->bRSided = true;
					cbd->opFlags |= BBSF_NTBSWAPED;
				}
				else if (!RSide && cbd->bRSided) {
					cbd->bLSided = true;
					cbd->bRSided = false;
					cbd->opFlags |= BBSF_NTBSWAPED;
				}
				if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem)) {
					cbd->bIMButton = false;
					cbd->bChatButton = false;

					if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep"))
						cbd->opFlags = BBSF_NTBDESTRUCT;
				}
				else {
					if (!cbd->bIMButton && !cbd->bChatButton)
						cbd->bIMButton = true;
					if (cbd->bSeparator && !strcmp(cbd->pszModuleName, "Tabsrmm_sep")) {
						cbd->bHidden = 0;
						cbd->opFlags &= ~BBSF_NTBDESTRUCT;
						++loc_sepcout;
					}
				}

				cbd->dwPosition = (DWORD)count;
				CB_WriteButtonSettings(NULL, cbd);

				if (!(cbd->opFlags & BBSF_NTBDESTRUCT))
					(RSide) ? (count -= 10) : (count += 10);
			}
			
			HTREEITEM hItem = TreeView_GetNextSibling(hToolBarTree, tvi.hItem);
			if (cbd->opFlags & BBSF_NTBDESTRUCT)
				TreeView_DeleteItem(hToolBarTree, tvi.hItem);
			tvi.hItem = hItem;
		}

		qsort(LButtonsList.getArray(), LButtonsList.getCount(), sizeof(void*), sstSortButtons);
		qsort(RButtonsList.getArray(), RButtonsList.getCount(), sizeof(void*), sstSortButtons);
	}
	db_set_dw(0, "TabSRMM_Toolbar", "SeparatorsCount", loc_sepcout);
	dwSepCount = loc_sepcout;
	return 1;
}
Example #29
0
void UnloadExtraIconsModule(void)
{
	for (int i=0; i < registeredExtraIcons.getCount(); i++)
		delete registeredExtraIcons[i];
}
Example #30
0
static CIrcProto* ircProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
{
	CIrcProto* ppro = new CIrcProto( pszProtoName, tszUserName );
	g_Instances.insert( ppro );
	return ppro;
}