summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/NewStory/src/history_array.cpp51
-rw-r--r--plugins/NewStory/src/history_array.h25
-rw-r--r--plugins/NewStory/src/templates.cpp16
-rw-r--r--plugins/NewStory/src/utils.cpp4
4 files changed, 23 insertions, 73 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index fa411b2178..96f79184c3 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -20,20 +20,13 @@ bool HistoryArray::ItemData::load(EventLoadMode mode)
dbe.pBlob = (PBYTE)mir_calloc(dbe.cbBlob + 1);
db_event_get(hEvent, &dbe);
- int aLength = 0;
- atext = 0;
wtext = 0;
switch (dbe.eventType) {
case EVENTTYPE_STATUSCHANGE:
case EVENTTYPE_MESSAGE:
- atext = (char *)dbe.pBlob;
- atext_del = false;
- aLength = (int)mir_strlen(atext);
- if (dbe.cbBlob > (DWORD)aLength + 1) {
- wtext = (wchar_t *)(dbe.pBlob + aLength + 1);
- wtext_del = false;
- }
+ wtext = mir_utf8decodeW((char*)dbe.pBlob);
+ wtext_del = false;
break;
case EVENTTYPE_JABBER_PRESENCE:
@@ -42,51 +35,28 @@ bool HistoryArray::ItemData::load(EventLoadMode mode)
break;
case EVENTTYPE_AUTHREQUEST:
- atext = new char[512];
- atext_del = true;
+ wtext = new wchar_t[512];
+ wtext_del = true;
if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) {
- mir_snprintf(atext, 512, ("%s requested authorization"), dbe.pBlob + 8);
+ mir_snwprintf(wtext, 512, L"%s requested authorization", dbe.pBlob + 8);
}
else {
- mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD *)(dbe.pBlob));
+ mir_snwprintf(wtext, 512, L"%d requested authorization", *(DWORD *)(dbe.pBlob));
}
- aLength = (int)mir_strlen(atext);
break;
case EVENTTYPE_ADDED:
- atext = new char[512];
- atext_del = true;
+ wtext = new wchar_t[512];
+ wtext_del = true;
if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) {
- mir_snprintf(atext, 512, ("%s added you to the contact list"), dbe.pBlob + 8);
+ mir_snwprintf(wtext, 512, L"%s added you to the contact list", dbe.pBlob + 8);
}
else {
- mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD *)(dbe.pBlob));
+ mir_snwprintf(wtext, 512, L"%d added you to the contact list", *(DWORD *)(dbe.pBlob));
}
- aLength = (int)mir_strlen(atext);
break;
}
- if (atext && !wtext) {
-#ifdef UNICODE
- int bufSize = MultiByteToWideChar(CP_ACP, 0, atext, aLength + 1, 0, 0);
- wtext = new wchar_t[bufSize + 1];
- MultiByteToWideChar(CP_ACP, 0, atext, aLength + 1, wtext, bufSize);
- wtext_del = true;
-#else
- this->wtext = 0;
- wtext_del = false;
-#endif
- }
- else if (!atext && wtext) {
- // strange situation, really :) I'll fix this later
- }
- else if (!atext && !wtext) {
- atext = "";
- atext_del = false;
- wtext = L"";
- wtext_del = false;
- }
-
return true;
}
@@ -100,7 +70,6 @@ HistoryArray::ItemData::~ItemData()
dbe.pBlob = 0;
}
if (wtext && wtext_del) delete[] wtext;
- if (atext && atext_del) delete[] atext;
if (data) MTextDestroy(data);
}
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index 9410c686b2..53dea911a4 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -40,8 +40,7 @@ public:
bool dbeOk = false;
DBEVENTINFO dbe;
- bool atext_del = false, wtext_del = false;
- char* atext = 0;
+ bool wtext_del = false;
wchar_t* wtext = 0;
HANDLE data = 0;
@@ -56,20 +55,6 @@ public:
return load(mode);
return true;
}
- inline wchar_t* getTBuf()
- {
- loadInline(ELM_DATA);
-#ifdef UNICODE
- return wtext;
-#else
- return atext;
-#endif
- }
- inline char* getBuf()
- {
- loadInline(ELM_DATA);
- return atext;
- }
inline wchar_t* getWBuf()
{
loadInline(ELM_DATA);
@@ -98,12 +83,12 @@ public:
EVENTTEXT = 0x080,
EVENTONLY = 0x100,
};
- Filter(WORD aFlags, wchar_t* aText)
+ Filter(WORD aFlags, wchar_t* wText)
{
refCount = new int(0);
flags = aFlags;
- text = new wchar_t[mir_wstrlen(aText) + 1];
- mir_wstrcpy(text, aText);
+ text = new wchar_t[mir_wstrlen(wText) + 1];
+ mir_wstrcpy(text, wText);
}
Filter(const Filter& other)
{
@@ -158,7 +143,7 @@ public:
}
if (flags & (EVENTTEXT | EVENTONLY)) {
item->loadInline(ELM_DATA);
- return CheckFilter(item->getTBuf(), text);
+ return CheckFilter(item->getWBuf(), text);
}
return true;
};
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp
index 848f12e208..48fffaa62a 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -236,49 +236,49 @@ void vfEvent(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
void vfMessage(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfFile(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfUrl(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfSign(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfAuth(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfAdded(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfPresence(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfDeleted(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
- vars->SetVar('M', item->getTBuf(), false);
+ vars->SetVar('M', item->getWBuf(), false);
}
void vfOther(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *)
diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp
index e3bea2beeb..41ae656c75 100644
--- a/plugins/NewStory/src/utils.cpp
+++ b/plugins/NewStory/src/utils.cpp
@@ -26,11 +26,7 @@ void CopyText(HWND hwnd, const wchar_t *text)
wchar_t *s = (wchar_t *)GlobalLock(hMem);
mir_wstrcpy(s, text);
GlobalUnlock(hMem);
-#ifdef UNICODE
SetClipboardData(CF_UNICODETEXT, hMem);
-#else
- SetClipboardData(CF_TEXT, hMem);
-#endif
CloseClipboard();
// GlobalFree(hMem);
}