diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-16 18:20:37 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-16 18:20:37 +0300 |
commit | 6163df27ad6fd2a5da5d9bbb48bb457d8a07a2b6 (patch) | |
tree | d0523b56e1b987789c6622916a31e8f356076d23 /plugins/NewEventNotify | |
parent | e021b02022a37bd23b599801026d631f5fd9f48c (diff) |
DB_AUTH_BLOB: handy piece of code moved into the core
Diffstat (limited to 'plugins/NewEventNotify')
-rw-r--r-- | plugins/NewEventNotify/src/popup.cpp | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp index 466cbf0661..4edd1c8bad 100644 --- a/plugins/NewEventNotify/src/popup.cpp +++ b/plugins/NewEventNotify/src/popup.cpp @@ -282,36 +282,20 @@ static wchar_t* GetEventPreview(DBEVENTINFO *dbei) case EVENTTYPE_AUTHREQUEST:
if (dbei->pBlob) {
- char szUin[16];
- wchar_t szBuf[2048];
- wchar_t* szNick = NULL;
- char *pszNick = (char *)dbei->pBlob + 8;
- char *pszFirst = pszNick + mir_strlen(pszNick) + 1;
- char *pszLast = pszFirst + mir_strlen(pszFirst) + 1;
- char *pszEmail = pszLast + mir_strlen(pszLast) + 1;
-
- mir_snprintf(szUin, "%d", *((DWORD*)dbei->pBlob));
- if (mir_strlen(pszNick) > 0) {
- if (dbei->flags & DBEF_UTF)
- szNick = mir_utf8decodeW(pszNick);
- else
- szNick = mir_a2u(pszNick);
+ DB_AUTH_BLOB blob(dbei->pBlob);
+
+ wchar_t *szNick = NULL;
+ if (blob.get_nick())
+ szNick = dbei->getString(blob.get_nick());
+ else if (blob.get_email())
+ szNick = dbei->getString(blob.get_email());
+ else if (blob.get_uin()) {
+ char szUin[16];
+ szNick = mir_a2u(itoa(blob.get_uin(), szUin, 10));
}
- else if (mir_strlen(pszEmail) > 0) {
- if (dbei->flags & DBEF_UTF)
- szNick = mir_utf8decodeW(pszEmail);
- else
- szNick = mir_a2u(pszEmail);
- }
- else if (*((DWORD*)dbei->pBlob) > 0)
- szNick = mir_a2u(szUin);
- if (szNick) {
- mir_wstrcpy(szBuf, szNick);
- mir_wstrcat(szBuf, TranslateT(" requested authorization"));
- mir_free(szNick);
- comment1 = mir_wstrdup(szBuf);
- }
+ if (szNick)
+ comment1 = CMStringW(FORMAT, L"%s%s", szNick, TranslateT(" requested authorization")).Detach();
}
commentFix = POPUP_COMMENT_AUTH;
break;
|