diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-03 22:25:13 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-03 22:25:13 +0000 |
commit | 67e460ae2bf43109b9095c518cd2ede4e043e202 (patch) | |
tree | d4b6afb98a75fa4142b2980b792e92ee8f8fc11a | |
parent | 784c2757e8c791b4c76a6e739f08b0fb92ec093a (diff) |
ptrT/A/W is used everywhere instead of DBVARIANT to read database strings
git-svn-id: http://svn.miranda-ng.org/main/trunk@6322 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
22 files changed, 816 insertions, 1134 deletions
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index f0e2fcf91a..e18ae8ab7a 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -141,11 +141,8 @@ void JabberByteSendConnection(HANDLE hConn, DWORD /*dwRemoteIP*/, void* extra) void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt)
{
- char* localAddr = NULL;
- DBVARIANT dbv;
TCHAR szPort[8];
HANDLE hEvent = NULL;
- TCHAR *proxyJid;
CJabberIqInfo *pInfo = NULL;
int nIqId = 0;
@@ -154,12 +151,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) BOOL bDirect = m_options.BsDirect;
if (m_options.BsProxyManual) {
- proxyJid = NULL;
- if ( !getString("BsProxyServer", &dbv)) {
- proxyJid = mir_a2t(dbv.pszVal);
- db_free(&dbv);
- }
-
+ ptrT proxyJid( getTStringA("BsProxyServer"));
if (proxyJid) {
jbt->bProxyDiscovered = FALSE;
jbt->szProxyHost = NULL;
@@ -198,10 +190,9 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) HXML query = iq << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR(_T("sid"), jbt->sid);
if (bDirect) {
- if (m_options.BsDirectManual) {
- if ( !getString("BsDirectAddr", &dbv))
- localAddr = dbv.pszVal;
- }
+ ptrA localAddr;
+ if (m_options.BsDirectManual)
+ localAddr = getStringA("BsDirectAddr");
NETLIBBIND nlb = {0};
nlb.cbSize = sizeof(NETLIBBIND);
@@ -232,7 +223,6 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) query << XCHILD(_T("streamhost")) << XATTR(_T("jid"), m_ThreadInfo->fullJID) << XATTR(_T("host"), _A2T(ihaddr->szIp[i])) << XATTRI(_T("port"), nlb.wPort);
mir_free(ihaddr);
- mir_free(localAddr);
}
if (jbt->bProxyDiscovered)
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index ec73143d6f..a476fb137e 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -137,32 +137,29 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) HANDLE hContact = HContactFromJID(item->jid);
if (hContact != NULL) {
- DBVARIANT dbv;
if (JABBER_LIST_ITEM *bookmark = ListGetItemPtr(LIST_BOOKMARK, item->jid))
if (bookmark->name) {
- if ( !db_get_ts(hContact, "CList", "MyHandle", &dbv))
- db_free(&dbv);
- else
+ ptrT myHandle( db_get_tsa(hContact, "CList", "MyHandle"));
+ if (myHandle == NULL)
db_set_ts(hContact, "CList", "MyHandle", bookmark->name);
}
- if ( !getTString(hContact, "MyNick", &dbv)) {
- if ( !lstrcmp(dbv.ptszVal, szNick))
+ ptrT tszNick( getTStringA(hContact, "MyNick"));
+ if (tszNick != NULL) {
+ if ( !lstrcmp(tszNick, szNick))
delSetting(hContact, "MyNick");
else
setTString(hContact, "MyNick", item->nick);
- db_free(&dbv);
}
else setTString(hContact, "MyNick", item->nick);
- TCHAR *passw = JGetStringCrypt(hContact, "LoginPassword");
+ ptrT passw( JGetStringCrypt(hContact, "LoginPassword"));
if (lstrcmp_null(passw, item->password)) {
if ( !item->password || !item->password[0])
delSetting(hContact, "LoginPassword");
else
JSetStringCrypt(hContact, "LoginPassword", item->password);
}
- mir_free(passw);
}
mir_free(szNick);
@@ -366,17 +363,15 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason) CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
CallServiceSync(MS_GC_EVENT, WINDOW_CLEARLOG, (LPARAM)&gce);
- DBVARIANT dbvMessage;
- if ( !getTString("GcMsgQuit", &dbvMessage)) {
- szMessage = NEWTSTR_ALLOCA(dbvMessage.ptszVal);
- db_free(&dbvMessage);
- }
- else szMessage = TranslateTS(JABBER_GC_MSG_QUIT);
+ ptrT tszMessage( getTStringA("GcMsgQuit"));
+ if (tszMessage != NULL)
+ szMessage = NEWTSTR_ALLOCA(tszMessage);
+ else
+ szMessage = TranslateTS(JABBER_GC_MSG_QUIT);
}
else {
- TCHAR *myNick = JabberNickFromJID(m_szJabberJID);
+ ptrT myNick( JabberNickFromJID(m_szJabberJID));
GcLogUpdateMemberStatus(item, myNick, myNick, NULL, GC_EVENT_KICK, reason);
- mir_free(myNick);
CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
}
@@ -812,11 +807,9 @@ public: if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0)) {
if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
- DBVARIANT dbv={0};
- m_proto->getTString(hContact, "jid", &dbv);
- if (dbv.ptszVal && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
- InviteUser(dbv.ptszVal, text);
- db_free(&dbv);
+ ptrT jid( m_proto->getTStringA(hContact, "jid"));
+ if (jid != NULL)
+ InviteUser(jid, text);
}
}
}
@@ -1051,9 +1044,9 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* switch(gch->dwData) {
case IDM_SLAP:
if (ppro->m_bJabberOnline) {
- DBVARIANT dbv = {0};
- TCHAR *szMessage = ppro->getTString("GcMsgSlap", &dbv) ?
- NEWTSTR_ALLOCA(TranslateTS(JABBER_GC_MSG_SLAP)) : dbv.ptszVal;
+ ptrT szMessage( ppro->getTStringA("GcMsgSlap"));
+ if (szMessage == NULL)
+ szMessage = mir_tstrdup( TranslateTS(JABBER_GC_MSG_SLAP));
TCHAR buf[256];
// do not use snprintf to avoid possible problems with % symbol
@@ -1067,9 +1060,6 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* ppro->m_ThreadInfo->send(
XmlNode(_T("message")) << XATTR(_T("to"), item->jid) << XATTR(_T("type"), _T("groupchat"))
<< XCHILD(_T("body"), buf));
-
- if (szMessage == dbv.ptszVal)
- db_free(&dbv);
}
break;
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 5a24587eac..e73742b119 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -378,12 +378,10 @@ void CJabberDlgConsole::OnInitDialog() m_proto->m_filterInfo.iq = m_proto->getByte("consoleWnd_iq", TRUE);
m_proto->m_filterInfo.type = (TFilterInfo::Type)m_proto->getByte("consoleWnd_ftype", TFilterInfo::T_OFF);
- DBVARIANT dbv;
*m_proto->m_filterInfo.pattern = 0;
- if ( !m_proto->getTString("consoleWnd_fpattern", &dbv)) {
- lstrcpyn(m_proto->m_filterInfo.pattern, dbv.ptszVal, SIZEOF(m_proto->m_filterInfo.pattern));
- db_free(&dbv);
- }
+ ptrT tszPattern( m_proto->getTStringA("consoleWnd_fpattern"));
+ if (tszPattern != NULL)
+ lstrcpyn(m_proto->m_filterInfo.pattern, tszPattern, SIZEOF(m_proto->m_filterInfo.pattern));
sttJabberConsoleRebuildStrings(m_proto, GetDlgItem(m_hwnd, IDC_CB_FILTER));
SetWindowText(GetDlgItem(m_hwnd, IDC_CB_FILTER), m_proto->m_filterInfo.pattern);
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 53fcf7ec48..0d37905b25 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -441,23 +441,21 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) else if ( !lstrcmp(szJid, _T(SD_FAKEJID_FAVORITES))) {
sttBrowseMode = SD_BROWSE_FAVORITES;
int count = getDword("discoWnd_favCount", 0);
- for (int i=0; i < count; i++)
- {
- DBVARIANT dbv;
+ for (int i=0; i < count; i++) {
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favName_%d", i);
- if ( !getTString(setting, &dbv)) {
- DBVARIANT dbvJid, dbvNode;
- mir_snprintf(setting, sizeof(setting), "discoWnd_favJID_%d", i);
- getTString(setting, &dbvJid);
- mir_snprintf(setting, sizeof(setting), "discoWnd_favNode_%d", i);
- getTString(setting, &dbvNode);
- CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(dbvJid.ptszVal, dbvNode.ptszVal, dbv.ptszVal);
- SendBothRequests(pNode, NULL);
- db_free(&dbv);
- db_free(&dbvJid);
- db_free(&dbvNode);
- } } }
+ ptrT tszName( getTStringA(setting));
+ if (tszName == NULL)
+ continue;
+
+ mir_snprintf(setting, sizeof(setting), "discoWnd_favJID_%d", i);
+ ptrT dbvJid( getTStringA(setting));
+ mir_snprintf(setting, sizeof(setting), "discoWnd_favNode_%d", i);
+ ptrT dbvNode( getTStringA(setting));
+ CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(dbvJid, dbvNode, tszName);
+ SendBothRequests(pNode, NULL);
+ }
+ }
else {
sttBrowseMode = SD_BROWSE_NORMAL;
CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(szJid, _tcslen(szNode) ? szNode : NULL, NULL);
@@ -804,16 +802,14 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) for (int i=0; i < count; i++) {
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favName_%d", i);
-
- DBVARIANT dbv;
- if ( !m_proto->getTString(setting, &dbv)) {
+ ptrT tszName( m_proto->getTStringA(setting));
+ if (tszName != NULL) {
HMENU hSubMenu = CreatePopupMenu();
AppendMenu(hSubMenu, MF_STRING, 100+i*10+0, TranslateT("Navigate"));
AppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(hSubMenu, MF_STRING, 100+i*10+1, TranslateT("Remove"));
- AppendMenu(hMenu, MF_POPUP|MF_STRING, (UINT_PTR)hSubMenu, dbv.ptszVal);
+ AppendMenu(hMenu, MF_POPUP|MF_STRING, (UINT_PTR)hSubMenu, tszName);
}
- db_free(&dbv);
}
int res = 0;
if (GetMenuItemCount(hMenu)) {
@@ -852,23 +848,21 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(""));
SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
- DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favJID_%d", res);
- if ( !m_proto->getTString(setting, &dbv)) SetDlgItemText(m_hwnd, IDC_COMBO_JID, dbv.ptszVal);
- db_free(&dbv);
+ ptrT dbv( m_proto->getTStringA(setting));
+ if (dbv) SetDlgItemText(m_hwnd, IDC_COMBO_JID, dbv);
+
mir_snprintf(setting, sizeof(setting), "discoWnd_favNode_%d", res);
- if ( !m_proto->getTString(setting, &dbv)) SetDlgItemText(m_hwnd, IDC_COMBO_NODE, dbv.ptszVal);
- db_free(&dbv);
+ dbv = m_proto->getTStringA(setting);
+ if (dbv) SetDlgItemText(m_hwnd, IDC_COMBO_NODE, dbv);
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON_BROWSE, 0), 0);
}
- } else
- if (res == 1)
- {
+ }
+ else if (res == 1) {
int count = m_proto->getDword("discoWnd_favCount", 0);
- for (int i=0; i < count; i++)
- {
+ for (int i=0; i < count; i++) {
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "discoWnd_favName_%d", i);
m_proto->delSetting(setting);
@@ -878,9 +872,8 @@ void CJabberDlgDiscovery::btnBookmarks_OnClick(CCtrlButton *) m_proto->delSetting(setting);
}
m_proto->delSetting("discoWnd_favCount");
- } else
- if ((res >= 10) && (res <= 20))
- {
+ }
+ else if ((res >= 10) && (res <= 20)) {
switch (res-10) {
case SD_BROWSE_FAVORITES:
SetDlgItemText(m_hwnd, IDC_COMBO_JID, _T(SD_FAKEJID_FAVORITES));
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp index f71ee0dcc6..916fb3e9b7 100644 --- a/protocols/JabberG/src/jabber_events.cpp +++ b/protocols/JabberG/src/jabber_events.cpp @@ -36,23 +36,22 @@ int CJabberProto::OnContactDeleted(WPARAM wParam, LPARAM) return 0;
HANDLE hContact = (HANDLE)wParam;
- DBVARIANT dbv;
- if ( !getTString(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid", &dbv)) {
- if (ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) {
- if ( !_tcschr(dbv.ptszVal, _T('@'))) {
- TCHAR szStrippedJid[JABBER_MAX_JID_LEN];
- JabberStripJid(m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid));
- TCHAR *szDog = _tcschr(szStrippedJid, _T('@'));
- if (szDog && _tcsicmp(szDog + 1, dbv.ptszVal))
- m_ThreadInfo->send( XmlNodeIq(_T("set"), SerialNext(), dbv.ptszVal) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD(_T("remove")));
- }
-
- // Remove from roster, server also handles the presence unsubscription process.
- m_ThreadInfo->send( XmlNodeIq(_T("set"), SerialNext()) << XQUERY(JABBER_FEAT_IQ_ROSTER)
- << XCHILD(_T("item")) << XATTR(_T("jid"), dbv.ptszVal) << XATTR(_T("subscription"), _T("remove")));
+ ptrT jid( getTStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid"));
+ if (jid == NULL)
+ return 0;
+
+ if (ListGetItemPtr(LIST_ROSTER, jid)) {
+ if ( !_tcschr(jid, _T('@'))) {
+ TCHAR szStrippedJid[JABBER_MAX_JID_LEN];
+ JabberStripJid(m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid));
+ TCHAR *szDog = _tcschr(szStrippedJid, _T('@'));
+ if (szDog && _tcsicmp(szDog + 1, jid))
+ m_ThreadInfo->send( XmlNodeIq(_T("set"), SerialNext(), jid) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD(_T("remove")));
}
- db_free(&dbv);
+ // Remove from roster, server also handles the presence unsubscription process.
+ m_ThreadInfo->send( XmlNodeIq(_T("set"), SerialNext()) << XQUERY(JABBER_FEAT_IQ_ROSTER)
+ << XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("subscription"), _T("remove")));
}
return 0;
}
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 9d4c57674a..77ad82e833 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -32,44 +32,35 @@ int JabberGcGetStatus(JABBER_RESOURCE_STATUS *r); struct JabberGcRecentInfo
{
- TCHAR *room, *server, *nick, *password;
+ ptrT room, server, nick, password;
CJabberProto *ppro;
JabberGcRecentInfo(CJabberProto* proto)
{
ppro = proto;
- room = server = nick = password = NULL;
}
JabberGcRecentInfo(CJabberProto* proto, const TCHAR *_room, const TCHAR *_server, const TCHAR *_nick = NULL, const TCHAR *_password = NULL)
{
ppro = proto;
- room = server = nick = password = NULL;
fillData(_room, _server, _nick, _password);
}
JabberGcRecentInfo(CJabberProto* proto, const TCHAR *jid)
{
ppro = proto;
- room = server = nick = password = NULL;
fillData(jid);
}
JabberGcRecentInfo(CJabberProto* proto, int iRecent)
{
ppro = proto;
- room = server = nick = password = NULL;
loadRecent(iRecent);
}
~JabberGcRecentInfo()
{
- cleanup();
}
void cleanup()
{
- mir_free(room);
- mir_free(server);
- mir_free(nick);
- mir_free(password);
room = server = nick = password = NULL;
}
@@ -100,11 +91,10 @@ struct JabberGcRecentInfo void fillData(const TCHAR *room, const TCHAR *server, const TCHAR *nick = NULL, const TCHAR *password = NULL)
{
- cleanup();
- this->room = room ? mir_tstrdup(room) : NULL;
- this->server = server ? mir_tstrdup(server) : NULL;
- this->nick = nick ? mir_tstrdup(nick) : NULL;
- this->password = password ? mir_tstrdup(password) : NULL;
+ this->room = mir_tstrdup(room);
+ this->server = mir_tstrdup(server);
+ this->nick = mir_tstrdup(nick);
+ this->password = mir_tstrdup(password);
}
void fillData(const TCHAR *jid)
@@ -112,13 +102,12 @@ struct JabberGcRecentInfo TCHAR *room, *server, *nick=NULL;
room = NEWTSTR_ALLOCA(jid);
server = _tcschr(room, _T('@'));
- if (server)
- {
+ if (server) {
*server++ = 0;
nick = _tcschr(server, _T('/'));
if (nick) *nick++ = 0;
- } else
- {
+ }
+ else {
server = room;
room = NULL;
}
@@ -128,28 +117,15 @@ struct JabberGcRecentInfo BOOL loadRecent(int iRecent)
{
- DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
-
- cleanup();
-
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_server", iRecent);
- if ( !ppro->getTString(setting, &dbv)) {
- server = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ server = ppro->getTStringA(setting);
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_room", iRecent);
- if ( !ppro->getTString(setting, &dbv)) {
- room = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ room = ppro->getTStringA(setting);
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_nick", iRecent);
- if ( !ppro->getTString(setting, &dbv)) {
- nick = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ nick = ppro->getTStringA(setting);
mir_snprintf(setting, sizeof(setting), "rcMuc_%d_passwordW", iRecent);
password = ppro->JGetStringCrypt(NULL, setting);
@@ -211,49 +187,42 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleJoinGroupchat(WPARAM, LPARAM) INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM wParam, LPARAM)
{
- DBVARIANT nick, jid;
HANDLE hContact = (HANDLE)wParam;
- if (getTString(hContact, "ChatRoomID", &jid))
+ ptrT jid( getTStringA(hContact, "ChatRoomID"));
+ if (jid == NULL)
return 0;
- if (getTString(hContact, "MyNick", &nick))
- if (getTString("Nick", &nick)) {
- db_free(&jid);
+ ptrT nick( getTStringA(hContact, "MyNick"));
+ if (nick == NULL)
+ if ((nick = getTStringA("Nick")) == NULL)
return 0;
- }
- TCHAR *password = JGetStringCrypt(hContact, "LoginPassword");
+ ptrT password( JGetStringCrypt(hContact, "LoginPassword"));
if (getWord(hContact, "Status", 0) != ID_STATUS_ONLINE) {
if ( !jabberChatDllPresent)
JabberChatDllError();
else {
- TCHAR *p = _tcschr(jid.ptszVal, '@');
+ TCHAR *p = _tcschr(jid, '@');
if (p != NULL) {
*p++ = 0;
- GroupchatJoinRoom(p, jid.ptszVal, nick.ptszVal, password);
+ GroupchatJoinRoom(p, jid, nick, password);
} } }
- mir_free(password);
- db_free(&nick);
- db_free(&jid);
return 0;
}
INT_PTR __cdecl CJabberProto::OnLeaveChat(WPARAM wParam, LPARAM)
{
- DBVARIANT jid;
HANDLE hContact = (HANDLE)wParam;
- if (getTString(hContact, "ChatRoomID", &jid))
- return 0;
-
- if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) {
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid.ptszVal);
- if (item != NULL)
- GcQuit(item, 0, NULL);
+ ptrT jid( getTStringA(hContact, "ChatRoomID"));
+ if (jid != NULL) {
+ if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE) {
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, jid);
+ if (item != NULL)
+ GcQuit(item, 0, NULL);
+ }
}
-
- db_free(&jid);
return 0;
}
@@ -457,13 +426,11 @@ void CJabberDlgGcJoin::OnInitDialog() JabberGcRecentInfo *info = NULL;
if (m_jid)
info = new JabberGcRecentInfo(m_proto, m_jid);
- else
- {
+ else {
OpenClipboard(m_hwnd);
HANDLE hData = GetClipboardData(CF_UNICODETEXT);
- if (hData)
- {
+ if (hData) {
TCHAR *buf = (TCHAR *)GlobalLock(hData);
if (buf && _tcschr(buf, _T('@')) && !_tcschr(buf, _T(' ')))
info = new JabberGcRecentInfo(m_proto, buf);
@@ -472,39 +439,28 @@ void CJabberDlgGcJoin::OnInitDialog() CloseClipboard();
}
- if (info)
- {
+ if (info) {
info->fillForm(m_hwnd);
delete info;
}
- DBVARIANT dbv;
- if ( !m_proto->getTString("Nick", &dbv)) {
- SetDlgItemText(m_hwnd, IDC_NICK, dbv.ptszVal);
- db_free(&dbv);
- }
- else {
- TCHAR *nick = JabberNickFromJID(m_proto->m_szJabberJID);
- SetDlgItemText(m_hwnd, IDC_NICK, nick);
- mir_free(nick);
- }
-
- {
- TEXTMETRIC tm = {0};
- HDC hdc = GetDC(m_hwnd);
- GetTextMetrics(hdc, &tm);
- ReleaseDC(m_hwnd, hdc);
- sttTextLineHeight = tm.tmHeight;
- SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight-1);
- }
-
- {
- LOGFONT lf = {0};
- HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
- GetObject(hfnt, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
- }
+ ptrT tszNick( m_proto->getTStringA("Nick"));
+ if (tszNick == NULL)
+ tszNick = JabberNickFromJID(m_proto->m_szJabberJID);
+ SetDlgItemText(m_hwnd, IDC_NICK, tszNick);
+
+ TEXTMETRIC tm = {0};
+ HDC hdc = GetDC(m_hwnd);
+ GetTextMetrics(hdc, &tm);
+ ReleaseDC(m_hwnd, hdc);
+ sttTextLineHeight = tm.tmHeight;
+ SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight-1);
+
+ LOGFONT lf = {0};
+ HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0);
+ GetObject(hfnt, sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks"));
SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0);
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 36994181cf..bc76f927c5 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -344,7 +344,7 @@ int CJabberProto::LoadAdvancedIcons(int iID) int CJabberProto::GetTransportProtoID(TCHAR* TransportDomain)
{
for (int i=0; i<SIZEOF(TransportProtoTable); i++)
- if (MatchMask(TransportDomain, TransportProtoTable[i].mask))
+ if ( MatchMask(TransportDomain, TransportProtoTable[i].mask))
return i;
return -1;
@@ -399,21 +399,16 @@ INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM wParam, LPARAM) if ( !getByte(hContact, "IsTransported", 0))
return -1;
- DBVARIANT dbv;
- if (getTString(hContact, "Transport", &dbv))
+ int iID = GetTransportProtoID( ptrT( getTStringA(hContact, "Transport")));
+ if (iID < 0)
return -1;
- int iID = GetTransportProtoID(dbv.ptszVal);
- db_free(&dbv);
- if (iID >= 0) {
- WORD Status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
- if (Status < ID_STATUS_OFFLINE)
- Status = ID_STATUS_OFFLINE;
- else if (Status > ID_STATUS_INVISIBLE)
- Status = ID_STATUS_ONLINE;
- return GetTransportStatusIconIndex(iID, Status);
- }
- return -1;
+ WORD Status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+ if (Status < ID_STATUS_OFFLINE)
+ Status = ID_STATUS_OFFLINE;
+ else if (Status > ID_STATUS_INVISIBLE)
+ Status = ID_STATUS_ONLINE;
+ return GetTransportStatusIconIndex(iID, Status);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index de7ab1f006..f769f5ed2e 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -556,14 +556,12 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo) else setTString(hContact, "jid", jid);
if (name != NULL) {
- DBVARIANT dbnick;
- if ( !getTString(hContact, "Nick", &dbnick)) {
- if (_tcscmp(nick, dbnick.ptszVal) != 0)
+ ptrT tszNick( getTStringA(hContact, "Nick"));
+ if (tszNick != NULL) {
+ if (_tcscmp(nick, tszNick) != 0)
db_set_ts(hContact, "CList", "MyHandle", nick);
else
db_unset(hContact, "CList", "MyHandle");
-
- db_free(&dbnick);
}
else db_set_ts(hContact, "CList", "MyHandle", nick);
}
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 070f0dca4b..2145250b25 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -263,11 +263,9 @@ void CJabberProto::OnIqResultSetAuth(HXML iqNode, CJabberIqInfo *pInfo) if ((type=xmlGetAttrValue(iqNode, _T("type"))) == NULL) return;
if ( !lstrcmp(type, _T("result"))) {
- DBVARIANT dbv;
- if (getTString("Nick", &dbv))
+ ptrT tszNick( getTStringA("Nick"));
+ if (tszNick == NULL)
setTString("Nick", m_ThreadInfo->username);
- else
- db_free(&dbv);
OnLoggedIn();
}
@@ -436,14 +434,12 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) }
if (name != NULL) {
- DBVARIANT dbNick;
- if ( !getTString(hContact, "Nick", &dbNick)) {
- if (lstrcmp(nick, dbNick.ptszVal) != 0)
+ ptrT tszNick( getTStringA("Nick"));
+ if (tszNick != NULL) {
+ if (lstrcmp(nick, tszNick) != 0)
db_set_ts(hContact, "CList", "MyHandle", nick);
else
db_unset(hContact, "CList", "MyHandle");
-
- db_free(&dbNick);
}
else db_set_ts(hContact, "CList", "MyHandle", nick);
}
@@ -474,11 +470,10 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) Clist_CreateGroup(0, item->group);
// Don't set group again if already correct, or Miranda may show wrong group count in some case
- DBVARIANT dbv;
- if ( !db_get_ts(hContact, "CList", "Group", &dbv)) {
- if (lstrcmp(dbv.ptszVal, item->group))
+ ptrT tszGroup( db_get_tsa(hContact, "CList", "Group"));
+ if (tszGroup != NULL) {
+ if ( lstrcmp(tszGroup, item->group))
db_set_ts(hContact, "CList", "Group", item->group);
- db_free(&dbv);
}
else db_set_ts(hContact, "CList", "Group", item->group);
}
@@ -636,8 +631,8 @@ void CJabberProto::OnIqResultGetVcardPhoto(const TCHAR *jid, HXML n, HANDLE hCon Log("My picture saved to %S", szAvatarFileName);
}
else {
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid != NULL) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
if (item == NULL) {
item = ListAdd(LIST_VCARD_TEMP, jid); // adding to the temp list to store information about photo
@@ -651,9 +646,8 @@ void CJabberProto::OnIqResultGetVcardPhoto(const TCHAR *jid, HXML n, HANDLE hCon Log("Contact's picture saved to %S", szAvatarFileName);
OnIqResultGotAvatar(hContact, o, szPicType);
}
-
- db_free(&dbv);
- } }
+ }
+ }
if ( !hasPhoto)
DeleteFile(szAvatarFileName);
@@ -1314,9 +1308,7 @@ void CJabberProto::OnIqResultGetVCardAvatar(HXML iqNode, CJabberIqInfo *pInfo) if (xmlGetChildCount(vCard) == 0) {
delSetting(hContact, "AvatarHash");
- DBVARIANT dbv = {0};
- if ( !getTString(hContact, "AvatarSaved", &dbv)) {
- db_free(&dbv);
+ if ( ptrT( getTStringA(hContact, "AvatarSaved")) != NULL) {
delSetting(hContact, "AvatarSaved");
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL);
}
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 909feaae84..ed2ade7d7e 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -344,17 +344,15 @@ void g_MenuUninit(void) int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
{
- DBVARIANT dbv;
- HANDLE hContact;
- if ((hContact=(HANDLE)wParam) == NULL)
+ HANDLE hContact = (HANDLE)wParam;
+ if (hContact == NULL)
return 0;
bool bIsChatRoom = isChatRoom(hContact);
bool bIsTransport = getBool(hContact, "IsTransport", false);
if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0) {
- if ( !getTString(hContact, bIsChatRoom?(char*)"ChatRoomID":(char*)"jid", &dbv)) {
- db_free(&dbv);
+ if ( ptrT( getTStringA(hContact, bIsChatRoom?(char*)"ChatRoomID":(char*)"jid")) != NULL) {
Menu_ShowItem(g_hMenuConvert, TRUE);
CLISTMENUITEM clmi = { sizeof(clmi) };
@@ -376,14 +374,13 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) }
if (bIsChatRoom) {
- if ( !getTString(hContact, "ChatRoomID", &dbv)) {
+ ptrT roomid( getTStringA(hContact, "ChatRoomID"));
+ if (roomid != NULL) {
Menu_ShowItem(g_hMenuRosterAdd, FALSE);
- if (ListGetItemPtr(LIST_BOOKMARK, dbv.ptszVal) == NULL)
+ if (ListGetItemPtr(LIST_BOOKMARK, roomid) == NULL)
if (m_ThreadInfo && m_ThreadInfo->jabberServerCaps & JABBER_CAPS_PRIVATE_STORAGE)
Menu_ShowItem(g_hMenuAddBookmark, TRUE);
-
- db_free(&dbv);
}
}
@@ -395,84 +392,85 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) Menu_ShowItem(g_hMenuRefresh, TRUE);
}
- if ( !getTString(hContact, "jid", &dbv)) {
- JabberCapsBits jcb = GetTotalJidCapabilites(dbv.ptszVal);
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- db_free(&dbv);
- if (item != NULL) {
- BOOL bCtrlPressed = (GetKeyState(VK_CONTROL)&0x8000) != 0;
- Menu_ShowItem(g_hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed);
- Menu_ShowItem(g_hMenuGrantAuth, bCtrlPressed);
- Menu_ShowItem(g_hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed);
- Menu_ShowItem(g_hMenuCommands, ((jcb & JABBER_CAPS_COMMANDS) != 0) || bCtrlPressed);
- Menu_ShowItem(g_hMenuSendNote, TRUE);
-
- if (item->arResources.getCount() >= 1) {
- Menu_ShowItem(g_hMenuResourcesRoot, TRUE);
-
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_ICON | CMIM_FLAGS;
- mi.icolibItem = m_hProtoIcon;
- Menu_ModifyItem(g_hMenuResourcesRoot, &mi);
-
- mi.flags = CMIM_ICON | CMIM_FLAGS | ((item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0);
- Menu_ModifyItem(g_hMenuResourcesActive, &mi);
-
- mi.flags = CMIM_FLAGS | ((item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0);
- Menu_ModifyItem(g_hMenuResourcesServer, &mi);
-
- int nMenuResourceItemsNew = m_nMenuResourceItems;
- if (m_nMenuResourceItems < item->arResources.getCount()) {
- m_phMenuResourceItems = (HGENMENU*)mir_realloc(m_phMenuResourceItems, item->arResources.getCount() * sizeof(HGENMENU));
- nMenuResourceItemsNew = item->arResources.getCount();
- }
-
- char text[ 256 ];
- strcpy(text, m_szModuleName);
- size_t nModuleNameLength = strlen(text);
- char* tDest = text + nModuleNameLength;
-
- mi.flags = CMIF_CHILDPOPUP;
- mi.position = 0;
- mi.icolibItem = NULL;
- mi.pszService = text;
- mi.pszContactOwner = m_szModuleName;
-
- TCHAR szTmp[512];
- for (int i=0; i < nMenuResourceItemsNew; i++) {
- mir_snprintf(tDest, SIZEOF(text) - nModuleNameLength, "/UseResource_%d", i);
- if (i >= m_nMenuResourceItems) {
- CreateProtoServiceParam(tDest, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES+i);
- mi.pszName = "";
- mi.position = i;
- mi.hParentMenu = g_hMenuResourcesRoot;
- m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi);
- }
- if (i < item->arResources.getCount()) {
- pResourceStatus r(item->arResources[i]);
- CLISTMENUITEM clmi = { sizeof(clmi) };
- clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR;
- if ((item->resourceMode == RSMODE_MANUAL) && (item->m_pManualResource == r))
- clmi.flags |= CMIF_CHECKED;
- if (ServiceExists(MS_FP_GETCLIENTICONT)) {
- clmi.flags |= CMIM_ICON;
- FormatMirVer(r, szTmp, SIZEOF(szTmp));
- clmi.hIcon = Finger_GetClientIcon(szTmp, 0);
- }
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"), r->m_tszResourceName, pcli->pfnGetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority);
- clmi.ptszName = szTmp;
- Menu_ModifyItem(m_phMenuResourceItems[i], &clmi);
- DestroyIcon(clmi.hIcon);
- }
- else Menu_ShowItem(m_phMenuResourceItems[i], FALSE);
- }
-
- m_nMenuResourceItems = nMenuResourceItemsNew;
- }
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ return 0;
- return 0;
- } }
+ JabberCapsBits jcb = GetTotalJidCapabilites(jid);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
+ if (item == NULL)
+ return 0;
+
+ BOOL bCtrlPressed = (GetKeyState(VK_CONTROL)&0x8000) != 0;
+ Menu_ShowItem(g_hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed);
+ Menu_ShowItem(g_hMenuGrantAuth, bCtrlPressed);
+ Menu_ShowItem(g_hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed);
+ Menu_ShowItem(g_hMenuCommands, ((jcb & JABBER_CAPS_COMMANDS) != 0) || bCtrlPressed);
+ Menu_ShowItem(g_hMenuSendNote, TRUE);
+
+ if (item->arResources.getCount() == 0)
+ return 0;
+ Menu_ShowItem(g_hMenuResourcesRoot, TRUE);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_ICON | CMIM_FLAGS;
+ mi.icolibItem = m_hProtoIcon;
+ Menu_ModifyItem(g_hMenuResourcesRoot, &mi);
+
+ mi.flags = CMIM_ICON | CMIM_FLAGS | ((item->resourceMode == RSMODE_LASTSEEN) ? CMIF_CHECKED : 0);
+ Menu_ModifyItem(g_hMenuResourcesActive, &mi);
+
+ mi.flags = CMIM_FLAGS | ((item->resourceMode == RSMODE_SERVER) ? CMIF_CHECKED : 0);
+ Menu_ModifyItem(g_hMenuResourcesServer, &mi);
+
+ int nMenuResourceItemsNew = m_nMenuResourceItems;
+ if (m_nMenuResourceItems < item->arResources.getCount()) {
+ m_phMenuResourceItems = (HGENMENU*)mir_realloc(m_phMenuResourceItems, item->arResources.getCount() * sizeof(HGENMENU));
+ nMenuResourceItemsNew = item->arResources.getCount();
+ }
+
+ char text[ 256 ];
+ strcpy(text, m_szModuleName);
+ size_t nModuleNameLength = strlen(text);
+ char* tDest = text + nModuleNameLength;
+
+ mi.flags = CMIF_CHILDPOPUP;
+ mi.position = 0;
+ mi.icolibItem = NULL;
+ mi.pszService = text;
+ mi.pszContactOwner = m_szModuleName;
+
+ TCHAR szTmp[512];
+ for (int i=0; i < nMenuResourceItemsNew; i++) {
+ mir_snprintf(tDest, SIZEOF(text) - nModuleNameLength, "/UseResource_%d", i);
+ if (i >= m_nMenuResourceItems) {
+ CreateProtoServiceParam(tDest, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES+i);
+ mi.pszName = "";
+ mi.position = i;
+ mi.hParentMenu = g_hMenuResourcesRoot;
+ m_phMenuResourceItems[i] = Menu_AddContactMenuItem(&mi);
+ }
+ if (i < item->arResources.getCount()) {
+ pResourceStatus r(item->arResources[i]);
+ CLISTMENUITEM clmi = { sizeof(clmi) };
+ clmi.flags = CMIM_NAME|CMIM_FLAGS | CMIF_CHILDPOPUP|CMIF_TCHAR;
+ if ((item->resourceMode == RSMODE_MANUAL) && (item->m_pManualResource == r))
+ clmi.flags |= CMIF_CHECKED;
+ if (ServiceExists(MS_FP_GETCLIENTICONT)) {
+ clmi.flags |= CMIM_ICON;
+ FormatMirVer(r, szTmp, SIZEOF(szTmp));
+ clmi.hIcon = Finger_GetClientIcon(szTmp, 0);
+ }
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s [%s, %d]"), r->m_tszResourceName, pcli->pfnGetStatusModeDescription(r->m_iStatus, 0), r->m_iPriority);
+ clmi.ptszName = szTmp;
+ Menu_ModifyItem(m_phMenuResourceItems[i], &clmi);
+ DestroyIcon(clmi.hIcon);
+ }
+ else Menu_ShowItem(m_phMenuResourceItems[i], FALSE);
+ }
+
+ m_nMenuResourceItems = nMenuResourceItemsNew;
return 0;
}
@@ -482,11 +480,10 @@ INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM wParam, LPARAM) BYTE bIsChatRoom = isChatRoom(hContact);
const char *szSetting = (bIsChatRoom) ? "ChatRoomID" : "jid";
- DBVARIANT dbv;
- if ( !getTString(hContact, szSetting, &dbv)) {
+ ptrT jid( getTStringA(hContact, szSetting));
+ if (jid != NULL) {
delSetting(hContact, szSetting);
- setTString(hContact, szSetting, dbv.ptszVal);
- db_free(&dbv);
+ setTString(hContact, szSetting, jid);
setByte(hContact, "ChatRoom", !bIsChatRoom);
}
return 0;
@@ -494,24 +491,15 @@ INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM wParam, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM wParam, LPARAM)
{
- DBVARIANT dbv;
if ( !wParam) return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
- if ( getTString((HANDLE)wParam, "ChatRoomID", &dbv)) return 0;
- TCHAR *roomID = NEWTSTR_ALLOCA(dbv.ptszVal);
- db_free(&dbv);
+ ptrT roomID( getTStringA((HANDLE)wParam, "ChatRoomID"));
+ if (roomID == NULL) return 0;
if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) {
- TCHAR *nick = 0;
- TCHAR *group = 0;
- if ( !db_get_ts((HANDLE)wParam, "CList", "Group", &dbv)) {
- group = NEWTSTR_ALLOCA(dbv.ptszVal);
- db_free(&dbv);
- }
- if ( !getTString((HANDLE)wParam, "Nick", &dbv)) {
- nick = NEWTSTR_ALLOCA(dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT group( db_get_tsa((HANDLE)wParam, "CList", "Group"));
+ ptrT nick( getTStringA((HANDLE)wParam, "Nick"));
+
AddContactToRoster(roomID, nick, group);
if (m_options.AddRoster2Bookmarks == TRUE) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID);
@@ -519,14 +507,9 @@ INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM wParam, LPARAM) item = new JABBER_LIST_ITEM();
item->jid = mir_tstrdup(roomID);
item->name = mir_tstrdup(nick);
- if ( !getTString((HANDLE)wParam, "MyNick", &dbv)) {
- item->nick = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ item->nick = getTStringA((HANDLE)wParam, "MyNick");
AddEditBookmark(item);
- mir_free(item->jid);
- mir_free(item->name);
- mir_free(item);
+ delete item;
}
}
}
@@ -572,19 +555,13 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportLogin(WPARAM wParam, LPARAM) if ( !getByte(hContact, "IsTransport", 0))
return 0;
- DBVARIANT jid;
- if (getTString(hContact, "jid", &jid))
- return 0;
-
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid.ptszVal);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrT( getTStringA(hContact, "jid")));
if (item != NULL) {
XmlNode p(_T("presence")); xmlAddAttr(p, _T("to"), item->jid);
if (item->getTemp()->m_iStatus == ID_STATUS_ONLINE)
xmlAddAttr(p, _T("type"), _T("unavailable"));
m_ThreadInfo->send(p);
}
-
- db_free(&jid);
return 0;
}
@@ -594,11 +571,9 @@ INT_PTR __cdecl CJabberProto::OnMenuTransportResolve(WPARAM wParam, LPARAM) if ( !getByte(hContact, "IsTransport", 0))
return 0;
- DBVARIANT jid;
- if ( !getTString(hContact, "jid", &jid)) {
- ResolveTransportNicks(jid.ptszVal);
- db_free(&jid);
- }
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid != NULL)
+ ResolveTransportNicks(jid);
return 0;
}
@@ -608,31 +583,18 @@ INT_PTR __cdecl CJabberProto::OnMenuBookmarkAdd(WPARAM wParam, LPARAM) if (!hContact)
return 0; // we do not add ourself to the roster. (buggy situation - should not happen)
- DBVARIANT dbv;
- if ( !getTString(hContact, "ChatRoomID", &dbv)) {
- TCHAR *roomID = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- if (ListGetItemPtr(LIST_BOOKMARK, roomID) == NULL) {
- TCHAR *nick = 0;
- if ( !getTString(hContact, "Nick", &dbv)) {
- nick = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
-
- JABBER_LIST_ITEM *item = new JABBER_LIST_ITEM();
- item->jid = mir_tstrdup(roomID);
- item->name = pcli->pfnGetContactDisplayName(hContact, 0);
- item->type = _T("conference");
- if ( !getTString(hContact, "MyNick", &dbv)) {
- item->nick = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- AddEditBookmark(item);
- mir_free(item);
+ ptrT roomID( getTStringA(hContact, "ChatRoomID"));
+ if (roomID == NULL)
+ return 0;
- if (nick) mir_free(nick);
- }
- mir_free(roomID);
+ if (ListGetItemPtr(LIST_BOOKMARK, roomID) == NULL) {
+ JABBER_LIST_ITEM *item = new JABBER_LIST_ITEM();
+ item->jid = mir_tstrdup(roomID);
+ item->name = pcli->pfnGetContactDisplayName(hContact, 0);
+ item->type = _T("conference");
+ item->nick = getTStringA(hContact, "MyNick");
+ AddEditBookmark(item);
+ delete item;
}
return 0;
}
@@ -1074,13 +1036,7 @@ int CJabberProto::OnProcessSrmmIconClick(WPARAM wParam, LPARAM lParam) if ( !hContact)
return 0;
- DBVARIANT dbv;
- if (getTString(hContact, "jid", &dbv))
- return 0;
-
- JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- db_free(&dbv);
-
+ JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, ptrT( getTStringA(hContact, "jid")));
if (LI == NULL)
return 0;
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 819250ba3f..4a94d5fd70 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -104,15 +104,11 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick) HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource)
{
- HANDLE hContact;
- TCHAR *s, *p, *q;
- size_t len;
-
if (jid == NULL || jid[0]=='\0')
return NULL;
- s = mir_tstrdup(jid);
- q = NULL;
+ TCHAR *s = NEWTSTR_ALLOCA(jid);
+ TCHAR *q = NULL, *p;
// strip resource if present
if ((p = _tcschr(s, '@')) != NULL)
if ((q = _tcschr(p, '/')) != NULL)
@@ -120,37 +116,31 @@ HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL t if ( !stripResource && q != NULL) // so that resource is not stripped
*q = '/';
- len = _tcslen(s);
// We can't use JabberHContactFromJID() here because of the stripResource option
- for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- p = dbv.ptszVal;
- if (p && _tcslen(p) >= len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len)) {
- db_free(&dbv);
- break;
- }
- db_free(&dbv);
- }
- }
+ size_t len = _tcslen(s);
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ continue;
- if (hContact == NULL) {
- hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName);
- setTString(hContact, "jid", s);
- if (nick != NULL && *nick != '\0')
- setTString(hContact, "Nick", nick);
- if (temporary)
- db_set_b(hContact, "CList", "NotOnList", 1);
- else
- SendGetVcard(s);
- Log("Create Jabber contact jid=%S, nick=%S", s, nick);
- DBCheckIsTransportedContact(s,hContact);
+ TCHAR *p = jid;
+ if (p && _tcslen(p) >= len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len))
+ return hContact;
}
- mir_free(s);
- return hContact;
+ HANDLE hNewContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hNewContact, (LPARAM)m_szModuleName);
+ setTString(hNewContact, "jid", s);
+ if (nick != NULL && *nick != '\0')
+ setTString(hNewContact, "Nick", nick);
+ if (temporary)
+ db_set_b(hNewContact, "CList", "NotOnList", 1);
+ else
+ SendGetVcard(s);
+ Log("Create Jabber contact jid=%S, nick=%S", s, nick);
+ DBCheckIsTransportedContact(s,hNewContact);
+ return hNewContact;
}
BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType)
@@ -255,28 +245,20 @@ void CJabberProto::ResolveTransportNicks(const TCHAR *jid) if ( !getByte(hContact, "IsTransported", 0))
continue;
- DBVARIANT dbv, nick;
- if (getTString(hContact, "jid", &dbv))
- continue;
- if (getTString(hContact, "Nick", &nick)) {
- db_free(&dbv);
+ ptrT dbJid( getTStringA(hContact, "jid")); if (dbJid == NULL) continue;
+ ptrT dbNick( getTStringA(hContact, "Nick")); if (dbNick == NULL) continue;
+
+ TCHAR *p = _tcschr(dbJid, '@');
+ if (p == NULL)
continue;
- }
- TCHAR *p = _tcschr(dbv.ptszVal, '@');
- if (p) {
- *p = 0;
- if ( !lstrcmp(jid, p+1) && !lstrcmp(dbv.ptszVal, nick.ptszVal)) {
- *p = '@';
- m_ThreadInfo->resolveID = SendGetVcard(dbv.ptszVal);
- m_ThreadInfo->resolveContact = hContact;
- db_free(&dbv);
- db_free(&nick);
- return;
- } }
-
- db_free(&dbv);
- db_free(&nick);
+ *p = 0;
+ if ( !lstrcmp(jid, p+1) && !lstrcmp(dbJid, dbNick)) {
+ *p = '@';
+ m_ThreadInfo->resolveID = SendGetVcard(dbJid);
+ m_ThreadInfo->resolveContact = hContact;
+ return;
+ }
}
m_ThreadInfo->resolveID = -1;
@@ -480,19 +462,17 @@ void CJabberProto::UpdateMirVer(HANDLE hContact, pResourceStatus &resource) FormatMirVer(resource, szMirVer, SIZEOF(szMirVer));
if (szMirVer[0])
setTString(hContact, "MirVer", szMirVer);
-// else
-// delSetting(hContact, "MirVer");
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- TCHAR szFullJid[JABBER_MAX_JID_LEN];
- if (resource->m_tszResourceName)
- mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), dbv.ptszVal, resource->m_tszResourceName);
- else
- lstrcpyn(szFullJid, dbv.ptszVal, SIZEOF(szFullJid));
- setTString(hContact, DBSETTING_DISPLAY_UID, szFullJid);
- db_free(&dbv);
- }
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ return;
+
+ TCHAR szFullJid[JABBER_MAX_JID_LEN];
+ if (resource->m_tszResourceName)
+ mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), jid, resource->m_tszResourceName);
+ else
+ lstrcpyn(szFullJid, jid, SIZEOF(szFullJid));
+ setTString(hContact, DBSETTING_DISPLAY_UID, szFullJid);
}
void CJabberProto::UpdateSubscriptionInfo(HANDLE hContact, JABBER_LIST_ITEM *item)
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 73548d9705..9fd5895529 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -442,7 +442,6 @@ protected: CSuper::OnInitDialog();
int i;
- DBVARIANT dbv;
m_gotservers = false;
@@ -467,17 +466,15 @@ protected: if (GetComputerName(szCompName, &dwCompNameLength))
m_cbResource.AddString(szCompName);
- if ( !m_proto->getTString("Resource", &dbv)) {
- if (CB_ERR == m_cbResource.FindString(dbv.ptszVal, -1, true))
- m_cbResource.AddString(dbv.ptszVal);
-
- m_cbResource.SetText(dbv.ptszVal);
- db_free(&dbv);
+ ptrT tszResource( m_proto->getTStringA("Resource"));
+ if (tszResource != NULL) {
+ if (CB_ERR == m_cbResource.FindString(tszResource, -1, true))
+ m_cbResource.AddString(tszResource);
+ m_cbResource.SetText(tszResource);
}
else m_cbResource.SetText(_T("Miranda"));
- for (i=0; g_LanguageCodes[i].szCode; i++)
- {
+ for (i=0; g_LanguageCodes[i].szCode; i++) {
int iItem = m_cbLocale.AddString(TranslateTS(g_LanguageCodes[i].szDescription), (LPARAM)g_LanguageCodes[i].szCode);
if ( !_tcscmp(m_proto->m_tszSelectedLang, g_LanguageCodes[i].szCode))
m_cbLocale.SetCurSel(iItem);
@@ -490,8 +487,7 @@ protected: if (m_proto->m_options.Disable3920auth) m_chkUseTls.SetState(BST_UNCHECKED);
m_chkUseSsl.Enable(m_proto->m_options.Disable3920auth || (m_proto->m_options.UseTLS ? false : true));
- if (m_proto->m_options.ManualConnect)
- {
+ if (m_proto->m_options.ManualConnect) {
m_txtManualHost.Enable();
m_txtManualPort.Enable();
m_txtPort.Disable();
@@ -501,7 +497,6 @@ protected: chkUseDomainLogin_OnChange(&m_chkUseDomainLogin);
CheckRegistration();
-
}
void OnApply()
@@ -509,8 +504,7 @@ protected: // clear saved password
*m_proto->m_savedPassword = 0;
- if (m_chkSavePassword.GetState() == BST_CHECKED)
- {
+ if (m_chkSavePassword.GetState() == BST_CHECKED) {
TCHAR *text = m_txtPassword.GetText();
m_proto->JSetStringCrypt(NULL, "LoginPassword", text);
mir_free(text);
@@ -518,8 +512,7 @@ protected: else m_proto->delSetting("LoginPassword");
int index = m_cbLocale.GetCurSel();
- if (index >= 0)
- {
+ if (index >= 0) {
TCHAR *szLanguageCode = (TCHAR *)m_cbLocale.GetItemData(index);
if (szLanguageCode) {
m_proto->setTString("XmlLang", szLanguageCode);
@@ -530,8 +523,7 @@ protected: sttStoreJidFromUI(m_proto, m_txtUsername, m_cbServer);
- if (m_proto->m_bJabberOnline)
- {
+ if (m_proto->m_bJabberOnline) {
if (m_txtUsername.IsChanged() || m_txtPassword.IsChanged() || m_cbResource.IsChanged() ||
m_cbServer.IsChanged() || m_chkUseHostnameAsResource.IsChanged() || m_txtPort.IsChanged() ||
m_txtManualHost.IsChanged() || m_txtManualPort.IsChanged() || m_cbLocale.IsChanged())
@@ -553,8 +545,7 @@ protected: INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_ACTIVATE:
m_chkUseTls.Enable(!m_proto->m_options.Disable3920auth && (m_proto->m_options.UseSSL ? false : true));
if (m_proto->m_options.Disable3920auth) m_chkUseTls.SetState(BST_UNCHECKED);
@@ -657,8 +648,7 @@ private: CCtrlCheck *chk = (CCtrlCheck *)sender;
m_cbResource.Enable(chk->GetState() != BST_CHECKED);
- if (chk->GetState() == BST_CHECKED)
- {
+ if (chk->GetState() == BST_CHECKED) {
TCHAR szCompName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD dwCompNameLength = MAX_COMPUTERNAME_LENGTH;
if (GetComputerName(szCompName, &dwCompNameLength))
@@ -684,14 +674,14 @@ private: void chkUseSsl_OnChange(CCtrlData*)
{
BOOL bManualHost = m_chkManualHost.GetState() == BST_CHECKED;
- if (m_chkUseSsl.GetState() == BST_CHECKED)
- {
+ if (m_chkUseSsl.GetState() == BST_CHECKED) {
m_chkUseTls.Disable();
if ( !bManualHost)
m_txtPort.SetInt(5223);
- } else
- {
- if ( !m_proto->m_options.Disable3920auth) m_chkUseTls.Enable();
+ }
+ else {
+ if ( !m_proto->m_options.Disable3920auth)
+ m_chkUseTls.Enable();
if ( !bManualHost)
m_txtPort.SetInt(5222);
}
@@ -711,12 +701,11 @@ private: m_txtUsername.GetText(regInfo.username, SIZEOF(regInfo.username));
m_txtPassword.GetText(regInfo.password, SIZEOF(regInfo.password));
m_cbServer.GetTextA(regInfo.server, SIZEOF(regInfo.server));
- if (m_chkManualHost.GetState() == BST_CHECKED)
- {
+ if (m_chkManualHost.GetState() == BST_CHECKED) {
regInfo.port = (WORD)m_txtManualPort.GetInt();
m_txtManualHost.GetTextA(regInfo.manualHost, SIZEOF(regInfo.manualHost));
- } else
- {
+ }
+ else {
regInfo.port = (WORD)m_txtPort.GetInt();
regInfo.manualHost[0] = '\0';
}
@@ -885,16 +874,15 @@ public: void chkDirect_OnChange(CCtrlData *)
{
- if (m_chkDirect.GetState() == BST_CHECKED)
- {
+ if (m_chkDirect.GetState() == BST_CHECKED) {
if (m_chkDirectManual.GetState() == BST_CHECKED)
m_txtDirect.Enable();
else
m_txtDirect.Disable();
m_chkDirectManual.Enable();
- } else
- {
+ }
+ else {
m_txtDirect.Disable();
m_chkDirectManual.Disable();
}
@@ -974,17 +962,13 @@ struct ROSTEREDITDAT static int _RosterInsertListItem(HWND hList, const TCHAR * jid, const TCHAR * nick, const TCHAR * group, const TCHAR * subscr, BOOL bChecked)
{
- LVITEM item={0};
- int index;
- item.mask=LVIF_TEXT|LVIF_STATE;
-
+ LVITEM item = {0};
+ item.mask = LVIF_TEXT | LVIF_STATE;
item.iItem = ListView_GetItemCount(hList);
- item.iSubItem = 0;
item.pszText = (TCHAR*)jid;
- index=ListView_InsertItem(hList, &item);
-
- if (index<0)
+ int index = ListView_InsertItem(hList, &item);
+ if (index < 0)
return index;
ListView_SetCheckState(hList, index, bChecked);
@@ -993,48 +977,48 @@ static int _RosterInsertListItem(HWND hList, const TCHAR * jid, const TCHAR * ni ListView_SetItemText(hList, index, 1, (TCHAR*)nick);
ListView_SetItemText(hList, index, 2, (TCHAR*)group);
ListView_SetItemText(hList, index, 3, TranslateTS(subscr));
-
return index;
}
static void _RosterListClear(HWND hwndDlg)
{
- HWND hList=GetDlgItem(hwndDlg, IDC_ROSTER);
- if ( !hList) return;
+ HWND hList = GetDlgItem(hwndDlg, IDC_ROSTER);
+ if ( !hList)
+ return;
+
ListView_DeleteAllItems(hList);
- while ( ListView_DeleteColumn(hList, 0));
+ while ( ListView_DeleteColumn(hList, 0));
- LV_COLUMN column={0};
- column.mask=LVCF_TEXT;
- column.cx=500;
+ LV_COLUMN column = {0};
+ column.mask = LVCF_TEXT;
+ column.cx = 500;
- column.pszText=TranslateT("JID");
+ column.pszText = TranslateT("JID");
ListView_InsertColumn(hList, 1, &column);
- column.pszText=TranslateT("Nick Name");
+ column.pszText = TranslateT("Nick Name");
ListView_InsertColumn(hList, 2, &column);
- column.pszText=TranslateT("Group");
+ column.pszText = TranslateT("Group");
ListView_InsertColumn(hList, 3, &column);
- column.pszText=TranslateT("Subscription");
+ column.pszText = TranslateT("Subscription");
ListView_InsertColumn(hList, 4, &column);
RECT rc;
GetClientRect(hList, &rc);
- int width=rc.right-rc.left;
+ int width = rc.right-rc.left;
- ListView_SetColumnWidth(hList,0,width*40/100);
- ListView_SetColumnWidth(hList,1,width*25/100);
- ListView_SetColumnWidth(hList,2,width*20/100);
- ListView_SetColumnWidth(hList,3,width*10/100);
+ ListView_SetColumnWidth(hList, 0, width*40/100);
+ ListView_SetColumnWidth(hList, 1, width*25/100);
+ ListView_SetColumnWidth(hList, 2, width*20/100);
+ ListView_SetColumnWidth(hList, 3, width*10/100);
}
void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*)
{
- HWND hList=GetDlgItem(rrud.hwndDlg, IDC_ROSTER);
- if (rrud.bRRAction==RRA_FILLLIST)
- {
+ HWND hList = GetDlgItem(rrud.hwndDlg, IDC_ROSTER);
+ if (rrud.bRRAction == RRA_FILLLIST) {
_RosterListClear(rrud.hwndDlg);
HXML query = xmlGetChild(node , "query");
if (query == NULL) return;
@@ -1056,35 +1040,22 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) // now it is require to process whole contact list to add not in roster contacts
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- LVFINDINFO lvfi={0};
- lvfi.flags = LVFI_STRING;
- lvfi.psz = dbv.ptszVal;
- TCHAR *p = _tcschr(dbv.ptszVal,_T('@'));
- if (p) {
- p = _tcschr(dbv.ptszVal, _T('/'));
- if (p) *p = _T('\0');
- }
- if (ListView_FindItem(hList, -1, &lvfi) == -1) {
- TCHAR *jid = mir_tstrdup(dbv.ptszVal);
- TCHAR *name = NULL;
- TCHAR *group = NULL;
- DBVARIANT dbvtemp;
- if ( !db_get_ts(hContact, "CList", "MyHandle", &dbvtemp)) {
- name = mir_tstrdup(dbvtemp.ptszVal);
- db_free(&dbvtemp);
- }
- if ( !db_get_ts(hContact, "CList", "Group", &dbvtemp)) {
- group = mir_tstrdup(dbvtemp.ptszVal);
- db_free(&dbvtemp);
- }
- _RosterInsertListItem(hList, jid, name, group, NULL, FALSE);
- mir_free(jid);
- mir_free(name);
- mir_free(group);
- }
- db_free(&dbv);
+ ptrT tszJid( getTStringA(hContact, "jid"));
+ if (tszJid == NULL)
+ continue;
+
+ LVFINDINFO lvfi = {0};
+ lvfi.flags = LVFI_STRING;
+ lvfi.psz = tszJid;
+ TCHAR *p = _tcschr(tszJid, _T('@'));
+ if (p) {
+ p = _tcschr(tszJid, _T('/'));
+ if (p) *p = _T('\0');
+ }
+ if ( ListView_FindItem(hList, -1, &lvfi) == -1) {
+ ptrT tszName( db_get_tsa(hContact, "CList", "MyHandle"));
+ ptrT tszGroup( db_get_tsa(hContact, "CList", "Group"));
+ _RosterInsertListItem(hList, tszJid, tszName, tszGroup, NULL, FALSE);
}
}
rrud.bReadyToDownload = FALSE;
@@ -1092,10 +1063,10 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) SetDlgItemText(rrud.hwndDlg, IDC_DOWNLOAD, TranslateT("Download"));
SetDlgItemText(rrud.hwndDlg, IDC_UPLOAD, TranslateT("Upload"));
SendMessage(rrud.hwndDlg, JM_STATUSCHANGED, 0, 0);
- return;
+ return;
}
- else if (rrud.bRRAction == RRA_SYNCROSTER)
- {
+
+ if (rrud.bRRAction == RRA_SYNCROSTER) {
SetDlgItemText(rrud.hwndDlg, IDC_UPLOAD, TranslateT("Uploading..."));
HXML queryRoster = xmlGetChild(node , "query");
if ( !queryRoster)
@@ -1107,8 +1078,7 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) int itemCount=0;
int ListItemCount=ListView_GetItemCount(hList);
- for (int index=0; index < ListItemCount; index++)
- {
+ for (int index=0; index < ListItemCount; index++) {
TCHAR jid[JABBER_MAX_JID_LEN]=_T("");
TCHAR name[260]=_T("");
TCHAR group[260]=_T("");
@@ -1119,14 +1089,12 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) ListView_GetItemText(hList, index, 3, subscr, SIZEOF(subscr));
HXML itemRoster = xmlGetChildByTag(queryRoster, "item", "jid", jid);
BOOL bRemove = !ListView_GetCheckState(hList,index);
- if (itemRoster && bRemove)
- {
+ if (itemRoster && bRemove) {
//delete item
query << XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("subscription") ,_T("remove"));
itemCount++;
}
- else if ( !bRemove)
- {
+ else if ( !bRemove) {
BOOL bPushed = itemRoster ? TRUE : FALSE;
if ( !bPushed) {
const TCHAR *rosterName = xmlGetAttrValue(itemRoster, _T("name"));
@@ -1154,21 +1122,18 @@ void CJabberProto::_RosterHandleGetRequest(HXML node, CJabberIqInfo*) }
}
}
- rrud.bRRAction=RRA_SYNCDONE;
+ rrud.bRRAction = RRA_SYNCDONE;
if (itemCount)
m_ThreadInfo->send(iq);
else
- _RosterSendRequest(rrud.hwndDlg,RRA_FILLLIST);
+ _RosterSendRequest(rrud.hwndDlg, RRA_FILLLIST);
}
- else
- {
- SetDlgItemText(rrud.hwndDlg,IDC_UPLOAD,TranslateT("Upload"));
- rrud.bReadyToUpload=FALSE;
- rrud.bReadyToDownload=FALSE;
- SendMessage(rrud.hwndDlg, JM_STATUSCHANGED,0,0);
- SetDlgItemText(rrud.hwndDlg,IDC_DOWNLOAD,TranslateT("Downloading..."));
- _RosterSendRequest(rrud.hwndDlg,RRA_FILLLIST);
-
+ else {
+ SetDlgItemText(rrud.hwndDlg, IDC_UPLOAD, TranslateT("Upload"));
+ rrud.bReadyToUpload = rrud.bReadyToDownload = FALSE;
+ SendMessage(rrud.hwndDlg, JM_STATUSCHANGED, 0, 0);
+ SetDlgItemText(rrud.hwndDlg, IDC_DOWNLOAD, TranslateT("Downloading..."));
+ _RosterSendRequest(rrud.hwndDlg, RRA_FILLLIST);
}
}
@@ -1655,15 +1620,10 @@ protected: {
CSuper::OnInitDialog();
- int i;
- DBVARIANT dbv;
- char server[256], manualServer[256]={0};
-
m_gotservers = false;
TCHAR *passw = m_proto->JGetStringCrypt(NULL, "LoginPassword");
- if (passw)
- {
+ if (passw) {
m_txtPassword.SetText(passw);
mir_free(passw);
}
@@ -1672,7 +1632,7 @@ protected: // fill predefined resources
TCHAR *szResources[] = { _T("Home"), _T("Work"), _T("Office"), _T("Miranda") };
- for (i=0; i < SIZEOF(szResources); i++)
+ for (int i=0; i < SIZEOF(szResources); i++)
m_cbResource.AddString(szResources[i]);
// append computer name to the resource list
@@ -1681,12 +1641,11 @@ protected: if (GetComputerName(szCompName, &dwCompNameLength))
m_cbResource.AddString(szCompName);
- if ( !m_proto->getTString("Resource", &dbv)) {
- if (CB_ERR == m_cbResource.FindString(dbv.ptszVal, -1, true))
- m_cbResource.AddString(dbv.ptszVal);
-
- m_cbResource.SetText(dbv.ptszVal);
- db_free(&dbv);
+ ptrT tszResource( m_proto->getTStringA("Resource"));
+ if (tszResource != NULL) {
+ if (CB_ERR == m_cbResource.FindString(tszResource, -1, true))
+ m_cbResource.AddString(tszResource);
+ m_cbResource.SetText(tszResource);
}
else m_cbResource.SetText(_T("Miranda"));
@@ -1699,11 +1658,11 @@ protected: m_cbType.AddString(TranslateT("Odnoklassniki"), ACC_OK);
m_cbType.AddString(TranslateT("S.ms"), ACC_SMS);
+ char server[256], manualServer[256]={0};
m_cbServer.GetTextA(server, SIZEOF(server));
- if ( !db_get_s(NULL, m_proto->m_szModuleName, "ManualHost", &dbv)) {
- lstrcpynA(manualServer, dbv.pszVal, SIZEOF(manualServer));
- db_free(&dbv);
- }
+ ptrA dbManualServer( db_get_sa(NULL, m_proto->m_szModuleName, "ManualHost"));
+ if (dbManualServer != NULL)
+ lstrcpynA(manualServer, dbManualServer, SIZEOF(manualServer));
m_canregister = true;
if ( !lstrcmpA(manualServer, "talk.google.com")) {
@@ -1740,10 +1699,9 @@ protected: m_txtManualHost.Enable();
m_txtPort.Enable();
- if ( !m_proto->getTString("ManualHost", &dbv)) {
- m_txtManualHost.SetText(dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT dbManualHost( m_proto->getTStringA("ManualHost"));
+ if (dbManualHost != NULL)
+ m_txtManualHost.SetText(dbManualHost);
m_txtPort.SetInt(m_proto->getWord("ManualPort", m_txtPort.GetInt()));
}
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 748a0d8df5..2c0c260c86 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -418,11 +418,9 @@ public: SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
{
for (HANDLE hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
- DBVARIANT dbv;
- if ( !m_proto->getTString(hContact, "jid", &dbv)) {
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT jid( m_proto->getTStringA(hContact, "jid"));
+ if (jid != NULL)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, jid);
}
// append known chatroom jids from bookmarks
@@ -1460,19 +1458,15 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = m_clcClist.FindContact(hContact);
- DBVARIANT dbv = {0};
- if (m_proto->getTString(hContact, "jid", &dbv))
- if (m_proto->getTString(hContact, "ChatRoomID", &dbv))
+ ptrT jid( m_proto->getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ if ((jid = m_proto->getTStringA(hContact, "ChatRoomID")) == NULL)
continue;
- szJid = dbv.ptszVal;
-
if (dwPackets = CListGetPackets(hwndList, hItem, true))
pList->AddRule(Jid, szJid, TRUE, dwOrder++, dwPackets);
if (dwPackets = CListGetPackets(hwndList, hItem, false))
pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
-
- db_free(&dbv);
}
// group handles start with 1 (0 is "root")
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 414d1df358..11524d4b56 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -155,19 +155,13 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) : db_set_resident(m_szModuleName, "Auth");
db_set_resident(m_szModuleName, "Grant");
- DBVARIANT dbv;
- if ( !getTString("XmlLang", &dbv)) {
- m_tszSelectedLang = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- else m_tszSelectedLang = mir_tstrdup(_T("en"));
-
- if ( !getString("Password", &dbv)) {
- CallService(MS_DB_CRYPT_DECODESTRING, lstrlenA(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
- TCHAR *pssw = mir_a2t(dbv.pszVal);
- JSetStringCrypt(NULL, "LoginPassword", pssw);
- mir_free(pssw);
- db_free(&dbv);
+ if ((m_tszSelectedLang = getTStringA("XmlLang")) == NULL)
+ m_tszSelectedLang = mir_tstrdup(_T("en"));
+
+ ptrA szPassword( getStringA("Password"));
+ if (szPassword != NULL) {
+ CallService(MS_DB_CRYPT_DECODESTRING, lstrlenA(szPassword) + 1, szPassword);
+ JSetStringCrypt(NULL, "LoginPassword", _A2T(szPassword));
delSetting("Password");
}
}
@@ -284,15 +278,14 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) if ( !getByte(hContact, "IsTransport", 0))
continue;
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- TCHAR *domain = NEWTSTR_ALLOCA(dbv.ptszVal);
- TCHAR *resourcepos = _tcschr(domain, '/');
- if (resourcepos != NULL)
- *resourcepos = '\0';
- m_lstTransports.insert(mir_tstrdup(domain));
- db_free(&dbv);
- }
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL) continue;
+
+ TCHAR *domain = NEWTSTR_ALLOCA(jid);
+ TCHAR *resourcepos = _tcschr(domain, '/');
+ if (resourcepos != NULL)
+ *resourcepos = '\0';
+ m_lstTransports.insert( mir_tstrdup(domain));
}
return 0;
@@ -931,20 +924,15 @@ int __cdecl CJabberProto::SendContacts(HANDLE hContact, int flags, int nContacts return 0;
XmlNode m(_T("message"));
-// m << XCHILD(_T("body"), msg);
HXML x = m << XCHILDNS(_T("x"), JABBER_FEAT_ROSTER_EXCHANGE);
for (int i=0; i < nContacts; i++) {
- DBVARIANT dbv;
- if ( !getTString(hContactsList[i], "jid", &dbv)) {
- x << XCHILD(_T("item")) << XATTR(_T("action"), _T("add")) << XATTR(_T("jid"), dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT jid( getTStringA(hContactsList[i], "jid"));
+ if (jid != NULL)
+ x << XCHILD(_T("item")) << XATTR(_T("action"), _T("add")) << XATTR(_T("jid"), jid);
}
- int id = SerialNext();
- m << XATTR(_T("to"), szClientJid) << XATTRID(id);
-
+ m << XATTR(_T("to"), szClientJid) << XATTRID( SerialNext());
m_ThreadInfo->send(m);
return 1;
}
@@ -959,23 +947,19 @@ HANDLE __cdecl CJabberProto::SendFile(HANDLE hContact, const TCHAR *szDescriptio if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
return 0;
- DBVARIANT dbv;
- if (getTString(hContact, "jid", &dbv))
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL)
return 0;
int i, j;
struct _stati64 statbuf;
- JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- if (item == NULL) {
- db_free(&dbv);
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
+ if (item == NULL)
return 0;
- }
// Check if another file transfer session request is pending (waiting for disco result)
- if (item->ft != NULL) {
- db_free(&dbv);
+ if (item->ft != NULL)
return 0;
- }
JabberCapsBits jcb = GetResourceCapabilites(item->jid, TRUE);
if (jcb == JABBER_RESOURCE_CAPS_IN_PROGRESS) {
@@ -1001,7 +985,6 @@ HANDLE __cdecl CJabberProto::SendFile(HANDLE hContact, const TCHAR *szDescriptio // XEP-0096 and OOB not supported?
|| !(jcb & (JABBER_CAPS_SI_FT | JABBER_CAPS_OOB)))
{
- db_free(&dbv);
MsgPopup(hContact, TranslateT("No compatible file transfer machanism exist"), item->jid);
return 0;
}
@@ -1024,14 +1007,12 @@ HANDLE __cdecl CJabberProto::SendFile(HANDLE hContact, const TCHAR *szDescriptio } }
if (j == 0) {
delete ft;
- db_free(&dbv);
return NULL;
}
ft->std.tszCurrentFile = mir_tstrdup(ppszFiles[0]);
ft->szDescription = mir_tstrdup(szDescription);
- ft->jid = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
+ ft->jid = mir_tstrdup(jid);
if (jcb & JABBER_CAPS_SI_FT)
FtInitiate(item->jid, ft);
@@ -1190,30 +1171,28 @@ int __cdecl CJabberProto::SetApparentMode(HANDLE hContact, int mode) if ( !m_bJabberOnline)
return 0;
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- TCHAR *jid = dbv.ptszVal;
- switch (mode) {
- case ID_STATUS_ONLINE:
- if (m_iStatus == ID_STATUS_INVISIBLE || oldMode == ID_STATUS_OFFLINE)
- m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), jid));
- break;
- case ID_STATUS_OFFLINE:
- if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE)
- SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL);
- break;
- case 0:
- if (oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE)
- SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL);
- else if (oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE)
- SendPresenceTo(m_iStatus, jid, NULL);
- break;
- }
- db_free(&dbv);
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ return 0;
+
+ switch (mode) {
+ case ID_STATUS_ONLINE:
+ if (m_iStatus == ID_STATUS_INVISIBLE || oldMode == ID_STATUS_OFFLINE)
+ m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), jid));
+ break;
+ case ID_STATUS_OFFLINE:
+ if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE)
+ SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL);
+ break;
+ case 0:
+ if (oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE)
+ SendPresenceTo(ID_STATUS_INVISIBLE, jid, NULL);
+ else if (oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE)
+ SendPresenceTo(m_iStatus, jid, NULL);
+ break;
}
// TODO: update the zebra list (jabber:iq:privacy)
-
return 0;
}
@@ -1268,17 +1247,15 @@ int __cdecl CJabberProto::SetStatus(int iNewStatus) void __cdecl CJabberProto::GetAwayMsgThread(void* hContact)
{
- DBVARIANT dbv;
- JABBER_LIST_ITEM *item;
- int i, msgCount;
-
- if ( !getTString(hContact, "jid", &dbv)) {
- if ((item = ListGetItemPtr(LIST_ROSTER, dbv.ptszVal)) != NULL) {
- db_free(&dbv);
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid != NULL) {
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
+ if (item != NULL) {
if (item->arResources.getCount() > 0) {
Log("arResources.getCount() > 0");
- size_t len = msgCount = 0;
- for (i=0; i < item->arResources.getCount(); i++) {
+ int msgCount = 0;
+ size_t len = 0;
+ for (int i=0; i < item->arResources.getCount(); i++) {
JABBER_RESOURCE_STATUS *r = item->arResources[i];
if (r->m_tszStatusMessage) {
msgCount++;
@@ -1288,7 +1265,7 @@ void __cdecl CJabberProto::GetAwayMsgThread(void* hContact) TCHAR *str = (TCHAR*)alloca(sizeof(TCHAR)*(len+1));
str[0] = str[len] = '\0';
- for (i=0; i < item->arResources.getCount(); i++) {
+ for (int i=0; i < item->arResources.getCount(); i++) {
JABBER_RESOURCE_STATUS *r = item->arResources[i];
if (r->m_tszStatusMessage) {
if (str[0] != '\0') _tcscat(str, _T("\r\n"));
@@ -1311,7 +1288,6 @@ void __cdecl CJabberProto::GetAwayMsgThread(void* hContact) return;
}
}
- else db_free(&dbv);
}
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)0);
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index e09a0cf5d0..9265a00316 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -466,27 +466,25 @@ int CJabberProto::RcGetUnreadEventsCount() {
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)) {
- HANDLE hDbEvent = db_event_firstUnread(hContact);
- while (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) {
- nEventsSent++;
- mir_free(szEventText);
- }
- }
- mir_free(dbei.pBlob);
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL) continue;
+
+ 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)
+ continue;
+
+ 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) {
+ nEventsSent++;
+ mir_free(szEventText);
}
- hDbEvent = db_event_next(hDbEvent);
}
- db_free(&dbv);
+ mir_free(dbei.pBlob);
}
}
return nEventsSent;
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index df04e24891..3fa5d218e1 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -481,44 +481,42 @@ static void JabberSearchAddUrlToRecentCombo(HWND hwndDlg, const TCHAR *szAddr) void CJabberProto::SearchDeleteFromRecent(const TCHAR *szAddr, BOOL deleteLastFromDB)
{
- DBVARIANT dbv;
- char key[30];
//search in recent
for (int i=0; i<10; i++) {
+ char key[30];
mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i);
- if ( !getTString(key, &dbv)) {
- if ( !_tcsicmp(szAddr, dbv.ptszVal)) {
- db_free(&dbv);
- for (int j=i; j<10; j++) {
- mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j + 1);
- if ( !getTString(key, &dbv)) {
- mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
- setTString(NULL,key,dbv.ptszVal);
- db_free(&dbv);
- }
- else {
- if (deleteLastFromDB) {
- mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
- delSetting(NULL,key);
- }
- break;
- } }
- break;
+ ptrT szValue( getTStringA(key));
+ if (szValue == NULL || _tcsicmp(szAddr, szValue))
+ continue;
+
+ for (int j=i; j < 10; j++) {
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j + 1);
+ szValue = getTStringA(key);
+ if (szValue != NULL) {
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
+ setTString(NULL, key, szValue);
}
- else db_free(&dbv);
-} } }
+ else {
+ if (deleteLastFromDB) {
+ mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
+ delSetting(NULL,key);
+ }
+ break;
+ } }
+ break;
+} }
void CJabberProto::SearchAddToRecent(const TCHAR *szAddr, HWND hwndDialog)
{
- DBVARIANT dbv;
char key[30];
SearchDeleteFromRecent(szAddr);
+
for (int j=9; j > 0; j--) {
mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j - 1);
- if ( !getTString(key, &dbv)) {
+ ptrT szValue( getTStringA(key));
+ if (szValue != NULL) {
mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", j);
- setTString(NULL,key,dbv.ptszVal);
- db_free(&dbv);
+ setTString(NULL, key, szValue);
} }
mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", 0);
@@ -551,14 +549,13 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp);
}
- DBVARIANT dbv;
for (i=0; i < 10; i++) {
char key[30];
mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i);
- if ( !dat->ppro->getTString(key, &dbv)) {
- JabberSearchAddUrlToRecentCombo(hwndDlg, dbv.ptszVal);
- db_free(&dbv);
- } }
+ ptrT szValue( dat->ppro->getTStringA(key));
+ if (szValue != NULL)
+ JabberSearchAddUrlToRecentCombo(hwndDlg, szValue);
+ }
//TO DO: Add 4 recently used
dat->lastRequestIq = dat->ppro->SearchRenewFields(hwndDlg,dat);
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index cea9a5b30d..fa5ff7d13e 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -540,23 +540,22 @@ INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM wParam, LPARAM) return 0;
HANDLE hContact = (HANDLE)wParam;
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- TCHAR tszJid[JABBER_MAX_JID_LEN];
- TCHAR *szResource = ListGetBestClientResourceNamePtr(dbv.ptszVal);
- if (szResource)
- mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), dbv.ptszVal, szResource);
- else
- mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s"), dbv.ptszVal);
- db_free(&dbv);
-
- JabberCapsBits jcb = GetResourceCapabilites(tszJid, FALSE);
-
- m_ThreadInfo->send(
- XmlNode(_T("message")) << XATTR(_T("type"), _T("headline")) << XATTR(_T("to"), tszJid)
- << XCHILDNS(_T("attention"),
- jcb & JABBER_CAPS_ATTENTION ? JABBER_FEAT_ATTENTION : JABBER_FEAT_ATTENTION_0));
- }
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ return 0;
+
+ TCHAR tszJid[JABBER_MAX_JID_LEN];
+ TCHAR *szResource = ListGetBestClientResourceNamePtr(jid);
+ if (szResource)
+ mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), jid, szResource);
+ else
+ mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s"), jid);
+
+ JabberCapsBits jcb = GetResourceCapabilites(tszJid, FALSE);
+ m_ThreadInfo->send(
+ XmlNode(_T("message")) << XATTR(_T("type"), _T("headline")) << XATTR(_T("to"), tszJid)
+ << XCHILDNS(_T("attention"),
+ (jcb & JABBER_CAPS_ATTENTION) ? JABBER_FEAT_ATTENTION : JABBER_FEAT_ATTENTION_0));
return 0;
}
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index c0b990b17e..34aef04081 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -231,10 +231,11 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData* info) void CJabberProto::ServerThread(ThreadData* info)
{
- DBVARIANT dbv;
char* buffer;
- int datalen;
- int oldStatus;
+ int datalen;
+ int oldStatus;
+ ptrA szValue;
+ ptrT tszValue;
Log("Thread started: type=%d", info->type);
@@ -242,11 +243,10 @@ void CJabberProto::ServerThread(ThreadData* info) info->auth = NULL;
if (m_options.ManualConnect == TRUE) {
- if ( !getString("ManualHost", &dbv)) {
- strncpy(info->manualHost, dbv.pszVal, SIZEOF(info->manualHost));
- info->manualHost[SIZEOF(info->manualHost)-1] = '\0';
- db_free(&dbv);
- }
+ ptrA szManualHost( getStringA("ManualHost"));
+ if (szManualHost != NULL)
+ strncpy_s(info->manualHost, SIZEOF(info->manualHost), szManualHost, _TRUNCATE);
+
info->port = getWord("ManualPort", JABBER_DEFAULT_PORT);
}
else info->port = getWord("Port", JABBER_DEFAULT_PORT);
@@ -254,10 +254,8 @@ void CJabberProto::ServerThread(ThreadData* info) info->useSSL = m_options.UseSSL;
if (info->type == JABBER_SESSION_NORMAL) {
-
// Normal server connection, we will fetch all connection parameters
// e.g. username, password, etc. from the database.
-
if (m_ThreadInfo != NULL) {
// Will not start another connection thread if a thread is already running.
// Make APC call to the main thread. This will immediately wake the thread up
@@ -271,13 +269,10 @@ LBL_Exit: }
m_ThreadInfo = info;
- if (m_szStreamId) mir_free(m_szStreamId);
- m_szStreamId = NULL;
+ replaceStr(m_szStreamId, NULL);
- if ( !getTString("LoginName", &dbv)) {
- _tcsncpy(info->username, dbv.ptszVal, SIZEOF(info->username)-1);
- db_free(&dbv);
- }
+ if ((tszValue = getTStringA("LoginName")) != NULL)
+ _tcsncpy_s(info->username, SIZEOF(info->username), tszValue, _TRUNCATE);
if (*rtrimt(info->username) == '\0') {
DWORD dwSize = SIZEOF(info->username);
@@ -298,26 +293,23 @@ LBL_FatalError: goto LBL_Exit;
}
- if ( !getString("LoginServer", &dbv)) {
- strncpy(info->server, dbv.pszVal, SIZEOF(info->server)-1);
- db_free(&dbv);
- }
+ if ((szValue = getStringA("LoginServer")) != NULL)
+ strncpy_s(info->server, SIZEOF(info->server), szValue, _TRUNCATE);
else {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_NONETWORK);
Log("Thread ended, login server is not configured");
goto LBL_FatalError;
}
- if (m_options.HostNameAsResource == FALSE) {
- if ( !getTString("Resource", &dbv)) {
- _tcsncpy(info->resource, dbv.ptszVal, SIZEOF(info->resource) - 1);
- db_free(&dbv);
- }
- else _tcscpy(info->resource, _T("Miranda"));
+ if (m_options.HostNameAsResource) {
+ DWORD dwCompNameLen = SIZEOF(info->resource)-1;
+ if ( !GetComputerName(info->resource, &dwCompNameLen))
+ _tcscpy(info->resource, _T("Miranda"));
}
else {
- DWORD dwCompNameLen = SIZEOF(info->resource) - 1;
- if ( !GetComputerName(info->resource, &dwCompNameLen))
+ if ((tszValue = getTStringA("Resource")) != NULL)
+ _tcsncpy_s(info->resource, SIZEOF(info->resource), tszValue, _TRUNCATE);
+ else
_tcscpy(info->resource, _T("Miranda"));
}
@@ -888,18 +880,16 @@ void CJabberProto::OnProcessSuccess(HXML node, ThreadData* info) return;
if ( !_tcscmp(type, _T("urn:ietf:params:xml:ns:xmpp-sasl"))) {
- DBVARIANT dbv;
-
if ( !info->auth->validateLogin(xmlGetText(node))) {
info->send("</stream:stream>");
return;
}
Log("Success: Logged-in.");
- if ( getString("Nick", &dbv))
+ ptrT tszNick( getTStringA("Nick"));
+ if (tszNick == NULL)
setTString("Nick", info->username);
- else
- db_free(&dbv);
+
xmlStreamInitialize("after successful sasl");
}
else Log("Success: unknown action %S.",type);
@@ -1672,9 +1662,8 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData* info) if ( !hasAvatar && removedAvatar) {
Log("Has no avatar");
delSetting(hContact, "AvatarHash");
- DBVARIANT dbv = {0};
- if ( !getTString(hContact, "AvatarSaved", &dbv)) {
- db_free(&dbv);
+
+ if ( ptrT( getTStringA(hContact, "AvatarSaved")) != NULL) {
delSetting(hContact, "AvatarSaved");
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, NULL);
} } }
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 9b3c4e8afb..fa37ead33d 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -467,26 +467,21 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa if ( !dat) break;
if ( !dat->item) {
- DBVARIANT dbv = {0};
- if (dat->ppro->getTString(dat->hContact, "jid", &dbv))
+ ptrT jid( dat->ppro->getTStringA(dat->hContact, "jid"));
+ if (jid == NULL)
break;
- if ( !(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)))
- dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
+ if ( !(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)))
+ dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, jid);
- if ( !dat->item)
- {
+ if ( !dat->item) {
HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_INFO);
TreeView_DeleteAllItems(hwndTree);
- HTREEITEM htiRoot = sttFillInfoLine(hwndTree, NULL, dat->ppro->LoadIconEx("main"), _T("JID"), dbv.ptszVal, sttInfoLineId(0, INFOLINE_NAME), true);
+ HTREEITEM htiRoot = sttFillInfoLine(hwndTree, NULL, dat->ppro->LoadIconEx("main"), _T("JID"), jid, sttInfoLineId(0, INFOLINE_NAME), true);
sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), NULL,
TranslateT("Please switch online to see more details."));
-
- db_free(&dbv);
break;
}
-
- db_free(&dbv);
}
sttFillUserInfo(dat->ppro, GetDlgItem(hwndDlg, IDC_TV_INFO), dat->item);
break;
@@ -560,15 +555,12 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa break;
case PSN_PARAMCHANGED:
- dat->ppro = (CJabberProto*)(CJabberProto*)((PSHNOTIFY*)lParam)->lParam;
+ dat->ppro = (CJabberProto*)((PSHNOTIFY*)lParam)->lParam;
if (dat->hContact != NULL) {
- DBVARIANT dbv = {0};
- if (dat->ppro->getTString(dat->hContact, "jid", &dbv))
- break;
-
- if ( !(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, dbv.ptszVal)))
- dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, dbv.ptszVal);
- db_free(&dbv);
+ ptrT jid( dat->ppro->getTStringA(dat->hContact, "jid"));
+ if (jid != NULL)
+ if ( !(dat->item = dat->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)))
+ dat->item = dat->ppro->ListGetItemPtr(LIST_ROSTER, jid);
}
break;
} }
@@ -640,17 +632,15 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP case WM_JABBER_REFRESH:
{
- JABBER_LIST_ITEM *item;
- DBVARIANT dbv;
-
if (photoInfo->hBitmap) {
DeleteObject(photoInfo->hBitmap);
photoInfo->hBitmap = NULL;
}
ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE);
- if ( !photoInfo->ppro->getTString(photoInfo->hContact, "jid", &dbv)) {
- TCHAR *jid = dbv.ptszVal;
- if ((item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
+ ptrT jid( photoInfo->ppro->getTStringA(photoInfo->hContact, "jid"));
+ if (jid != NULL) {
+ JABBER_LIST_ITEM *item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid);
+ if (item == NULL)
item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid);
if (item != NULL) {
if (item->photoFileName) {
@@ -660,7 +650,6 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_SHOW);
}
}
- db_free(&dbv);
}
InvalidateRect(hwndDlg, NULL, TRUE);
UpdateWindow(hwndDlg);
@@ -670,80 +659,52 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_SAVE:
- {
- DBVARIANT dbv;
- JABBER_LIST_ITEM *item;
- HANDLE hFile;
- static TCHAR szFilter[512];
- unsigned char buffer[3];
- TCHAR szFileName[MAX_PATH];
- DWORD n;
-
- if (photoInfo->ppro->getTString(photoInfo->hContact, "jid", &dbv))
+ static TCHAR szFilter[512];
+ DWORD n;
+
+ ptrT jid( photoInfo->ppro->getTStringA(photoInfo->hContact, "jid"));
+ if (jid == NULL)
+ break;
+
+ JABBER_LIST_ITEM *item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid);
+ if (item == NULL)
+ if ((item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid)) == NULL)
break;
- TCHAR *jid = dbv.ptszVal;
- if ((item = photoInfo->ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
- item = photoInfo->ppro->ListGetItemPtr(LIST_ROSTER, jid);
- if (item != NULL) {
- if ((hFile=CreateFile(item->photoFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
- if (ReadFile(hFile, buffer, 3, &n, NULL) && n==3) {
- if ( !strncmp((char*)buffer, "BM", 2)) {
- mir_sntprintf(szFilter, SIZEOF(szFilter), _T("BMP %s (*.bmp)"), TranslateT("format"));
- n = (DWORD)_tcslen(szFilter);
- _tcsncpy(szFilter+n+1, _T("*.BMP"), SIZEOF(szFilter)-n-2);
- }
- else if ( !strncmp((char*)buffer, "GIF", 3)) {
- mir_sntprintf(szFilter, SIZEOF(szFilter), _T("GIF %s (*.gif)"), TranslateT("format"));
- n = (DWORD)_tcslen(szFilter);
- _tcsncpy(szFilter+n+1, _T("*.GIF"), SIZEOF(szFilter)-n-2);
- }
- else if (buffer[0]==0xff && buffer[1]==0xd8 && buffer[2]==0xff) {
- mir_sntprintf(szFilter, SIZEOF(szFilter), _T("JPEG %s (*.jpg;*.jpeg)"), TranslateT("format"));
- n = (DWORD)_tcslen(szFilter);
- _tcsncpy(szFilter+n+1, _T("*.JPG;*.JPEG"), SIZEOF(szFilter)-n-2);
- }
- else {
- mir_sntprintf(szFilter, SIZEOF(szFilter), _T("%s (*.*)"), TranslateT("Unknown format"));
- n = (DWORD)_tcslen(szFilter);
- _tcsncpy(szFilter+n+1, _T("*.*"), SIZEOF(szFilter)-n-2);
- }
- szFilter[SIZEOF(szFilter)-1] = 0;
-
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.hInstance = NULL;
- ofn.lpstrFilter = szFilter;
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 0;
- ofn.lpstrFile = szFileName;
- ofn.nMaxFile = _MAX_PATH;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 0;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = NULL;
- ofn.Flags = OFN_OVERWRITEPROMPT;
- ofn.nFileOffset = 0;
- ofn.nFileExtension = 0;
- ofn.lpstrDefExt = NULL;
- ofn.lCustData = 0L;
- ofn.lpfnHook = NULL;
- ofn.lpTemplateName = NULL;
- szFileName[0] = '\0';
- if (GetSaveFileName(&ofn)) {
- photoInfo->ppro->Log("File selected is %s", szFileName);
- CopyFile(item->photoFileName, szFileName, FALSE);
- }
- }
- CloseHandle(hFile);
- }
- }
- db_free(&dbv);
+ switch ( ProtoGetAvatarFileFormat(item->photoFileName)) {
+ case PA_FORMAT_BMP:
+ n = mir_sntprintf(szFilter, SIZEOF(szFilter), _T("BMP %s (*.bmp)"), TranslateT("format"));
+ _tcsncpy(szFilter+n+1, _T("*.BMP"), SIZEOF(szFilter)-n-2);
+ break;
+
+ case PA_FORMAT_GIF:
+ n = mir_sntprintf(szFilter, SIZEOF(szFilter), _T("GIF %s (*.gif)"), TranslateT("format"));
+ _tcsncpy(szFilter+n+1, _T("*.GIF"), SIZEOF(szFilter)-n-2);
+ break;
+ case PA_FORMAT_JPEG:
+ n = mir_sntprintf(szFilter, SIZEOF(szFilter), _T("JPEG %s (*.jpg;*.jpeg)"), TranslateT("format"));
+ _tcsncpy(szFilter+n+1, _T("*.JPG;*.JPEG"), SIZEOF(szFilter)-n-2);
+ break;
+
+ default:
+ n = mir_sntprintf(szFilter, SIZEOF(szFilter), _T("%s (*.*)"), TranslateT("Unknown format"));
+ _tcsncpy(szFilter+n+1, _T("*.*"), SIZEOF(szFilter)-n-2);
+ }
+ szFilter[SIZEOF(szFilter)-1] = 0;
+
+ TCHAR szFileName[MAX_PATH]; szFileName[0] = '\0';
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.lpstrFilter = szFilter;
+ ofn.lpstrFile = szFileName;
+ ofn.nMaxFile = _MAX_PATH;
+ ofn.Flags = OFN_OVERWRITEPROMPT;
+ if ( GetSaveFileName(&ofn)) {
+ photoInfo->ppro->Log("File selected is %s", szFileName);
+ CopyFile(item->photoFileName, szFileName, FALSE);
}
- break;
}
break;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 9b56bf9c5b..07d8a18e1d 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -50,18 +50,13 @@ HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid) return NULL;
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- int result = getTString(hContact, "ChatRoomID", &dbv);
- if (result)
- result = getTString(hContact, "jid", &dbv);
+ ptrT dbJid( getTStringA(hContact, "ChatRoomID"));
+ if (dbJid == NULL)
+ if ((dbJid = getTStringA(hContact, "jid")) == NULL)
+ continue;
- if ( !result) {
- int result;
- result = lstrcmpi(jid, dbv.ptszVal);
- db_free(&dbv);
- if ( !result && isChatRoom(hContact))
- return hContact;
- }
+ if (!lstrcmpi(jid, dbJid) && isChatRoom(hContact))
+ return hContact;
}
return NULL;
@@ -80,27 +75,26 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource) for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
bool bIsChat = isChatRoom(hContact);
- DBVARIANT dbv;
- if ( !getTString(hContact, bIsChat ? "ChatRoomID" : "jid", &dbv)) {
+ ptrT dbJid( getTStringA(hContact, bIsChat ? "ChatRoomID" : "jid"));
+ if (dbJid != NULL) {
int result;
if (item != NULL)
- result = lstrcmpi(jid, dbv.ptszVal);
+ result = lstrcmpi(jid, dbJid);
else {
if (bStripResource == 3) {
if (bIsChat)
- result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
+ result = lstrcmpi(jid, dbJid); // for chat room we have to have full contact matched
else if (TRUE)
- result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
+ result = _tcsnicmp(jid, dbJid, _tcslen(dbJid));
else
- result = JabberCompareJids(jid, dbv.ptszVal);
+ result = JabberCompareJids(jid, dbJid);
}
// most probably it should just look full matching contact
else
- result = lstrcmpi(jid, dbv.ptszVal);
-
+ result = lstrcmpi(jid, dbJid);
}
- db_free(&dbv);
- if ( !result)
+
+ if (result == 0)
return hContact;
}
}
@@ -875,13 +869,13 @@ const char* TStringPairs::operator[](const char* key) const void CJabberProto::ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount)
{
for (int i=0; i < recentCount; i++) {
- DBVARIANT dbv;
char setting[MAXMODULELABELLENGTH];
mir_snprintf(setting, sizeof(setting), "%s%d", param, i);
- if ( !getTString(setting, &dbv)) {
- SendDlgItemMessage(hwndDlg, idcCombo, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- } }
+ ptrT tszRecent( getTStringA(setting));
+ if (tszRecent != NULL)
+ SendDlgItemMessage(hwndDlg, idcCombo, CB_ADDSTRING, 0, tszRecent);
+ }
+
if ( !SendDlgItemMessage(hwndDlg, idcCombo, CB_GETCOUNT, 0, 0))
SendDlgItemMessage(hwndDlg, idcCombo, CB_ADDSTRING, 0, (LPARAM)_T(""));
}
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index c8b875165b..a24c71f55a 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -45,13 +45,11 @@ int CJabberProto::SendGetVcard(const TCHAR *jid) static void SetDialogField(CJabberProto *ppro, HWND hwndDlg, int nDlgItem, char* key, bool bTranslate = false)
{
- DBVARIANT dbv;
-
- if ( !ppro->getTString(key, &dbv)) {
- SetDlgItemText(hwndDlg, nDlgItem, (bTranslate) ? TranslateTS(dbv.ptszVal) : dbv.ptszVal);
- db_free(&dbv);
- }
- else SetDlgItemTextA(hwndDlg, nDlgItem, "");
+ ptrT tszValue( ppro->getTStringA(key));
+ if (tszValue != NULL)
+ SetDlgItemText(hwndDlg, nDlgItem, (bTranslate) ? TranslateTS(tszValue) : tszValue);
+ else
+ SetDlgItemTextA(hwndDlg, nDlgItem, "");
}
static INT_PTR CALLBACK PersonalDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -545,55 +543,51 @@ struct EditDlgParam static INT_PTR CALLBACK EditEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- EditDlgParam* dat = (EditDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ EditDlgParam *dat = (EditDlgParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
- {
- EditDlgParam* dat = (EditDlgParam*)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ dat = (EditDlgParam*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault(hwndDlg);
+ TranslateDialogDefault(hwndDlg);
- if (lParam >= 0) {
- DBVARIANT dbv;
- char idstr[33];
- WORD nFlag;
-
- SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Email Address"));
- mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
- if ( !dat->ppro->getString(idstr, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
- db_free(&dbv);
- mir_snprintf(idstr, SIZEOF(idstr), "e-mailFlag%d", lParam);
- nFlag = dat->ppro->getWord(idstr, 0);
- if (nFlag & JABBER_VCEMAIL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
- if (nFlag & JABBER_VCEMAIL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
- if (nFlag & JABBER_VCEMAIL_INTERNET) CheckDlgButton(hwndDlg, IDC_INTERNET, TRUE);
- if (nFlag & JABBER_VCEMAIL_X400) CheckDlgButton(hwndDlg, IDC_X400, TRUE);
- } } }
+ if (lParam >= 0) {
+ SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Email Address"));
+
+ char idstr[33];
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
+ ptrA email( dat->ppro->getStringA(idstr));
+ if (email != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_EMAIL, email);
+
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mailFlag%d", lParam);
+ WORD nFlag = dat->ppro->getWord(idstr, 0);
+ if (nFlag & JABBER_VCEMAIL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
+ if (nFlag & JABBER_VCEMAIL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
+ if (nFlag & JABBER_VCEMAIL_INTERNET) CheckDlgButton(hwndDlg, IDC_INTERNET, TRUE);
+ if (nFlag & JABBER_VCEMAIL_X400) CheckDlgButton(hwndDlg, IDC_X400, TRUE);
+ }
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- TCHAR text[128];
- char idstr[33];
- DBVARIANT dbv;
- WORD nFlag;
+ char idstr[33];
- if (dat->id < 0) {
- for (dat->id=0;;dat->id++) {
- mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
- if ( dat->ppro->getString(idstr, &dbv)) break;
- db_free(&dbv);
- } }
- GetDlgItemText(hwndDlg, IDC_EMAIL, text, SIZEOF(text));
- mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
- dat->ppro->setTString(idstr, text);
-
- nFlag = 0;
+ if (dat->id < 0)
+ for (dat->id=0;;dat->id++) {
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
+ if ( ptrA( dat->ppro->getStringA(idstr)) == NULL)
+ break;
+ }
+
+ TCHAR text[128];
+ GetDlgItemText(hwndDlg, IDC_EMAIL, text, SIZEOF(text));
+ mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", dat->id);
+ dat->ppro->setTString(idstr, text);
+ {
+ WORD nFlag = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCEMAIL_HOME;
if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCEMAIL_WORK;
if (IsDlgButtonChecked(hwndDlg, IDC_INTERNET)) nFlag |= JABBER_VCEMAIL_INTERNET;
@@ -616,70 +610,67 @@ static INT_PTR CALLBACK EditPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, switch (msg) {
case WM_INITDIALOG:
- {
- EditDlgParam* dat = (EditDlgParam*)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ dat = (EditDlgParam*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- TranslateDialogDefault(hwndDlg);
- if (dat->id >= 0) {
- DBVARIANT dbv;
- char idstr[33];
- WORD nFlag;
+ TranslateDialogDefault(hwndDlg);
+ if (dat->id >= 0) {
+ SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Phone Number"));
- SetWindowText(hwndDlg, TranslateT("Jabber vCard: Edit Phone Number"));
- mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
- if ( !dat->ppro->getString(idstr, &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_PHONE, dbv.pszVal);
- db_free(&dbv);
- mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
- nFlag = dat->ppro->getWord(idstr, 0);
- if (nFlag & JABBER_VCTEL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
- if (nFlag & JABBER_VCTEL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
- if (nFlag & JABBER_VCTEL_VOICE) CheckDlgButton(hwndDlg, IDC_VOICE, TRUE);
- if (nFlag & JABBER_VCTEL_FAX) CheckDlgButton(hwndDlg, IDC_FAX, TRUE);
- if (nFlag & JABBER_VCTEL_PAGER) CheckDlgButton(hwndDlg, IDC_PAGER, TRUE);
- if (nFlag & JABBER_VCTEL_MSG) CheckDlgButton(hwndDlg, IDC_MSG, TRUE);
- if (nFlag & JABBER_VCTEL_CELL) CheckDlgButton(hwndDlg, IDC_CELL, TRUE);
- if (nFlag & JABBER_VCTEL_VIDEO) CheckDlgButton(hwndDlg, IDC_VIDEO, TRUE);
- if (nFlag & JABBER_VCTEL_BBS) CheckDlgButton(hwndDlg, IDC_BBS, TRUE);
- if (nFlag & JABBER_VCTEL_MODEM) CheckDlgButton(hwndDlg, IDC_MODEM, TRUE);
- if (nFlag & JABBER_VCTEL_ISDN) CheckDlgButton(hwndDlg, IDC_ISDN, TRUE);
- if (nFlag & JABBER_VCTEL_PCS) CheckDlgButton(hwndDlg, IDC_PCS, TRUE);
- } } }
+ char idstr[33];
+ mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
+ ptrA phone( dat->ppro->getStringA(idstr));
+ if (phone != NULL)
+ SetDlgItemTextA(hwndDlg, IDC_PHONE, phone);
+
+ mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
+ int nFlag = dat->ppro->getWord(idstr, 0);
+ if (nFlag & JABBER_VCTEL_HOME) CheckDlgButton(hwndDlg, IDC_HOME, TRUE);
+ if (nFlag & JABBER_VCTEL_WORK) CheckDlgButton(hwndDlg, IDC_WORK, TRUE);
+ if (nFlag & JABBER_VCTEL_VOICE) CheckDlgButton(hwndDlg, IDC_VOICE, TRUE);
+ if (nFlag & JABBER_VCTEL_FAX) CheckDlgButton(hwndDlg, IDC_FAX, TRUE);
+ if (nFlag & JABBER_VCTEL_PAGER) CheckDlgButton(hwndDlg, IDC_PAGER, TRUE);
+ if (nFlag & JABBER_VCTEL_MSG) CheckDlgButton(hwndDlg, IDC_MSG, TRUE);
+ if (nFlag & JABBER_VCTEL_CELL) CheckDlgButton(hwndDlg, IDC_CELL, TRUE);
+ if (nFlag & JABBER_VCTEL_VIDEO) CheckDlgButton(hwndDlg, IDC_VIDEO, TRUE);
+ if (nFlag & JABBER_VCTEL_BBS) CheckDlgButton(hwndDlg, IDC_BBS, TRUE);
+ if (nFlag & JABBER_VCTEL_MODEM) CheckDlgButton(hwndDlg, IDC_MODEM, TRUE);
+ if (nFlag & JABBER_VCTEL_ISDN) CheckDlgButton(hwndDlg, IDC_ISDN, TRUE);
+ if (nFlag & JABBER_VCTEL_PCS) CheckDlgButton(hwndDlg, IDC_PCS, TRUE);
+ }
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
{
- char text[128];
char idstr[33];
- DBVARIANT dbv;
- WORD nFlag;
- if (dat->id < 0) {
+ if (dat->id < 0)
for (dat->id=0;;dat->id++) {
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
- if ( dat->ppro->getString(idstr, &dbv)) break;
- db_free(&dbv);
+ if ( ptrA( dat->ppro->getStringA(idstr)) == NULL)
+ break;
}
- }
+
+ char text[128];
GetDlgItemTextA(hwndDlg, IDC_PHONE, text, SIZEOF(text));
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", dat->id);
dat->ppro->setString(idstr, text);
- nFlag = 0;
- if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCTEL_HOME;
- if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCTEL_WORK;
+
+ WORD nFlag = 0;
+ if (IsDlgButtonChecked(hwndDlg, IDC_HOME)) nFlag |= JABBER_VCTEL_HOME;
+ if (IsDlgButtonChecked(hwndDlg, IDC_WORK)) nFlag |= JABBER_VCTEL_WORK;
if (IsDlgButtonChecked(hwndDlg, IDC_VOICE)) nFlag |= JABBER_VCTEL_VOICE;
- if (IsDlgButtonChecked(hwndDlg, IDC_FAX)) nFlag |= JABBER_VCTEL_FAX;
+ if (IsDlgButtonChecked(hwndDlg, IDC_FAX)) nFlag |= JABBER_VCTEL_FAX;
if (IsDlgButtonChecked(hwndDlg, IDC_PAGER)) nFlag |= JABBER_VCTEL_PAGER;
- if (IsDlgButtonChecked(hwndDlg, IDC_MSG)) nFlag |= JABBER_VCTEL_MSG;
- if (IsDlgButtonChecked(hwndDlg, IDC_CELL)) nFlag |= JABBER_VCTEL_CELL;
+ if (IsDlgButtonChecked(hwndDlg, IDC_MSG)) nFlag |= JABBER_VCTEL_MSG;
+ if (IsDlgButtonChecked(hwndDlg, IDC_CELL)) nFlag |= JABBER_VCTEL_CELL;
if (IsDlgButtonChecked(hwndDlg, IDC_VIDEO)) nFlag |= JABBER_VCTEL_VIDEO;
- if (IsDlgButtonChecked(hwndDlg, IDC_BBS)) nFlag |= JABBER_VCTEL_BBS;
+ if (IsDlgButtonChecked(hwndDlg, IDC_BBS)) nFlag |= JABBER_VCTEL_BBS;
if (IsDlgButtonChecked(hwndDlg, IDC_MODEM)) nFlag |= JABBER_VCTEL_MODEM;
- if (IsDlgButtonChecked(hwndDlg, IDC_ISDN)) nFlag |= JABBER_VCTEL_ISDN;
- if (IsDlgButtonChecked(hwndDlg, IDC_PCS)) nFlag |= JABBER_VCTEL_PCS;
+ if (IsDlgButtonChecked(hwndDlg, IDC_ISDN)) nFlag |= JABBER_VCTEL_ISDN;
+ if (IsDlgButtonChecked(hwndDlg, IDC_PCS)) nFlag |= JABBER_VCTEL_PCS;
mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", dat->id);
dat->ppro->setWord(idstr, nFlag);
}
@@ -730,31 +721,33 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP break;
case M_REMAKELISTS:
{
- LVITEM lvi;
int i;
char idstr[33];
TCHAR number[20];
- DBVARIANT dbv;
//e-mails
ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS));
+
+ LVITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iSubItem = 0;
lvi.iItem = 0;
for (i=0;;i++) {
mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i);
- if ( ppro->getTString(idstr, &dbv)) break;
+ ptrT email( ppro->getTStringA(idstr));
+ if (email == NULL) break;
+
mir_sntprintf(number, SIZEOF(number), _T("%d"), i+1);
lvi.pszText = number;
lvi.lParam = (LPARAM)i;
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal);
- db_free(&dbv);
+ ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, email);
lvi.iItem++;
}
lvi.mask = LVIF_PARAM;
lvi.lParam = (LPARAM)(-1);
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
+
//phones
ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES));
lvi.mask = LVIF_TEXT | LVIF_PARAM;
@@ -762,13 +755,14 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP lvi.iItem = 0;
for (i=0;;i++) {
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", i);
- if ( ppro->getTString(idstr, &dbv)) break;
+ ptrT phone( ppro->getTStringA(idstr));
+ if (phone == NULL) break;
+
mir_sntprintf(number, SIZEOF(number), _T("%d"), i+1);
lvi.pszText = number;
lvi.lParam = (LPARAM)i;
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
- db_free(&dbv);
+ ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, phone);
lvi.iItem++;
}
lvi.mask = LVIF_PARAM;
@@ -776,9 +770,10 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
}
break;
+
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
- case 0: {
+ case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_PARAMCHANGED:
SendMessage(hwndDlg, WM_INITDIALOG, 0, ((PSHNOTIFY*)lParam)->lParam);
@@ -789,7 +784,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP if ( !ppro->m_vCardUpdates)
ppro->SetServerVcard(ppro->m_bPhotoChanged, ppro->m_szPhotoFileName);
break;
- } }
+ }
break;
case IDC_EMAILS:
@@ -804,108 +799,107 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP case CDDS_ITEMPREPAINT:
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
return TRUE;
+
case CDDS_SUBITEM|CDDS_ITEMPREPAINT:
- {
- RECT rc;
- HICON hIcon;
-
- ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
- if (nm->nmcd.lItemlParam==(LPARAM)(-1) && nm->iSubItem==3)
- hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
- else if (nm->iSubItem==2 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
- hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_EDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
- else if (nm->iSubItem==3 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
- hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
- else break;
- DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2,hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
- DestroyIcon(hIcon);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- }
+ RECT rc;
+ HICON hIcon;
+
+ ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
+ if (nm->nmcd.lItemlParam==(LPARAM)(-1) && nm->iSubItem==3)
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ else if (nm->iSubItem==2 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_EDIT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ else if (nm->iSubItem==3 && nm->nmcd.lItemlParam!=(LPARAM)(-1))
+ hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ else break;
+ DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2,hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ DestroyIcon(hIcon);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
return TRUE;
}
}
break;
+
case NM_CLICK:
- {
- NMLISTVIEW *nm = (NMLISTVIEW *) lParam;
- LVITEM lvi;
- const char* szIdTemplate = nm->hdr.idFrom==IDC_PHONES?"Phone%d":"e-mail%d";
- const char* szFlagTemplate = nm->hdr.idFrom==IDC_PHONES?"PhoneFlag%d":"e-mailFlag%d";
- LVHITTESTINFO hti;
-
- if (nm->iSubItem < 2) break;
- hti.pt.x = (short) LOWORD(GetMessagePos());
- hti.pt.y = (short) HIWORD(GetMessagePos());
- ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
- if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hti.iItem;
- lvi.iSubItem = 0;
- ListView_GetItem(nm->hdr.hwndFrom, &lvi);
- if (lvi.lParam == (LPARAM)(-1)) {
- if (hti.iSubItem == 3) {
- //add
- EditDlgParam param = { -1, ppro };
- int res;
- if (nm->hdr.idFrom == IDC_PHONES)
- res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
- else
- res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
- if (res != IDOK)
- break;
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
+ NMLISTVIEW *nm = (NMLISTVIEW *) lParam;
+ if (nm->iSubItem < 2)
+ break;
+
+ const char* szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "Phone%d" : "e-mail%d";
+ const char* szFlagTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "PhoneFlag%d" : "e-mailFlag%d";
+
+ LVHITTESTINFO hti;
+ hti.pt.x = (short) LOWORD(GetMessagePos());
+ hti.pt.y = (short) HIWORD(GetMessagePos());
+ ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
+ if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1)
+ break;
+
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hti.iItem;
+ lvi.iSubItem = 0;
+ ListView_GetItem(nm->hdr.hwndFrom, &lvi);
+ if (lvi.lParam == (LPARAM)(-1)) {
+ if (hti.iSubItem == 3) {
+ //add
+ EditDlgParam param = { -1, ppro };
+ int res;
+ if (nm->hdr.idFrom == IDC_PHONES)
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
+ else
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
+ if (res != IDOK)
+ break;
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
+ ppro->m_vCardUpdates |= (1UL<<iPageId);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- else {
- if (hti.iSubItem == 3) {
- //delete
- int i;
- char idstr[33];
- DBVARIANT dbv;
-
- for (i=lvi.lParam;;i++) {
- WORD nFlag;
-
- mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i + 1);
- if (ppro->getString(idstr, &dbv)) break;
- mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
- ppro->setString(idstr, dbv.pszVal);
- mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i + 1);
- db_free(&dbv);
- nFlag = ppro->getWord(idstr, 0);
- mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i);
- ppro->setWord(idstr, nFlag);
- }
+ }
+ else {
+ if (hti.iSubItem == 3) {
+ //delete
+ char idstr[33];
+
+ int i;
+ for (i=lvi.lParam; ; i++) {
+ mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i + 1);
+ ptrA fieldVal( ppro->getStringA(idstr));
+ if (fieldVal == NULL) break;
mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
- ppro->delSetting(idstr);
+ ppro->setString(idstr, fieldVal);
+
+ mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i + 1);
+ WORD nFlag = ppro->getWord(idstr, 0);
mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i);
- ppro->delSetting(idstr);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- else if (hti.iSubItem == 2) {
- EditDlgParam param = { lvi.lParam, ppro };
- int res;
- if (nm->hdr.idFrom == IDC_PHONES)
- res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
- else
- res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
- if (res != IDOK)
- break;
- SendMessage(hwndDlg,M_REMAKELISTS,0,0);
- ppro->m_vCardUpdates |= (1UL<<iPageId);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ ppro->setWord(idstr, nFlag);
}
+ mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
+ ppro->delSetting(idstr);
+ mir_snprintf(idstr, SIZEOF(idstr), szFlagTemplate, i);
+ ppro->delSetting(idstr);
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
+ ppro->m_vCardUpdates |= (1UL << iPageId);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ else if (hti.iSubItem == 2) {
+ EditDlgParam param = { lvi.lParam, ppro };
+ int res;
+ if (nm->hdr.idFrom == IDC_PHONES)
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDPHONE), hwndDlg, EditPhoneDlgProc, (LPARAM)¶m);
+ else
+ res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_VCARD_ADDEMAIL), hwndDlg, EditEmailDlgProc, (LPARAM)¶m);
+ if (res != IDOK)
+ break;
+ SendMessage(hwndDlg,M_REMAKELISTS,0,0);
+ ppro->m_vCardUpdates |= (1UL<<iPageId);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
- break;
}
- break;
}
break;
+
case WM_SETCURSOR:
if (LOWORD(lParam) != HTCLIENT) break;
if (GetForegroundWindow() == GetParent(hwndDlg)) {
@@ -915,6 +909,7 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click
}
break;
+
case WM_DESTROY:
ppro->WindowUnsubscribe(hwndDlg);
break;
@@ -1011,28 +1006,21 @@ void CJabberProto::SaveVcardToDB(HWND hwndPage, int iPage) // is always synced with db
} }
-void CJabberProto::AppendVcardFromDB(HXML n, char* tag, char* key)
+void CJabberProto::AppendVcardFromDB(HXML n, char *tag, char *key)
{
if (n == NULL || tag == NULL || key == NULL)
return;
- DBVARIANT dbv;
- if ( getTString(key, &dbv))
- n << XCHILD(_A2T(tag));
- else {
- n << XCHILD(_A2T(tag), dbv.ptszVal);
- db_free(&dbv);
-} }
+ ptrT tszValue( getTStringA(key));
+ n << XCHILD( _A2T(tag), tszValue);
+}
void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName)
{
if ( !m_bJabberOnline) return;
- DBVARIANT dbv;
- TCHAR *szFileName;
int i;
char idstr[33];
- WORD nFlag;
XmlNodeIq iq( AddIQ(&CJabberProto::OnIqResultSetVcard, JABBER_IQ_TYPE_SET));
HXML v = iq << XCHILDNS(_T("vCard"), JABBER_FEAT_VCARD_TEMP);
@@ -1050,15 +1038,15 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) for (i=0; ; i++) {
mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i);
- if ( getTString(idstr, &dbv))
+ ptrT email( getTStringA(idstr));
+ if (email == NULL)
break;
- HXML e = v << XCHILD(_T("EMAIL"), dbv.ptszVal);
- db_free(&dbv);
+ HXML e = v << XCHILD(_T("EMAIL"), email);
AppendVcardFromDB(e, "USERID", idstr);
mir_snprintf(idstr, SIZEOF(idstr), "e-mailFlag%d", i);
- nFlag = getWord(idstr, 0);
+ WORD nFlag = getWord(idstr, 0);
if (nFlag & JABBER_VCEMAIL_HOME) e << XCHILD(_T("HOME"));
if (nFlag & JABBER_VCEMAIL_WORK) e << XCHILD(_T("WORK"));
if (nFlag & JABBER_VCEMAIL_INTERNET) e << XCHILD(_T("INTERNET"));
@@ -1098,14 +1086,15 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) for (i=0; ; i++) {
mir_snprintf(idstr, SIZEOF(idstr), "Phone%d", i);
- if ( getTString(idstr, &dbv)) break;
- db_free(&dbv);
+ ptrT phone( getTStringA(idstr));
+ if (phone == NULL)
+ break;
n = v << XCHILD(_T("TEL"));
AppendVcardFromDB(n, "NUMBER", idstr);
mir_snprintf(idstr, SIZEOF(idstr), "PhoneFlag%d", i);
- nFlag = getWord(idstr, 0);
+ WORD nFlag = getWord(idstr, 0);
if (nFlag & JABBER_VCTEL_HOME) n << XCHILD(_T("HOME"));
if (nFlag & JABBER_VCTEL_WORK) n << XCHILD(_T("WORK"));
if (nFlag & JABBER_VCTEL_VOICE) n << XCHILD(_T("VOICE"));
@@ -1120,7 +1109,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) if (nFlag & JABBER_VCTEL_PCS) n << XCHILD(_T("PCS"));
}
- TCHAR szAvatarName[ MAX_PATH ];
+ TCHAR szAvatarName[MAX_PATH], *szFileName;
GetAvatarFileName(NULL, szAvatarName, SIZEOF(szAvatarName));
if (bPhotoChanged)
szFileName = szPhotoFileName;
@@ -1136,18 +1125,19 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) delSetting("AvatarHash");
}
else {
- HANDLE hFile;
- struct _stat st;
- char* buffer, *str;
- DWORD nRead;
-
Log("Saving picture from %S", szFileName);
- if (_tstat(szFileName, &st) >= 0) {
+
+ struct _stat st;
+ if ( _tstat(szFileName, &st) >= 0) {
// Note the FILE_SHARE_READ attribute so that the CopyFile can succeed
- if ((hFile=CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
- if ((buffer=(char*)mir_alloc(st.st_size)) != NULL) {
+ HANDLE hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ ptrA buffer((char*)mir_alloc(st.st_size));
+ if (buffer != NULL) {
+ DWORD nRead;
if (ReadFile(hFile, buffer, st.st_size, &nRead, NULL)) {
- if ((str=mir_base64_encode((PBYTE)buffer, nRead)) != NULL) {
+ ptrA str( mir_base64_encode((PBYTE)(LPSTR)buffer, nRead));
+ if (str != NULL) {
n = v << XCHILD(_T("PHOTO"));
TCHAR *szFileType;
switch( ProtoGetBufferFormat(buffer)) {
@@ -1157,16 +1147,13 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) default: szFileType = _T("image/jpeg"); break;
}
n << XCHILD(_T("TYPE"), szFileType);
-
n << XCHILD(_T("BINVAL"), _A2T(str));
- mir_free(str);
// NEED TO UPDATE OUR AVATAR HASH:
-
BYTE digest[MIR_SHA1_HASH_SIZE];
mir_sha1_ctx sha1ctx;
mir_sha1_init(&sha1ctx);
- mir_sha1_append(&sha1ctx, (BYTE*)buffer, nRead);
+ mir_sha1_append(&sha1ctx, (BYTE*)(LPSTR)buffer, nRead);
mir_sha1_finish(&sha1ctx, digest);
char buf[MIR_SHA1_HASH_SIZE*2+1];
@@ -1178,17 +1165,18 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) DeleteFile(szAvatarName);
GetAvatarFileName(NULL, szAvatarName, SIZEOF(szAvatarName));
-
CopyFile(szFileName, szAvatarName, FALSE);
}
setString("AvatarHash", buf);
setString("AvatarSaved", buf);
- } }
- mir_free(buffer);
+ }
+ }
}
CloseHandle(hFile);
- } } }
+ }
+ }
+ }
m_ThreadInfo->send(iq);
}
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index e220c14302..1e18c1fbc2 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -283,13 +283,8 @@ void CJabberDlgPepSimple::cbModes_OnChange(CCtrlData *) if ((m_prevSelected >= 0) && (m_modes[m_cbModes.GetItemData(m_prevSelected)].m_id >= 0)) {
mir_snprintf(szSetting, SIZEOF(szSetting), "PepMsg_%s", m_modes[m_cbModes.GetItemData(m_prevSelected)].m_name);
- DBVARIANT dbv;
- if ( !m_proto->getTString(szSetting, &dbv)) {
- m_txtDescription.SetText(dbv.ptszVal);
- db_free(&dbv);
- }
- else m_txtDescription.SetTextA("");
-
+ ptrT szDescr( m_proto->getTStringA(szSetting));
+ m_txtDescription.SetText((szDescr != NULL) ? szDescr : _T(""));
m_txtDescription.Enable(true);
}
else {
@@ -1494,32 +1489,18 @@ void CJabberProto::WriteAdvStatus(HANDLE hContact, const char *pszSlot, const TC }
}
-char *CJabberProto::ReadAdvStatusA(HANDLE hContact, const char *pszSlot, const char *pszValue)
+char* CJabberProto::ReadAdvStatusA(HANDLE hContact, const char *pszSlot, const char *pszValue)
{
char szSetting[128];
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", m_szModuleName, pszSlot, pszValue);
-
- DBVARIANT dbv;
- if ( db_get_s(hContact, "AdvStatus", szSetting, &dbv))
- return NULL;
-
- char *res = mir_strdup(dbv.pszVal);
- db_free(&dbv);
- return res;
+ return db_get_sa(hContact, "AdvStatus", szSetting);
}
-TCHAR *CJabberProto::ReadAdvStatusT(HANDLE hContact, const char *pszSlot, const char *pszValue)
+TCHAR* CJabberProto::ReadAdvStatusT(HANDLE hContact, const char *pszSlot, const char *pszValue)
{
char szSetting[128];
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", m_szModuleName, pszSlot, pszValue);
-
- DBVARIANT dbv;
- if ( db_get_ts(hContact, "AdvStatus", szSetting, &dbv))
- return NULL;
-
- TCHAR *res = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- return res;
+ return db_get_tsa(hContact, "AdvStatus", szSetting);
}
///////////////////////////////////////////////////////////////////////////////
|