diff options
Diffstat (limited to 'plugins/SmileyAdd/src/smileys.cpp')
-rw-r--r-- | plugins/SmileyAdd/src/smileys.cpp | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index 213e8307d0..e0bb7d8287 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -143,12 +143,12 @@ bool SmileyType::LoadFromImage(IStream *pStream) if (m_xepimg)
m_xepimg->Release();
- CMString name;
+ CMStringW name;
m_xepimg = new ImageType(0, name, pStream);
return true;
}
-bool SmileyType::LoadFromResource(const CMString &file, const int index)
+bool SmileyType::LoadFromResource(const CMStringW &file, const int index)
{
m_index = index;
m_filepath = file;
@@ -226,9 +226,9 @@ void SmileyType::CallSmileyService(MCONTACT hContact) _TMatcher *m0 = srvsplit->createTMatcher(GetTriggerText());
m0->findFirstMatch();
- CMString name = m0->getGroup(1);
- CMString par1 = m0->getGroup(2);
- CMString par2 = m0->getGroup(3);
+ CMStringW name = m0->getGroup(1);
+ CMStringW par1 = m0->getGroup(2);
+ CMStringW par2 = m0->getGroup(3);
delete m0;
delete srvsplit;
@@ -262,7 +262,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) {
_TPattern *p = _TPattern::compile(L"\\s+");
{
- CMString emptystr;
+ CMStringW emptystr;
m_SmileyLookup.insert(new SmileyLookup(urlRegEx, true, -1, emptystr));
m_SmileyLookup.insert(new SmileyLookup(pathRegEx, true, -1, emptystr));
m_SmileyLookup.insert(new SmileyLookup(timeRegEx, true, -1, emptystr));
@@ -285,7 +285,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) while (m0->findNextMatch()) {
int stind = m0->getStartingIndex();
if (li != stind) {
- CMString out;
+ CMStringW out;
ReplaceAllSpecials(m0->getString().Mid(li, stind - li), out);
SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
if (dats->IsValid()) {
@@ -301,7 +301,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) int stind = (int)m0->getString().GetLength();
if (li < stind) {
- CMString out;
+ CMStringW out;
ReplaceAllSpecials(m0->getString().Mid(li, stind - li), out);
SmileyLookup *dats = new SmileyLookup(out, false, dist, GetFilename());
if (dats->IsValid()) {
@@ -320,7 +320,7 @@ void SmileyPackType::AddTriggersToSmileyLookup(void) delete p;
}
-void SmileyPackType::ReplaceAllSpecials(const CMString &Input, CMString &Output)
+void SmileyPackType::ReplaceAllSpecials(const CMStringW &Input, CMStringW &Output)
{
Output = _TPattern::replace(L"%%_{1,2}%%", Input, L" ");
Output = _TPattern::replace(L"%%''%%", Output, L"\"");
@@ -341,7 +341,7 @@ void SmileyPackType::Clear(void) errorFound = false;
}
-bool SmileyPackType::LoadSmileyFile(const CMString &filename, const CMString &packname, bool onlyInfo, bool noerr)
+bool SmileyPackType::LoadSmileyFile(const CMStringW &filename, const CMStringW &packname, bool onlyInfo, bool noerr)
{
Clear();
@@ -350,7 +350,7 @@ bool SmileyPackType::LoadSmileyFile(const CMString &filename, const CMString &pa return false;
}
- CMString modpath;
+ CMStringW modpath;
pathToAbsolute(filename, modpath);
// Load xep file
@@ -359,7 +359,7 @@ bool SmileyPackType::LoadSmileyFile(const CMString &filename, const CMString &pa if (!noerr) {
static const wchar_t errmsg[] = LPGENW("Smiley pack %s for category \"%s\" not found.\nSelect correct smiley pack in the Options -> Customize -> Smileys.");
wchar_t msgtxt[1024];
- mir_snwprintf(msgtxt, TranslateTS(errmsg), modpath.c_str(), packname);
+ mir_snwprintf(msgtxt, TranslateW(errmsg), modpath.c_str(), packname);
ReportError(msgtxt);
}
@@ -382,7 +382,7 @@ bool SmileyPackType::LoadSmileyFile(const CMString &filename, const CMString &pa // Close file
_close(fh);
- CMString tbuf;
+ CMStringW tbuf;
if (len > 2 && *(wchar_t*)buf == 0xfeff)
tbuf = ((wchar_t*)buf + 1);
@@ -405,9 +405,9 @@ bool SmileyPackType::LoadSmileyFile(const CMString &filename, const CMString &pa return res;
}
-bool SmileyPackType::LoadSmileyFileMSL(CMString &tbuf, bool onlyInfo, CMString &modpath)
+bool SmileyPackType::LoadSmileyFileMSL(CMStringW &tbuf, bool onlyInfo, CMStringW &modpath)
{
- CMString pathstr, packstr;
+ CMStringW pathstr, packstr;
{
_TPattern *pathsplit = _TPattern::compile(L"(.*\\\\)(.*)\\.|$");
_TMatcher *m0 = pathsplit->createTMatcher(modpath);
@@ -469,7 +469,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMString &tbuf, bool onlyInfo, CMString & {
_TMatcher *m0 = smiley->createTMatcher(tbuf);
while (m0->findNextMatch()) {
- CMString resname = m0->getGroup(2);
+ CMStringW resname = m0->getGroup(2);
if (resname.Find(L"http://") != -1) {
if (GetSmileyFile(resname, packstr))
continue;
@@ -519,7 +519,7 @@ bool SmileyPackType::LoadSmileyFileMSL(CMString &tbuf, bool onlyInfo, CMString & if (!noerr) {
static const wchar_t errmsg[] = LPGENW("Smiley #%u in file %s for smiley pack %s not found.");
wchar_t msgtxt[1024];
- mir_snwprintf(msgtxt, TranslateTS(errmsg), smnum, resname.c_str(), modpath.c_str());
+ mir_snwprintf(msgtxt, TranslateW(errmsg), smnum, resname.c_str(), modpath.c_str());
CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
errorFound = true;
}
@@ -540,11 +540,11 @@ bool SmileyPackType::LoadSmileyFileMSL(CMString &tbuf, bool onlyInfo, CMString & }
-static void DecodeHTML(CMString &str)
+static void DecodeHTML(CMStringW &str)
{
if (str.Find('&') != -1) {
- str = _TPattern::replace(CMString(L"<"), str, CMString(L"<"));
- str = _TPattern::replace(CMString(L">"), str, CMString(L">"));
+ str = _TPattern::replace(CMStringW(L"<"), str, CMStringW(L"<"));
+ str = _TPattern::replace(CMStringW(L">"), str, CMStringW(L">"));
}
}
@@ -571,7 +571,7 @@ static IStream* DecodeBase64Data(const char *pData) }
-bool SmileyPackType::LoadSmileyFileXEP(CMString &tbuf, bool onlyInfo, CMString&)
+bool SmileyPackType::LoadSmileyFileXEP(CMStringW &tbuf, bool onlyInfo, CMStringW&)
{
_TMatcher *m0, *m1, *m2;
@@ -584,7 +584,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString &tbuf, bool onlyInfo, CMString&) m0 = settings_re->createTMatcher(tbuf);
if (m0->findFirstMatch()) {
- CMString settings = m0->getGroup(1);
+ CMStringW settings = m0->getGroup(1);
m1 = author_re->createTMatcher(settings);
if (m1->findFirstMatch()) {
@@ -622,7 +622,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString &tbuf, bool onlyInfo, CMString&) m0 = images_re->createTMatcher(tbuf);
if (m0->findFirstMatch()) {
- CMString images = m0->getGroup(1);
+ CMStringW images = m0->getGroup(1);
m1 = imagedt_re->createTMatcher(images);
if (m1->findFirstMatch()) {
@@ -646,7 +646,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString &tbuf, bool onlyInfo, CMString&) dat->m_ToolText = m0->getGroup(2);
DecodeHTML(dat->m_ToolText);
- CMString rec = m0->getGroup(3);
+ CMStringW rec = m0->getGroup(3);
m1 = expression_re->createTMatcher(rec);
if (m1->findFirstMatch()) {
@@ -665,7 +665,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString &tbuf, bool onlyInfo, CMString&) m1 = image_re->createTMatcher(rec);
if (m1->findFirstMatch()) {
- CMString images = m1->getGroup(1);
+ CMStringW images = m1->getGroup(1);
m2 = imagedt_re->createTMatcher(images);
if (m2->findFirstMatch()) {
@@ -709,7 +709,7 @@ bool SmileyPackType::LoadSmileyFileXEP(CMString &tbuf, bool onlyInfo, CMString&) //
-bool SmileyPackListType::AddSmileyPack(CMString &filename, CMString &packname)
+bool SmileyPackListType::AddSmileyPack(CMStringW &filename, CMStringW &packname)
{
bool res = true;
if (GetSmileyPack(filename) == NULL) { //not exist yet, so add
@@ -725,13 +725,13 @@ bool SmileyPackListType::AddSmileyPack(CMString &filename, CMString &packname) }
-SmileyPackType* SmileyPackListType::GetSmileyPack(CMString &filename)
+SmileyPackType* SmileyPackListType::GetSmileyPack(CMStringW &filename)
{
- CMString modpath;
+ CMStringW modpath;
pathToAbsolute(filename, modpath);
for (int i = 0; i < m_SmileyPacks.getCount(); i++) {
- CMString modpath1;
+ CMStringW modpath1;
pathToAbsolute(m_SmileyPacks[i].GetFilename(), modpath1);
if (mir_wstrcmpi(modpath.c_str(), modpath1.c_str()) == 0) return &m_SmileyPacks[i];
}
@@ -749,8 +749,8 @@ void SmileyPackListType::ClearAndFreeAll() //
-SmileyCategoryType::SmileyCategoryType(SmileyPackListType *pSPS, const CMString &name,
- const CMString &displayName, const CMString &defaultFilename, SmcType typ)
+SmileyCategoryType::SmileyCategoryType(SmileyPackListType *pSPS, const CMStringW &name,
+ const CMStringW &displayName, const CMStringW &defaultFilename, SmcType typ)
{
m_pSmileyPackStore = pSPS;
type = typ;
@@ -800,7 +800,7 @@ void SmileyCategoryListType::ClearAndLoadAll(void) }
-SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(const CMString &name)
+SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(const CMStringW &name)
{
for (int i = 0; i < m_SmileyCategories.getCount(); i++)
if (name.CompareNoCase(m_SmileyCategories[i].GetName()) == 0)
@@ -816,7 +816,7 @@ SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(unsigned index) }
-SmileyPackType* SmileyCategoryListType::GetSmileyPack(CMString &categoryname)
+SmileyPackType* SmileyCategoryListType::GetSmileyPack(CMStringW &categoryname)
{
SmileyCategoryType *smc = GetSmileyCategory(categoryname);
return smc != NULL ? smc->GetSmileyPack() : NULL;
@@ -825,7 +825,7 @@ SmileyPackType* SmileyCategoryListType::GetSmileyPack(CMString &categoryname) void SmileyCategoryListType::SaveSettings(void)
{
- CMString catstr;
+ CMStringW catstr;
for (int i = 0; i < m_SmileyCategories.getCount(); i++) {
m_SmileyCategories[i].SaveSettings();
if (m_SmileyCategories[i].IsCustom()) {
@@ -837,7 +837,7 @@ void SmileyCategoryListType::SaveSettings(void) }
-void SmileyCategoryListType::AddAndLoad(const CMString &name, const CMString &displayName)
+void SmileyCategoryListType::AddAndLoad(const CMStringW &name, const CMStringW &displayName)
{
if (GetSmileyCategory(name) != NULL)
return;
@@ -849,7 +849,7 @@ void SmileyCategoryListType::AddAndLoad(const CMString &name, const CMString &di }
-void SmileyCategoryListType::AddCategory(const CMString &name, const CMString &displayName, SmcType typ, const CMString &defaultFilename)
+void SmileyCategoryListType::AddCategory(const CMStringW &name, const CMStringW &displayName, SmcType typ, const CMStringW &defaultFilename)
{
if (GetSmileyCategory(name) == NULL)
m_SmileyCategories.insert(new SmileyCategoryType(m_pSmileyPackStore, name, displayName, defaultFilename, typ));
@@ -867,14 +867,14 @@ bool SmileyCategoryListType::DeleteCustomCategory(int index) return false;
}
-void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMString &defaultFile)
+void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStringW &defaultFile)
{
if (Proto_IsAccountEnabled(acc) && acc->szProtoName && IsSmileyProto(acc->szModuleName)) {
- CMString displayName(acc->tszAccountName ? acc->tszAccountName : _A2T(acc->szModuleName));
- CMString PhysProtoName, paths;
+ CMStringW displayName(acc->tszAccountName ? acc->tszAccountName : _A2T(acc->szModuleName));
+ CMStringW PhysProtoName, paths;
DBVARIANT dbv;
- if (db_get_ts(NULL, acc->szModuleName, "AM_BaseProto", &dbv) == 0) {
+ if (db_get_ws(NULL, acc->szModuleName, "AM_BaseProto", &dbv) == 0) {
PhysProtoName = L"AllProto";
PhysProtoName += dbv.ptszVal;
db_free(&dbv);
@@ -894,19 +894,19 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr mir_snprintf(path, "Smileys\\nova\\%s.msl", packnam);
paths = _A2T(path);
- CMString patha;
+ CMStringW patha;
pathToAbsolute(paths, patha);
if (_waccess(patha.c_str(), 0) != 0)
paths = defaultFile;
}
- CMString tname(_A2T(acc->szModuleName));
+ CMStringW tname(_A2T(acc->szModuleName));
AddCategory(tname, displayName, acc->bIsVirtual ? smcVirtualProto : smcProto, paths);
}
}
-void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMString &defaultFile)
+void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMStringW &defaultFile)
{
if (acc == NULL)
return;
@@ -920,21 +920,21 @@ void SmileyCategoryListType::AddProtoAsCategory(char *acc, const CMString &defau char path[MAX_PATH];
mir_snprintf(path, "Smileys\\nova\\%s.msl", packnam);
- CMString paths = _A2T(path), patha;
+ CMStringW paths = _A2T(path), patha;
pathToAbsolute(paths, patha);
if (_waccess(patha.c_str(), 0) != 0)
paths = defaultFile;
- CMString dName(acc), displayName;
+ CMStringW dName(acc), displayName;
displayName.AppendFormat(TranslateT("%s global smiley pack"), dName.GetBuffer());
- CMString tname("AllProto");
+ CMStringW tname("AllProto");
tname += _A2T(acc);
AddCategory(tname, displayName, smcPhysProto, paths);
}
void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc)
{
- CMString tname(_A2T(acc->szModuleName));
+ CMStringW tname(_A2T(acc->szModuleName));
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
@@ -942,7 +942,7 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) continue;
DBVARIANT dbv;
- if (!db_get_ts(hContact, proto, "Transport", &dbv)) {
+ if (!db_get_ws(hContact, proto, "Transport", &dbv)) {
bool found = (tname.CompareNoCase(dbv.ptszVal) == 0);
db_free(&dbv);
if (found)
@@ -958,14 +958,14 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) }
}
-void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, const CMString &defaultFile)
+void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, const CMStringW &defaultFile)
{
char *proto = GetContactProto(hContact);
if (proto == NULL)
return;
DBVARIANT dbv;
- if (!db_get_ts(hContact, proto, "Transport", &dbv)) {
+ if (!db_get_ws(hContact, proto, "Transport", &dbv)) {
if (dbv.ptszVal[0] == '\0') {
db_free(&dbv);
return;
@@ -987,12 +987,12 @@ void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, co mir_free(trsp);
- CMString displayName = dbv.ptszVal;
+ CMStringW displayName = dbv.ptszVal;
if (packname != NULL) {
char path[MAX_PATH];
mir_snprintf(path, "Smileys\\nova\\%s.msl", packname);
- CMString paths = _A2T(path), patha;
+ CMStringW paths = _A2T(path), patha;
pathToAbsolute(paths, patha);
if (_waccess(patha.c_str(), 0) != 0)
@@ -1008,11 +1008,11 @@ void SmileyCategoryListType::AddContactTransportAsCategory(MCONTACT hContact, co void SmileyCategoryListType::AddAllProtocolsAsCategory(void)
{
- CMString displayName = TranslateT("Standard");
- CMString tname = L"Standard";
+ CMStringW displayName = TranslateT("Standard");
+ CMStringW tname = L"Standard";
AddCategory(tname, displayName, smcStd);
- const CMString &defaultFile = GetSmileyCategory(tname)->GetFilename();
+ const CMStringW &defaultFile = GetSmileyCategory(tname)->GetFilename();
PROTOCOLDESCRIPTOR **proto;
int protoCount = 0;
@@ -1032,7 +1032,7 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
AddContactTransportAsCategory(hContact, defaultFile);
- CMString cats;
+ CMStringW cats;
opt.ReadCustomCategories(cats);
int cppv = 0;
@@ -1053,13 +1053,13 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) }
-SmileyLookup::SmileyLookup(const CMString &str, const bool regexs, const int ind, const CMString &smpt)
+SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int ind, const CMStringW &smpt)
{
wchar_t msgtxt[1024];
m_ind = ind;
if (regexs) {
- static const CMString testString(L"Test String");
+ static const CMStringW testString(L"Test String");
m_pattern = _TPattern::compile(str);
m_valid = m_pattern != NULL;
if (m_valid) {
@@ -1068,13 +1068,13 @@ SmileyLookup::SmileyLookup(const CMString &str, const bool regexs, const int ind matcher->getStartingIndex() != matcher->getEndingIndex());
if (!m_valid) {
static const wchar_t errmsg[] = LPGENW("Regular expression \"%s\" in smiley pack \"%s\" could produce \"empty matches\".");
- mir_snwprintf(msgtxt, TranslateTS(errmsg), str.c_str(), smpt.c_str());
+ mir_snwprintf(msgtxt, TranslateW(errmsg), str.c_str(), smpt.c_str());
}
delete matcher;
}
else {
static const wchar_t errmsg[] = LPGENW("Regular expression \"%s\" in smiley pack \"%s\" malformed.");
- mir_snwprintf(msgtxt, TranslateTS(errmsg), str.c_str(), smpt.c_str());
+ mir_snwprintf(msgtxt, TranslateW(errmsg), str.c_str(), smpt.c_str());
}
if (!m_valid)
@@ -1094,7 +1094,7 @@ SmileyLookup::~SmileyLookup() }
-void SmileyLookup::Find(const CMString &str, SmileyLocVecType &smlcur, bool firstOnly) const
+void SmileyLookup::Find(const CMStringW &str, SmileyLocVecType &smlcur, bool firstOnly) const
{
if (!m_valid) return;
|