From e2c2a1f5a84c6c9b705dc85c6a2dd1f97edd57e4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 22 May 2015 16:04:17 +0000 Subject: T2Utf - handy replacement for ptrA git-svn-id: http://svn.miranda-ng.org/main/trunk@13758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Yahoo/src/chat.cpp | 18 ++++---------- protocols/Yahoo/src/file_transfer.cpp | 8 +----- protocols/Yahoo/src/proto.cpp | 6 ++--- protocols/Yahoo/src/yahoo.cpp | 46 +++++++---------------------------- 4 files changed, 18 insertions(+), 60 deletions(-) (limited to 'protocols/Yahoo') 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*)¶m->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 : ""); - 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) -- cgit v1.2.3