summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-22 16:04:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-22 16:04:17 +0000
commite2c2a1f5a84c6c9b705dc85c6a2dd1f97edd57e4 (patch)
treeba79bdcede96f80039f8b88d2791f198b9ec2981 /protocols
parentf8e34b5f83f3ce5f39d541e9068b6b8cb6d92acd (diff)
T2Utf - handy replacement for ptrA<mir_utf8decodeT()>
git-svn-id: http://svn.miranda-ng.org/main/trunk@13758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/AimOscar/src/chat.cpp7
-rw-r--r--protocols/AimOscar/src/conv.cpp3
-rw-r--r--protocols/AimOscar/src/file.cpp14
-rw-r--r--protocols/AimOscar/src/server.cpp6
-rw-r--r--protocols/AimOscar/src/services.cpp24
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp6
-rw-r--r--protocols/FacebookRM/src/json.cpp4
-rw-r--r--protocols/FacebookRM/src/process.cpp11
-rw-r--r--protocols/FacebookRM/src/proto.cpp5
-rw-r--r--protocols/GTalkExt/src/notifications.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/dialogs.cpp49
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp30
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp6
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp10
-rw-r--r--protocols/Gadu-Gadu/src/services.cpp9
-rw-r--r--protocols/JabberG/src/jabber_archive.cpp4
-rw-r--r--protocols/JabberG/src/jabber_byte.cpp19
-rw-r--r--protocols/JabberG/src/jabber_file.cpp4
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp2
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp11
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp5
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp4
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp9
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp8
-rw-r--r--protocols/MRA/src/Mra_proto.cpp2
-rw-r--r--protocols/MSN/src/msn_misc.cpp3
-rw-r--r--protocols/MSN/src/msn_p2p.cpp4
-rw-r--r--protocols/MSN/src/msn_proto.cpp8
-rw-r--r--protocols/MSN/src/msn_soapstore.cpp6
-rw-r--r--protocols/MSN/src/msn_svcs.cpp2
-rw-r--r--protocols/Sametime/src/conference.cpp46
-rw-r--r--protocols/Sametime/src/files.cpp11
-rw-r--r--protocols/Sametime/src/options.cpp7
-rw-r--r--protocols/Sametime/src/sametime_proto.cpp12
-rw-r--r--protocols/Sametime/src/sametime_session.cpp7
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h4
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h6
-rw-r--r--protocols/SkypeWeb/src/requests/subscriptions.h2
-rw-r--r--protocols/SkypeWeb/src/requests/trouter.h6
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_search.cpp2
-rw-r--r--protocols/Steam/src/steam_pooling.cpp2
-rw-r--r--protocols/Steam/src/steam_queue.cpp2
-rw-r--r--protocols/Tox/src/tox_multimedia.cpp5
-rw-r--r--protocols/Tox/src/tox_proto.cpp2
-rw-r--r--protocols/Tox/src/tox_search.cpp2
-rw-r--r--protocols/Tox/src/tox_services.cpp5
-rw-r--r--protocols/Twitter/src/chat.cpp2
-rw-r--r--protocols/Twitter/src/contacts.cpp7
-rw-r--r--protocols/VKontakte/src/misc.cpp10
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp2
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp2
-rw-r--r--protocols/VKontakte/src/vk_files.cpp2
-rw-r--r--protocols/VKontakte/src/vk_history.cpp4
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp5
-rw-r--r--protocols/VKontakte/src/vk_options.cpp4
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp2
-rw-r--r--protocols/WhatsApp/src/chat.cpp10
-rw-r--r--protocols/WhatsApp/src/proto.cpp2
-rw-r--r--protocols/Yahoo/src/chat.cpp18
-rw-r--r--protocols/Yahoo/src/file_transfer.cpp8
-rw-r--r--protocols/Yahoo/src/proto.cpp6
-rw-r--r--protocols/Yahoo/src/yahoo.cpp46
63 files changed, 184 insertions, 346 deletions
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp
index a861dccb84..0188d4609f 100644
--- a/protocols/AimOscar/src/chat.cpp
+++ b/protocols/AimOscar/src/chat.cpp
@@ -123,12 +123,9 @@ int CAimProto::OnGCEvent(WPARAM, LPARAM lParam)
case GC_USER_MESSAGE:
if (gch->ptszText && mir_tstrlen(gch->ptszText))
- {
- char* msg = mir_utf8encodeT(gch->ptszText);
- aim_chat_send_message(item->hconn, item->seqno, msg);
- mir_free(msg);
- }
+ aim_chat_send_message(item->hconn, item->seqno, T2Utf(gch->ptszText));
break;
+
case GC_USER_CHANMGR:
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, invite_to_chat_dialog,
LPARAM(new invite_chat_param(item->id, this)));
diff --git a/protocols/AimOscar/src/conv.cpp b/protocols/AimOscar/src/conv.cpp
index f0458f7fde..75c95e2cc7 100644
--- a/protocols/AimOscar/src/conv.cpp
+++ b/protocols/AimOscar/src/conv.cpp
@@ -771,10 +771,9 @@ char* rtf_to_html(HWND hwndDlg,int DlgItem)
}
else
{
- char* txt = mir_utf8encodeT(text);
+ T2Utf txt(text);
strcpy(&buf[pos], txt);
pos += mir_strlen(txt);
- mir_free(txt);
}
start++;
end++;
diff --git a/protocols/AimOscar/src/file.cpp b/protocols/AimOscar/src/file.cpp
index b8eb1840f0..d47aa56b02 100644
--- a/protocols/AimOscar/src/file.cpp
+++ b/protocols/AimOscar/src/file.cpp
@@ -120,24 +120,22 @@ bool setup_next_file_send(file_transfer *ft)
ft->pfts.currentFileProgress = 0;
char* fnamea;
- char* fname = mir_utf8encodeT(file);
+ T2Utf fname(file);
if (ft->pfts.totalFiles > 1 && ft->file[0])
{
size_t dlen = mir_strlen(ft->file);
if (strncmp(fname, ft->file, dlen) == 0 && fname[dlen] == '\\')
{
fnamea = &fname[dlen+1];
- for (char *p = fnamea; *p; ++p) { if (*p == '\\') *p = 1; }
+ for (char *p = fnamea; *p; ++p)
+ if (*p == '\\')
+ *p = 1;
}
- else
- fnamea = get_fname(fname);
+ else fnamea = get_fname(fname);
}
- else
- fnamea = get_fname(fname);
+ else fnamea = get_fname(fname);
send_init_oft2(ft, fnamea);
-
- mir_free(fname);
return true;
}
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp
index 1f3a2403d9..a48b25df92 100644
--- a/protocols/AimOscar/src/server.cpp
+++ b/protocols/AimOscar/src/server.cpp
@@ -1264,11 +1264,10 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho
if (channel == 1) { //Message not file
if (auto_response) { //this message must be an autoresponse
- char* away = mir_utf8encodeT(TranslateT("[Auto-Response]:"));
+ T2Utf away(TranslateT("[Auto-Response]:"));
size_t len = mir_strlen(msg_buf) + mir_strlen(away) + 2;
char* buf = (char*)mir_alloc(len);
mir_snprintf(buf, len, "%s %s", away, msg_buf);
- mir_free(away);
mir_free(msg_buf);
msg_buf = buf;
}
@@ -1291,11 +1290,10 @@ void CAimProto::snac_received_message(SNAC &snac,HANDLE hServerConn,unsigned sho
{
char* s_msg = process_status_msg(*msgptr, sn);
- char* away = mir_utf8encodeT(TranslateT("[Auto-Response]:"));
+ T2Utf away(TranslateT("[Auto-Response]:"));
size_t len = mir_strlen(s_msg) + mir_strlen(away) + 2;
char* buf = (char*)alloca(len);
mir_snprintf(buf, len, "%s %s", away, s_msg);
- mir_free(away);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
diff --git a/protocols/AimOscar/src/services.cpp b/protocols/AimOscar/src/services.cpp
index 5097b0d080..01944ef024 100644
--- a/protocols/AimOscar/src/services.cpp
+++ b/protocols/AimOscar/src/services.cpp
@@ -204,34 +204,26 @@ int CAimProto::OnGroupChange(WPARAM hContact,LPARAM lParam)
if (hContact == NULL) {
if (grpchg->pszNewName == NULL && grpchg->pszOldName != NULL) {
- char* szOldName = mir_utf8encodeT(grpchg->pszOldName);
+ T2Utf szOldName(grpchg->pszOldName);
unsigned short group_id = group_list.find_id(szOldName);
if (group_id) {
aim_delete_contact(hServerConn, seqno, szOldName, 0, group_id, 1, false);
group_list.remove_by_id(group_id);
update_server_group("", 0);
}
- mir_free(szOldName);
}
else if (grpchg->pszNewName != NULL && grpchg->pszOldName != NULL) {
- char* szOldName = mir_utf8encodeT(grpchg->pszOldName);
- unsigned short group_id = group_list.find_id(szOldName);
- if (group_id) {
- char* szNewName = mir_utf8encodeT(grpchg->pszNewName);
- update_server_group(szNewName, group_id);
- mir_free(szNewName);
- }
- mir_free(szOldName);
+ unsigned short group_id = group_list.find_id(T2Utf(grpchg->pszOldName));
+ if (group_id)
+ update_server_group(T2Utf(grpchg->pszNewName), group_id);
}
}
else {
if (is_my_contact(hContact) && getBuddyId(hContact, 1) && !db_get_b(hContact, MOD_KEY_CL, AIM_KEY_NL, 0)) {
- if (grpchg->pszNewName) {
- char* szNewName = mir_utf8encodeT(grpchg->pszNewName);
- add_contact_to_group(hContact, szNewName);
- mir_free(szNewName);
- }
- else add_contact_to_group(hContact, AIM_DEFAULT_GROUP);
+ if (grpchg->pszNewName)
+ add_contact_to_group(hContact, T2Utf(grpchg->pszNewName));
+ else
+ add_contact_to_group(hContact, AIM_DEFAULT_GROUP);
}
}
return 0;
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index b736b2c239..771adf60bd 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -299,16 +299,16 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
status->user_id = data->walls[wall_id]->user_id;
status->isPage = data->walls[wall_id]->isPage;
status->privacy = privacy_types[privacy_id].id;
- status->place = ptrA(mir_utf8encodeT(placeT));
+ status->place = T2Utf(placeT);
status->url = _T2A(urlT);
HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST);
GetSelectedContacts(data->proto, NULL, hwndList, &status->users);
- ptrA narrow(mir_utf8encodeT(mindMessageT));
+ T2Utf narrow(mindMessageT);
status->text = narrow;
- if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char *)narrow)
+ if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char*)narrow)
data->proto->last_status_msg_ = narrow;
data->proto->ForkThread(&FacebookProto::SetAwayMsgWorker, status);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index defcec4595..36dcc6aae9 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -378,12 +378,12 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE
TCHAR title[200];
mir_sntprintf(title, SIZEOF(title), TranslateT("User sent %s:"), newText.c_str());
- *message_text += ptrA(mir_utf8encodeT(title));
+ *message_text += T2Utf(title);
*message_text += attachments_text;
}
else {
// TODO: better support for these attachments (parse it from "m_messaging" instead of "messaging"
- *message_text += ptrA(mir_utf8encodeT(TranslateT("User sent an unsupported attachment. Open your browser to see it.")));
+ *message_text += T2Utf(TranslateT("User sent an unsupported attachment. Open your browser to see it."));
}
}
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index af61679db4..e89049cd70 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -27,7 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/**
* Helper function for loading name from database (or use default one specified as parameter), used for title of few notifications.
*/
-std::string getContactName(FacebookProto *proto, MCONTACT hContact, const char *defaultName) {
+std::string getContactName(FacebookProto *proto, MCONTACT hContact, const char *defaultName)
+{
std::string name = defaultName;
DBVARIANT dbv;
@@ -1225,8 +1226,7 @@ void FacebookProto::SearchAckThread(void *targ)
int count = 0;
- char *arg = mir_utf8encodeT((TCHAR*)targ);
- std::string search = utils::url::encode(arg);
+ std::string search = utils::url::encode(T2Utf((TCHAR *)targ).str());
std::string ssid;
while (count < 50 && !isOffline())
@@ -1300,15 +1300,13 @@ void FacebookProto::SearchAckThread(void *targ)
facy.handle_success("searchAckThread");
mir_free(targ);
- mir_free(arg);
}
void FacebookProto::SearchIdAckThread(void *targ)
{
facy.handle_entry("searchIdAckThread");
- char *arg = mir_utf8encodeT((TCHAR*)targ);
- std::string search = utils::url::encode(arg) + "?";
+ std::string search = utils::url::encode(T2Utf((TCHAR*)targ).str()) + "?";
if (!isOffline())
{
@@ -1358,5 +1356,4 @@ void FacebookProto::SearchIdAckThread(void *targ)
facy.handle_success("searchIdAckThread");
mir_free(targ);
- mir_free(arg);
}
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index afa5303574..7018e530ea 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -227,10 +227,9 @@ int FacebookProto::SetAwayMsg(int, const PROTOCHAR *msg)
return 0;
}
- char *narrow = mir_utf8encodeT(msg);
- if (last_status_msg_ != narrow)
+ T2Utf narrow(msg);
+ if (last_status_msg_ != (char*)narrow)
last_status_msg_ = narrow;
- mir_free(narrow);
if (isOnline() && getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
diff --git a/protocols/GTalkExt/src/notifications.cpp b/protocols/GTalkExt/src/notifications.cpp
index 1a6eb2825d..fa83bcb284 100644
--- a/protocols/GTalkExt/src/notifications.cpp
+++ b/protocols/GTalkExt/src/notifications.cpp
@@ -190,7 +190,7 @@ MCONTACT SetupPseudocontact(LPCTSTR jid, LPCTSTR unreadCount, LPCSTR acc, LPCTST
static MEVENT AddCListNotification(MCONTACT hContact, LPCSTR acc, POPUPDATAT *data, LPCTSTR url)
{
- mir_ptr<char> szUrl(mir_utf8encodeT(url)), szText(mir_utf8encodeT(data->lptzText));
+ T2Utf szUrl(url), szText(data->lptzText);
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = (LPSTR)acc;
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp
index a75e6ef516..5ace2600c9 100644
--- a/protocols/Gadu-Gadu/src/dialogs.cpp
+++ b/protocols/Gadu-Gadu/src/dialogs.cpp
@@ -832,32 +832,20 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
req = gg_pubdir50_new(GG_PUBDIR50_WRITE);
GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_LASTNAME, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_NICKNAME, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_CITY, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_CITY, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_CITY, T2Utf(text));
// Gadu-Gadu Female <-> Male
switch(SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0)) {
@@ -872,25 +860,16 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
}
GetDlgItemText(hwndDlg, IDC_BIRTHYEAR, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_FAMILYNAME, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, T2Utf(text));
GetDlgItemText(hwndDlg, IDC_CITYORIGIN, text, SIZEOF(text));
- if (mir_tstrlen(text)){
- char* text_utf8 = mir_utf8encodeT(text);
- gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, text_utf8);
- mir_free(text_utf8);
- }
+ if (mir_tstrlen(text))
+ gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, T2Utf(text));
// Run update
gg_pubdir50_seq_set(req, GG_SEQ_CHINFO);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index 6c532d195b..2b6d0db04a 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -277,14 +277,10 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id)
return (HANDLE)1;
}
- char *id_utf8 = mir_utf8encodeT(id);
-
// Add uin and search it
- gg_pubdir50_add(req, GG_PUBDIR50_UIN, id_utf8);
+ gg_pubdir50_add(req, GG_PUBDIR50_UIN, T2Utf(id));
gg_pubdir50_seq_set(req, GG_SEQ_SEARCH);
- mir_free(id_utf8);
-
gg_EnterCriticalSection(&sess_mutex, "SearchBasic", 50, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
@@ -330,28 +326,25 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName,
// Add nick,firstName,lastName and search it
if (nick)
{
- char *nick_utf8 = mir_utf8encodeT(nick);
+ T2Utf nick_utf8(nick);
gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nick_utf8);
strncat(data, nick_utf8, sizeof(data) - mir_strlen(data));
- mir_free(nick_utf8);
}
strncat(data, ".", sizeof(data) - mir_strlen(data));
if (firstName)
{
- char *firstName_utf8 = mir_utf8encodeT(firstName);
+ T2Utf firstName_utf8(firstName);
gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstName_utf8);
strncat(data, firstName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(firstName_utf8);
}
strncat(data, ".", sizeof(data) - mir_strlen(data));
if (lastName)
{
- char *lastName_utf8 = mir_utf8encodeT(lastName);
+ T2Utf lastName_utf8(lastName);
gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastName_utf8);
strncat(data, lastName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(lastName_utf8);
}
strncat(data, ".", sizeof(data) - mir_strlen(data));
@@ -407,40 +400,36 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *firstName_utf8 = mir_utf8encodeT(text);
+ T2Utf firstName_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstName_utf8);
strncat(data, firstName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(firstName_utf8);
}
/* 1 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
GetDlgItemText(hwndDlg, IDC_LASTNAME, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *lastName_utf8 = mir_utf8encodeT(text);
+ T2Utf lastName_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastName_utf8);
strncat(data, lastName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(lastName_utf8);
}
/* 2 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
GetDlgItemText(hwndDlg, IDC_NICKNAME, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *nickName_utf8 = mir_utf8encodeT(text);
+ T2Utf nickName_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nickName_utf8);
strncat(data, nickName_utf8, sizeof(data) - mir_strlen(data));
- mir_free(nickName_utf8);
}
/* 3 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
GetDlgItemText(hwndDlg, IDC_CITY, text, SIZEOF(text));
if (mir_tstrlen(text))
{
- char *city_utf8 = mir_utf8encodeT(text);
+ T2Utf city_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_CITY, city_utf8);
strncat(data, city_utf8, sizeof(data) - mir_strlen(data));
- mir_free(city_utf8);
}
/* 4 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
@@ -468,10 +457,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
yearFrom = ay - yearFrom;
mir_sntprintf(text, SIZEOF(text), _T("%d %d"), yearFrom, yearTo);
- char *age_utf8 = mir_utf8encodeT(text);
+ T2Utf age_utf8(text);
gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, age_utf8);
strncat(data, age_utf8, sizeof(data) - mir_strlen(data));
- mir_free(age_utf8);
}
/* 5 */ strncat(data, ".", sizeof(data) - mir_strlen(data));
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index 4735a055e9..1e194c6ece 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -181,12 +181,10 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
mir_free(nickT);
- char* pszText_utf8 = mir_utf8encodeT(gch->ptszText);
+ T2Utf pszText_utf8(gch->ptszText);
gg_EnterCriticalSection(&sess_mutex, "gc_event", 57, "sess_mutex", 1);
- gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText_utf8);
+ gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, pszText_utf8);
gg_LeaveCriticalSection(&sess_mutex, "gc_event", 57, 1, "sess_mutex", 1);
- mir_free(pszText_utf8);
-
return 1;
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index a93de45b5a..5f1dd86fd3 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -862,18 +862,14 @@ int GGPROTO::img_displayasmsg(MCONTACT hContact, void *img)
TCHAR image_msg[MAX_PATH + 11];
mir_sntprintf(image_msg, SIZEOF(image_msg), _T("[img]%s[/img]"), szPath);
+ T2Utf szMessage(image_msg);
PROTORECVEVENT pre = {0};
pre.timestamp = time(NULL);
- pre.szMessage = mir_utf8encodeT(image_msg);
+ pre.szMessage = szMessage;
ProtoChainRecvMsg(hContact, &pre);
debugLog(_T("img_displayasmsg(): Image saved to %s."), szPath);
-
- mir_free(pre.szMessage);
- }
- else
- {
- debugLog(_T("img_displayasmsg(): Cannot save image to %s."), szPath);
}
+ else debugLog(_T("img_displayasmsg(): Cannot save image to %s."), szPath);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp
index 26c0d62734..af998847a4 100644
--- a/protocols/Gadu-Gadu/src/services.cpp
+++ b/protocols/Gadu-Gadu/src/services.cpp
@@ -105,16 +105,14 @@ int GGPROTO::refreshstatus(int status)
gg_EnterCriticalSection(&modemsg_mutex, "refreshstatus", 69, "modemsg_mutex", 1);
szMsg = getstatusmsg(status);
gg_LeaveCriticalSection(&modemsg_mutex, "refreshstatus", 69, 1, "modemsg_mutex", 1);
- char *szMsg_utf8 = mir_utf8encodeT(szMsg);
- if (szMsg_utf8)
- {
+ T2Utf szMsg_utf8(szMsg);
+ if (szMsg_utf8) {
debugLogA("refreshstatus(): Setting status and away message.");
gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 70, "sess_mutex", 1);
gg_change_status_descr(sess, status_m2gg(status, szMsg_utf8 != NULL), szMsg_utf8);
gg_LeaveCriticalSection(&sess_mutex, "refreshstatus", 70, 1, "sess_mutex", 1);
}
- else
- {
+ else {
debugLogA("refreshstatus(): Setting just status.");
gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 71, "sess_mutex", 1);
gg_change_status(sess, status_m2gg(status, 0));
@@ -123,7 +121,6 @@ int GGPROTO::refreshstatus(int status)
// Change status of the contact with our own UIN (if got yourself added to the contact list)
changecontactstatus( getDword(GG_KEY_UIN, 0), status_m2gg(status, szMsg != NULL), szMsg, 0, 0, 0, 0);
broadcastnewstatus(status);
- mir_free(szMsg_utf8);
}
return TRUE;
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp
index 18fbec6911..21e686c742 100644
--- a/protocols/JabberG/src/jabber_archive.cpp
+++ b/protocols/JabberG/src/jabber_archive.cpp
@@ -288,14 +288,14 @@ void CJabberProto::OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*)
if (!tszBody || !tszSecs)
continue;
- ptrA szEventText( mir_utf8encodeT(tszBody));
+ T2Utf szEventText(tszBody);
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.szModule = m_szModuleName;
dbei.cbBlob = (DWORD)mir_strlen(szEventText);
dbei.flags = DBEF_READ + DBEF_UTF + from;
- dbei.pBlob = (PBYTE)(char*)szEventText;
+ dbei.pBlob = szEventText;
dbei.timestamp = tmStart + _ttol(tszSecs) - timezone;
if (!IsDuplicateEvent(hContact, dbei))
db_event_add(hContact, &dbei);
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp
index b9910d9b5d..ffbc79d77f 100644
--- a/protocols/JabberG/src/jabber_byte.cpp
+++ b/protocols/JabberG/src/jabber_byte.cpp
@@ -367,7 +367,7 @@ int CJabberProto::ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* b
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- ptrA szAuthString(mir_utf8encodeT(text));
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -516,7 +516,7 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT(text);
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -524,7 +524,6 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch
Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
@@ -705,12 +704,13 @@ int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char
data[4] = 40;
TCHAR text[JABBER_MAX_JID_LEN * 2];
- TCHAR *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
- TCHAR *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
- mir_free(szInitiatorJid);
- mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT(text);
+ {
+ ptrT szInitiatorJid(JabberPrepareJid(jbt->srcJID));
+ ptrT szTargetJid(JabberPrepareJid(jbt->dstJID));
+ mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
+ }
+
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -718,7 +718,6 @@ int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char
Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index 1c51a3b87e..d962cac51e 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -277,7 +277,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
else
p = ft->std.ptszFiles[i];
- char *pFileName = mir_urlEncode(ptrA(mir_utf8encodeT(p)));
+ ptrA pFileName(mir_urlEncode(T2Utf(p)));
if (pFileName != NULL) {
ft->szId = JabberId2string(SerialNext());
@@ -290,8 +290,6 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
char szAddr[256];
mir_snprintf(szAddr, SIZEOF(szAddr), "http://%s:%d/%s", myAddr, nlb.wPort, pFileName);
- mir_free(pFileName);
-
size_t len = mir_tstrlen(ptszResource) + mir_tstrlen(ft->jid) + 2;
TCHAR *fulljid = (TCHAR *)alloca(sizeof(TCHAR) * len);
mir_sntprintf(fulljid, len, _T("%s/%s"), ft->jid, ptszResource);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index a109b3bea3..59594259fa 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -217,7 +217,7 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*)
query << XCHILD(_T("username"), m_ThreadInfo->conn.username);
if (xmlGetChild(queryNode, "digest") != NULL && m_ThreadInfo->szStreamId) {
JabberShaStrBuf buf;
- ptrA str(mir_utf8encodeT(m_ThreadInfo->conn.password));
+ T2Utf str(m_ThreadInfo->conn.password);
char text[200];
mir_snprintf(text, SIZEOF(text), "%s%s", m_ThreadInfo->szStreamId, str);
query << XCHILD(_T("digest"), _A2T(JabberSha1(text, buf)));
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 7072c507db..672857fe74 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -73,11 +73,11 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
MCONTACT hContact = DBCreateContact(jid, nick, TRUE, TRUE);
delSetting(hContact, "Hidden");
- char* szJid = mir_utf8encodeT(jid);
- char* szNick = mir_utf8encodeT(nick);
+ T2Utf szJid(jid);
+ T2Utf szNick(nick);
- //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- //blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
+ // blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ // blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)time(NULL);
@@ -95,9 +95,6 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
db_event_add(NULL, &dbei);
debugLogA("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);
-
- mir_free(szJid);
- mir_free(szNick);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 5afc459a87..bdf8e06dc0 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -1232,11 +1232,8 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg)
fwrite(header, 1, sizeof(header) - 1 /* for zero terminator */, fp);
TCHAR *xtmp = xi.toString(root, NULL);
- char *tmp = mir_utf8encodeT(xtmp);
+ fputs(T2Utf(xtmp), fp);
xi.freeMem(xtmp);
-
- fwrite(tmp, 1, mir_strlen(tmp), fp);
- mir_free(tmp);
fclose(fp);
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index ac27168eb1..c7b61995a2 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -804,8 +804,8 @@ HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstN
int __cdecl CJabberProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt)
{
- ptrA szResUtf(mir_utf8encodeT((LPCTSTR)evt->lParam));
- evt->pCustomData = szResUtf;
+ T2Utf szResUtf((LPCTSTR)evt->lParam);
+ evt->pCustomData = (char*)szResUtf;
evt->cbCustomDataSize = (DWORD)mir_strlen(szResUtf);
Proto_RecvMessage(hContact, evt);
return 0;
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index ce2cafb2fc..a364050197 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -157,9 +157,8 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge)
CallService(MS_UTILS_GETRANDOM, sizeof(digest), (LPARAM)digest);
mir_snprintf(cnonce, SIZEOF(cnonce), "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
- ptrA uname(mir_utf8encodeT(info->conn.username)),
- passw(mir_utf8encodeT(info->conn.password)),
- serv(mir_utf8encode(info->conn.server));
+ T2Utf uname(info->conn.username), passw(info->conn.password);
+ ptrA serv(mir_utf8encode(info->conn.server));
mir_md5_init(&ctx);
mir_md5_append(&ctx, (BYTE*)(char*)uname, (int)mir_strlen(uname));
@@ -304,7 +303,7 @@ char* TScramAuth::getChallenge(const TCHAR *challenge)
char* TScramAuth::getInitialRequest()
{
- ptrA uname(mir_utf8encodeT(info->conn.username));
+ T2Utf uname(info->conn.username);
unsigned char nonce[24];
CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
@@ -339,7 +338,7 @@ TPlainAuth::~TPlainAuth()
char* TPlainAuth::getInitialRequest()
{
- ptrA uname(mir_utf8encodeT(info->conn.username)), passw(mir_utf8encodeT(info->conn.password));
+ T2Utf uname(info->conn.username), passw(info->conn.password);
size_t size = 2 * mir_strlen(uname) + mir_strlen(passw) + mir_strlen(info->conn.server) + 4;
char *toEncode = (char*)alloca(size);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 917a0af363..c5c18a6453 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -205,15 +205,14 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData *info)
xmlAddAttr(stream, _T("version"), _T("1.0"));
LPTSTR xmlQuery = xi.toString(n, NULL);
- char* buf = mir_utf8encodeT(xmlQuery);
+ T2Utf buf(xmlQuery);
int bufLen = (int)mir_strlen(buf);
if (bufLen > 2) {
- strdel(buf + bufLen - 2, 1);
+ strdel((char*)buf + bufLen - 2, 1);
bufLen--;
}
info->send(buf, bufLen);
- mir_free(buf);
xi.freeMem(xmlQuery);
xi.destroyNode(n);
}
@@ -1987,9 +1986,8 @@ int ThreadData::send(HXML node)
*q = 0;
- char* utfStr = mir_utf8encodeT(str);
+ T2Utf utfStr(str);
int result = send(utfStr, (int)mir_strlen(utfStr));
- mir_free(utfStr);
xi.freeMem(str);
return result;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index 856ab61442..80eed2e2a7 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -1781,7 +1781,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA &
if (m_heNudgeReceived)
NotifyEventHooks(m_heNudgeReceived, hContact, NULL);
else {
- ptrA szMsg(mir_utf8encodeT(TranslateTS(MRA_ALARM_MESSAGE)));
+ T2Utf szMsg(TranslateTS(MRA_ALARM_MESSAGE));
pre.szMessage = szMsg;
ProtoChainRecvMsg(hContact, &pre);
}
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index 8776bfd310..7408bd7df4 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -236,7 +236,7 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen)
mir_sha1_ctx sha1ctx;
BYTE sha1c[MIR_SHA1_HASH_SIZE], sha1d[MIR_SHA1_HASH_SIZE];
- char *szFname = mir_utf8encodeT(sztFname);
+ T2Utf szFname(sztFname);
mir_sha1_init(&sha1ctx);
mir_sha1_append(&sha1ctx, (BYTE*)pData, (int)cbLen);
@@ -281,7 +281,6 @@ int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen)
char* szBuffer = ezxml_toxml(xmlp, false);
ezxml_free(xmlp);
- mir_free(szFname);
ptrA szEncodedBuffer(mir_urlEncode(szBuffer));
free(szBuffer);
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp
index 2a515a0e8c..46b85d9f43 100644
--- a/protocols/MSN/src/msn_p2p.cpp
+++ b/protocols/MSN/src/msn_p2p.cpp
@@ -249,9 +249,7 @@ void CMsnProto::p2p_savePicture2disk(filetransfer* ft)
setString(ft->std.hContact, "PictSavedContext", ft->p2p_object);
ProtoBroadcastAck(AI.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0);
- char *filename = mir_utf8encodeT(AI.filename);
- debugLogA("Avatar for contact %08x saved to file '%s'", AI.hContact, filename);
- mir_free(filename);
+ debugLogA("Avatar for contact %08x saved to file '%s'", AI.hContact, T2Utf(AI.filename));
}
break;
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 5a2036a115..acf07cc3a4 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -295,16 +295,13 @@ int __cdecl CMsnProto::AuthRequest(MCONTACT hContact, const TCHAR* szMessage)
db_get_static(hContact, m_szModuleName, "e-mail", email, sizeof(email)))
return 1;
- char* szMsg = mir_utf8encodeT(szMessage);
-
int netId = strncmp(email, "tel:", 4) == 0 ? NETID_MOB : (strncmp(email, "live:", 5) == 0 ? NETID_SKYPE : NETID_MSN);
- if (MSN_AddUser(hContact, email, netId, LIST_FL, szMsg)) {
+ if (MSN_AddUser(hContact, email, netId, LIST_FL, T2Utf(szMessage))) {
MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);
MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
MSN_AddUser(hContact, email, netId, LIST_AL);
}
MSN_SetContactDb(hContact, email);
- mir_free(szMsg);
if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact);
return 0;
@@ -400,7 +397,7 @@ int CMsnProto::AuthDeny(MEVENT hDbEvent, const TCHAR*)
void __cdecl CMsnProto::MsnSearchAckThread(void* arg)
{
const TCHAR* emailT = (TCHAR*)arg;
- char *email = mir_utf8encodeT(emailT);
+ T2Utf email(emailT);
if (Lists_IsInList(LIST_FL, email)) {
MSN_ShowPopup(emailT, TranslateT("Contact already in your contact list"), MSN_ALLOW_MSGBOX, NULL);
@@ -442,7 +439,6 @@ void __cdecl CMsnProto::MsnSearchAckThread(void* arg)
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, arg, 0);
break;
}
- mir_free(email);
mir_free(arg);
}
diff --git a/protocols/MSN/src/msn_soapstore.cpp b/protocols/MSN/src/msn_soapstore.cpp
index 42a6d9ae8f..a10dbd11f0 100644
--- a/protocols/MSN/src/msn_soapstore.cpp
+++ b/protocols/MSN/src/msn_soapstore.cpp
@@ -507,7 +507,7 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime
{
char* reqHdr;
ezxml_t tbdy;
- char* szName = mir_utf8encodeT(sztName);
+ T2Utf szName(sztName);
ezxml_t xmlp = storeSoapHdr("CreateDocument", "RoamingIdentityChanged", tbdy, reqHdr);
ezxml_t hndl = ezxml_add_child(tbdy, "parentHandle", 0);
@@ -544,7 +544,6 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime
char* szData = ezxml_toxml(xmlp, true);
ezxml_free(xmlp);
- mir_free(szName);
unsigned status = 0;
char *storeUrl = NULL, *tResult = NULL;
@@ -589,7 +588,7 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime
bool CMsnProto::MSN_StoreUpdateDocument(const TCHAR *sztName, const char *szMimeType, const char *szPicData, bool allowRecurse)
{
char* reqHdr;
- char* szName = mir_utf8encodeT(sztName);
+ T2Utf szName(sztName);
ezxml_t tbdy;
ezxml_t xmlp = storeSoapHdr("UpdateDocument", "RoamingIdentityChanged", tbdy, reqHdr);
@@ -616,7 +615,6 @@ bool CMsnProto::MSN_StoreUpdateDocument(const TCHAR *sztName, const char *szMime
char* szData = ezxml_toxml(xmlp, true);
ezxml_free(xmlp);
- mir_free(szName);
unsigned status = 0;
char *storeUrl = NULL, *tResult = NULL;
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp
index 32de674020..8a70038f54 100644
--- a/protocols/MSN/src/msn_svcs.cpp
+++ b/protocols/MSN/src/msn_svcs.cpp
@@ -436,7 +436,7 @@ int CMsnProto::OnGroupChange(WPARAM hContact, LPARAM lParam)
}
else {
if (MSN_IsMyContact(hContact))
- MSN_MoveContactToGroup(hContact, ptrA(mir_utf8encodeT(grpchg->pszNewName)));
+ MSN_MoveContactToGroup(hContact, T2Utf(grpchg->pszNewName));
}
return 0;
}
diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp
index a34be253cf..4f3402413a 100644
--- a/protocols/Sametime/src/conference.cpp
+++ b/protocols/Sametime/src/conference.cpp
@@ -34,9 +34,7 @@ void mwServiceConf_on_invited(mwConference* conf, mwLoginInfo* inviter, const ch
for (;mem;mem=mem->next) {
if (proto->my_login_info && strcmp(proto->my_login_info->login_id, ((mwLoginInfo*)mem->data)->login_id) == 0) {
proto->debugLog(_T("mwServiceConf_on_invited() already present"));
- char* utfs = mir_utf8encodeT(TranslateT("Invitation rejected - already present."));
- mwConference_reject(conf, 0, utfs);
- mir_free(utfs);
+ mwConference_reject(conf, 0, T2Utf(TranslateT("Invitation rejected - already present.")));
return;
}
}
@@ -75,14 +73,11 @@ void CSametimeProto::ClearInviteQueue()
MCONTACT hContact = FindContactByUserId(idb.user);
if (!hContact) {
mwSametimeList* user_list = mwSametimeList_new();
- char* utfs = mir_utf8encodeT(TranslateT("None"));
- mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, utfs);
+ mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, T2Utf(TranslateT("None")));
mwSametimeUser* stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &idb);
hContact = AddContact(stuser, (options.add_contacts ? false : true));
mwSametimeList_free(user_list);
- mir_free(utfs);
-
}
bool found = false;
@@ -96,11 +91,8 @@ void CSametimeProto::ClearInviteQueue()
}
g_list_free(members);
- if (!found) {
- char* temp = mir_utf8encodeT(TranslateT("Please join this meeting."));
- mwConference_invite(my_conference, &idb, temp);
- mir_free(temp);
- }
+ if (!found)
+ mwConference_invite(my_conference, &idb, T2Utf(TranslateT("Please join this meeting.")));
invite_queue.pop();
}
@@ -209,14 +201,12 @@ void mwServiceConf_on_peer_joined(mwConference* conf, mwLoginInfo *user)
idb.community = 0;
mwSametimeList* user_list = mwSametimeList_new();
- char* utfs = mir_utf8encodeT(TranslateT("None"));
- mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, utfs);
+ mwSametimeGroup* stgroup = mwSametimeGroup_new(user_list, mwSametimeGroup_NORMAL, T2Utf(TranslateT("None")));
mwSametimeUser* stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &idb);
hContact = proto->AddContact(stuser, (proto->options.add_contacts ? false : true));
mwSametimeList_free(user_list);
- mir_free(utfs);
}
ptrT tszConfId(mir_utf8decodeT(mwConference_getName(conf)));
@@ -360,10 +350,7 @@ int CSametimeProto::GcEventHook(WPARAM wParam, LPARAM lParam) {
case GC_USER_MESSAGE:
{
debugLog(_T("CSametimeProto::GcEventHook() GC_USER_MESSAGE"));
- char* utf_msg;
- utf_msg = mir_utf8encodeT(gch->ptszText);
- mwConference_sendText((mwConference*)conf->data, utf_msg);
- mir_free(utf_msg);
+ mwConference_sendText((mwConference*)conf->data, T2Utf(gch->ptszText));
}
break;
case GC_SESSION_TERMINATE:
@@ -373,9 +360,7 @@ int CSametimeProto::GcEventHook(WPARAM wParam, LPARAM lParam) {
CloseMyConference(this);
} else {
debugLog(_T("CSametimeProto::GcEventHook() GC_SESSION_TERMINATE mwConference_destroy"));
- char* utfs = mir_utf8encodeT(TranslateT("I'm outa here."));
- mwConference_destroy((mwConference*)conf->data, 0, utfs);
- mir_free(utfs);
+ mwConference_destroy((mwConference*)conf->data, 0, T2Utf(TranslateT("I'm outa here.")));
}
}
break;
@@ -435,11 +420,10 @@ INT_PTR CSametimeProto::onMenuCreateChat(WPARAM wParam, LPARAM lParam)
if (!my_conference) {
debugLog(_T("CSametimeProto::onMenuCreateChat() mwConference_open"));
- char* utfs;
- my_conference = mwConference_new(service_conference, utfs = mir_utf8encodeT(title));
+ my_conference = mwConference_new(service_conference, T2Utf(title));
mwConference_open(my_conference);
- mir_free(utfs);
- } else {
+ }
+ else {
debugLog(_T("CSametimeProto::onMenuCreateChat() ClearInviteQueue"));
ClearInviteQueue();
}
@@ -503,12 +487,10 @@ void CSametimeProto::DeinitConference()
if (service_conference){
conferences = conf = mwServiceConference_getConferences(service_conference);
for (;conf;conf = conf->next) {
- if (my_conference == conf->data) CloseMyConference(this);
- else {
- char* utfs = mir_utf8encodeT(TranslateT("I'm outa here."));
- mwConference_destroy((mwConference*)conf->data, 0, utfs);
- mir_free(utfs);
- }
+ if (my_conference == conf->data)
+ CloseMyConference(this);
+ else
+ mwConference_destroy((mwConference*)conf->data, 0, T2Utf(TranslateT("I'm outa here.")));
}
g_list_free(conferences);
}
diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp
index e3836b75ae..f65b6c3b87 100644
--- a/protocols/Sametime/src/files.cpp
+++ b/protocols/Sametime/src/files.cpp
@@ -297,17 +297,10 @@ HANDLE CSametimeProto::SendFilesToUser(MCONTACT hContact, PROTOCHAR** files, con
TCHAR *fn = _tcsrchr(files[i], '\\');
if (fn)
fn++;
-
- char* pszDesc_utf8 = mir_utf8encodeT(ptszDesc);
- char* pszFile_utf8;
- if (fn)
- pszFile_utf8 = mir_utf8encodeT(fn);
else
- pszFile_utf8 = mir_utf8encodeT(files[i]);
+ fn = files[i];
- ft = mwFileTransfer_new(service_files, &idb, pszDesc_utf8, pszFile_utf8, filesize);
- mir_free(pszFile_utf8);
- mir_free(pszDesc_utf8);
+ ft = mwFileTransfer_new(service_files, &idb, T2Utf(ptszDesc), T2Utf(fn), filesize);
ftcd = new FileTransferClientData;
memset((void*)ftcd, 0, sizeof(FileTransferClientData));
diff --git a/protocols/Sametime/src/options.cpp b/protocols/Sametime/src/options.cpp
index cd44b6c915..5d1f077911 100644
--- a/protocols/Sametime/src/options.cpp
+++ b/protocols/Sametime/src/options.cpp
@@ -292,14 +292,13 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
TCHAR ws[2048];
- char* utf;
GetDlgItemText(hwndDlg, IDC_ED_SNAME, ws, LSTRINGLEN);
- strcpy(proto->options.server_name, utf = mir_utf8encodeT(ws)); mir_free(utf);
+ strcpy(proto->options.server_name, T2Utf(ws));
GetDlgItemText(hwndDlg, IDC_ED_NAME, ws, LSTRINGLEN);
- strcpy(proto->options.id, utf = mir_utf8encodeT(ws)); mir_free(utf);
+ strcpy(proto->options.id, T2Utf(ws));
GetDlgItemText(hwndDlg, IDC_ED_PWORD, ws, LSTRINGLEN);
- strcpy(proto->options.pword, utf = mir_utf8encodeT(ws)); mir_free(utf);
+ strcpy(proto->options.pword, T2Utf(ws));
BOOL translated;
int port = GetDlgItemInt(hwndDlg, IDC_ED_PORT, &translated, FALSE);
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp
index e0a01850ac..6aa6eb2325 100644
--- a/protocols/Sametime/src/sametime_proto.cpp
+++ b/protocols/Sametime/src/sametime_proto.cpp
@@ -171,24 +171,18 @@ int CSametimeProto::GetInfo(MCONTACT hContact, int infoType)
HANDLE CSametimeProto::SearchBasic(const PROTOCHAR* id)
{
debugLog(_T("CSametimeProto::SearchBasic() id:len=[%d]"), id == NULL ? -1 : mir_tstrlen(id));
- char* id_utf8 = mir_utf8encodeT(id);
- int ret = SearchForUser(id_utf8, FALSE);
- mir_free(id_utf8);
- return (HANDLE)ret;
+ return (HANDLE)SearchForUser(T2Utf(id), FALSE);
///TODO - add timeout (like at GGPROTO::searchthread)
}
HWND CSametimeProto::SearchAdvanced(HWND owner)
{
TCHAR buf[512];
- int ret = 0;
if (GetDlgItemText(owner, IDC_EDIT1, buf, SIZEOF(buf))) {
debugLog(_T("CSametimeProto::SearchAdvanced() buf:len=[%d]"), buf == NULL ? -1 : mir_tstrlen(buf));
- char* buf_utf8 = mir_utf8encodeT(buf);
- ret = SearchForUser(buf_utf8, TRUE);
- mir_free(buf_utf8);
+ return (HWND)SearchForUser(T2Utf(buf), TRUE);
}
- return (HWND)ret;
+ return NULL;
}
HWND CSametimeProto::CreateExtendedSearchUI(HWND owner)
diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp
index 3adfbdf8ec..c0ee790d85 100644
--- a/protocols/Sametime/src/sametime_session.cpp
+++ b/protocols/Sametime/src/sametime_session.cpp
@@ -319,7 +319,7 @@ void CSametimeProto::SetSessionAwayMessage(int status, const PROTOCHAR* msgT)
{
debugLog(_T("SetSessionAwayMessage() status=[%d], msgT:len=[%d]"), status, msgT == NULL ? -1 : mir_tstrlen(msgT));
- ptrA msg(mir_utf8encodeT(msgT));
+ T2Utf msg(msgT);
if (status == ID_STATUS_ONLINE)
replaceStr(AwayMessages.szOnline, msg);
else if (status == ID_STATUS_AWAY)
@@ -540,9 +540,8 @@ void CSametimeProto::DeinitAwayMsg()
void SendAnnouncement(SendAnnouncementFunc_arg* arg)
{
CSametimeProto* proto = arg->proto;
- char* utfs = mir_utf8encodeT(arg->msg);
- if (proto->session && arg->recipients) mwSession_sendAnnounce(proto->session, false, utfs, arg->recipients);
- mir_free(utfs);
+ if (proto->session && arg->recipients)
+ mwSession_sendAnnounce(proto->session, false, T2Utf(arg->msg), arg->recipients);
}
INT_PTR CSametimeProto::SessionAnnounce(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index f5a1dfd6db..57e76b2cf2 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -54,7 +54,7 @@ public:
json_push_back(node, json_new_a("contenttype", "text"));
json_push_back(node, json_new_a("content", ptrA(mir_utf8encode(message))));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
@@ -79,7 +79,7 @@ public:
json_push_back(node, json_new_a("content", ptrA(mir_utf8encode(message))));
json_push_back(node, json_new_i("skypeemoteoffset", 4));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index 922253b0df..3523a95f47 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -34,7 +34,7 @@ public:
json_push_back(node, json_new_a("contenttype", "text"));
json_push_back(node, json_new_a("content", message));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
@@ -62,7 +62,7 @@ public:
json_push_back(node, json_new_a("content", content));
json_push_back(node, json_new_i("skypeemoteoffset", (int)(mir_strlen(username) + 1)));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
@@ -88,7 +88,7 @@ public:
json_push_back(node, json_new_a("contenttype", "text"));
json_push_back(node, json_new_a("content", ""));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
json_delete(node);
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h
index 718d342d72..c0777819b0 100644
--- a/protocols/SkypeWeb/src/requests/subscriptions.h
+++ b/protocols/SkypeWeb/src/requests/subscriptions.h
@@ -42,7 +42,7 @@ public:
json_push_back(interestedResources, json_new_a(NULL, "/v1/threads/ALL"));
json_push_back(node, interestedResources);
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
diff --git a/protocols/SkypeWeb/src/requests/trouter.h b/protocols/SkypeWeb/src/requests/trouter.h
index 89bad5a14b..1d68e78470 100644
--- a/protocols/SkypeWeb/src/requests/trouter.h
+++ b/protocols/SkypeWeb/src/requests/trouter.h
@@ -40,10 +40,8 @@ public:
JSONNODE *node = json_new(5);
json_push_back(node, json_new_a("sr", sr));
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
-
- Body << VALUE(data);
+ Body << VALUE(T2Utf(ptrT(json_write(node))));
json_delete(node);
}
//{"sr":"AUKRNgA8_eKV0Ibsx037Gbd8GVrsDg8zLQRt1pH8sCyIAile3gtoWmlq2x1yZ_VNZ3tf","issuer":"edf","sp":"connect","st":"1430236511619","se":"1430318082619","sig":"nYczCdlBENCxoAFLy7lPkGELVV1w5TcUnpSUE2G7GLA"}
@@ -85,7 +83,7 @@ public:
json_push_back(transports, TROUTER);
json_push_back(node, transports);
- ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ T2Utf data(ptrT(json_write(node)));
Body << VALUE(data);
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index fde3788e65..26628255b3 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -168,7 +168,7 @@ int CSkypeProto::AuthRequest(MCONTACT hContact, const PROTOCHAR *szMessage)
ptrA token(getStringA("TokenSecret"));
ptrA skypename(getStringA(hContact, SKYPE_SETTINGS_ID));
- PushRequest(new AddContactRequest(token, skypename, ptrA(mir_utf8encodeT(szMessage))));
+ PushRequest(new AddContactRequest(token, skypename, T2Utf(szMessage)));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp
index 67f3892f02..b74daf47c1 100644
--- a/protocols/SkypeWeb/src/skype_search.cpp
+++ b/protocols/SkypeWeb/src/skype_search.cpp
@@ -30,7 +30,7 @@ void CSkypeProto::SearchBasicThread(void* id)
return;
ptrT idT((TCHAR *)id);
- ptrA string(mir_urlEncode(ptrA(mir_utf8encodeT(idT))));
+ ptrA string(mir_urlEncode(T2Utf(idT)));
SendRequest(new GetSearchRequest(TokenSecret, string), &CSkypeProto::OnSearch);
}
diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp
index 912af1e7a5..4ea31428e8 100644
--- a/protocols/Steam/src/steam_pooling.cpp
+++ b/protocols/Steam/src/steam_pooling.cpp
@@ -30,7 +30,7 @@ void CSteamProto::ParsePollData(JSONNODE *data)
node = json_get(item, "text");
ptrT text(json_as_string(node));
- ptrA szMessage(mir_utf8encodeT(text));
+ T2Utf szMessage(text);
if (_tcsstr(type, _T("my_")) == NULL)
{
diff --git a/protocols/Steam/src/steam_queue.cpp b/protocols/Steam/src/steam_queue.cpp
index fee24bee64..c838b91294 100644
--- a/protocols/Steam/src/steam_queue.cpp
+++ b/protocols/Steam/src/steam_queue.cpp
@@ -36,7 +36,7 @@ void CSteamProto::StartQueue()
}
else
{
- ptrA username(mir_urlEncode(ptrA(mir_utf8encodeT(getTStringA("Username")))));
+ ptrA username(mir_urlEncode(T2Utf(getTStringA("Username"))));
if (username == NULL || username[0] == '\0')
return;
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp
index 0325794eb2..2068b64a44 100644
--- a/protocols/Tox/src/tox_multimedia.cpp
+++ b/protocols/Tox/src/tox_multimedia.cpp
@@ -291,14 +291,13 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg)
TCHAR message[MAX_PATH];
mir_sntprintf(message, SIZEOF(message), TranslateT("Incoming call from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
+ T2Utf szMessage(message);
PROTORECVEVENT recv = { 0 };
recv.timestamp = time(NULL);
recv.lParam = callId;
- recv.szMessage = mir_utf8encodeT(message);
+ recv.szMessage = szMessage;
ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv);
-
- mir_free(recv.szMessage);
}
// save event to db
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index ab48ce60a2..3891400c79 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -219,7 +219,7 @@ int CToxProto::SetAwayMsg(int, const PROTOCHAR *msg)
{
if (IsOnline())
{
- ptrA statusMessage(mir_utf8encodeT(msg));
+ T2Utf statusMessage(msg);
TOX_ERR_SET_INFO error;
if (tox_self_set_status_message(tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUS_MESSAGE_LENGTH, mir_strlen(statusMessage)), &error))
debugLogA("CToxProto::SetAwayMsg: failed to set status status message %s (%d)", msg, error);
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp
index 0eb8eca77e..c9962d90a0 100644
--- a/protocols/Tox/src/tox_search.cpp
+++ b/protocols/Tox/src/tox_search.cpp
@@ -190,7 +190,7 @@ HWND CToxProto::OnSearchAdvanced(HWND owner)
TCHAR text[MAX_PATH];
GetDlgItemText(owner, IDC_SEARCH, text, SIZEOF(text));
- const std::string query = ptrA(mir_utf8encodeT(text));
+ const std::string query = T2Utf(text);
if (std::regex_search(query, match, regex))
{
std::string address = match[1];
diff --git a/protocols/Tox/src/tox_services.cpp b/protocols/Tox/src/tox_services.cpp
index 3b5ba18395..f42a3d35c0 100644
--- a/protocols/Tox/src/tox_services.cpp
+++ b/protocols/Tox/src/tox_services.cpp
@@ -3,10 +3,11 @@
INT_PTR CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam)
{
ptrT nickname((wParam & SMNN_UNICODE) ? mir_u2t((TCHAR*)lParam) : mir_a2t((char*)lParam));
-
setTString("Nick", nickname);
+
+ T2Utf szNick8(nickname);
TOX_ERR_SET_INFO error;
- if (!tox_self_set_name(tox, (uint8_t*)(char*)ptrA(mir_utf8encodeT(nickname)), mir_tstrlen(nickname), &error))
+ if (!tox_self_set_name(tox, szNick8, mir_strlen(szNick8), &error))
{
debugLogA(__FUNCTION__": failed to set nick name");
return 1;
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index 5990cb63a1..6771ce6cd2 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -66,7 +66,7 @@ int TwitterProto::OnChatOutgoing(WPARAM, LPARAM lParam)
case GC_USER_MESSAGE:
debugLog(_T("**Chat - Outgoing message: %s"), hook->ptszText);
{
- ptrA text(mir_utf8encodeT(hook->ptszText));
+ T2Utf text(hook->ptszText);
std::string tweet(text);
replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index cea1ce17ef..e58c6ee01f 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -107,14 +107,13 @@ void TwitterProto::DoSearch(void *p)
bool found = false;
try {
- char *p = mir_utf8encodeT(query->query.c_str());
+ T2Utf p(query->query.c_str());
mir_cslock s(twitter_lock_);
if (query->by_email)
- found = twit_.get_info_by_email(p, &info);
+ found = twit_.get_info_by_email(p.str(), &info);
else
- found = twit_.get_info(p, &info);
- mir_free(p);
+ found = twit_.get_info(p.str(), &info);
}
catch (const std::exception &e) {
ShowPopup((std::string("While searching for contacts, an error occurred: ") + e.what()).c_str());
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index e90b7b84fd..357a094f69 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -463,9 +463,9 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
CMStringA name = getAttr(pFieldBeg, "name");
CMStringA value = getAttr(pFieldBeg, "value");
if (name == "email")
- value = ptrA(mir_utf8encodeT(ptrT(getTStringA("Login"))));
+ value = (char*)T2Utf(ptrT(getTStringA("Login")));
else if (name == "pass")
- value = ptrA(mir_utf8encodeT(ptrT(GetUserStoredPassword())));
+ value = (char*)T2Utf(ptrT(GetUserStoredPassword()));
else if (name == "captcha_key") {
char *pCaptchaBeg = strstr(pFormBeg, "<img id=\"captcha\"");
if (pCaptchaBeg != NULL)
@@ -580,9 +580,9 @@ void CVkProto::DBAddAuthRequest(const MCONTACT hContact)
{
debugLogA("CVkProto::DBAddAuthRequest");
- ptrA szNick(mir_utf8encodeT(ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"))));
- ptrA szFirstName(mir_utf8encodeT(ptrT(db_get_tsa(hContact, m_szModuleName, "FirstName"))));
- ptrA szLastName(mir_utf8encodeT(ptrT(db_get_tsa(hContact, m_szModuleName, "LastName"))));
+ T2Utf szNick(ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")));
+ T2Utf szFirstName(ptrT(db_get_tsa(hContact, m_szModuleName, "FirstName")));
+ T2Utf szLastName(ptrT(db_get_tsa(hContact, m_szModuleName, "LastName")));
//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
//blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ)
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index ea75491a07..b2c7fd4060 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -376,7 +376,7 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
UnEscapeChatTags(buf);
AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh)
<< INT_PARAM("chat_id", cc->m_chatid)
- << CHAR_PARAM("message", mir_utf8encodeT(buf))
+ << CHAR_PARAM("message", T2Utf(buf))
<< VER_API;
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
Push(pReq);
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index cd84677cc8..966d1ccaee 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -54,7 +54,7 @@ void CVkProto::AddFeedEvent(CMString& tszBody, time_t tTime)
}
MCONTACT hContact = FindUser(VK_FEED_USER, true);
- ptrA pszBody(mir_utf8encodeT(tszBody));
+ T2Utf pszBody(tszBody);
PROTORECVEVENT recv = { 0 };
recv.timestamp = tTime;
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 0bdf7aefeb..bcc509c3e4 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -48,7 +48,7 @@ CVkFileUploadParam::VKFileType CVkFileUploadParam::GetType()
_tsplitpath(FileName, DRIVE, DIR, FNAME, EXT);
CMStringA fn;
- ptrA pszFNAME(mir_utf8encodeT(FNAME)), pszEXT(mir_utf8encodeT(EXT));
+ T2Utf pszFNAME(FNAME), pszEXT(EXT);
fn.AppendFormat("%s%s", pszFNAME, pszEXT);
fname = mir_strdup(fn.GetBuffer());
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index fb10ae9c05..a07b003730 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -216,6 +216,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
ptszBody = mir_tstrdup(CMString(ptszBody) + tszAttachmentDescr);
}
+ T2Utf pszBody(ptszBody);
MCONTACT hContact = FindUser(uid, true);
PROTORECVEVENT recv = { 0 };
if (isRead)
@@ -223,14 +224,13 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
if (isOut)
recv.flags |= PREF_SENT;
recv.timestamp = datetime;
- recv.szMessage = mir_utf8encodeT(ptszBody);
+ recv.szMessage = pszBody;
recv.lParam = isOut;
recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)mir_strlen(szMid);
ProtoChainRecvMsg(hContact, &recv);
count++;
- mir_free((char*)recv.szMessage);
}
setDword(param->hContact, "lastmsgid", iLastMsgId);
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 6a9d6825ed..1c24dc30e5 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -253,8 +253,9 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
else if (m_bUserForceOnlineOnActivity)
SetInvisible(hContact);
+ T2Utf pszBody(ptszBody);
recv.timestamp = m_bUseLocalTime ? time(NULL) : datetime;
- recv.szMessage = mir_utf8encodeT(ptszBody);
+ recv.szMessage = pszBody;
recv.lParam = isOut;
recv.pCustomData = szMid;
recv.cbCustomDataSize = (int)mir_strlen(szMid);
@@ -270,8 +271,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (!isOut)
m_incIds.insert((HANDLE)mid);
}
-
- mir_free((char*)recv.szMessage);
}
if (!mids.IsEmpty())
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 78f417c487..0e169aceb9 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -67,7 +67,7 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
ppro->setTString("Login", str);
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- ptrA szRawPasswd(mir_utf8encodeT(str));
+ T2Utf szRawPasswd(str);
if (szRawPasswd != NULL)
ppro->setString("Password", szRawPasswd);
}
@@ -180,7 +180,7 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
}
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
- ptrA szRawPasswd(mir_utf8encodeT(str));
+ T2Utf szRawPasswd(str);
if (szRawPasswd != NULL)
ppro->setString("Password", szRawPasswd);
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index c01442fa26..4934c3a29f 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -177,7 +177,7 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const CHAR_PARAM &param)
AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const TCHAR_PARAM &param)
{
- ptrA szValue(mir_utf8encodeT(param.tszValue));
+ T2Utf szValue(param.tszValue);
CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp
index 8f4469af3e..68ccac9a58 100644
--- a/protocols/WhatsApp/src/chat.cpp
+++ b/protocols/WhatsApp/src/chat.cpp
@@ -25,7 +25,7 @@ INT_PTR __cdecl WhatsAppProto::OnCreateGroup(WPARAM wParam, LPARAM lParam)
es.szModuleName = m_szModuleName;
if (EnterString(&es)) {
if (isOnline()) {
- std::string groupName(ptrA(mir_utf8encodeT(es.ptszResult)));
+ std::string groupName(T2Utf(es.ptszResult));
m_pConnection->sendCreateGroupChat(groupName);
}
mir_free(es.ptszResult);
@@ -43,7 +43,7 @@ int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam)
if (mir_strcmp(gch->pDest->pszModule, m_szModuleName))
return 0;
- std::string chat_id(ptrA(mir_utf8encodeT(gch->pDest->ptszID)));
+ std::string chat_id(T2Utf(gch->pDest->ptszID));
WAChatInfo *pInfo = SafeGetChat(chat_id);
if (pInfo == NULL)
return 0;
@@ -59,7 +59,7 @@ int WhatsAppProto::onGroupChatEvent(WPARAM wParam, LPARAM lParam)
case GC_USER_MESSAGE:
if (isOnline()) {
- std::string msg(ptrA(mir_utf8encodeT(gch->ptszText)));
+ std::string msg(T2Utf(gch->ptszText));
try {
int msgId = GetSerial();
@@ -156,8 +156,8 @@ void WhatsAppProto::EditChatSubject(WAChatInfo *pInfo)
es.caption = title;
es.szDataPrefix = "setSubject_";
if (EnterString(&es)) {
- ptrA gjid(mir_utf8encodeT(pInfo->tszJid));
- ptrA gsubject(mir_utf8encodeT(es.ptszResult));
+ T2Utf gjid(pInfo->tszJid);
+ T2Utf gsubject(es.ptszResult);
m_pConnection->sendSetNewSubject(std::string(gjid), std::string(gsubject));
mir_free(es.ptszResult);
}
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp
index 2bf2bd88db..b594ad63fd 100644
--- a/protocols/WhatsApp/src/proto.cpp
+++ b/protocols/WhatsApp/src/proto.cpp
@@ -168,7 +168,7 @@ MCONTACT WhatsAppProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
if (psr->id == NULL)
return NULL;
- std::string phone(ptrA(mir_utf8encodeT(psr->id)));
+ std::string phone(T2Utf(psr->id));
std::string jid(phone + "@s.whatsapp.net");
MCONTACT hContact = AddToContactList(jid, phone.c_str());
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp
index 39e584b655..6cb48c658e 100644
--- a/protocols/Yahoo/src/chat.cpp
+++ b/protocols/Yahoo/src/chat.cpp
@@ -289,11 +289,9 @@ int __cdecl CYahooProto::OnGCEventHook(WPARAM, LPARAM lParam)
case GC_USER_MESSAGE:
if (gch->ptszText && gch->ptszText[0])
{
- char* msg = mir_utf8encodeT(gch->ptszText);
ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
if (cm)
- yahoo_conference_message(m_id, NULL, cm->members, room, msg, 1);
- mir_free(msg);
+ yahoo_conference_message(m_id, NULL, cm->members, room, T2Utf(gch->ptszText), 1);
}
break;
@@ -435,17 +433,13 @@ static void clist_chat_invite_send(MCONTACT hItem, HWND hwndList, YList* &who, c
if (root && who)
{
- char *msg8 = mir_utf8encodeT(msg);
+ T2Utf msg8(msg);
CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
- if (cm)
- {
+ if (cm) {
for (YList *l = who; l; l = l->next)
yahoo_conference_addinvite(ppro->m_id, NULL, (char*)l->data, room, cm->members, msg8);
}
- else
- yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);
-
- mir_free(msg8);
+ else yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);
for (YList *l = who; l; l = l->next) mir_free(l->data);
y_list_free(who);
@@ -630,9 +624,7 @@ INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
{
TCHAR msg[1024];
GetDlgItemText(hwndDlg, IDC_MSG2, msg, SIZEOF(msg));
- char *msg8 = mir_utf8encodeT(msg);
- yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, msg8);
- mir_free(msg8);
+ yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, T2Utf(msg));
param->ppro->m_chatrooms.remove((CYahooProto::ChatRoom*)&param->room);
}
diff --git a/protocols/Yahoo/src/file_transfer.cpp b/protocols/Yahoo/src/file_transfer.cpp
index 08a884023d..f757f81a96 100644
--- a/protocols/Yahoo/src/file_transfer.cpp
+++ b/protocols/Yahoo/src/file_transfer.cpp
@@ -685,13 +685,7 @@ HANDLE __cdecl CYahooProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescr
struct yahoo_file_info *fi = y_new(struct yahoo_file_info,1);
- /**
- * Need to use regular memory allocator/deallocator, since this is how things are build w/ libyahoo2
- */
- char *s = mir_utf8encodeT(ppszFiles[i]);
- fi->filename = strdup(s);
- mir_free(s);
-
+ fi->filename = strdup(T2Utf(ppszFiles[i]));
fi->filesize = tFileSize;
fs = y_list_append(fs, fi);
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp
index 50fa071785..c757fa6fe7 100644
--- a/protocols/Yahoo/src/proto.cpp
+++ b/protocols/Yahoo/src/proto.cpp
@@ -248,10 +248,10 @@ int CYahooProto::AuthDeny(MEVENT hdbe, const TCHAR *reason)
/* Need to remove the buddy from our Miranda Lists */
MCONTACT hContact = DbGetAuthEventContact(&dbei);
if (hContact != NULL) {
- ptrA who( getStringA(hContact, YAHOO_LOGINID));
+ ptrA who(getStringA(hContact, YAHOO_LOGINID));
if (who) {
- ptrA myid( getStringA(hContact, "MyIdentity"));
- ptrA u_reason( mir_utf8encodeT(reason));
+ ptrA myid(getStringA(hContact, "MyIdentity"));
+ T2Utf u_reason(reason);
debugLogA("Rejecting buddy:%s msg: %s", who, u_reason);
reject(myid, who, getWord(hContact, "yprotoid", 0), u_reason);
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp
index 3f70ae957a..58c9089d4d 100644
--- a/protocols/Yahoo/src/yahoo.cpp
+++ b/protocols/Yahoo/src/yahoo.cpp
@@ -200,56 +200,28 @@ void CYahooProto::logout()
void CYahooProto::AddBuddy(MCONTACT hContact, const char *group, const TCHAR *msg)
{
- DBVARIANT dbv;
- char *fname=NULL, *lname=NULL, *ident=NULL, *who, *u_msg;
- int protocol;
-
/* We adding a buddy to our list.
2 Stages.
1. We send add buddy packet.
2. We get a packet back from the server confirming add.
No refresh needed. */
-
- if (!getString(hContact, YAHOO_LOGINID, &dbv))
- {
- who = strdup(dbv.pszVal);
- db_free(&dbv);
- }
- else
- return;
-
- protocol = getWord(hContact, "yprotoid", 0);
- u_msg = mir_utf8encodeT(msg);
- if (!getString(hContact, "MyIdentity", &dbv))
- {
- ident = strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ ptrA who(getStringA(hContact, YAHOO_LOGINID));
+ if (who == NULL)
+ return;
- if (!GetStringUtf(NULL, "FirstName", &dbv))
- {
- fname = strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ int protocol = getWord(hContact, "yprotoid", 0);
+ T2Utf u_msg(msg);
- if (!GetStringUtf(NULL, "LastName", &dbv))
- {
- lname = strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ ptrA ident(getStringA(hContact, "MyIdentity"));
+ ptrT fname(getTStringA(NULL, "FirstName"));
+ ptrT lname(getTStringA(NULL, "LastName"));
SetStringUtf(hContact, "YGroup", group);
debugLogA("Adding Permanently %s to list. Auth: %s", who, u_msg ? u_msg : "<None>");
- yahoo_add_buddy(m_id, ident, fname, lname, who, protocol, group, u_msg);
-
- free(fname);
- free(lname);
- free(ident);
- free(who);
- mir_free(u_msg);
+ yahoo_add_buddy(m_id, ident, T2Utf(fname), T2Utf(lname), who, protocol, group, u_msg);
}
MCONTACT CYahooProto::getbuddyH(const char *yahoo_id)