diff options
author | Szymon Tokarz <wsx22@o2.pl> | 2012-10-26 23:21:11 +0000 |
---|---|---|
committer | Szymon Tokarz <wsx22@o2.pl> | 2012-10-26 23:21:11 +0000 |
commit | 22aa69a8d572fa38305471698da4340b93aa4290 (patch) | |
tree | 116ca32c63cf382098b3c570fa75a2b7797ed344 /protocols/Gadu-Gadu | |
parent | 3e5555efc2ca8030db992597a7b549f0ef07b1cd (diff) |
Gadu-Gadu protocol
- groupchats fixed
- minor TCHAR fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@2089 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu')
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 48 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/groupchat.cpp | 41 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/token.cpp | 4 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/userutils.cpp | 6 |
4 files changed, 60 insertions, 39 deletions
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index ec456139d6..02a12bbf9f 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -359,9 +359,9 @@ void __cdecl GGPROTO::mainthread(void *) if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal)))
{
TCHAR error[128];
- TCHAR* forwardHostT = mir_a2t(dbv.pszVal);
- mir_sntprintf(error, SIZEOF(error), TranslateT("External direct connections hostname %S is invalid. Disabling external host forwarding."), forwardHostT);
- mir_free(forwardHostT);
+ TCHAR* forwardHostT = mir_a2t(dbv.pszVal);
+ mir_sntprintf(error, SIZEOF(error), TranslateT("External direct connections hostname %s is invalid. Disabling external host forwarding."), forwardHostT);
+ mir_free(forwardHostT);
showpopup(m_tszUserName, error, GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX);
}
else
@@ -389,9 +389,9 @@ retry: if (!(p.server_addr = gg_dnslookup(this, hosts[hostnum].hostname)))
{
TCHAR error[128];
- TCHAR* hostnameT = mir_a2t(hosts[hostnum].hostname);
- mir_sntprintf(error, SIZEOF(error), TranslateT("Server hostname %S is invalid. Using default hostname provided by the network."), hostnameT);
- mir_free(hostnameT);
+ TCHAR* hostnameT = mir_a2t(hosts[hostnum].hostname);
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Server hostname %s is invalid. Using default hostname provided by the network."), hostnameT);
+ mir_free(hostnameT);
showpopup(m_tszUserName, error, GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX);
}
else
@@ -640,7 +640,7 @@ retry: GGSEARCHRESULT sr;
memset(&sr, 0, sizeof(sr));
sr.cbSize = sizeof(sr);
- sr.flags = PSR_TCHAR;
+ sr.flags = PSR_TCHAR;
sr.nick = mir_a2t(__nick);
sr.firstName = mir_a2t(__firstname);
sr.lastName = mir_a2t(__lastname);
@@ -808,12 +808,14 @@ retry: UIN2ID(e->event.msg.sender, id);
gcevent.pszUID = id;
- gcevent.pszText = e->event.msg.message;
- gcevent.pszNick = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), 0);
+ TCHAR* messageT = mir_a2t(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;
- gcevent.dwFlags = GCEF_ADDTOLOG;
+ gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
netlog("gg_mainthread(%x): Conference message to room %s & id %s.", this, chat, id);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
+ mir_free(messageT);
}
}
// Check if not empty message ( who needs it? )
@@ -875,17 +877,23 @@ retry: UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), id);
gcevent.pszUID = id;
- gcevent.pszText = e->event.multilogon_msg.message;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ))
- gcevent.pszNick = dbv.pszVal;
- else
- gcevent.pszNick = Translate("Me");
+ TCHAR* messageT = mir_a2t(e->event.multilogon_msg.message);
+ gcevent.ptszText = messageT;
+ TCHAR* pszValT;
+ if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ)){
+ pszValT = mir_a2t(dbv.pszVal);
+ gcevent.ptszNick = pszValT;
+ DBFreeVariant(&dbv);
+ } else {
+ gcevent.ptszNick = TranslateT("Me");
+ }
gcevent.time = e->event.multilogon_msg.time;
gcevent.bIsMe = 1;
gcevent.dwFlags = GCEF_ADDTOLOG;
netlog("gg_mainthread(%x): Sent conference message to room %s.", this, chat);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
- if (gcevent.pszNick == dbv.pszVal) DBFreeVariant(&dbv);
+ mir_free(messageT);
+ if (pszValT != NULL) mir_free(pszValT);;
}
}
else if (!e->event.multilogon_msg.recipients_count && e->event.multilogon_msg.message && *e->event.multilogon_msg.message
@@ -1528,9 +1536,11 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) db_set_w(hContact, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
// If nick specified use it
- if (szNick)
- db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, szNick);
- else if (isonline()) {
+ if (szNick) {
+ char* szNickA = mir_t2a(szNick);
+ db_set_s(hContact, m_szModuleName, GG_KEY_NICK, szNickA);
+ mir_free(szNickA);
+ } else if (isonline()) {
gg_pubdir50_t req;
// Search for that nick
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 4089c8fac3..cdee390581 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -161,7 +161,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) }
// Message typed / send only if online
- if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->pszText)
+ if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText)
{
char id[32];
DBVARIANT dbv;
@@ -172,24 +172,33 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) UIN2ID(uin, id);
gcevent.pszUID = id;
- gcevent.pszText = gch->pszText;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ))
- gcevent.pszNick = dbv.pszVal;
- else
- gcevent.pszNick = Translate("Me");
+ gcevent.ptszText = gch->ptszText;
+ TCHAR* pszValT;
+ if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ)){
+ pszValT = mir_a2t(dbv.pszVal);
+ gcevent.ptszNick = pszValT;
+ DBFreeVariant(&dbv);
+ } else {
+ gcevent.ptszNick = TranslateT("Me");
+ }
// Get rid of CRLF at back
- lc = (int)strlen(gch->pszText) - 1;
- while(lc >= 0 && (gch->pszText[lc] == '\n' || gch->pszText[lc] == '\r')) gch->pszText[lc --] = 0;
+ 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 = GCEF_ADDTOLOG;
- netlog("gg_gc_event(): Sending conference message to room %s, \"%s\".", gch->pDest->pszID, gch->pszText);
+ gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ netlog("gg_gc_event(): Sending conference message to room %s, \"%s\".", gch->pDest->pszID, pszText);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
- if (gcevent.pszNick == dbv.pszVal) DBFreeVariant(&dbv);
+ if (pszValT != NULL) mir_free(pszValT);;
+
EnterCriticalSection(&sess_mutex);
- gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)gch->pszText);
+ gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText);
LeaveCriticalSection(&sess_mutex);
+ mir_free(pszText);
+
return 1;
}
@@ -200,7 +209,9 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) if ((uin = atoi(gch->pszUID)) && (hContact = getcontact(uin, 1, 0, NULL)))
CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)0);
}
- netlog("gg_gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->pDest->iType, chat, uin, gch->pszText);
+ char* pszText = mir_t2a(gch->ptszText);
+ netlog("gg_gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->pDest->iType, chat, uin, pszText);
+ mir_free(pszText);
return 0;
}
@@ -346,8 +357,8 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) if (uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0))
{
UIN2ID(uin, id);
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)) {
- gcevent.ptszNick = NEWTSTR_ALLOCA(dbv.ptszVal);
+ if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_ASCIIZ)) {
+ gcevent.ptszNick = mir_a2t(dbv.pszVal);
db_free(&dbv);
}
else gcevent.ptszNick = TranslateT("Me");
diff --git a/protocols/Gadu-Gadu/src/token.cpp b/protocols/Gadu-Gadu/src/token.cpp index d2946c12ef..d6ff406fd5 100644 --- a/protocols/Gadu-Gadu/src/token.cpp +++ b/protocols/Gadu-Gadu/src/token.cpp @@ -117,7 +117,7 @@ int GGPROTO::gettoken(GGTOKEN *token) if (!(h = gg_token(0)) || gg_token_watch_fd(h) || h->state == GG_STATE_ERROR || h->state != GG_STATE_DONE) {
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("Token retrieval failed because of error:\n\t%S"), http_error_string(h ? h->error : 0));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Token retrieval failed because of error:\n\t%s"), http_error_string(h ? h->error : 0));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
gg_free_pubdir(h);
return FALSE;
@@ -125,7 +125,7 @@ int GGPROTO::gettoken(GGTOKEN *token) if (!(t = (struct gg_token *)h->data) || (!h->body)) {
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("Token retrieval failed because of error:\n\t%S"), http_error_string(h ? h->error : 0));
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Token retrieval failed because of error:\n\t%s"), http_error_string(h ? h->error : 0));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
gg_free_pubdir(h);
return FALSE;
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index 877cea3f20..599a8691b6 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -41,7 +41,7 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail) if (!(h = gg_register3(newEmail, newPass, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success || !s->uin)
{
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot register new account because of error:\n\t%S"),
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot register new account because of error:\n\t%s"),
(h && !s) ? http_error_string(h ? h->error : 0) :
(s ? TranslateT("Registration rejected") : _tcserror(errno)));
MessageBox(
@@ -93,7 +93,7 @@ void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password) if (!(h = gg_unregister3(uin, password, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success || s->uin != uin)
{
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("Your account cannot be removed because of error:\n\t%S"),
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Your account cannot be removed because of error:\n\t%s"),
(h && !s) ? http_error_string(h ? h->error : 0) :
(s ? TranslateT("Bad number or password") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
@@ -145,7 +145,7 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) if (!(h = gg_change_passwd4(uin, email, password, newPass, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success)
{
TCHAR error[128];
- mir_sntprintf(error, SIZEOF(error), TranslateT("Your password cannot be changed because of error:\n\t%S"),
+ mir_sntprintf(error, SIZEOF(error), TranslateT("Your password cannot be changed because of error:\n\t%s"),
(h && !s) ? http_error_string(h ? h->error : 0) :
(s ? TranslateT("Invalid data entered") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
|