summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2012-12-22 00:30:47 +0000
committerSzymon Tokarz <wsx22@o2.pl>2012-12-22 00:30:47 +0000
commit1b50be65056f9f625a2242b3eab128b2c1c2ad7f (patch)
tree6fd7a6af17c7f78b312e669b24bd10bf85061873 /protocols/Gadu-Gadu/src
parent5d674840ea8cafd9975bd5f1ce7aa13a504891c5 (diff)
Gadu-Gadu protocol:
Change libgadu gg encoding from GG_ENCODING_CP1250 to GG_ENCODING_UTF8 and support it. This is a long-awaited change with introducing UTF-8 support at: - messages - status descriptions (fixes issue #8) - group chats (searching and public directory not support UTF-8 beacouse of libgadu limitations, thats works as previously) Thanks to Tomasz Figa for his path from http://code.google.com/p/miranda/issues/detail?id=1195 git-svn-id: http://svn.miranda-ng.org/main/trunk@2786 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu/src')
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp227
-rw-r--r--protocols/Gadu-Gadu/src/dialogs.cpp166
-rw-r--r--protocols/Gadu-Gadu/src/gg.cpp8
-rw-r--r--protocols/Gadu-Gadu/src/gg.h14
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp137
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h17
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp23
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp23
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp40
-rw-r--r--protocols/Gadu-Gadu/src/oauth.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/services.cpp17
12 files changed, 396 insertions, 282 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index d49b888064..a8c2b6efa7 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -379,7 +379,7 @@ void __cdecl GGPROTO::setavatarthread(void *param)
int file_fd, avatardatalen, datalen, contentlen, contentendlen, res = 0, repeat = 0;
netlog("setavatarthread(): started. Trying to set user avatar.");
- UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
+ UIN2IDA( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
file_fd = _topen(szFilename, _O_RDONLY | _O_BINARY, _S_IREAD);
if (file_fd == -1) {
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index 607f67533b..24f237ca2c 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -67,58 +67,58 @@ void GGPROTO::disconnect()
switch (db_get_w(NULL, m_szModuleName, GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
case ID_STATUS_ONLINE:
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 6, "modemsg_mutex", 1);
- szMsg = mir_strdup(modemsg.online);
+ szMsg = mir_utf8encodeT(modemsg.online);
gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 6, 1, "modemsg_mutex", 1);
- if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_ONLINE, "Default"), &dbv, DBVT_ASCIIZ)) {
- if (dbv.pszVal && *(dbv.pszVal))
- szMsg = mir_strdup(dbv.pszVal);
+ if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_ONLINE, "Default"), &dbv, DBVT_TCHAR)) {
+ if (dbv.ptszVal && *(dbv.ptszVal))
+ szMsg = mir_utf8encodeT(dbv.ptszVal);
DBFreeVariant(&dbv);
}
break;
case ID_STATUS_AWAY:
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 7, "modemsg_mutex", 1);
- szMsg = mir_strdup(modemsg.away);
+ szMsg = mir_utf8encodeT(modemsg.away);
gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 7, 1, "modemsg_mutex", 1);
- if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_AWAY, "Default"), &dbv, DBVT_ASCIIZ)) {
- if (dbv.pszVal && *(dbv.pszVal))
- szMsg = mir_strdup(dbv.pszVal);
+ if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_AWAY, "Default"), &dbv, DBVT_TCHAR)) {
+ if (dbv.ptszVal && *(dbv.ptszVal))
+ szMsg = mir_utf8encodeT(dbv.ptszVal);
DBFreeVariant(&dbv);
}
break;
case ID_STATUS_DND:
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 8, "modemsg_mutex", 1);
- szMsg = mir_strdup(modemsg.dnd);
+ szMsg = mir_utf8encodeT(modemsg.dnd);
gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 8, 1, "modemsg_mutex", 1);
- if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_DND, "Default"), &dbv, DBVT_ASCIIZ)) {
- if (dbv.pszVal && *(dbv.pszVal))
- szMsg = mir_strdup(dbv.pszVal);
+ if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_DND, "Default"), &dbv, DBVT_TCHAR)) {
+ if (dbv.ptszVal && *(dbv.ptszVal))
+ szMsg = mir_utf8encodeT(dbv.ptszVal);
DBFreeVariant(&dbv);
}
break;
case ID_STATUS_FREECHAT:
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 9, "modemsg_mutex", 1);
- szMsg = mir_strdup(modemsg.freechat);
+ szMsg = mir_utf8encodeT(modemsg.freechat);
gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 9, 1, "modemsg_mutex", 1);
- if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_FREECHAT, "Default"), &dbv, DBVT_ASCIIZ)) {
- if (dbv.pszVal && *(dbv.pszVal))
- szMsg = mir_strdup(dbv.pszVal);
+ if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_FREECHAT, "Default"), &dbv, DBVT_TCHAR)) {
+ if (dbv.ptszVal && *(dbv.ptszVal))
+ szMsg = mir_utf8encodeT(dbv.ptszVal);
DBFreeVariant(&dbv);
}
break;
case ID_STATUS_INVISIBLE:
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 10, "modemsg_mutex", 1);
- szMsg = mir_strdup(modemsg.invisible);
+ szMsg = mir_utf8encodeT(modemsg.invisible);
gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 10, 1, "modemsg_mutex", 1);
- if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_INVISIBLE, "Default"), &dbv, DBVT_ASCIIZ)) {
- if (dbv.pszVal && *(dbv.pszVal))
- szMsg = mir_strdup(dbv.pszVal);
+ if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_INVISIBLE, "Default"), &dbv, DBVT_TCHAR)) {
+ if (dbv.ptszVal && *(dbv.ptszVal))
+ szMsg = mir_utf8encodeT(dbv.ptszVal);
DBFreeVariant(&dbv);
}
break;
default:
// Set last status
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 11, "modemsg_mutex", 1);
- szMsg = mir_strdup(getstatusmsg(m_iStatus));
+ szMsg = mir_utf8encodeT(getstatusmsg(m_iStatus));
gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 11, 1, "modemsg_mutex", 1);
}
}
@@ -237,18 +237,18 @@ void __cdecl GGPROTO::mainthread(void *)
GGHOST hosts[64];
// Gadu-gadu login errors
static const struct tagReason { int type; TCHAR *str; } reason[] = {
- { GG_FAILURE_RESOLVING, LPGENT("Miranda was unable to resolve the name of the Gadu-Gadu server to its numeric address.") },
- { GG_FAILURE_CONNECTING, LPGENT("Miranda was unable to make a connection with a server. It is likely that the server is down, in which case you should wait for a while and try again later.") },
- { GG_FAILURE_INVALID, LPGENT("Received invalid server response.") },
- { GG_FAILURE_READING, LPGENT("The connection with the server was abortively closed during the connection attempt. You may have lost your local network connection.") },
- { GG_FAILURE_WRITING, LPGENT("The connection with the server was abortively closed during the connection attempt. You may have lost your local network connection.") },
- { GG_FAILURE_PASSWORD, LPGENT("Your Gadu-Gadu number and password combination was rejected by the Gadu-Gadu server. Please check login details at M->Options->Network->Gadu-Gadu and try again.") },
- { GG_FAILURE_404, LPGENT("Connecting to Gadu-Gadu hub failed.") },
- { GG_FAILURE_TLS, LPGENT("Cannot establish secure connection.") },
- { GG_FAILURE_NEED_EMAIL, LPGENT("Server disconnected asking you for changing your e-mail.") },
- { GG_FAILURE_INTRUDER, LPGENT("Too many login attempts with invalid password.") },
+ { GG_FAILURE_RESOLVING, LPGENT("Miranda was unable to resolve the name of the Gadu-Gadu server to its numeric address.") },
+ { GG_FAILURE_CONNECTING, LPGENT("Miranda was unable to make a connection with a server. It is likely that the server is down, in which case you should wait for a while and try again later.") },
+ { GG_FAILURE_INVALID, LPGENT("Received invalid server response.") },
+ { GG_FAILURE_READING, LPGENT("The connection with the server was abortively closed during the connection attempt. You may have lost your local network connection.") },
+ { GG_FAILURE_WRITING, LPGENT("The connection with the server was abortively closed during the connection attempt. You may have lost your local network connection.") },
+ { GG_FAILURE_PASSWORD, LPGENT("Your Gadu-Gadu number and password combination was rejected by the Gadu-Gadu server. Please check login details at M->Options->Network->Gadu-Gadu and try again.") },
+ { GG_FAILURE_404, LPGENT("Connecting to Gadu-Gadu hub failed.") },
+ { GG_FAILURE_TLS, LPGENT("Cannot establish secure connection.") },
+ { GG_FAILURE_NEED_EMAIL, LPGENT("Server disconnected asking you for changing your e-mail.") },
+ { GG_FAILURE_INTRUDER, LPGENT("Too many login attempts with invalid password.") },
{ GG_FAILURE_UNAVAILABLE, LPGENT("Gadu-Gadu servers are now down. Try again later.") },
- { 0, LPGENT("Unknown") }
+ { 0, LPGENT("Unknown") }
};
time_t logonTime = 0;
time_t timeDeviation = db_get_w(NULL, m_szModuleName, GG_KEY_TIMEDEVIATION, GG_KEYDEF_TIMEDEVIATION);
@@ -268,7 +268,7 @@ void __cdecl GGPROTO::mainthread(void *)
p.client_version = GG_DEFAULT_CLIENT_VERSION;
p.protocol_version = GG_DEFAULT_PROTOCOL_VERSION;
p.protocol_features = GG_FEATURE_DND_FFC | GG_FEATURE_UNKNOWN_100 | GG_FEATURE_USER_DATA | GG_FEATURE_MSG_ACK | GG_FEATURE_TYPING_NOTIFICATION | GG_FEATURE_MULTILOGON;
- p.encoding = GG_ENCODING_CP1250;
+ p.encoding = GG_ENCODING_UTF8;
p.status_flags = GG_STATUS_FLAG_UNKNOWN;
if (db_get_b(NULL, m_szModuleName, GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS))
p.status_flags |= GG_STATUS_FLAG_SPAM;
@@ -390,11 +390,12 @@ void __cdecl GGPROTO::mainthread(void *)
retry:
// Loadup startup status & description
gg_EnterCriticalSection(&modemsg_mutex, "mainthread", 13, "modemsg_mutex", 1);
- p.status_descr = mir_strdup(getstatusmsg(m_iDesiredStatus));
+
+ p.status_descr = mir_utf8encodeT(getstatusmsg(m_iDesiredStatus));
p.status = status_m2gg(m_iDesiredStatus, p.status_descr != NULL);
- netlog("mainthread() (%x): Connecting with number %d, status %d and description \"%s\".", this, p.uin, m_iDesiredStatus,
- p.status_descr ? p.status_descr : "<none>");
+ netlog("mainthread() (%x): Connecting with number %d, status %d and description \"%S\".", this, p.uin, m_iDesiredStatus,
+ p.status_descr ? getstatusmsg(m_iDesiredStatus) : _T("<none>"));
gg_LeaveCriticalSection(&modemsg_mutex, "mainthread", 13, 1, "modemsg_mutex", 1);
// Check manual hosts
@@ -492,7 +493,9 @@ retry:
{
broadcastnewstatus(m_iDesiredStatus);
// Change status of the contact with our own UIN (if got yourself added to the contact list)
- changecontactstatus(p.uin, p.status, p.status_descr, 0, 0, 0, 0);
+ TCHAR *status_descr = mir_utf8decodeT(p.status_descr);
+ changecontactstatus(p.uin, p.status, status_descr, 0, 0, 0, 0);
+ mir_free(status_descr);
}
if (check_first_conn) // First connection to the account
{
@@ -572,8 +575,9 @@ retry:
for (; n->uin; n++)
{
- char *descr = (e->type == GG_EVENT_NOTIFY_DESCR) ? e->event.notify_descr.descr : NULL;
- changecontactstatus(n->uin, n->status, descr, 0, n->remote_ip, n->remote_port, n->version);
+ TCHAR *descrT = (e->type == GG_EVENT_NOTIFY_DESCR) ? mir_utf8decodeT(e->event.notify_descr.descr) : NULL;
+ changecontactstatus(n->uin, n->status, descrT, 0, n->remote_ip, n->remote_port, n->version);
+ if (descrT) mir_free(descrT);
}
break;
}
@@ -584,9 +588,11 @@ retry:
int i;
for(i = 0; e->event.notify60[i].uin; i++) {
if (e->event.notify60[i].uin == uin) continue;
- changecontactstatus(e->event.notify60[i].uin, e->event.notify60[i].status, e->event.notify60[i].descr,
+ TCHAR *descrT = mir_utf8decodeT(e->event.notify60[i].descr);
+ changecontactstatus(e->event.notify60[i].uin, e->event.notify60[i].status, descrT,
e->event.notify60[i].time, e->event.notify60[i].remote_ip, e->event.notify60[i].remote_port,
e->event.notify60[i].version);
+ mir_free(descrT);
requestAvatar(getcontact(e->event.notify60[i].uin, 0, 0, NULL), 0);
}
break;
@@ -624,13 +630,13 @@ retry:
{
// Loadup fields
const char *__fmnumber = gg_pubdir50_get(res, i, GG_PUBDIR50_UIN);
- const char *__nick = gg_pubdir50_get(res, i, GG_PUBDIR50_NICKNAME);
- const char *__firstname = gg_pubdir50_get(res, i, GG_PUBDIR50_FIRSTNAME);
- const char *__lastname = gg_pubdir50_get(res, i, GG_PUBDIR50_LASTNAME);
- const char *__familyname = gg_pubdir50_get(res, i, GG_PUBDIR50_FAMILYNAME);
+ TCHAR *__nickname = mir_utf8decodeT(gg_pubdir50_get(res, i, GG_PUBDIR50_NICKNAME));
+ TCHAR *__firstname = mir_utf8decodeT(gg_pubdir50_get(res, i, GG_PUBDIR50_FIRSTNAME));
+ TCHAR *__lastname = mir_utf8decodeT(gg_pubdir50_get(res, i, GG_PUBDIR50_LASTNAME));
+ TCHAR *__familyname = mir_utf8decodeT(gg_pubdir50_get(res, i, GG_PUBDIR50_FAMILYNAME));
+ TCHAR *__city = mir_utf8decodeT(gg_pubdir50_get(res, i, GG_PUBDIR50_CITY));
+ TCHAR *__familycity = mir_utf8decodeT(gg_pubdir50_get(res, i, GG_PUBDIR50_FAMILYCITY));
const char *__birthyear = gg_pubdir50_get(res, i, GG_PUBDIR50_BIRTHYEAR);
- const char *__city = gg_pubdir50_get(res, i, GG_PUBDIR50_CITY);
- const char *__origincity = gg_pubdir50_get(res, i, GG_PUBDIR50_FAMILYCITY);
const char *__gender = gg_pubdir50_get(res, i, GG_PUBDIR50_GENDER);
const char *__status = gg_pubdir50_get(res, i, GG_PUBDIR50_STATUS);
uin_t uin = __fmnumber ? atoi(__fmnumber) : 0;
@@ -639,14 +645,14 @@ retry:
netlog("mainthread() (%x): Search result for uin %d, seq %d.", this, uin, res->seq);
if (res->seq == GG_SEQ_SEARCH)
{
- char strFmt1[64];
- char strFmt2[64];
+ TCHAR strFmt1[64];
+ TCHAR strFmt2[64];
- mir_snprintf(strFmt2, sizeof(strFmt2), "%s", (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status_gg2m(atoi(__status)), 0));
+ mir_sntprintf(strFmt2, SIZEOF(strFmt2), _T("%s"), (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status_gg2m(atoi(__status)), GSMDF_TCHAR));
if (__city)
{
- mir_snprintf(strFmt1, sizeof(strFmt1), ", %s %s", Translate("City:"), __city);
- strncat(strFmt2, strFmt1, sizeof(strFmt2) - strlen(strFmt2));
+ mir_sntprintf(strFmt1, SIZEOF(strFmt1), _T(", %s %s"), TranslateT("City:"), __city);
+ _tcsncat(strFmt2, strFmt1, SIZEOF(strFmt2) - _tcslen(strFmt2));
}
if (__birthyear)
{
@@ -656,8 +662,8 @@ retry:
if (br < (lt->tm_year + 1900) && br > 1900)
{
- mir_snprintf(strFmt1, sizeof(strFmt1), ", %s %d", Translate("Age:"), (lt->tm_year + 1900) - br);
- strncat(strFmt2, strFmt1, sizeof(strFmt2) - strlen(strFmt2));
+ mir_sntprintf(strFmt1, SIZEOF(strFmt1), _T(", %s %d"), TranslateT("Age:"), (lt->tm_year + 1900) - br);
+ _tcsncat(strFmt2, strFmt1, SIZEOF(strFmt2) - _tcslen(strFmt2));
}
}
@@ -665,61 +671,54 @@ retry:
memset(&sr, 0, sizeof(sr));
sr.cbSize = sizeof(sr);
sr.flags = PSR_TCHAR;
- sr.nick = mir_a2t(__nick);
- sr.firstName = mir_a2t(__firstname);
- sr.lastName = mir_a2t(__lastname);
- sr.email = mir_a2t(strFmt2);
- sr.id = mir_a2t(_ultoa(uin, strFmt1, 10));
+ sr.nick = __nickname;
+ sr.firstName = __firstname;
+ sr.lastName = __lastname;
+ sr.email = strFmt2;
+ sr.id = _ultot(uin, strFmt1, 10);
sr.uin = uin;
ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM)&sr);
- mir_free(sr.nick);
- mir_free(sr.firstName);
- mir_free(sr.lastName);
- mir_free(sr.email);
- mir_free(sr.id);
}
if (((res->seq == GG_SEQ_INFO || res->seq == GG_SEQ_GETNICK) && hContact != NULL)
|| res->seq == GG_SEQ_CHINFO)
{
// Change nickname if it's not present
- if (__nick && (res->seq == GG_SEQ_GETNICK || res->seq == GG_SEQ_CHINFO)){
- TCHAR* __nickT = mir_a2t(__nick);
- db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, __nickT);
- mir_free(__nickT);
+ if (__nickname && (res->seq == GG_SEQ_GETNICK || res->seq == GG_SEQ_CHINFO)){
+ db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, __nickname);
}
- if (__nick){
- db_set_s(hContact, m_szModuleName, "NickName", __nick);
+ if (__nickname){
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_NICKNAME, __nickname);
} else if (res->seq == GG_SEQ_CHINFO) {
- db_unset(NULL, m_szModuleName, "NickName");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_NICKNAME);
}
// Change other info
if (__city)
- db_set_s(hContact, m_szModuleName, "City", __city);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_CITY, __city);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, "City");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_CITY);
if (__firstname)
- db_set_s(hContact, m_szModuleName, "FirstName", __firstname);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FIRSTNAME, __firstname);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, "FirstName");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_FIRSTNAME);
if (__lastname)
- db_set_s(hContact, m_szModuleName, "LastName", __lastname);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_LASTNAME, __lastname);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, "LastName");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_LASTNAME);
if (__familyname)
- db_set_s(hContact, m_szModuleName, "FamilyName", __familyname);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FAMILYNAME, __familyname);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, "FamilyName");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_FAMILYNAME);
- if (__origincity)
- db_set_s(hContact, m_szModuleName, "CityOrigin", __origincity);
+ if (__familycity)
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FAMILYCITY, __familycity);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, "CityOrigin");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_FAMILYCITY);
if (__birthyear)
{
@@ -728,36 +727,44 @@ retry:
int br = atoi(__birthyear);
if (br > 0)
{
- db_set_w(hContact, m_szModuleName, "Age", (WORD)(lt->tm_year + 1900 - br));
- db_set_w(hContact, m_szModuleName, "BirthYear", (WORD)br);
+ db_set_w(hContact, m_szModuleName, GG_KEY_PD_AGE, (WORD)(lt->tm_year + 1900 - br));
+ db_set_w(hContact, m_szModuleName, GG_KEY_PD_BIRTHYEAR, (WORD)br);
}
}
else if (res->seq == GG_SEQ_CHINFO)
{
- db_unset(NULL, m_szModuleName, "Age");
- db_unset(NULL, m_szModuleName, "BirthYear");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_AGE);
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_BIRTHYEAR);
}
// Gadu-Gadu Male <-> Female
if (__gender)
{
if (res->seq == GG_SEQ_CHINFO)
- db_set_b(hContact, m_szModuleName, "Gender",
+ db_set_b(hContact, m_szModuleName, GG_KEY_PD_GANDER,
(BYTE)(!strcmp(__gender, GG_PUBDIR50_GENDER_SET_MALE) ? 'M' :
(!strcmp(__gender, GG_PUBDIR50_GENDER_SET_FEMALE) ? 'F' : '?')));
else
- db_set_b(hContact, m_szModuleName, "Gender",
+ db_set_b(hContact, m_szModuleName, GG_KEY_PD_GANDER,
(BYTE)(!strcmp(__gender, GG_PUBDIR50_GENDER_MALE) ? 'M' :
(!strcmp(__gender, GG_PUBDIR50_GENDER_FEMALE) ? 'F' : '?')));
}
else if (res->seq == GG_SEQ_CHINFO)
{
- db_unset(NULL, m_szModuleName, "Gender");
+ db_unset(NULL, m_szModuleName, GG_KEY_PD_GANDER);
}
netlog("mainthread() (%x): Setting user info for uin %d.", this, uin);
ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
}
+
+ if (__nickname) mir_free(__nickname);
+ if (__firstname) mir_free(__firstname);
+ if (__lastname) mir_free(__lastname);
+ if (__familyname) mir_free(__familyname);
+ if (__city) mir_free(__city);
+ if (__familycity) mir_free(__familycity);
+
}
}
if (res->seq == GG_SEQ_SEARCH)
@@ -767,7 +774,11 @@ retry:
// Status (deprecated)
case GG_EVENT_STATUS:
- changecontactstatus(e->event.status.uin, e->event.status.status, e->event.status.descr, 0, 0, 0, 0);
+ {
+ TCHAR *descrT = mir_utf8decodeT(e->event.status.descr);
+ changecontactstatus(e->event.status.uin, e->event.status.status, descrT, 0, 0, 0, 0);
+ mir_free(descrT);
+ }
break;
// Status (version >= 6.0)
@@ -777,16 +788,20 @@ retry:
int oldstatus = db_get_w(hContact, m_szModuleName, GG_KEY_STATUS, (WORD)ID_STATUS_OFFLINE);
uin_t uin = (uin_t)db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0);
+ TCHAR *descrT = mir_utf8decodeT(e->event.status60.descr);
+
if (e->event.status60.uin == uin)
{
// Status was changed by the user simultaneously logged on using different Miranda account or IM client
int iStatus = status_gg2m(e->event.status60.status);
- CallProtoService(m_szModuleName, PS_SETAWAYMSG, iStatus, (LPARAM)e->event.status60.descr);
+ CallProtoService(m_szModuleName, PS_SETAWAYMSGT, iStatus, (LPARAM)descrT);
CallProtoService(m_szModuleName, PS_SETSTATUS, iStatus, 0);
}
-
- changecontactstatus(e->event.status60.uin, e->event.status60.status, e->event.status60.descr,
+
+ changecontactstatus(e->event.status60.uin, e->event.status60.status, descrT,
e->event.status60.time, e->event.status60.remote_ip, e->event.status60.remote_port, e->event.status60.version);
+
+ mir_free(descrT);
if (oldstatus == ID_STATUS_OFFLINE && db_get_w(hContact, m_szModuleName, GG_KEY_STATUS, (WORD)ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
requestAvatar(hContact, 0);
@@ -835,11 +850,9 @@ retry:
gcdest.iType = GC_EVENT_MESSAGE;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
time_t t = time(NULL);
-
UIN2IDT(e->event.msg.sender, id);
-
gcevent.ptszUID = id;
- TCHAR* messageT = mir_a2t(e->event.msg.message);
+ TCHAR* messageT = mir_utf8decodeT(e->event.msg.message);
gcevent.ptszText = messageT;
gcevent.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR);
gcevent.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
@@ -855,6 +868,7 @@ retry:
PROTORECVEVENT pre = {0};
time_t t = time(NULL);
pre.timestamp = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
+ pre.flags = PREF_UTF;
pre.szMessage = e->event.msg.message;
ProtoChainRecvMsg( getcontact(e->event.msg.sender, 1, 0, NULL), &pre);
}
@@ -903,11 +917,9 @@ retry:
gcdest.ptszID = chat;
gcdest.iType = GC_EVENT_MESSAGE;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
-
UIN2IDT(db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), id);
-
gcevent.ptszUID = id;
- TCHAR* messageT = mir_a2t(e->event.multilogon_msg.message);
+ TCHAR* messageT = mir_utf8decodeT(e->event.multilogon_msg.message);
gcevent.ptszText = messageT;
TCHAR* nickT;
if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)){
@@ -919,7 +931,7 @@ retry:
gcevent.ptszNick = nickT;
gcevent.time = e->event.multilogon_msg.time;
gcevent.bIsMe = 1;
- gcevent.dwFlags = GCEF_ADDTOLOG;
+ gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
netlog("mainthread() (%x): Sent conference message to room %S.", this, chat);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
mir_free(messageT);
@@ -933,7 +945,7 @@ retry:
dbei.cbSize = sizeof(dbei);
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)e->event.multilogon_msg.time;
- dbei.flags = DBEF_SENT;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = (DWORD)strlen(e->event.multilogon_msg.message) + 1;
dbei.pBlob = (PBYTE)e->event.multilogon_msg.message;
@@ -1300,6 +1312,7 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam)
gcdest.ptszID = dbv.ptszVal;
gcdest.iType = GC_EVENT_CONTROL;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
+ gcevent.dwFlags = GC_TCHAR;
GGGC *chat = gc_lookup(dbv.ptszVal);
netlog("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal);
@@ -1645,9 +1658,9 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
// Change status of the contact with our own UIN (if got yourself added to the contact list)
if (db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0) == uin) {
- char *szMsg;
+ TCHAR *szMsg;
gg_EnterCriticalSection(&modemsg_mutex, "getcontact", 33, "modemsg_mutex", 1);
- szMsg = mir_strdup(getstatusmsg(m_iStatus));
+ szMsg = mir_tstrdup(getstatusmsg(m_iStatus));
gg_LeaveCriticalSection(&modemsg_mutex, "getcontact", 33, 1, "modemsg_mutex", 1);
changecontactstatus(uin, status_m2gg(m_iStatus, szMsg != NULL), szMsg, 0, 0, 0, 0);
mir_free(szMsg);
@@ -1741,7 +1754,7 @@ int GGPROTO::status_gg2m(int status)
////////////////////////////////////////////////////////////
// Called when contact status is changed
-void GGPROTO::changecontactstatus(uin_t uin, int status, const char *idescr, int time, uint32_t remote_ip, uint16_t remote_port, uint32_t version)
+void GGPROTO::changecontactstatus(uin_t uin, int status, const TCHAR *idescr, int time, uint32_t remote_ip, uint16_t remote_port, uint32_t version)
{
#ifdef DEBUGMODE
netlog("changecontactstatus(): uin=%d status=%d", uin, status);
@@ -1757,12 +1770,12 @@ void GGPROTO::changecontactstatus(uin_t uin, int status, const char *idescr, int
// Check if there's description and if it's not empty
if (idescr && *idescr)
{
- netlog("changecontactstatus(): Saving for %d status descr \"%s\".", uin, idescr);
- db_set_s(hContact, "CList", GG_KEY_STATUSDESCR, idescr);
- }
- else
+ netlog("changecontactstatus(): Saving for %d status descr \"%S\".", uin, idescr);
+ db_set_ts(hContact, "CList", GG_KEY_STATUSDESCR, idescr);
+ } else {
// Remove status if there's nothing
db_unset(hContact, "CList", GG_KEY_STATUSDESCR);
+ }
// Store contact ip and port
if (remote_ip) db_set_dw(hContact, m_szModuleName, GG_KEY_CLIENTIP, (DWORD) swap32(remote_ip));
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp
index 1e194f0951..a16fa6ea88 100644
--- a/protocols/Gadu-Gadu/src/dialogs.cpp
+++ b/protocols/Gadu-Gadu/src/dialogs.cpp
@@ -41,7 +41,9 @@ extern INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam
static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule, char *szSetting, int special, int disableIfUndef)
{
DBVARIANT dbv = {0};
- char str[80], *pstr = NULL;
+ TCHAR str[256];
+ TCHAR *ptstr = NULL;
+ TCHAR* valT = NULL;
int unspecified = 0;
dbv.type = DBVT_DELETED;
@@ -51,37 +53,41 @@ static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule,
switch (dbv.type) {
case DBVT_BYTE:
if (special == SVS_GENDER) {
- if (dbv.cVal == 'M') pstr = Translate("Male");
- else if (dbv.cVal == 'F') pstr = Translate("Female");
+ if (dbv.cVal == 'M') ptstr = TranslateT("Male");
+ else if (dbv.cVal == 'F') ptstr = TranslateT("Female");
else unspecified = 1;
}
else if (special == SVS_MONTH) {
if (dbv.bVal > 0 && dbv.bVal <= 12) {
- pstr = str;
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1 - 1 + dbv.bVal, str, SIZEOF(str));
+ ptstr = str;
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1 - 1 + dbv.bVal, str, SIZEOF(str));
}
else unspecified = 1;
}
else if (special == SVS_TIMEZONE) {
if (dbv.cVal == -100) unspecified = 1;
else {
- pstr = str;
- mir_snprintf(str, SIZEOF(str), dbv.cVal ? "GMT%+d:%02d" : "GMT", -dbv.cVal / 2, (dbv.cVal & 1) * 30);
+ ptstr = str;
+ mir_sntprintf(str, SIZEOF(str), dbv.cVal ? _T("GMT%+d:%02d") : _T("GMT"), -dbv.cVal / 2, (dbv.cVal & 1) * 30);
}
- }
- else {
+ } else {
unspecified = (special == SVS_ZEROISUNSPEC && dbv.bVal == 0);
- pstr = _itoa(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, str, 10);
+ ptstr = _itot(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, str, 10);
}
break;
case DBVT_WORD:
if (special == SVS_COUNTRY) {
- pstr = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, dbv.wVal, 0);
- unspecified = pstr == NULL;
+ char* pstr = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, dbv.wVal, 0);
+ if (pstr == NULL){
+ unspecified = 1;
+ } else {
+ ptstr = str;
+ mir_sntprintf(str, SIZEOF(str), _T("%S"), pstr);
+ }
}
else {
unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0);
- pstr = _itoa(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, str, 10);
+ ptstr = _itot(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, str, 10);
}
break;
case DBVT_DWORD:
@@ -89,19 +95,41 @@ static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule,
if (special == SVS_IP) {
struct in_addr ia;
ia.S_un.S_addr = htonl(dbv.dVal);
- pstr = inet_ntoa(ia);
+ char* pstr = inet_ntoa(ia);
+ if (pstr == NULL){
+ unspecified = 1;
+ } else {
+ ptstr = str;
+ mir_sntprintf(str, SIZEOF(str), _T("%S"), pstr);
+ }
if (dbv.dVal == 0) unspecified = 1;
+ } else if (special == SVS_GGVERSION) {
+ ptstr = str;
+ mir_sntprintf(str, SIZEOF(str), _T("%S"), (char *)gg_version2string(dbv.dVal));
+ } else {
+ ptstr = _itot(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, str, 10);
}
- else if (special == SVS_GGVERSION)
- pstr = (char *)gg_version2string(dbv.dVal);
- else
- pstr = _itoa(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, str, 10);
break;
case DBVT_ASCIIZ:
unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0');
- pstr = dbv.pszVal;
+ ptstr = str;
+ mir_sntprintf(str, SIZEOF(str), _T("%S"), dbv.pszVal);
+ break;
+ case DBVT_TCHAR:
+ unspecified = (special == SVS_ZEROISUNSPEC && dbv.ptszVal[0] == '\0');
+ ptstr = dbv.ptszVal;
+ break;
+ case DBVT_UTF8:
+ unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0');
+ valT = mir_utf8decodeT(dbv.pszVal);
+ ptstr = str;
+ _tcscpy_s(str, SIZEOF(str), valT);
+ mir_free(valT);
+ break;
+ default:
+ ptstr = str;
+ lstrcpy(str, _T("???"));
break;
- default: pstr = str; lstrcpyA(str, "???"); break;
}
}
@@ -110,12 +138,12 @@ static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule,
if (unspecified)
SetDlgItemText(hwndDlg, idCtrl, TranslateT("<not specified>"));
else
- SetDlgItemTextA(hwndDlg, idCtrl, pstr);
+ SetDlgItemText(hwndDlg, idCtrl, ptstr);
}
else {
EnableWindow(GetDlgItem(hwndDlg, idCtrl), TRUE);
if (!unspecified)
- SetDlgItemTextA(hwndDlg, idCtrl, pstr);
+ SetDlgItemText(hwndDlg, idCtrl, ptstr);
}
DBFreeVariant(&dbv);
}
@@ -409,15 +437,15 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (LOWORD(wParam) != IDC_CHPASS && LOWORD(wParam) != IDC_CHEMAIL)
{
db_unset(NULL, gg->m_szModuleName, GG_KEY_NICK);
- db_unset(NULL, gg->m_szModuleName, "NickName");
- db_unset(NULL, gg->m_szModuleName, "City");
- db_unset(NULL, gg->m_szModuleName, "FirstName");
- db_unset(NULL, gg->m_szModuleName, "LastName");
- db_unset(NULL, gg->m_szModuleName, "FamilyName");
- db_unset(NULL, gg->m_szModuleName, "CityOrigin");
- db_unset(NULL, gg->m_szModuleName, "Age");
- db_unset(NULL, gg->m_szModuleName, "BirthYear");
- db_unset(NULL, gg->m_szModuleName, "Gender");
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_NICKNAME);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_CITY);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_FIRSTNAME);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_LASTNAME);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_FAMILYNAME);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_FAMILYCITY );
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_AGE);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_BIRTHYEAR);
+ db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_GANDER);
}
}
}
@@ -758,20 +786,20 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
SetValue(hwndDlg, IDC_PORT, hContact, szProto, GG_KEY_CLIENTPORT, SVS_ZEROISUNSPEC, hContact != NULL);
SetValue(hwndDlg, IDC_VERSION, hContact, szProto, GG_KEY_CLIENTVERSION, SVS_GGVERSION, hContact != NULL);
- SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_NICKNAME, hContact, szProto, "NickName", SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_BIRTHYEAR, hContact, szProto, "BirthYear", SVS_ZEROISUNSPEC, hContact != NULL);
- SetValue(hwndDlg, IDC_CITY, hContact, szProto, "City", SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_FAMILYNAME, hContact, szProto, "FamilyName", SVS_NORMAL, hContact != NULL);
- SetValue(hwndDlg, IDC_CITYORIGIN, hContact, szProto, "CityOrigin", SVS_NORMAL, hContact != NULL);
+ SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, GG_KEY_PD_FIRSTNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, GG_KEY_PD_LASTNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(hwndDlg, IDC_NICKNAME, hContact, szProto, GG_KEY_PD_NICKNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(hwndDlg, IDC_BIRTHYEAR, hContact, szProto, GG_KEY_PD_BIRTHYEAR, SVS_ZEROISUNSPEC, hContact != NULL);
+ SetValue(hwndDlg, IDC_CITY, hContact, szProto, GG_KEY_PD_CITY, SVS_NORMAL, hContact != NULL);
+ SetValue(hwndDlg, IDC_FAMILYNAME, hContact, szProto, GG_KEY_PD_FAMILYNAME, SVS_NORMAL, hContact != NULL);
+ SetValue(hwndDlg, IDC_CITYORIGIN, hContact, szProto, GG_KEY_PD_FAMILYCITY , SVS_NORMAL, hContact != NULL);
if (hContact)
{
- SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER, hContact != NULL);
+ SetValue(hwndDlg, IDC_GENDER, hContact, szProto, GG_KEY_PD_GANDER, SVS_GENDER, hContact != NULL);
SetValue(hwndDlg, IDC_STATUSDESCR, hContact, "CList", GG_KEY_STATUSDESCR, SVS_NORMAL, hContact != NULL);
}
- else switch((char)db_get_b(hContact, gg->m_szModuleName, "Gender", (BYTE)'?'))
+ else switch((char)db_get_b(hContact, gg->m_szModuleName, GG_KEY_PD_GANDER, (BYTE)'?'))
{
case 'F':
SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 1, 0);
@@ -795,7 +823,7 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (dat && !dat->hContact && LOWORD(wParam) == IDC_SAVE && HIWORD(wParam) == BN_CLICKED)
{
// Save user data
- char text[256];
+ TCHAR text[256];
gg_pubdir50_t req;
GGPROTO *gg = dat->gg;
@@ -811,17 +839,33 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
req = gg_pubdir50_new(GG_PUBDIR50_WRITE);
- GetDlgItemTextA(hwndDlg, IDC_FIRSTNAME, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, text);
+ GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, text_utf8);
+ mir_free(text_utf8);
+ }
- GetDlgItemTextA(hwndDlg, IDC_LASTNAME, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, text);
+ GetDlgItemText(hwndDlg, IDC_LASTNAME, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, text_utf8);
+ mir_free(text_utf8);
+ }
- GetDlgItemTextA(hwndDlg, IDC_NICKNAME, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, text);
+ GetDlgItemText(hwndDlg, IDC_NICKNAME, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, text_utf8);
+ mir_free(text_utf8);
+ }
- GetDlgItemTextA(hwndDlg, IDC_CITY, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_CITY, text);
+ GetDlgItemText(hwndDlg, IDC_CITY, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_CITY, text_utf8);
+ mir_free(text_utf8);
+ }
// Gadu-Gadu Female <-> Male
switch(SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0))
@@ -836,14 +880,26 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
gg_pubdir50_add(req, GG_PUBDIR50_GENDER, "");
}
- GetDlgItemTextA(hwndDlg, IDC_BIRTHYEAR, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, text);
+ GetDlgItemText(hwndDlg, IDC_BIRTHYEAR, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, text_utf8);
+ mir_free(text_utf8);
+ }
- GetDlgItemTextA(hwndDlg, IDC_FAMILYNAME, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, text);
+ GetDlgItemText(hwndDlg, IDC_FAMILYNAME, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, text_utf8);
+ mir_free(text_utf8);
+ }
- GetDlgItemTextA(hwndDlg, IDC_CITYORIGIN, text, sizeof(text));
- if (strlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, text);
+ GetDlgItemText(hwndDlg, IDC_CITYORIGIN, text, sizeof(text));
+ if (_tcslen(text)){
+ char* text_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, text_utf8);
+ mir_free(text_utf8);
+ }
// Run update
gg_pubdir50_seq_set(req, GG_SEQ_CHINFO);
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp
index 9b7078f416..edf791284d 100644
--- a/protocols/Gadu-Gadu/src/gg.cpp
+++ b/protocols/Gadu-Gadu/src/gg.cpp
@@ -237,12 +237,12 @@ static int gg_prebuildcontactmenu(WPARAM wParam, LPARAM lParam)
return 0;
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_NAME | CMIM_FLAGS | CMIF_ICONFROMICOLIB;
+ mi.flags = CMIM_NAME | CMIM_FLAGS | CMIF_ICONFROMICOLIB | CMIF_TCHAR;
if ( db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0) == db_get_b(NULL, gg->m_szModuleName, GG_KEY_UIN, 0) ||
db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0) ||
db_get_b(hContact, "CList", "NotOnList", 0))
mi.flags |= CMIF_HIDDEN;
- mi.pszName = db_get_b(hContact, gg->m_szModuleName, GG_KEY_BLOCK, 0) ? LPGEN("&Unblock") : LPGEN("&Block");
+ mi.ptszName = db_get_b(hContact, gg->m_szModuleName, GG_KEY_BLOCK, 0) ? LPGENT("&Unblock") : LPGENT("&Block");
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)gg->hBlockMenuItem, (LPARAM)&mi);
return 0;
}
@@ -269,10 +269,10 @@ void GGPROTO::block_init()
createObjService(service, &GGPROTO::blockuser);
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIF_ICONFROMICOLIB;
+ mi.flags = CMIF_ICONFROMICOLIB | CMIF_TCHAR;
mi.position = -500050000;
mi.icolibItem = iconList[8].hIcolib;
- mi.pszName = LPGEN("&Block");
+ mi.ptszName = LPGENT("&Block");
mi.pszService = service;
mi.pszContactOwner = m_szModuleName;
hBlockMenuItem = Menu_AddContactMenuItem(&mi);
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h
index 8b5a5b313b..a33ad71c14 100644
--- a/protocols/Gadu-Gadu/src/gg.h
+++ b/protocols/Gadu-Gadu/src/gg.h
@@ -263,6 +263,19 @@ typedef struct
#define GG_KEY_RECONNINTERVAL "ReconnectInterval"
#define GG_KEYDEF_RECONNINTERVAL 3000
+
+#define GG_KEY_PD_NICKNAME "NickName" // GG Public directory: Nick name
+#define GG_KEY_PD_FIRSTNAME "FirstName" // GG Public directory: First name
+#define GG_KEY_PD_LASTNAME "LastName" // GG Public directory: Last name
+#define GG_KEY_PD_FAMILYNAME "FamilyName" // GG Public directory: Family name
+#define GG_KEY_PD_CITY "City" // GG Public directory: City
+#define GG_KEY_PD_FAMILYCITY "CityOrigin" // GG Public directory: Family city
+
+#define GG_KEY_PD_AGE "Age" // GG Public directory: Age
+#define GG_KEY_PD_BIRTHYEAR "BirthYear" // GG Public directory: Birth year
+#define GG_KEY_PD_GANDER "Gender" // GG Public directory: Gander
+
+
// chpassdlgproc() multipurpose dialog proc modes
#define GG_USERUTIL_PASS 0
#define GG_USERUTIL_CREATE 1
@@ -330,7 +343,6 @@ void gg_links_instancemenu_init();
void gg_links_init();
void gg_links_destroy();
-#define UIN2ID(uin,id) _itoa(uin,id,10) //@deprecated
#define UIN2IDA(uin,id) _itoa(uin,id,10)
#define UIN2IDT(uin,id) _itot(uin,id,10)
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index ced5f83cd5..a8f662fe9a 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -60,6 +60,7 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName)
createProtoService(PS_SETMYAVATART, &GGPROTO::setmyavatar);
createProtoService(PS_GETMYAWAYMSG, &GGPROTO::getmyawaymsg);
+ createProtoService(PS_SETAWAYMSGT, (GGServiceFunc)&GGPROTO::SetAwayMsg);
createProtoService(PS_CREATEACCMGRUI, &GGPROTO::get_acc_mgr_gui);
createProtoService(PS_LEAVECHAT, &GGPROTO::leavechat);
@@ -327,13 +328,13 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id)
return (HANDLE)1;
}
- TCHAR *ida = mir_tstrdup(id);
+ char *id_utf8 = mir_utf8encodeT(id);
// Add uin and search it
- gg_pubdir50_add(req, GG_PUBDIR50_UIN, _T2A(ida));
+ gg_pubdir50_add(req, GG_PUBDIR50_UIN, id_utf8);
gg_pubdir50_seq_set(req, GG_SEQ_SEARCH);
- mir_free(ida);
+ mir_free(id_utf8);
gg_EnterCriticalSection(&sess_mutex, "SearchBasic", 50, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
@@ -377,31 +378,31 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName,
return (HANDLE)1;
}
- // Add uin and search it
+ // Add nick,firstName,lastName and search it
if (nick)
{
- char *nickA = mir_t2a(nick);
- gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nickA);
- strncat(data, nickA, sizeof(data) - strlen(data));
- mir_free(nickA);
+ char *nick_utf8 = mir_utf8encodeT(nick);
+ gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nick_utf8);
+ strncat(data, nick_utf8, sizeof(data) - strlen(data));
+ mir_free(nick_utf8);
}
strncat(data, ".", sizeof(data) - strlen(data));
if (firstName)
{
- char *firstNameA = mir_t2a(firstName);
- gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstNameA);
- strncat(data, firstNameA, sizeof(data) - strlen(data));
- mir_free(firstNameA);
+ char *firstName_utf8 = mir_utf8encodeT(firstName);
+ gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstName_utf8);
+ strncat(data, firstName_utf8, sizeof(data) - strlen(data));
+ mir_free(firstName_utf8);
}
strncat(data, ".", sizeof(data) - strlen(data));
if (lastName)
{
- char *lastNameA = mir_t2a(lastName);
- gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastNameA);
- strncat(data, lastNameA, sizeof(data) - strlen(data));
- mir_free(lastNameA);
+ char *lastName_utf8 = mir_utf8encodeT(lastName);
+ gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastName_utf8);
+ strncat(data, lastName_utf8, sizeof(data) - strlen(data));
+ mir_free(lastName_utf8);
}
strncat(data, ".", sizeof(data) - strlen(data));
@@ -437,7 +438,8 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName,
HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
{
gg_pubdir50_t req;
- char text[64], data[512] = "\0";
+ TCHAR text[64];
+ char data[800] = "\0";
unsigned long crc;
// Check if connected
@@ -453,42 +455,50 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
}
// Fetch search data
- GetDlgItemTextA(hwndDlg, IDC_FIRSTNAME, text, sizeof(text));
- if (strlen(text))
+ GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, sizeof(text));
+ if (_tcslen(text))
{
- gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, text);
- strncat(data, text, sizeof(data) - strlen(data));
+ char *firstName_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, firstName_utf8);
+ strncat(data, firstName_utf8, sizeof(data) - strlen(data));
+ mir_free(firstName_utf8);
}
/* 1 */ strncat(data, ".", sizeof(data) - strlen(data));
- GetDlgItemTextA(hwndDlg, IDC_LASTNAME, text, sizeof(text));
- if (strlen(text))
+ GetDlgItemText(hwndDlg, IDC_LASTNAME, text, sizeof(text));
+ if (_tcslen(text))
{
- gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, text);
- strncat(data, text, sizeof(data) - strlen(data));
+ char *lastName_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, lastName_utf8);
+ strncat(data, lastName_utf8, sizeof(data) - strlen(data));
+ mir_free(lastName_utf8);
}
/* 2 */ strncat(data, ".", sizeof(data) - strlen(data));
- GetDlgItemTextA(hwndDlg, IDC_NICKNAME, text, sizeof(text));
- if (strlen(text))
+ GetDlgItemText(hwndDlg, IDC_NICKNAME, text, sizeof(text));
+ if (_tcslen(text))
{
- gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, text);
- strncat(data, text, sizeof(data) - strlen(data));
+ char *nickName_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, nickName_utf8);
+ strncat(data, nickName_utf8, sizeof(data) - strlen(data));
+ mir_free(nickName_utf8);
}
/* 3 */ strncat(data, ".", sizeof(data) - strlen(data));
- GetDlgItemTextA(hwndDlg, IDC_CITY, text, sizeof(text));
- if (strlen(text))
+ GetDlgItemText(hwndDlg, IDC_CITY, text, sizeof(text));
+ if (_tcslen(text))
{
- gg_pubdir50_add(req, GG_PUBDIR50_CITY, text);
- strncat(data, text, sizeof(data) - strlen(data));
+ char *city_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_CITY, city_utf8);
+ strncat(data, city_utf8, sizeof(data) - strlen(data));
+ mir_free(city_utf8);
}
/* 4 */ strncat(data, ".", sizeof(data) - strlen(data));
- GetDlgItemTextA(hwndDlg, IDC_AGEFROM, text, sizeof(text));
- if (strlen(text))
+ GetDlgItemText(hwndDlg, IDC_AGEFROM, text, sizeof(text));
+ if (_tcslen(text))
{
- int yearTo = atoi(text);
+ int yearTo = _tstoi(text);
int yearFrom;
time_t t = time(NULL);
struct tm *lt = localtime(&t);
@@ -507,10 +517,12 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
yearFrom = 0;
else
yearFrom = ay - yearFrom;
- mir_snprintf(text, sizeof(text), "%d %d", yearFrom, yearTo);
+ mir_sntprintf(text, sizeof(text), _T("%d %d"), yearFrom, yearTo);
- gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, text);
- strncat(data, text, sizeof(data) - strlen(data));
+ char *age_utf8 = mir_utf8encodeT(text);
+ gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, age_utf8);
+ strncat(data, age_utf8, sizeof(data) - strlen(data));
+ mir_free(age_utf8);
}
/* 5 */ strncat(data, ".", sizeof(data) - strlen(data));
@@ -625,12 +637,21 @@ void __cdecl GGPROTO::sendackthread(void *ack)
int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg)
{
uin_t uin;
+ char* msg_utf8;
+
+ if ( flags & PREF_TCHAR )
+ msg_utf8 = mir_utf8encodeT( ( wchar_t* )&msg[ strlen( msg )+1 ] );
+ else if ( flags & PREF_UTF )
+ msg_utf8 = mir_strdup(msg);
+ else
+ msg_utf8 = mir_utf8encode(msg);
+
- if (msg && isonline() && (uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)))
+ if (msg_utf8 && isonline() && (uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)))
{
int seq;
gg_EnterCriticalSection(&sess_mutex, "SendMsg", 53, "sess_mutex", 1);
- seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg);
+ seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg_utf8);
gg_LeaveCriticalSection(&sess_mutex, "SendMsg", 53, 1, "sess_mutex", 1);
if (!db_get_b(NULL, m_szModuleName, GG_KEY_MSGACK, GG_KEYDEF_MSGACK))
{
@@ -646,8 +667,10 @@ int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg)
forkthread(&GGPROTO::sendackthread, ack);
}
}
+ mir_free(msg_utf8);
return seq;
}
+ mir_free(msg_utf8);
return 0;
}
@@ -714,56 +737,53 @@ HANDLE GGPROTO::GetAwayMsg(HANDLE hContact)
//////////////////////////////////////////////////////////
// when away message is being set
-int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *msgt)
+int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *newMsg)
{
int status = gg_normalizestatus(iStatus);
- char **szMsg;
- char *msg = mir_t2a(msgt);
+ TCHAR **msgPtr;
- netlog("SetAwayMsg(): PS_SETAWAYMSG(%d, \"%s\").", iStatus, msg);
+ netlog("SetAwayMsg(): PS_SETAWAYMSG(%d, \"%S\").", iStatus, newMsg);
gg_EnterCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, "modemsg_mutex", 1);
- // Select proper msg
+ // Select proper our msg ptr
switch(status)
{
case ID_STATUS_ONLINE:
- szMsg = &modemsg.online;
+ msgPtr = &modemsg.online;
break;
case ID_STATUS_AWAY:
- szMsg = &modemsg.away;
+ msgPtr = &modemsg.away;
break;
case ID_STATUS_DND:
- szMsg = &modemsg.dnd;
+ msgPtr = &modemsg.dnd;
break;
case ID_STATUS_FREECHAT:
- szMsg = &modemsg.freechat;
+ msgPtr = &modemsg.freechat;
break;
case ID_STATUS_INVISIBLE:
- szMsg = &modemsg.invisible;
+ msgPtr = &modemsg.invisible;
break;
default:
gg_LeaveCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, 1, "modemsg_mutex", 1);
- mir_free(msg);
return 1;
}
// Check if we change status here somehow
- if (*szMsg && msg && !strcmp(*szMsg, msg)
- || !*szMsg && (!msg || !*msg))
+ if (*msgPtr && newMsg && !_tcscmp(*msgPtr, newMsg)
+ || !*msgPtr && (!newMsg || !*newMsg))
{
if (status == m_iDesiredStatus && m_iDesiredStatus == m_iStatus)
{
netlog("SetAwayMsg(): Message hasn't been changed, return.");
gg_LeaveCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, 2, "modemsg_mutex", 1);
- mir_free(msg);
return 0;
}
}
else
{
- if (*szMsg)
- mir_free(*szMsg);
- *szMsg = msg && *msg ? mir_strdup(msg) : NULL;
+ if (*msgPtr)
+ mir_free(*msgPtr);
+ *msgPtr = newMsg && *newMsg ? mir_tstrdup(newMsg) : NULL;
#ifdef DEBUGMODE
netlog("SetAwayMsg(): Message changed.");
#endif
@@ -774,7 +794,6 @@ int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *msgt)
if (status == m_iDesiredStatus)
refreshstatus(status);
- mir_free(msg);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index 10ca4efafa..3c75f1179d 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -132,8 +132,8 @@ struct GGPROTO : public PROTO_INTERFACE, public MZeroedObject
int contactdeleted(WPARAM wParam, LPARAM lParam);
int dbsettingchanged(WPARAM wParam, LPARAM lParam);
void notifyall();
- void changecontactstatus(uin_t uin, int status, const char *idescr, int time, uint32_t remote_ip, uint16_t remote_port, uint32_t version);
- char *getstatusmsg(int status);
+ void changecontactstatus(uin_t uin, int status, const TCHAR *idescr, int time, uint32_t remote_ip, uint16_t remote_port, uint32_t version);
+ TCHAR *getstatusmsg(int status);
void dccstart();
void dccconnect(uin_t uin);
int gettoken(GGTOKEN *token);
@@ -223,7 +223,6 @@ struct GGPROTO : public PROTO_INTERFACE, public MZeroedObject
TCHAR * gc_getchat(uin_t sender, uin_t *recipients, int recipients_count);
GGGC *gc_lookup(TCHAR *id);
int gc_changenick(HANDLE hContact, TCHAR *ptszNick);
- #define UIN2ID(uin,id) _itoa(uin,id,10)
int __cdecl gc_event(WPARAM wParam, LPARAM lParam);
@@ -271,12 +270,12 @@ struct GGPROTO : public PROTO_INTERFACE, public MZeroedObject
UINT_PTR timer;
struct
{
- char *online;
- char *away;
- char *dnd;
- char *freechat;
- char *invisible;
- char *offline;
+ TCHAR *online;
+ TCHAR *away;
+ TCHAR *dnd;
+ TCHAR *freechat;
+ TCHAR *invisible;
+ TCHAR *offline;
} modemsg;
HANDLE netlib;
HGENMENU hMenuRoot;
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index e742263aae..a0768e238f 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -65,7 +65,7 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot)
char service[64];
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTHANDLE;
+ mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTHANDLE | CMIF_TCHAR;
mi.hParentMenu = hRoot;
// Conferencing
@@ -73,7 +73,7 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot)
createObjService(service, &GGPROTO::gc_openconf);
mi.position = 2000050001;
mi.icolibItem = iconList[14].hIcolib;
- mi.pszName = LPGEN("Open &conference...");
+ mi.ptszName = LPGENT("Open &conference...");
mi.pszService = service;
hMainMenu[0] = Menu_AddProtoMenuItem(&mi);
@@ -82,7 +82,7 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot)
createObjService(service, &GGPROTO::gc_clearignored);
mi.position = 2000050002;
mi.icolibItem = iconList[15].hIcolib;
- mi.pszName = LPGEN("&Clear ignored conferences");
+ mi.ptszName = LPGENT("&Clear ignored conferences");
mi.pszService = service;
hMainMenu[1] = Menu_AddProtoMenuItem(&mi);
}
@@ -186,19 +186,19 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
// Get rid of CRLF at back
lc = (int)_tcslen(gch->ptszText) - 1;
while(lc >= 0 && (gch->ptszText[lc] == '\n' || gch->ptszText[lc] == '\r')) gch->ptszText[lc --] = 0;
- char* pszText = mir_t2a(gch->ptszText);
gcevent.time = time(NULL);
gcevent.bIsMe = 1;
gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- netlog("gc_event(): Sending conference message to room %S, \"%s\".", gch->pDest->ptszID, pszText);
+ netlog("gc_event(): Sending conference message to room %S, \"%S\".", gch->pDest->ptszID, gch->ptszText);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
mir_free(nickT);
+ char* pszText_utf8 = mir_utf8encodeT(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);
+ gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText_utf8);
gg_LeaveCriticalSection(&sess_mutex, "gc_event", 57, 1, "sess_mutex", 1);
- mir_free(pszText);
+ mir_free(pszText_utf8);
return 1;
}
@@ -210,9 +210,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
if ((uin = _ttoi(gch->ptszUID)) && (hContact = getcontact(uin, 1, 0, NULL)))
CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
}
- char* pszText = mir_t2a(gch->ptszText);
- netlog("gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->pDest->iType, chat, uin, pszText);
- mir_free(pszText);
+ netlog("gc_event(): Unhandled event %d, chat %x, uin %d, text \"%S\".", gch->pDest->iType, chat, uin, gch->ptszText);
return 0;
}
@@ -401,7 +399,7 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count
CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gcevent);
CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gcevent);
- netlog("gc_getchat(): Returning new chat window %s, count %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Returning new chat window %S, count %d.", chat->id, chat->recipients_count);
list_add(&chats, chat, 0);
return chat->id;
}
@@ -517,6 +515,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
gcdest.ptszID = chat;
gcdest.iType = GC_EVENT_CONTROL;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
+ gcevent.dwFlags = GC_TCHAR;
CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gcevent);
}
free(participants);
@@ -683,7 +682,7 @@ int GGPROTO::gc_changenick(HANDLE hContact, TCHAR *ptszNick)
gce.dwFlags = GC_TCHAR;
gce.ptszText = ptszNick;
- netlog("gc_changenick(): Found room %S with uin %d, sending nick change %s.", chat->id, uin, id);
+ netlog("gc_changenick(): Found room %S with uin %d, sending nick change %S.", chat->id, uin, id);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
break;
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index a24fffb720..f3a36a4c3c 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -74,10 +74,10 @@ int GGPROTO::img_init()
// Send image contact menu item
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIF_ICONFROMICOLIB;
+ mi.flags = CMIF_ICONFROMICOLIB | CMIF_TCHAR;
mi.position = -2000010000;
mi.icolibItem = iconList[11].hIcolib;
- mi.pszName = LPGEN("&Image");
+ mi.ptszName = LPGENT("&Image");
mi.pszService = service;
mi.pszContactOwner = m_szModuleName;
hImageMenuItem = Menu_AddContactMenuItem(&mi);
@@ -848,18 +848,19 @@ int GGPROTO::img_displayasmsg(HANDLE hContact, void *img)
}
if (res != 0) {
- char image_msg[MAX_PATH + 11];
- mir_snprintf(image_msg, SIZEOF(image_msg), "[img]%s[/img]", (char*)_T2A(szPath));
+ TCHAR image_msg[MAX_PATH + 11];
+ mir_sntprintf(image_msg, SIZEOF(image_msg), _T("[img]%s[/img]"), szPath);
PROTORECVEVENT pre = {0};
+ pre.flags = PREF_TCHAR;
pre.timestamp = time(NULL);
- pre.szMessage = image_msg;
+ pre.tszMessage = image_msg;
ProtoChainRecvMsg(hContact, &pre);
- netlog("img_displayasmsg(): Image saved to %s.", szPath);
+ netlog("img_displayasmsg(): Image saved to %S.", szPath);
}
else
{
- netlog("img_displayasmsg(): Cannot save image to %s.", szPath);
+ netlog("img_displayasmsg(): Cannot save image to %S.", szPath);
}
return 0;
@@ -969,7 +970,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName)
FILE *fp = _tfopen(szFileName, _T("rb"));
if (!fp) {
free(dat);
- netlog("img_loadpicture(): fopen(\"%s\", \"rb\") failed.", szFileName);
+ netlog("img_loadpicture(): fopen(\"%S\", \"rb\") failed.", szFileName);
return NULL;
}
fseek(fp, 0, SEEK_END);
@@ -978,7 +979,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName)
{
fclose(fp);
free(dat);
- netlog("img_loadpicture(): Zero file size \"%s\" failed.", szFileName);
+ netlog("img_loadpicture(): Zero file size \"%S\" failed.", szFileName);
return NULL;
}
// Maximum acceptable image size
@@ -986,7 +987,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName)
{
fclose(fp);
free(dat);
- netlog("img_loadpicture(): Image size of \"%s\" exceeds 255 KB.", szFileName);
+ netlog("img_loadpicture(): Image size of \"%S\" exceeds 255 KB.", szFileName);
MessageBox(NULL, TranslateT("Image exceeds maximum allowed size of 255 KB."), m_tszUserName, MB_OK | MB_ICONEXCLAMATION);
return NULL;
}
@@ -997,7 +998,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName)
free(dat->lpData);
fclose(fp);
free(dat);
- netlog("img_loadpicture(): Reading file \"%s\" failed.", szFileName);
+ netlog("img_loadpicture(): Reading file \"%S\" failed.", szFileName);
return NULL;
}
fclose(fp);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 3d71b9052a..6e6d8aa155 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -110,16 +110,20 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
DBVARIANT dbv;
// Readup FirstName
- if (!db_get_s(hContact, gg->m_szModuleName, "FirstName", &dbv, DBVT_ASCIIZ))
+ if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_FIRSTNAME, &dbv, DBVT_WCHAR))
{
+ char* pszValA = mir_t2a(dbv.ptszVal);
string_append(s, dbv.pszVal);
+ mir_free(pszValA);
DBFreeVariant(&dbv);
}
string_append_c(s, ';');
// Readup LastName
- if (!db_get_s(hContact, gg->m_szModuleName, "LastName", &dbv, DBVT_ASCIIZ))
+ if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_LASTNAME, &dbv, DBVT_WCHAR))
{
+ char* pszValA = mir_t2a(dbv.ptszVal);
string_append(s, dbv.pszVal);
+ mir_free(pszValA);
DBFreeVariant(&dbv);
}
string_append_c(s, ';');
@@ -129,9 +133,11 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
{
char* dbvA = mir_t2a(dbv.ptszVal);
DBVARIANT dbv2;
- if (!db_get_s(hContact, gg->m_szModuleName, "NickName", &dbv2, DBVT_ASCIIZ))
+ if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_NICKNAME, &dbv2, DBVT_WCHAR))
{
- string_append(s, dbv2.pszVal);
+ char* pszValA = mir_t2a(dbv2.ptszVal);
+ string_append(s, pszValA);
+ mir_free(pszValA);
DBFreeVariant(&dbv2);
} else {
string_append(s, dbvA);
@@ -293,8 +299,16 @@ void GGPROTO::parsecontacts(char *contacts)
db_set_s(hContact, "CList", "Group", CreateGroup(strGroup));
// Write misc data
- if (hContact && strFirstName) db_set_s(hContact, m_szModuleName, "FirstName", strFirstName);
- if (hContact && strLastName) db_set_s(hContact, m_szModuleName, "LastName", strLastName);
+ if (hContact && strFirstName){
+ TCHAR *tstrFirstName = mir_a2t(strFirstName);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FIRSTNAME, tstrFirstName);
+ mir_free(tstrFirstName);
+ }
+ if (hContact && strLastName){
+ TCHAR *tstrLastName = mir_a2t(strLastName);
+ db_set_ts(hContact, m_szModuleName, GG_KEY_PD_LASTNAME, tstrLastName);
+ mir_free(tstrLastName);
+ }
if (hContact && strPhone) db_set_s(hContact, "UserInfo", "MyPhone0", strPhone); // Store now in User Info
if (hContact && strMail) db_set_s(hContact, "UserInfo", "Mye-mail0", strMail); // Store now in User Info
}
@@ -440,7 +454,7 @@ INT_PTR GGPROTO::import_text(WPARAM wParam, LPARAM lParam)
return 0;
*pfilter = '\0';
- *str = _T('\0');
+ *str = '\0';
ofn.lpstrFilter = filter;
ofn.lpstrFile = str;
@@ -607,11 +621,11 @@ void GGPROTO::import_init(HGENMENU hRoot)
createObjService(service, &GGPROTO::import_server);
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTHANDLE;
+ mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTHANDLE | CMIF_TCHAR;
mi.hParentMenu = hRoot;
mi.position = 2000500001;
mi.icolibItem = iconList[1].hIcolib;
- mi.pszName = LPGEN("Import List From &Server");
+ mi.ptszName = LPGENT("Import List From &Server");
mi.pszService = service;
hMainMenu[2] = Menu_AddProtoMenuItem(&mi);
@@ -621,7 +635,7 @@ void GGPROTO::import_init(HGENMENU hRoot)
mi.position = 2000500002;
mi.icolibItem = iconList[2].hIcolib;
- mi.pszName = LPGEN("Import List From &Text File...");
+ mi.ptszName = LPGENT("Import List From &Text File...");
mi.pszService = service;
hMainMenu[3] = Menu_AddProtoMenuItem(&mi);
@@ -631,7 +645,7 @@ void GGPROTO::import_init(HGENMENU hRoot)
mi.position = 2000500003;
mi.icolibItem = iconList[3].hIcolib;
- mi.pszName = LPGEN("&Remove List From Server");
+ mi.ptszName = LPGENT("&Remove List From Server");
mi.pszService = service;
hMainMenu[4] = Menu_AddProtoMenuItem(&mi);
@@ -641,7 +655,7 @@ void GGPROTO::import_init(HGENMENU hRoot)
mi.position = 2005000001;
mi.icolibItem = iconList[4].hIcolib;
- mi.pszName = LPGEN("Export List To &Server");
+ mi.ptszName = LPGENT("Export List To &Server");
mi.pszService = service;
hMainMenu[5] = Menu_AddProtoMenuItem(&mi);
@@ -651,7 +665,7 @@ void GGPROTO::import_init(HGENMENU hRoot)
mi.position = 2005000002;
mi.icolibItem = iconList[5].hIcolib;
- mi.pszName = LPGEN("Export List To &Text File...");
+ mi.ptszName = LPGENT("Export List To &Text File...");
mi.pszService = service;
hMainMenu[6] = Menu_AddProtoMenuItem(&mi);
}
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp
index 007e364507..a7e5ebac80 100644
--- a/protocols/Gadu-Gadu/src/oauth.cpp
+++ b/protocols/Gadu-Gadu/src/oauth.cpp
@@ -361,7 +361,7 @@ char* GGPROTO::oauth_header(const char *httpmethod, const char *url)
char *res, uin[32], *password = NULL, *token = NULL, *token_secret = NULL;
DBVARIANT dbv;
- UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
+ UIN2IDA( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)(int)strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
password = mir_strdup(dbv.pszVal);
@@ -395,7 +395,7 @@ int GGPROTO::oauth_receivetoken()
int res = 0;
HANDLE nlc = NULL;
- UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
+ UIN2IDA( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
password = mir_strdup(dbv.pszVal);
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp
index 3df7eced87..9d6ae0115f 100644
--- a/protocols/Gadu-Gadu/src/services.cpp
+++ b/protocols/Gadu-Gadu/src/services.cpp
@@ -50,7 +50,7 @@ char *gg_status2db(int status, const char *suffix)
//////////////////////////////////////////////////////////
// gets protocol status
-char* GGPROTO::getstatusmsg(int status)
+TCHAR* GGPROTO::getstatusmsg(int status)
{
switch(status) {
case ID_STATUS_ONLINE:
@@ -100,16 +100,17 @@ int GGPROTO::refreshstatus(int status)
}
else
{
- char *szMsg = NULL;
+ TCHAR *szMsg = NULL;
// Select proper msg
gg_EnterCriticalSection(&modemsg_mutex, "refreshstatus", 69, "modemsg_mutex", 1);
- szMsg = mir_strdup(getstatusmsg(status));
+ szMsg = getstatusmsg(status);
gg_LeaveCriticalSection(&modemsg_mutex, "refreshstatus", 69, 1, "modemsg_mutex", 1);
- if (szMsg)
+ char *szMsg_utf8 = mir_utf8encodeT(szMsg);
+ if (szMsg_utf8)
{
netlog("refreshstatus(): Setting status and away message.");
gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 70, "sess_mutex", 1);
- gg_change_status_descr(sess, status_m2gg(status, szMsg != NULL), szMsg);
+ gg_change_status_descr(sess, status_m2gg(status, szMsg_utf8 != NULL), szMsg_utf8);
gg_LeaveCriticalSection(&sess_mutex, "refreshstatus", 70, 1, "sess_mutex", 1);
}
else
@@ -122,7 +123,7 @@ int GGPROTO::refreshstatus(int status)
// Change status of the contact with our own UIN (if got yourself added to the contact list)
changecontactstatus( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), status_m2gg(status, szMsg != NULL), szMsg, 0, 0, 0, 0);
broadcastnewstatus(status);
- mir_free(szMsg);
+ mir_free(szMsg_utf8);
}
return TRUE;
@@ -326,12 +327,12 @@ INT_PTR GGPROTO::setmyavatar(WPARAM wParam, LPARAM lParam)
INT_PTR GGPROTO::getmyawaymsg(WPARAM wParam, LPARAM lParam)
{
INT_PTR res = 0;
- char *szMsg;
+ TCHAR *szMsg;
gg_EnterCriticalSection(&modemsg_mutex, "refreshstatus", 72, "modemsg_mutex", 1);
szMsg = getstatusmsg(wParam ? gg_normalizestatus(wParam) : m_iStatus);
if (isonline() && szMsg)
- res = (lParam & SGMA_UNICODE) ? (INT_PTR)mir_a2u(szMsg) : (INT_PTR)mir_strdup(szMsg);
+ res = (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(szMsg) : (INT_PTR)mir_t2a(szMsg);
gg_LeaveCriticalSection(&modemsg_mutex, "refreshstatus", 72, 1, "modemsg_mutex", 1);
return res;
}