summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp8
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp27
-rw-r--r--protocols/JabberG/src/jabber_proto.h10
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp92
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp8
-rw-r--r--protocols/JabberG/src/jabber_util.cpp247
6 files changed, 131 insertions, 261 deletions
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index ffec5dbc2f..14ccdb56c4 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -396,7 +396,7 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason)
/////////////////////////////////////////////////////////////////////////////////////////
// Context menu hooks
-static struct gc_item *sttFindGcMenuItem(GCMENUITEMS *items, DWORD id)
+static gc_item *sttFindGcMenuItem(GCMENUITEMS *items, DWORD id)
{
for (int i = 0; i < items->nItems; i++)
if (items->Item[i].dwID == id)
@@ -482,7 +482,7 @@ static gc_item sttLogListItems[] =
};
static TCHAR sttRJidBuf[JABBER_MAX_JID_LEN] = {0};
-static struct gc_item sttListItems[] =
+static gc_item sttListItems[] =
{
{ LPGENT("&Slap"), IDM_SLAP, MENU_ITEM }, // 0
{ LPGENT("&User details"), IDM_VCARD, MENU_ITEM }, // 1
@@ -612,13 +612,13 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
sttFindGcMenuItem(gcmi, idx)->uType = 0;
for (i = 0; i < SIZEOF(sttAffiliationItems); i++) {
- struct gc_item *item = sttFindGcMenuItem(gcmi, sttAffiliationItems[i].id);
+ gc_item *item = sttFindGcMenuItem(gcmi, sttAffiliationItems[i].id);
item->uType = (him->m_affiliation == sttAffiliationItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
item->bDisabled = !(force || sttAffiliationItems[i].check(me, him));
}
for (i = 0; i < SIZEOF(sttRoleItems); i++) {
- struct gc_item *item = sttFindGcMenuItem(gcmi, sttRoleItems[i].id);
+ gc_item *item = sttFindGcMenuItem(gcmi, sttRoleItems[i].id);
item->uType = (him->m_role == sttRoleItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
item->bDisabled = !(force || sttRoleItems[i].check(me, him));
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 14aaaae002..08bbb6cba5 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -67,13 +67,11 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) :
m_priorityMenuValSet(false),
m_hPrivacyMenuRoot(0),
m_hPrivacyMenuItems(10),
- m_pLastResourceList(NULL),
m_lstJabberFeatCapPairsDynamic(2),
m_uEnabledFeatCapsDynamic(0)
{
InitializeCriticalSection(&m_csModeMsgMutex);
InitializeCriticalSection(&m_csLists);
- InitializeCriticalSection(&m_csLastResourceMap);
m_szXmlStreamToBeInitialized = NULL;
@@ -179,8 +177,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) :
db_free(&dbv);
delSetting("Password");
}
-
- CleanLastResourceMap();
}
CJabberProto::~CJabberProto()
@@ -199,8 +195,6 @@ CJabberProto::~CJabberProto()
DestroyHookableEvent(m_hEventXStatusIconChanged);
DestroyHookableEvent(m_hEventXStatusChanged);
- CleanLastResourceMap();
-
ListWipe();
DeleteCriticalSection(&m_csLists);
@@ -209,7 +203,6 @@ CJabberProto::~CJabberProto()
DeleteCriticalSection(&m_filterInfo.csPatternLock);
DeleteCriticalSection(&m_csModeMsgMutex);
- DeleteCriticalSection(&m_csLastResourceMap);
mir_free(m_modeMsgs.szOnline);
mir_free(m_modeMsgs.szAway);
@@ -311,7 +304,6 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
}
}
- CleanLastResourceMap();
return 0;
}
@@ -914,7 +906,7 @@ int __cdecl CJabberProto::RecvContacts(HANDLE /*hContact*/, PROTORECVEVENT*)
////////////////////////////////////////////////////////////////////////////////////////
// RecvFile
-int __cdecl CJabberProto::RecvFile(HANDLE hContact, PROTORECVFILET* evt)
+int __cdecl CJabberProto::RecvFile(HANDLE hContact, PROTORECVFILET *evt)
{
return Proto_RecvFile(hContact, evt);
}
@@ -922,19 +914,12 @@ int __cdecl CJabberProto::RecvFile(HANDLE hContact, PROTORECVFILET* evt)
////////////////////////////////////////////////////////////////////////////////////////
// RecvMsg
-int __cdecl CJabberProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* evt)
+int __cdecl CJabberProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *evt)
{
- INT_PTR nDbEvent = Proto_RecvMessage(hContact, evt);
-
- EnterCriticalSection(&m_csLastResourceMap);
- if (IsLastResourceExists((void*)evt->lParam)) {
- m_ulpResourceToDbEventMap[ m_dwResourceMapPointer++ ] = nDbEvent;
- m_ulpResourceToDbEventMap[ m_dwResourceMapPointer++ ] = evt->lParam;
- if (m_dwResourceMapPointer >= SIZEOF(m_ulpResourceToDbEventMap))
- m_dwResourceMapPointer = 0;
- }
- LeaveCriticalSection(&m_csLastResourceMap);
-
+ ptrA szResUtf( mir_utf8encodeT((LPCTSTR)evt->lParam));
+ evt->pCustomData = szResUtf;
+ evt->cbCustomDataSize = lstrlenA(szResUtf);
+ Proto_RecvMessage(hContact, evt);
return 0;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 5122f1c086..e301a45199 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -344,11 +344,6 @@ struct CJabberProto : public PROTO<CJabberProto>
CNoteList m_notes;
- CRITICAL_SECTION m_csLastResourceMap;
- void *m_pLastResourceList;
- ULONG_PTR m_ulpResourceToDbEventMap[256]; // last 128 messages (128+128)
- DWORD m_dwResourceMapPointer;
-
CJabberInterface m_JabberApi;
CJabberSysInterface m_JabberSysApi;
CJabberNetInterface m_JabberNetApi;
@@ -359,11 +354,6 @@ struct CJabberProto : public PROTO<CJabberProto>
void JabberUpdateDialogs(BOOL bEnable);
- void CleanLastResourceMap();
- BOOL IsLastResourceExists(void *pResource);
- void* AddToLastResourceMap(LPCTSTR szFullJid);
- TCHAR* FindLastResourceByDbEvent(HANDLE hDbEvent);
-
//---- jabber_adhoc.cpp --------------------------------------------------------------
int __cdecl ContactMenuRunCommands(WPARAM wParam, LPARAM lParam);
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 9cfc9aceb3..aa660ff8ff 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -554,60 +554,60 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
int nEventsSent = 0;
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- if ( getTString(hContact, "jid", &dbv))
+ ptrT tszJid( getTStringA(hContact, "jid"));
+ if (tszJid == NULL)
continue;
- HANDLE hDbEvent = db_event_firstUnread(hContact);
- while (hDbEvent) {
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
+ for (HANDLE hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hDbEvent)) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- if (dbei.cbBlob != -1) {
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
- int nGetTextResult = db_event_get(hDbEvent, &dbei);
- if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
- TCHAR *szEventText = DbGetEventTextT(&dbei, CP_ACP);
- if (szEventText) {
- XmlNode msg(_T("message"));
- msg << XATTR(_T("to"), pInfo->GetFrom()) << XATTRID(SerialNext())
- << XCHILD(_T("body"), szEventText);
-
- HXML addressesNode = msg << XCHILDNS(_T("addresses"), JABBER_FEAT_EXT_ADDRESSING);
- TCHAR szOFrom[JABBER_MAX_JID_LEN];
- EnterCriticalSection(&m_csLastResourceMap);
- TCHAR *szOResource = FindLastResourceByDbEvent(hDbEvent);
- if (szOResource)
- mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s/%s"), dbv.ptszVal, szOResource);
- else
- mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s"), dbv.ptszVal);
- LeaveCriticalSection(&m_csLastResourceMap);
- addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("ofrom")) << XATTR(_T("jid"), szOFrom);
- addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("oto")) << XATTR(_T("jid"), m_ThreadInfo->fullJID);
-
- time_t ltime = (time_t)dbei.timestamp;
- struct tm *gmt = gmtime(&ltime);
- TCHAR stime[512];
- mir_sntprintf(stime, SIZEOF(stime), _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
- gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
- msg << XCHILDNS(_T("delay"), _T("urn:xmpp:delay")) << XATTR(_T("stamp"), stime);
-
- m_ThreadInfo->send(msg);
+ if (dbei.cbBlob == -1)
+ continue;
- nEventsSent++;
+ mir_ptr<BYTE> pEventBuf((PBYTE)mir_alloc(dbei.cbBlob + 1));
+ dbei.pBlob = pEventBuf;
+ if ( db_event_get(hDbEvent, &dbei))
+ continue;
- db_event_markRead(hContact, hDbEvent);
- if (bRemoveCListEvents)
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
+ if (dbei.eventType != EVENTTYPE_MESSAGE || (dbei.flags & (DBEF_READ | DBEF_SENT)))
+ continue;
- mir_free(szEventText);
- }
- }
- mir_free(dbei.pBlob);
+ ptrT szEventText( DbGetEventTextT(&dbei, CP_ACP));
+ if (szEventText == NULL)
+ continue;
+
+ XmlNode msg(_T("message"));
+ msg << XATTR(_T("to"), pInfo->GetFrom()) << XATTRID(SerialNext())
+ << XCHILD(_T("body"), szEventText);
+
+ HXML addressesNode = msg << XCHILDNS(_T("addresses"), JABBER_FEAT_EXT_ADDRESSING);
+ TCHAR szOFrom[JABBER_MAX_JID_LEN];
+
+ size_t cbBlob = strlen((LPSTR)dbei.pBlob)+1;
+ if (cbBlob < dbei.cbBlob) { // rest of message contains a sender's resource
+ ptrT szOResource( mir_utf8decodeT((LPSTR)dbei.pBlob + cbBlob+1));
+ mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s/%s"), tszJid, szOResource);
}
- hDbEvent = db_event_next(hDbEvent);
+ else mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s"), tszJid);
+
+ addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("ofrom")) << XATTR(_T("jid"), szOFrom);
+ addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("oto")) << XATTR(_T("jid"), m_ThreadInfo->fullJID);
+
+ time_t ltime = (time_t)dbei.timestamp;
+ struct tm *gmt = gmtime(&ltime);
+ TCHAR stime[512];
+ mir_sntprintf(stime, SIZEOF(stime), _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
+ gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
+ msg << XCHILDNS(_T("delay"), _T("urn:xmpp:delay")) << XATTR(_T("stamp"), stime);
+
+ m_ThreadInfo->send(msg);
+
+ nEventsSent++;
+
+ db_event_markRead(hContact, hDbEvent);
+ if (bRemoveCListEvents)
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
}
- db_free(&dbv);
}
mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%d message(s) forwarded"), nEventsSent);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index d12bf6fcff..4c2495fbfe 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1453,15 +1453,11 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData* info)
if (m_options.FixIncorrectTimestamps && (msgTime > now || (msgTime < (time_t)JabberGetLastContactMessageTime(hContact))))
msgTime = now;
- PROTORECVEVENT recv;
+ PROTORECVEVENT recv = { 0 };
recv.flags = PREF_UTF;
recv.timestamp = (DWORD)msgTime;
recv.szMessage = buf;
-
- EnterCriticalSection(&m_csLastResourceMap);
- recv.lParam = (LPARAM)AddToLastResourceMap(from);
- LeaveCriticalSection(&m_csLastResourceMap);
-
+ recv.lParam = (LPARAM)((pFromResource != NULL && m_options.EnableRemoteControl) ? pFromResource->m_tszResourceName : 0);
ProtoChainRecvMsg(hContact, &recv);
mir_free((void*)szMessage);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index bf8c94a298..d2a4bf22e4 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -1136,12 +1136,12 @@ struct JabberEnterStringParams
static int sttEnterStringResizer(HWND, LPARAM, UTILRESIZECONTROL *urc)
{
- switch (urc->wId)
- {
+ switch (urc->wId) {
case IDC_TXT_MULTILINE:
case IDC_TXT_COMBO:
case IDC_TXT_RICHEDIT:
return RD_ANCHORX_LEFT|RD_ANCHORY_TOP|RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT;
+
case IDOK:
case IDCANCEL:
return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM;
@@ -1155,42 +1155,35 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
switch (msg) {
case WM_INITDIALOG:
- {
- //SetWindowPos(hwndDlg, HWND_TOPMOST ,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
TranslateDialogDefault(hwndDlg);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIconBig(SKINICON_OTHER_RENAME));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_RENAME));
- JabberEnterStringParams *params = (JabberEnterStringParams *)lParam;
+ params = (JabberEnterStringParams *)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params);
SetWindowText(hwndDlg, params->caption);
-
- RECT rc; GetWindowRect(hwndDlg, &rc);
- switch (params->type)
{
+ RECT rc; GetWindowRect(hwndDlg, &rc);
+ switch (params->type) {
case JES_PASSWORD:
- {
params->idcControl = IDC_TXT_PASSWORD;
params->height = rc.bottom-rc.top;
break;
- }
+
case JES_MULTINE:
- {
params->idcControl = IDC_TXT_MULTILINE;
params->height = 0;
rc.bottom += (rc.bottom-rc.top) * 2;
SetWindowPos(hwndDlg, NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOMOVE|SWP_NOREPOSITION);
break;
- }
+
case JES_COMBO:
- {
params->idcControl = IDC_TXT_COMBO;
params->height = rc.bottom-rc.top;
if (params->windowName && params->recentCount)
params->ppro->ComboLoadRecentStrings(hwndDlg, IDC_TXT_COMBO, params->windowName, params->recentCount);
break;
- }
+
case JES_RICHEDIT:
- {
params->idcControl = IDC_TXT_RICHEDIT;
SendDlgItemMessage(hwndDlg, IDC_TXT_RICHEDIT, EM_AUTOURLDETECT, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_TXT_RICHEDIT, EM_SETEVENTMASK, 0, ENM_LINK);
@@ -1200,7 +1193,6 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
break;
}
}
-
ShowWindow(GetDlgItem(hwndDlg, params->idcControl), SW_SHOW);
SetDlgItemText(hwndDlg, params->idcControl, params->result);
@@ -1209,8 +1201,7 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
SetTimer(hwndDlg, 1000, 50, NULL);
- if (params->timeout > 0)
- {
+ if (params->timeout > 0) {
SetTimer(hwndDlg, 1001, 1000, NULL);
TCHAR buf[128];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("OK (%d)"), params->timeout);
@@ -1218,75 +1209,73 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
}
return TRUE;
- }
+
case WM_DESTROY:
WindowFreeIcon(hwndDlg);
break;
+
case WM_TIMER:
- {
- switch (wParam)
- {
- case 1000:
- KillTimer(hwndDlg,1000);
- EnableWindow(GetParent(hwndDlg), TRUE);
- return TRUE;
-
- case 1001:
- {
- TCHAR buf[128];
- mir_sntprintf(buf, SIZEOF(buf), TranslateT("OK (%d)"), --params->timeout);
- SetDlgItemText(hwndDlg, IDOK, buf);
-
- if (params->timeout < 0)
- {
- KillTimer(hwndDlg, 1001);
- UIEmulateBtnClick(hwndDlg, IDOK);
- }
+ switch (wParam) {
+ case 1000:
+ KillTimer(hwndDlg,1000);
+ EnableWindow(GetParent(hwndDlg), TRUE);
+ break;
+
+ case 1001:
+ TCHAR buf[128];
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("OK (%d)"), --params->timeout);
+ SetDlgItemText(hwndDlg, IDOK, buf);
- return TRUE;
+ if (params->timeout < 0) {
+ KillTimer(hwndDlg, 1001);
+ UIEmulateBtnClick(hwndDlg, IDOK);
}
}
- }
+ return TRUE;
+
case WM_SIZE:
- {
- UTILRESIZEDIALOG urd = {0};
- urd.cbSize = sizeof(urd);
- urd.hInstance = hInst;
- urd.hwndDlg = hwndDlg;
- urd.lpTemplate = MAKEINTRESOURCEA(IDD_GROUPCHAT_INPUT);
- urd.pfnResizer = sttEnterStringResizer;
- CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
+ {
+ UTILRESIZEDIALOG urd = {0};
+ urd.cbSize = sizeof(urd);
+ urd.hInstance = hInst;
+ urd.hwndDlg = hwndDlg;
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_GROUPCHAT_INPUT);
+ urd.pfnResizer = sttEnterStringResizer;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
+ }
break;
- }
+
case WM_GETMINMAXINFO:
- {
- LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
- if (params && params->height)
- lpmmi->ptMaxSize.y = lpmmi->ptMaxTrackSize.y = params->height;
+ {
+ LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam;
+ if (params && params->height)
+ lpmmi->ptMaxSize.y = lpmmi->ptMaxTrackSize.y = params->height;
+ }
break;
- }
+
case WM_NOTIFY:
- {
- ENLINK *param = (ENLINK *)lParam;
- if (param->nmhdr.idFrom != IDC_TXT_RICHEDIT) break;
- if (param->nmhdr.code != EN_LINK) break;
- if (param->msg != WM_LBUTTONUP) break;
-
- CHARRANGE sel;
- SendMessage(param->nmhdr.hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
- if (sel.cpMin != sel.cpMax) break; // allow link selection
-
- TEXTRANGE tr;
- tr.chrg = param->chrg;
- tr.lpstrText = (TCHAR *)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 2));
- SendMessage(param->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
-
- char *tmp = mir_t2a(tr.lpstrText);
- CallService(MS_UTILS_OPENURL, 1, (LPARAM)tmp);
- mir_free(tmp);
- mir_free(tr.lpstrText);
- return TRUE;
- }
+ {
+ ENLINK *param = (ENLINK *)lParam;
+ if (param->nmhdr.idFrom != IDC_TXT_RICHEDIT) break;
+ if (param->nmhdr.code != EN_LINK) break;
+ if (param->msg != WM_LBUTTONUP) break;
+
+ CHARRANGE sel;
+ SendMessage(param->nmhdr.hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
+ if (sel.cpMin != sel.cpMax) break; // allow link selection
+
+ TEXTRANGE tr;
+ tr.chrg = param->chrg;
+ tr.lpstrText = (TCHAR *)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 2));
+ SendMessage(param->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
+
+ char *tmp = mir_t2a(tr.lpstrText);
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)tmp);
+ mir_free(tmp);
+ mir_free(tr.lpstrText);
+ }
+ return TRUE;
+
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
@@ -1310,21 +1299,20 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
case IDC_TXT_MULTILINE:
case IDC_TXT_RICHEDIT:
- if ((HIWORD(wParam) != EN_SETFOCUS) && (HIWORD(wParam) != EN_KILLFOCUS))
- {
+ if ((HIWORD(wParam) != EN_SETFOCUS) && (HIWORD(wParam) != EN_KILLFOCUS)) {
SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
KillTimer(hwndDlg, 1001);
}
break;
case IDC_TXT_COMBO:
- if ((HIWORD(wParam) != CBN_SETFOCUS) && (HIWORD(wParam) != CBN_KILLFOCUS))
- {
+ if ((HIWORD(wParam) != CBN_SETFOCUS) && (HIWORD(wParam) != CBN_KILLFOCUS)) {
SetDlgItemText(hwndDlg, IDOK, TranslateT("OK"));
KillTimer(hwndDlg, 1001);
}
break;
- } }
+ }
+ }
return FALSE;
}
@@ -1332,11 +1320,10 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
BOOL CJabberProto::EnterString(TCHAR *result, size_t resultLen, TCHAR *caption, int type, char *windowName, int recentCount, int timeout)
{
bool free_caption = false;
- if ( !caption || (caption==result))
- {
+ if ( !caption || caption == result) {
free_caption = true;
caption = mir_tstrdup(result);
- result[ 0 ] = _T('\0');
+ result[0] = _T('\0');
}
JabberEnterStringParams params = { this, type, caption, result, resultLen, windowName, recentCount, timeout };
@@ -1348,7 +1335,9 @@ BOOL CJabberProto::EnterString(TCHAR *result, size_t resultLen, TCHAR *caption,
return bRetVal;
}
+/////////////////////////////////////////////////////////////////////////////////////////
// XEP-0203 delay support
+
bool JabberReadXep203delay(HXML node, time_t &msgTime)
{
HXML n = xmlGetChildByTag(node, "delay", "xmlns", _T("urn:xmpp:delay"));
@@ -1373,7 +1362,7 @@ bool JabberReadXep203delay(HXML node, time_t &msgTime)
return msgTime != 0;
}
-////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
// Premultiply bitmap channels for 32-bit bitmaps
void JabberBitmapPremultiplyChannels(HBITMAP hBitmap)
@@ -1415,96 +1404,6 @@ void JabberBitmapPremultiplyChannels(HBITMAP hBitmap)
free(p);
}
-// Last resource map
-void CJabberProto::CleanLastResourceMap()
-{
- EnterCriticalSection(&m_csLastResourceMap);
-
- m_dwResourceMapPointer = 0;
- ZeroMemory(m_ulpResourceToDbEventMap, sizeof(m_ulpResourceToDbEventMap));
-
- while (m_pLastResourceList) {
- void *pNext = ((void **)m_pLastResourceList)[ 0 ];
- mir_free(m_pLastResourceList);
- m_pLastResourceList = pNext;
- }
-
- LeaveCriticalSection(&m_csLastResourceMap);
-}
-
-// lock CS before use
-BOOL CJabberProto::IsLastResourceExists(void *pResource)
-{
- if ( !pResource)
- return FALSE;
-
- void *pOurResource = m_pLastResourceList;
- while (pOurResource) {
- if (pOurResource == pResource)
- return TRUE;
- pOurResource = ((void **)pOurResource)[ 0 ];
- }
- return FALSE;
-}
-
-// lock CS before use
-void* CJabberProto::AddToLastResourceMap(LPCTSTR szFullJid)
-{
- // detach resource from full jid
- const TCHAR *szResource = _tcschr(szFullJid, '/');
- if (szResource == NULL)
- return NULL;
- if (*++szResource == '\0')
- return NULL;
-
- DWORD dwResourceCount = 0;
-
- void *pNewTailResource = NULL;
- void *pOurResource = m_pLastResourceList;
- while (pOurResource) {
- dwResourceCount++;
-
- if ( !_tcscmp((TCHAR *)((BYTE *)pOurResource + sizeof(void *)), szResource))
- return pOurResource;
-
- void *pTmp = ((void **)pOurResource)[ 0 ];
- if (pTmp && !(((void **)pTmp)[ 0 ]))
- pNewTailResource = pOurResource;
- pOurResource = pTmp;
- }
-
- if (pNewTailResource && (dwResourceCount > (SIZEOF(m_ulpResourceToDbEventMap) / 2))) {
- void *pTmp = ((void **)pNewTailResource)[ 0 ];
- ((void **)pNewTailResource)[ 0 ] = NULL;
- mir_free(pTmp);
- }
-
- void *pNewResource = mir_alloc(sizeof(void *) + sizeof(TCHAR) * (_tcslen(szResource) + 1));
- if ( !pNewResource)
- return NULL;
-
- ((void **)pNewResource)[ 0 ] = m_pLastResourceList;
- _tcscpy((TCHAR *)((BYTE *)pNewResource + sizeof(void *)), szResource);
-
- m_pLastResourceList = pNewResource;
-
- return pNewResource;
-}
-
-// lock CS before use
-TCHAR* CJabberProto::FindLastResourceByDbEvent(HANDLE hDbEvent)
-{
- for (int i = 0; i < SIZEOF(m_ulpResourceToDbEventMap); i += 2) {
- if (m_ulpResourceToDbEventMap[ i ] == (ULONG_PTR)hDbEvent) {
- TCHAR *szRetVal = (TCHAR *)(m_ulpResourceToDbEventMap[ i + 1 ] + sizeof(void *));
- m_ulpResourceToDbEventMap[ i ] = 0;
- m_ulpResourceToDbEventMap[ i + 1 ] = 0;
- return szRetVal;
- }
- }
- return NULL;
-}
-
BOOL CJabberProto::IsMyOwnJID(LPCTSTR szJID)
{
if ( !m_ThreadInfo)