summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu
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/Gadu-Gadu
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/Gadu-Gadu')
-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
5 files changed, 31 insertions, 73 deletions
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;