From a5184b5e19951983bb9f699807cd9c5cf206c7ce Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 7 Jun 2015 13:12:43 +0000 Subject: YAHOO search -> utf8 git-svn-id: http://svn.miranda-ng.org/main/trunk@14049 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Yahoo/src/links.cpp | 63 ++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) (limited to 'protocols/Yahoo/src/links.cpp') diff --git a/protocols/Yahoo/src/links.cpp b/protocols/Yahoo/src/links.cpp index ae7ef3f0aa..a436c3f400 100644 --- a/protocols/Yahoo/src/links.cpp +++ b/protocols/Yahoo/src/links.cpp @@ -33,21 +33,17 @@ static void url_decode(TCHAR* str) { TCHAR* s = str, *d = str; - while(*s) - { - if (*s == '%') - { + while (*s) { + if (*s == '%') { int digit1 = SingleHexToDecimal(s[1]); - if (digit1 != -1) - { + if (digit1 != -1) { int digit2 = SingleHexToDecimal(s[2]); - if (digit2 != -1) - { + if (digit2 != -1) { s += 3; *d++ = (TCHAR)((digit1 << 4) | digit2); continue; - } - } + } + } } *d++ = *s++; } @@ -64,18 +60,18 @@ static char* get_buddy(TCHAR ** arg) if (!buf[0]) return NULL; url_decode(buf); - + *arg = tok ? tok + 1 : NULL; return mir_t2a(buf); } -/* +/* add user: ymsgr:addfriend?ID send message: ymsgr:sendim?ID&m=MESSAGE add chatroom: ymsgr:chat?ROOM -*/ + */ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) { TCHAR *arg = (TCHAR*)lParam; @@ -84,16 +80,14 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) /* skip leading prefix */ arg = _tcschr(arg, ':'); if (arg == NULL) return 1; /* parse failed */ - + for (++arg; *arg == '/'; ++arg) {} if (g_instances.getCount() == 0) return 0; CYahooProto *proto = g_instances[0]; - for (int i = 0; i < g_instances.getCount(); ++i) - { - if (g_instances[i]->m_iStatus > ID_STATUS_OFFLINE) - { + for (int i = 0; i < g_instances.getCount(); ++i) { + if (g_instances[i]->m_iStatus > ID_STATUS_OFFLINE) { proto = g_instances[i]; break; } @@ -101,22 +95,21 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) if (!proto) return 1; /* add a contact to the list */ - if (!_tcsnicmp(arg, _T("addfriend?"), 10)) - { + if (!_tcsnicmp(arg, _T("addfriend?"), 10)) { arg += 10; char *id = get_buddy(&arg); if (!id) return 1; - + if (proto->getbuddyH(id) == NULL) /* does not yet check if id is current user */ { - ADDCONTACTSTRUCT acs = {0}; - PROTOSEARCHRESULT psr = {0}; - + ADDCONTACTSTRUCT acs = { 0 }; + PROTOSEARCHRESULT psr = { 0 }; + acs.handleType = HANDLE_SEARCHRESULT; acs.szProto = proto->m_szModuleName; acs.psr = &psr; - + psr.cbSize = sizeof(PROTOSEARCHRESULT); psr.id.t = (TCHAR*)id; CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); @@ -126,8 +119,7 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) return 0; } /* send a message to a contact */ - else if (!_tcsnicmp(arg, _T("sendim?"), 7)) - { + else if (!_tcsnicmp(arg, _T("sendim?"), 7)) { arg += 7; char *id = get_buddy(&arg); @@ -135,19 +127,17 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) TCHAR *msg = NULL; - while (arg) - { - if (!_tcsnicmp(arg, _T("m="), 2)) - { + while (arg) { + if (!_tcsnicmp(arg, _T("m="), 2)) { msg = arg + 2; url_decode(msg); break; } - + arg = _tcschr(arg + 1, '&'); /* first token */ if (arg) *arg = 0; } - + MCONTACT hContact = proto->add_buddy(id, id, 0, PALF_TEMPORARY); /* ensure contact is on list */ if (hContact) CallService(MS_MSG_SENDMESSAGET, hContact, (LPARAM)msg); @@ -156,12 +146,11 @@ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) return 0; } /* open a chatroom */ - else if (!_tcsnicmp(arg, _T("chat?"), 5)) - { + else if (!_tcsnicmp(arg, _T("chat?"), 5)) { arg += 5; -// char *id = get_buddy(&arg); -// if (!id) return 1; + // char *id = get_buddy(&arg); + // if (!id) return 1; /* not yet implemented (rm contains name of chatroom)*/ return 0; -- cgit v1.2.3