Exemplo n.º 1
0
INT_PTR PluginCommand_GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
	TCHAR *ret = (TCHAR *)lParam;
	char *proto = (char *)wParam;

	if (ret == NULL)
		return -1;

	if (proto == NULL) {
		mir_tstrncpy(ret, protocols->default_avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE);
		return 0;
	}

	for (int i = 0; i < protocols->GetSize(); i++) {
		if (mir_strcmpi(protocols->Get(i)->name, proto) == 0) {
			if (!protocols->Get(i)->CanGetAvatar())
				return -2;

			protocols->Get(i)->GetAvatar();

			if (mir_tstrlen(protocols->Get(i)->avatar_file))
				mir_tstrncpy(ret, protocols->Get(i)->avatar_file, MS_MYDETAILS_GETMYAVATAR_BUFFER_SIZE);
			else
				ret[0] = '\0';

			return 0;
		}
	}

	return -1;
}
Exemplo n.º 2
0
TCHAR *GetProtoName(struct ClcContact *item)
{
	PROTOACCOUNT *acc;
#ifdef UNICODE
	char description[128];
#endif

	proto_name[0] = '\0';
	if (item->hContact == NULL || item->proto == NULL)
	{
		mir_tstrncpy(proto_name, TranslateT("Unknown protocol"), _countof(proto_name));
		return proto_name;
	}

	acc = Proto_GetAccount(item->proto);

	if (acc == NULL)
	{
#ifdef UNICODE
		CallProtoService(item->proto, PS_GETNAME, sizeof(description),(LPARAM) description);
		mir_sntprintf(proto_name, _countof(proto_name), L"%S", description);
#else
		CallProtoService(item->proto, PS_GETNAME, sizeof(proto_name),(LPARAM) proto_name);
#endif
		return proto_name;
	}

	mir_tstrncpy(proto_name, acc->tszAccountName, _countof(proto_name));

	return proto_name;
}
Exemplo n.º 3
0
void XPath::ProcessPath(LookupInfo &info, bool bCreate)
{
	if (!info.nodeName) return;

	TCHAR *nodeName = (TCHAR *)alloca(sizeof(TCHAR) * (info.nodeName.length+1));
	mir_tstrncpy(nodeName, info.nodeName.p, info.nodeName.length+1);

	if (info.attrName && info.attrValue) {
		TCHAR *attrName = (TCHAR *)alloca(sizeof(TCHAR)* (info.attrName.length + 1));
		mir_tstrncpy(attrName, info.attrName.p, info.attrName.length + 1);
		TCHAR *attrValue = (TCHAR *)alloca(sizeof(TCHAR)* (info.attrValue.length + 1));
		mir_tstrncpy(attrValue, info.attrValue.p, info.attrValue.length + 1);
		HXML hXml = XmlGetChildByTag(m_hXml, nodeName, attrName, attrValue);

		m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName) << XATTR(attrName, attrValue));
	}
	else if (info.nodeIndex) {
		int idx = _ttoi(info.nodeIndex.p);
		m_hXml = mir_tstrcmp(nodeName, _T("*")) ? XmlGetNthChild(m_hXml, nodeName, idx) : XmlGetChild(m_hXml, idx - 1);
	}
	else {
		HXML hXml = XmlGetChild(m_hXml, nodeName);
		m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName));
	}

	info.Reset();
}
Exemplo n.º 4
0
void __stdcall	ShowPopup(TCHAR *line1, TCHAR *line2, int flags)
{
	if (CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;

	if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
		ShowClassPopupT("pingpopups", line1, line2);
	}
	else if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
		POPUPDATAT *ppd = (POPUPDATAT*)calloc(sizeof(POPUPDATAT), 1);

		ppd->lchContact = NULL;
		ppd->lchIcon = (flags ? hIconResponding : hIconNotResponding);
		mir_tstrncpy(ppd->lptzContactName, line1, _countof(ppd->lptzContactName));
		mir_tstrncpy(ppd->lptzText, line2, _countof(ppd->lptzText));

		ppd->colorBack = GetSysColor(COLOR_BTNFACE);
		ppd->colorText = GetSysColor(COLOR_WINDOWTEXT);
		ppd->iSeconds = 10;

		ppd->PluginWindowProc = NullWindowProc;
		ppd->PluginData = NULL;

		QueueUserAPC(sttMainThreadCallback, mainThread, (ULONG_PTR)ppd);
	}
	else{
		MessageBox(NULL, line2, _T(PLUG) _T(" Message"), MB_OK | MB_ICONINFORMATION);
		return;
	}
}
Exemplo n.º 5
0
TCHAR* MyDBGetContactSettingTString(MCONTACT hContact, char* module, char* setting, TCHAR* out, size_t len, TCHAR *def)
{
	DBVARIANT dbv;

	out[0] = _T('\0');

	if (!db_get_ts(hContact, module, setting, &dbv)) {
		if (dbv.type == DBVT_ASCIIZ)
			MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, out, (int)len);
		else if (dbv.type == DBVT_UTF8)
			MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, out, (int)len);
		else if (dbv.type == DBVT_WCHAR)
			mir_tstrncpy(out, dbv.pwszVal, (int)len);
		else if (def != NULL)
			mir_tstrncpy(out, def, (int)len);

		db_free(&dbv);
	}
	else {
		if (def != NULL)
			mir_tstrncpy(out, def, (int)len);
	}

	return out;
}
Exemplo n.º 6
0
int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, const TCHAR *pszSection, const TCHAR *pszDescription, const TCHAR* pszBackgroundGroup, const TCHAR* pszBackgroundName, int position, BOOL bAllowEffects, LOGFONT *plfDefault, COLORREF clrDefault)
{
	FontIDT fid;
	memset(&fid, 0, sizeof(fid));
	fid.cbSize=sizeof(fid);
	mir_strncpy(fid.dbSettingsGroup,pszDbModule,sizeof(fid.dbSettingsGroup)); /* buffer safe */
	mir_strncpy(fid.prefix,pszDbName,sizeof(fid.prefix)); /* buffer safe */
	mir_tstrncpy(fid.group,pszSection,SIZEOF(fid.group)); /* buffer safe */
	mir_tstrncpy(fid.name,pszDescription,SIZEOF(fid.name)); /* buffer safe */
	mir_tstrncpy(fid.backgroundGroup, pszBackgroundGroup, SIZEOF(fid.backgroundGroup)); /* buffer safe */
	mir_tstrncpy(fid.backgroundName, pszBackgroundName, SIZEOF(fid.backgroundName)); /* buffer safe */
	fid.flags = FIDF_ALLOWREREGISTER;
	if(bAllowEffects) fid.flags|=FIDF_ALLOWEFFECTS;
	fid.order=position;
	if(plfDefault!=NULL) {
		fid.flags|=FIDF_DEFAULTVALID;
		fid.deffontsettings.colour=clrDefault;
		fid.deffontsettings.size=(char)plfDefault->lfHeight;
		if(plfDefault->lfItalic) fid.deffontsettings.style|=DBFONTF_ITALIC;
		if(plfDefault->lfWeight!=FW_NORMAL) fid.deffontsettings.style|=DBFONTF_BOLD;
		if(plfDefault->lfUnderline) fid.deffontsettings.style|=DBFONTF_UNDERLINE;
		if(plfDefault->lfStrikeOut) fid.deffontsettings.style|=DBFONTF_STRIKEOUT;
		fid.deffontsettings.charset=plfDefault->lfCharSet;
		mir_tstrncpy(fid.deffontsettings.szFace,plfDefault->lfFaceName,SIZEOF(fid.deffontsettings.szFace)); /* buffer safe */
	}
	FontRegisterT(&fid);
	return 0;
}
/*
*	Get the text for First Line
*/
void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact)
{
	if (GetCurrentThreadId() != g_dwMainThreadID)
		return;

	ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
	TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0);
	if (dat->first_line_append_nick && (!dat->force_in_dialog)) {
		DBVARIANT dbv = { 0 };
		if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) {
			TCHAR nick[_countof(contact->szText)];
			mir_tstrncpy(nick, dbv.ptszVal, _countof(contact->szText));
			db_free(&dbv);

			// They are the same -> use the name to keep the case
			if (mir_tstrcmpi(name, nick) == 0)
				mir_tstrncpy(contact->szText, name, _countof(contact->szText));
			else // Append then
				mir_sntprintf(contact->szText, _T("%s - %s"), name, nick);
		}
		else mir_tstrncpy(contact->szText, name, _countof(contact->szText));
	}
	else mir_tstrncpy(contact->szText, name, _countof(contact->szText));

	if (!dat->force_in_dialog) {
		SHORTDATA data = { 0 };
		Sync(CLUI_SyncGetShortData, (WPARAM)pcli->hwndContactTree, (LPARAM)&data);
		contact->ssText.ReplaceSmileys(&data, pdnce, contact->szText, dat->first_line_draw_smileys);
	}
}
Exemplo n.º 8
0
int FontService_GetFont(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr,LOGFONT *plf)
{
	FontIDT fid;
	fid.cbSize=sizeof(fid);
	mir_tstrncpy(fid.group,pszSection,SIZEOF(fid.group)); /* buffer sfae */
	mir_tstrncpy(fid.name,pszDescription,SIZEOF(fid.name)); /* buffer safe */
	*pclr=(COLORREF)CallService(MS_FONT_GETT,(WPARAM)&fid,(LPARAM)plf); /* uses fallback font on error */
	return (int)*pclr==-1;
}
Exemplo n.º 9
0
int FontService_RegisterColor(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF clrDefault)
{
	ColourIDT cid;
	memset(&cid, 0, sizeof(cid));
	cid.cbSize=sizeof(cid);
	cid.defcolour=clrDefault;
	mir_strncpy(cid.dbSettingsGroup,pszDbModule,sizeof(cid.dbSettingsGroup)); /* buffer safe */
	mir_strncpy(cid.setting,pszDbName,sizeof(cid.setting)); /* buffer safe */
	mir_tstrncpy(cid.group,pszSection,SIZEOF(cid.group)); /* buffer safe */
	mir_tstrncpy(cid.name,pszDescription,SIZEOF(cid.name)); /* buffer safe */
	ColourRegisterT(&cid);
	return 0;
}
Exemplo n.º 10
0
void import_ping_address(int index, PINGADDRESS &pa) {
	DBVARIANT dbv;
	char buf[256];
	mir_snprintf(buf, "Address%d", index);
	if (!db_get_ts(0, "PingPlug", buf, &dbv)) {
		mir_tstrncpy(pa.pszName, dbv.ptszVal, _countof(pa.pszName));
		db_free(&dbv);
	}
	else
		mir_tstrncpy(pa.pszName, TranslateT("Unknown Address"), _countof(pa.pszName));

	mir_snprintf(buf, "Label%d", index);
	if (!db_get_ts(0, "PingPlug", buf, &dbv)) {
		mir_tstrncpy(pa.pszLabel, dbv.ptszVal, _countof(pa.pszLabel));
		db_free(&dbv);
	}
	else
		mir_tstrncpy(pa.pszLabel, TranslateT("Unknown"), _countof(pa.pszLabel));

	mir_snprintf(buf, "Port%d", index);
	pa.port = (int)db_get_dw(0, "PingPlug", buf, -1);

	mir_snprintf(buf, "Proto%d", index);
	if (!db_get_s(0, "PingPlug", buf, &dbv)) {
		mir_strncpy(pa.pszProto, dbv.pszVal, _countof(pa.pszProto));
		db_free(&dbv);
		mir_snprintf(buf, "Status%d", index);
		pa.set_status = db_get_w(0, "PingPlug", buf, ID_STATUS_ONLINE);
		mir_snprintf(buf, "Status2%d", index);
		pa.get_status = db_get_w(0, "PingPlug", buf, ID_STATUS_OFFLINE);
	}
	else
		pa.pszProto[0] = '\0';


	pa.responding = false;
	pa.round_trip_time = 0;
	pa.miss_count = 0;
	pa.index = index;
	pa.pszCommand[0] = '\0';
	pa.pszParams[0] = '\0';

	pa.item_id = 0;
	mir_snprintf(buf, "Enabled%d", index);
	if (db_get_b(0, "PingPlug", buf, 1) == 1)
		pa.status = PS_NOTRESPONDING;
	else
		pa.status = PS_DISABLED;
}
Exemplo n.º 11
0
static int sttRegisterFontWorker(FontIDW* font_id, int hLangpack)
{
	if (font_id->cbSize != sizeof(FontIDW) && font_id->cbSize != FontIDW_OLDSIZE)
		return -1;

	for (int i=0; i < font_id_list.getCount(); i++) {
		FontInternal& F = font_id_list[i];
		if (!mir_tstrcmp(F.group, font_id->group) && !mir_tstrcmp(F.name, font_id->name) && !(F.flags & FIDF_ALLOWREREGISTER))
			return 1;
	}

	char idstr[256];
	mir_snprintf(idstr, SIZEOF(idstr), "%sFlags", font_id->prefix);
	db_set_dw(0, font_id->dbSettingsGroup, idstr, font_id->flags);

	FontInternal* newItem = new FontInternal;
	memset(newItem, 0, sizeof(FontInternal));
	memcpy(newItem, font_id, font_id->cbSize);
	newItem->hLangpack = hLangpack;

	if (!mir_tstrcmp(newItem->deffontsettings.szFace, _T("MS Shell Dlg"))) {
		LOGFONT lf;
		SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE);
		mir_tstrncpy(newItem->deffontsettings.szFace, lf.lfFaceName, SIZEOF(newItem->deffontsettings.szFace));
		if (!newItem->deffontsettings.size)
			newItem->deffontsettings.size = lf.lfHeight;
	}

	UpdateFontSettings(font_id, &newItem->value);
	font_id_list.insert(newItem);
	return 0;
}
Exemplo n.º 12
0
INT_PTR CMraProto::MraGetXStatusEx(WPARAM hContact, LPARAM lParam)
{
	CUSTOM_STATUS *pData = (CUSTOM_STATUS*)lParam;

	if (pData->cbSize < sizeof(CUSTOM_STATUS))
		return 1;

	// fill status member
	if (pData->flags & CSSF_MASK_STATUS)
		*pData->status = m_iXStatus;

	// fill status name member
	if (pData->flags & CSSF_MASK_NAME) {
		if (pData->flags & CSSF_DEFAULT_NAME) {
			DWORD dwXStatus = (pData->wParam == NULL) ? m_iXStatus : *pData->wParam;
			if (!IsXStatusValid(dwXStatus))
				return 1;

			if (pData->flags & CSSF_UNICODE)
				mir_tstrncpy(pData->ptszName, lpcszXStatusNameDef[dwXStatus], (STATUS_TITLE_MAX + 1));
			else {
				size_t dwStatusTitleSize = mir_tstrlen(lpcszXStatusNameDef[dwXStatus]);
				if (dwStatusTitleSize > STATUS_TITLE_MAX)
					dwStatusTitleSize = STATUS_TITLE_MAX;

				WideCharToMultiByte(MRA_CODE_PAGE, 0, lpcszXStatusNameDef[dwXStatus], (DWORD)dwStatusTitleSize, pData->pszName, MAX_PATH, NULL, NULL);
				(*((CHAR*)(pData->pszName + dwStatusTitleSize))) = 0;
			}
		}
		else {
			if (pData->flags & CSSF_UNICODE)
				mraGetStaticStringW(hContact, DBSETTING_XSTATUSNAME, pData->pwszName, (STATUS_TITLE_MAX + 1), NULL);
			else
				mraGetStaticStringA(hContact, DBSETTING_XSTATUSNAME, pData->pszName, (STATUS_TITLE_MAX + 1), NULL);
		}
	}

	// fill status message member
	if (pData->flags & CSSF_MASK_MESSAGE) {
		char szSetting[100];
		mir_snprintf(szSetting, SIZEOF(szSetting), "XStatus%dMsg", m_iXStatus);
		if (pData->flags & CSSF_UNICODE)
			mraGetStaticStringW(hContact, szSetting, pData->pwszMessage, (STATUS_DESC_MAX + 1), NULL);
		else
			mraGetStaticStringA(hContact, szSetting, pData->pszMessage, (STATUS_DESC_MAX + 1), NULL);
	}

	if ((pData->flags & CSSF_DISABLE_UI) && pData->wParam)
		*pData->wParam = m_bHideXStatusUI;

	if ((pData->flags & CSSF_STATUSES_COUNT) && pData->wParam)
		*pData->wParam = MRA_XSTATUS_COUNT - 1;

	//**deb можно оптимизировать, данный параметр возможно уже был вычислен при получении самих текстов
	if (pData->flags & CSSF_STR_SIZES) {
		if (pData->wParam) mraGetStaticStringW(hContact, DBSETTING_XSTATUSNAME, NULL, 0, (size_t*)pData->wParam);
		if (pData->lParam) mraGetStaticStringW(hContact, DBSETTING_XSTATUSMSG, NULL, 0, (size_t*)pData->lParam);
	}
	return 0;
}
Exemplo n.º 13
0
static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon)
{
	TCHAR *comma;
	TCHAR file[ MAX_PATH ], fileFull[ MAX_PATH ];
	int n;
	HICON hIcon;

	if (!path)
		return (HICON)NULL;

	mir_tstrncpy(file, path, SIZEOF(file));
	comma = _tcsrchr(file, ',');
	if (!comma)
		n = 0;
	else {
		n = _ttoi(comma+1);
		*comma = 0;
	}
	PathToAbsoluteT(file, fileFull);
	hIcon = NULL;

	//SHOULD BE REPLACED WITH GOOD ENOUGH FUNCTION
	_ExtractIconEx(fileFull, n, cxIcon, cyIcon, &hIcon, LR_COLOR);
	return hIcon;
}
Exemplo n.º 14
0
void CToxOptionsMain::ProfileExport_OnClick(CCtrlButton*)
{
	TCHAR filter[MAX_PATH];
	mir_sntprintf(filter, _T("%s(*.tox)%c*.tox%c%c"),
		TranslateT("Tox profile"), 0, 0, 0);

	TCHAR profilePath[MAX_PATH];
	mir_tstrncpy(profilePath, _T("tox_save.tox"), _countof(profilePath));

	OPENFILENAME ofn = { sizeof(ofn) };
	ofn.hwndOwner = m_hwnd;
	ofn.lpstrFilter = filter;
	ofn.nFilterIndex = 0;
	ofn.lpstrFile = profilePath;
	ofn.lpstrTitle = TranslateT("Save Tox profile");
	ofn.nMaxFile = MAX_PATH;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_EXPLORER;
	ofn.lpstrInitialDir = _T("%HOMEPATH%");

	if (!GetSaveFileName(&ofn))
		return;

	ptrT defaultProfilePath(m_proto->GetToxProfilePath());
	if (mir_tstrcmpi(profilePath, defaultProfilePath) != 0)
		CopyFile(defaultProfilePath, profilePath, FALSE);
}
Exemplo n.º 15
0
/*
Service: /GetMyAvatar
wParam=(char *)Buffer to file name
lParam=(int)Buffer size
return=0 on success, else on error
*/
INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
	TCHAR *buffer = (TCHAR*)wParam;
	int size = (int)lParam;

	debugLogA("[YahooGetMyAvatar]");

	if (buffer == NULL || size <= 0)
		return -1;

	if (!getByte("ShowAvatars", 1))
		return -2;

	DBVARIANT dbv;
	int ret = -3;

	if (getDword("AvatarHash", 0)) {
		if (!getTString("AvatarFile", &dbv)) {
			if (_taccess(dbv.ptszVal, 0) == 0) {
				mir_tstrncpy(buffer, dbv.ptszVal, size - 1);
				buffer[size - 1] = '\0';

				ret = 0;
			}
			db_free(&dbv);
		}
	}

	return ret;
}
Exemplo n.º 16
0
int fnAddInfoItemToGroup(ClcGroup *group, int flags, const TCHAR *pszText)
{
	int i=0;

	if (flags & CLCIIF_BELOWCONTACTS)
		i = group->cl.count;
	else if (flags & CLCIIF_BELOWGROUPS) {
		for (; i < group->cl.count; i++)
			if (group->cl.items[i]->type == CLCIT_CONTACT)
				break;
	}
	else
		for (; i < group->cl.count; i++)
			if (group->cl.items[i]->type != CLCIT_INFO)
				break;
	i = cli.pfnAddItemToGroup(group, i);
	iInfoItemUniqueHandle = LOWORD(iInfoItemUniqueHandle+1);
	if (iInfoItemUniqueHandle == 0)
		++iInfoItemUniqueHandle;
	group->cl.items[i]->type = CLCIT_INFO;
	group->cl.items[i]->flags = (BYTE) flags;
	group->cl.items[i]->hContact = (MCONTACT)++iInfoItemUniqueHandle;
	mir_tstrncpy(group->cl.items[i]->szText, pszText, _countof(group->cl.items[i]->szText));
	return i;
}
Exemplo n.º 17
0
INT_PTR CDropbox::SendFileToDropbox(WPARAM hContact, LPARAM lParam)
{
	if (!HasAccessToken())
		return 0;

	if (hContact == NULL)
		hContact = GetDefaultContact();

	TCHAR *filePath = (TCHAR*)lParam;

	FileTransferParam *ftp = new FileTransferParam();
	ftp->pfts.hContact = hContact;
	ftp->pfts.totalFiles = 1;
	ftp->hContact = (hTransferContact) ? hTransferContact : hContact;
	hTransferContact = 0;

	int length = _tcsrchr(filePath, '\\') - filePath;
	ftp->pfts.tszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * (length + 1));
	mir_tstrncpy(ftp->pfts.tszWorkingDir, filePath, length + 1);
	ftp->pfts.tszWorkingDir[length] = '\0';

	ftp->pfts.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * (ftp->pfts.totalFiles + 1));
	ftp->pfts.ptszFiles[0] = mir_wstrdup(filePath);
	ftp->pfts.ptszFiles[ftp->pfts.totalFiles] = NULL;

	ULONG fileId = InterlockedIncrement(&hFileProcess);
	ftp->hProcess = (HANDLE)fileId;

	mir_forkthreadowner(CDropbox::SendFilesAndEventAsync, this, ftp, 0);

	return fileId;
}
Exemplo n.º 18
0
Protocol::Protocol(const char *aName, const TCHAR *descr)
{
	mir_strncpy(name, aName, _countof(name));
	mir_tstrncpy(description, descr, _countof(description));

	data_changed = true;

	// Load services
	int caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0);
	if (caps & PF1_IM)
		valid = true;
	else
		return;

	can_have_listening_to = (ProtoServiceExists(name, PS_SET_LISTENINGTO) != 0);

	PF3 = CallProtoService(name, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0);
	caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_4, 0);
	can_have_avatar = (caps & PF4_AVATARS) != 0;
	can_set_nick = ProtoServiceExists(name, PS_SETMYNICKNAME) != FALSE;

	// Initial value
	GetStatus();
	GetStatusMsg();
	GetNick();
	GetAvatar();
}
Exemplo n.º 19
0
void Protocol::lcopystr(TCHAR *dest, TCHAR *src, size_t maxlen)
{
	if (mir_tstrcmp(dest, src) != 0) {
		data_changed = true;
		mir_tstrncpy(dest, src, (DWORD)maxlen);
	}
}
Exemplo n.º 20
0
void ProtocolArray::GetDefaultAvatar()
{
	ptrT tszFile(db_get_tsa(0, "ContactPhoto", "File"));
	if (tszFile)
		mir_tstrncpy(default_avatar_file, tszFile, _countof(default_avatar_file));
	else
		default_avatar_file[0] = '\0';
}
Exemplo n.º 21
0
void ProtocolArray::GetDefaultNick()
{
	ptrT tszNick(db_get_tsa(0, MODULE_NAME, SETTING_DEFAULT_NICK));
	if (tszNick)
		mir_tstrncpy(default_nick, tszNick, _countof(default_nick));
	else
		default_nick[0] = '\0';
}
Exemplo n.º 22
0
INT_PTR BasicSearch(WPARAM, LPARAM lParam)
{
	static TCHAR buf[300];

	if (lParam)
		mir_tstrncpy(buf, (const TCHAR*) lParam, 256);

	if (searchId != -1)
		return 0; // only one search at a time

	mir_tstrncpy(sID, (TCHAR*)lParam, _countof(sID));
	searchId = 1;

	// create a thread for the ID search
	mir_forkthread(BasicSearchTimerProc, &buf);
	return searchId;
}
Exemplo n.º 23
0
void ShowPopup(ALARM *alarm)
{
	if ( ServiceExists(MS_POPUP_ADDPOPUPT)) {
		ALARM *data = new ALARM;
		memset(data, 0, sizeof(ALARM));
		copy_alarm_data(data, alarm);

		POPUPDATAT ppd = { 0 };
		ppd.lchIcon = hIconMenuSet;
		mir_tstrncpy(ppd.lptzContactName, data->szTitle, MAX_CONTACTNAME);
		mir_tstrncpy(ppd.lptzText, data->szDesc, MAX_SECONDLINE);
		ppd.PluginWindowProc = PopupAlarmDlgProc;
		ppd.PluginData = data;
		ppd.iSeconds = -1;
		PUAddPopupT(&ppd);
	}
}
Exemplo n.º 24
0
INT_PTR CToxProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
	std::tstring path = GetAvatarFilePath();
	if (IsFileExists(path))
		mir_tstrncpy((TCHAR*)wParam, path.c_str(), (int)lParam);

	return 0;
}
Exemplo n.º 25
0
static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc)
{
	if (!PathIsAbsolute(pSrc))
		mir_tstrncpy(pOut, pSrc, (int)outSize);
	else {
		if (dbPath[0] == _T('\0')) {
			char tmp[1024];
			CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp);
			mir_sntprintf(dbPath, _T("%S\\"), tmp);
		}

		size_t len = mir_tstrlen(dbPath);
		if (!_tcsnicmp(pSrc, dbPath, len))
			len = 0;
		mir_tstrncpy(pOut, pSrc + len, outSize);
	}
}
Exemplo n.º 26
0
static TCHAR* MyDBGetContactSettingTString(MCONTACT hContact, char* module, char* setting, TCHAR* out, size_t len, TCHAR *def)
{
	DBVARIANT dbv = { 0 };

	out[0] = _T('\0');

	if (!db_get_ts(hContact, module, setting, &dbv)) {
		mir_tstrncpy(out, dbv.ptszVal, (int)len);
		db_free(&dbv);
	}
	else {
		if (def != NULL)
			mir_tstrncpy(out, def, (int)len);
	}

	return out;
}
Exemplo n.º 27
0
void show_popup(HWND hDlg, LPCTSTR pszTitle, LPCTSTR pszText, int iNumber, int ActType)
{
	LPMSGPOPUPDATA	pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA));
	if (!pmpd)
		return;

	POPUPDATAT_V2 pd = { 0 };
	pd.cbSize = sizeof(pd);
	pd.lchContact = NULL; //(HANDLE)wParam;
	pd.lchIcon = Skin_LoadIcon(PopupsList[iNumber].Icon);
	mir_tstrncpy(pd.lptzText, pszText, _countof(pd.lptzText));
	mir_tstrncpy(pd.lptzContactName, pszTitle, _countof(pd.lptzContactName));
	switch (MyOptions.DefColors) {
	case byCOLOR_WINDOWS:
		pd.colorBack = GetSysColor(COLOR_BTNFACE);
		pd.colorText = GetSysColor(COLOR_WINDOWTEXT);
		break;
	case byCOLOR_OWN:
		pd.colorBack = PopupsList[iNumber].colorBack;
		pd.colorText = PopupsList[iNumber].colorText;
		break;
	case byCOLOR_POPUP:
		pd.colorBack = pd.colorText = 0;
		break;
	}
	if (iNumber == 0 && ActType != 0)
		pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
	else
		pd.PluginWindowProc = (WNDPROC)PopupDlgProc2;
	pd.PluginData = pmpd;
	if (iNumber == 0)
		pd.iSeconds = -1;
	else
		pd.iSeconds = MyOptions.Timeout;
	pd.hNotification = NULL;
	pd.lpActions = pmpd->pa;

	pmpd->hDialog = hDlg;
	if (ActType == 1) {
		MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
		MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
	}

	CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, APF_NEWDATA);
}
Exemplo n.º 28
0
static void __stdcall CreateDownloadDialog(void*)
{
	if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups3", DEFAULT_POPUP_ENABLED))
		hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgDownloadPop);
	else if (db_get_b(NULL, MODNAME, "Popups3M", DEFAULT_MESSAGE_ENABLED)) {
		mir_tstrncpy(tszDialogMsg, Text, _countof(tszDialogMsg));
		hDlgDld = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DOWNLOAD), NULL, DlgDownload);
	}
}
Exemplo n.º 29
0
INT_PTR CMraProto::MraGetMyAvatar(WPARAM wParam, LPARAM lParam)
{
	CMStringW wszFileName;
	if (MraAvatarsGetFileName(hAvatarsQueueHandle, NULL, GetContactAvatarFormat(NULL, PA_FORMAT_DEFAULT), wszFileName) == NO_ERROR) {
		mir_tstrncpy((LPTSTR)wParam, wszFileName, (size_t)lParam);
		return 0;
	}
	return 1;
}
Exemplo n.º 30
0
void GetSmileyCacheFolder(void)
{
	hFolder = FoldersRegisterCustomPathT(LPGEN("SmileyAdd"), LPGEN("Smiley cache"), MIRANDA_USERDATAT _T("\\SmileyCache"));
	if (hFolder) {
		FoldersGetCustomPathT(hFolder, cachepath, MAX_PATH, _T(""));
		HookEvent(ME_FOLDERS_PATH_CHANGED, FolderChanged);
	}
	else mir_tstrncpy(cachepath, VARST( _T("%miranda_userdata%\\SmileyCache")), MAX_PATH);
}