Example #1
0
SmileyPackType* SmileyPackListType::GetSmileyPack(CMString& filename)
{
	CMString modpath;
	pathToAbsolute(filename, modpath);

	for (int i = 0; i < m_SmileyPacks.getCount(); i++) {
		CMString modpath1;
		pathToAbsolute(m_SmileyPacks[i].GetFilename(), modpath1);
		if (mir_tstrcmpi(modpath.c_str(), modpath1.c_str()) == 0) return &m_SmileyPacks[i];
	}
	return NULL;
}
Example #2
0
void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMString& defaultFile)
{
	if (acc == NULL)
		return;

	const char* packnam = acc;
	if (mir_strcmp(packnam, "JABBER") == 0)
		packnam = "JGMail";
	else if (strstr(packnam, "SIP") != NULL)
		packnam = "MSN";

	char path[MAX_PATH];
	mir_snprintf(path, "Smileys\\nova\\%s.msl", packnam);

	CMString paths = A2T_SM(path), patha;
	pathToAbsolute(paths, patha);

	if (_taccess(patha.c_str(), 0) != 0)
		paths = defaultFile;
	CMString dName(acc), displayName;
	displayName.AppendFormat(TranslateT("%s global smiley pack"), dName.GetBuffer());
	CMString tname("AllProto");
	tname += A2T_SM(acc);
	AddCategory(tname, displayName, smcPhysProto, paths);
}
Example #3
0
void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, const CMString &defaultFile)
{
	char *proto = GetContactProto(hContact);
	if (proto == NULL)
		return;

	DBVARIANT dbv;
	if (!db_get_ts(hContact, proto, "Transport", &dbv)) {
		if (dbv.ptszVal[0] == '\0') {
			db_free(&dbv);
			return;
		}
		char *trsp = mir_strdup(_T2A(dbv.ptszVal));
		_strlwr(trsp);

		const char *packname = NULL;
		if (strstr(trsp, "msn") != NULL)
			packname = "msn";
		else if (strstr(trsp, "icq") != NULL)
			packname = "icq";
		else if (strstr(trsp, "yahoo") != NULL)
			packname = "yahoo";
		else if (strstr(trsp, "aim") != NULL)
			packname = "aim";
		else if (strstr(trsp, "lcs") != NULL)
			packname = "msn";

		mir_free(trsp);

		CMString displayName = dbv.ptszVal;
		if (packname != NULL) {
			char path[MAX_PATH];
			mir_snprintf(path, "Smileys\\nova\\%s.msl", packname);

			CMString paths = _A2T(path), patha;
			pathToAbsolute(paths, patha);

			if (_taccess(patha.c_str(), 0) != 0)
				paths = defaultFile;

			AddCategory(displayName, displayName, smcTransportProto, paths);
		}
		else AddCategory(displayName, displayName, smcTransportProto, defaultFile);

		db_free(&dbv);
	}
}
Example #4
0
void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMString& defaultFile)
{
	if (Proto_IsAccountEnabled(acc) && acc->szProtoName && IsSmileyProto(acc->szModuleName)) {
		CMString displayName(acc->tszAccountName ? acc->tszAccountName : A2T_SM(acc->szModuleName));
		CMString PhysProtoName, paths;
		DBVARIANT dbv;

		if (db_get_ts(NULL, acc->szModuleName, "AM_BaseProto", &dbv) == 0) {
			PhysProtoName = _T("AllProto");
			PhysProtoName += dbv.ptszVal;
			db_free(&dbv);
		}

		if (!PhysProtoName.IsEmpty())
			paths = g_SmileyCategories.GetSmileyCategory(PhysProtoName) ? g_SmileyCategories.GetSmileyCategory(PhysProtoName)->GetFilename() : _T("");

		if (paths.IsEmpty()) {
			const char* packnam = acc->szProtoName;
			if (mir_strcmp(packnam, "JABBER") == 0)
				packnam = "JGMail";
			else if (strstr(packnam, "SIP") != NULL)
				packnam = "MSN";

			char path[MAX_PATH];
			mir_snprintf(path, "Smileys\\nova\\%s.msl", packnam);

			paths = A2T_SM(path);
			CMString patha;
			pathToAbsolute(paths, patha);

			if (_taccess(patha.c_str(), 0) != 0)
				paths = defaultFile;
		}

		CMString tname(A2T_SM(acc->szModuleName));
		AddCategory(tname, displayName, acc->bIsVirtual ? smcVirtualProto : smcProto, paths);
	}
}
Example #5
0
bool SmileyPackType::LoadSmileyFile(const CMString& filename, const CMString& packname, bool onlyInfo, bool noerr)
{
	Clear();

	if (filename.IsEmpty()) {
		m_Name = _T("Nothing loaded");
		return false;
	}

	CMString modpath;
	pathToAbsolute(filename, modpath);

	// Load xep file
	int fh = _topen(modpath.c_str(), _O_BINARY | _O_RDONLY);
	if (fh == -1) {
		if (!noerr) {
			static const TCHAR errmsg[] = LPGENT("Smiley pack %s for category \"%s\" not found.\nSelect correct smiley pack in the Options -> Customize -> Smileys.");
			TCHAR msgtxt[1024];
			mir_sntprintf(msgtxt, TranslateTS(errmsg), modpath.c_str(), packname);
			ReportError(msgtxt);
		}

		m_Name = _T("Nothing loaded");
		return false;
	}

	m_Filename = filename;

	// Find file size
	const long flen = _filelength(fh);

	// Allocate file buffer
	char* buf = new char[flen + sizeof(wchar_t)];

	// Read xep file in
	int len = _read(fh, buf, flen);
	*(wchar_t*)(buf + len) = 0;

	// Close file
	_close(fh);

	CMString tbuf;

	if (len > 2 && *(wchar_t*)buf == 0xfeff)
		tbuf = W2T_SM((wchar_t*)buf + 1);
	else if (len > 3 && buf[0] == '\xef' && buf[1] == '\xbb' && buf[2] == '\xbf')
		tbuf = W2T_SM(A2W_SM(buf + 3, CP_UTF8));
	else
		tbuf = A2T_SM(buf);

	delete[] buf;

	bool res;
	if (filename.Find(_T(".xep")) == -1)
		res = LoadSmileyFileMSL(tbuf, onlyInfo, modpath);
	else
		res = LoadSmileyFileXEP(tbuf, onlyInfo, modpath);

	if (errorFound)
		ReportError(TranslateT("There were problems loading smiley pack (it should be corrected).\nSee network log for details."));

	return res;
}