diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber_groupchat.cpp | 18 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 43 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_misc.cpp | 7 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_notes.cpp | 13 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 5 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_search.cpp | 8 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_std.cpp | 37 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 2 |
9 files changed, 36 insertions, 99 deletions
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index f4e5ee0d0c..900e21ebc5 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -1129,14 +1129,11 @@ void CJabberProto::GroupchatProcessPresence(HXML node) else if ( !_tcscmp(type, _T("error"))) {
int errorCode = 0;
HXML errorNode = xmlGetChild(node , "error");
- TCHAR* str = JabberErrorMsg(errorNode, &errorCode);
+ ptrT str( JabberErrorMsg(errorNode, &errorCode));
if (errorCode == JABBER_ERROR_CONFLICT) {
- TCHAR newNick[256] = { 0 };
- if (++item->iChatState == 1 &&
- JGetStringT(NULL, "GcAltNick", newNick, SIZEOF(newNick)) != NULL &&
- newNick[0] != _T('\0'))
- {
+ ptrT newNick( db_get_tsa(NULL, m_szModuleName, "GcAltNick"));
+ if (++item->iChatState == 1 && newNick != NULL && newNick[0] != 0) {
replaceStrT(item->nick, newNick);
TCHAR text[1024] = { 0 };
mir_sntprintf(text, SIZEOF(text), _T("%s/%s"), item->jid, newNick);
@@ -1146,16 +1143,15 @@ void CJabberProto::GroupchatProcessPresence(HXML node) CallFunctionAsync(JabberGroupchatChangeNickname, new JabberGroupchatChangeNicknameParam(this, from));
item->iChatState = 0;
}
- mir_free(str);
return;
}
MsgPopup(NULL, str, TranslateT("Jabber Error"));
- if (item != NULL)
- if ( !item->bChatActive) ListRemove(LIST_CHATROOM, from);
- mir_free(str);
-} }
+ if (item != NULL && !item->bChatActive)
+ ListRemove(LIST_CHATROOM, from);
+ }
+}
void CJabberProto::GroupchatProcessMessage(HXML node)
{
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index a099108366..3e6c05eeb1 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -334,33 +334,25 @@ void CJabberProto::OnIqResultSession(HXML iqNode, CJabberIqInfo* pInfo) void CJabberProto::GroupchatJoinByHContact(HANDLE hContact, bool autojoin)
{
- TCHAR* roomjid = JGetStringT(hContact, "ChatRoomID");
- if ( !roomjid) return;
+ ptrT roomjid( db_get_tsa(hContact, m_szModuleName, "ChatRoomID"));
+ if (roomjid == NULL)
+ return;
- TCHAR* room = roomjid;
- TCHAR* server = _tcschr(roomjid, '@');
- if ( !server) {
- mir_free(roomjid);
+ TCHAR *room = roomjid;
+ TCHAR *server = _tcschr(roomjid, '@');
+ if ( !server)
return;
- }
+
server[0] = 0; server++;
- TCHAR *nick = JGetStringT(hContact, "MyNick");
- if ( !nick) {
+ ptrT nick( db_get_tsa(hContact, m_szModuleName, "MyNick"));
+ if (nick == NULL) {
nick = JabberNickFromJID(m_szJabberJID);
- if ( !nick) {
- mir_free(roomjid);
+ if (nick == NULL)
return;
- }
}
- TCHAR *password = JGetStringCrypt(hContact, "LoginPassword");
-
- GroupchatJoinRoom(server, room, nick, password, autojoin);
-
- mir_free(password);
- mir_free(nick);
- mir_free(roomjid);
+ GroupchatJoinRoom(server, room, nick, ptrT(JGetStringCrypt(hContact, "LoginPassword")), autojoin);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1062,15 +1054,10 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode) } }
if (hasFn && !hasNick) {
- TCHAR *name = JGetStringT(hContact, "FullName");
- TCHAR *nick = JGetStringT(hContact, "Nick");
- TCHAR *jidNick = JabberNickFromJID(jid);
- if ( !nick || (jidNick && !_tcsicmp(nick, jidNick)))
- setTString(hContact, "Nick", name);
-
- mir_free(jidNick);
- mir_free(nick);
- mir_free(name);
+ ptrT nick( db_get_tsa(hContact, m_szModuleName, "Nick"));
+ ptrT jidNick( JabberNickFromJID(jid));
+ if (!nick || (jidNick && !_tcsicmp(nick, jidNick)))
+ setTString(hContact, "Nick", ptrT( db_get_tsa(hContact, m_szModuleName, "FullName")));
}
if ( !hasFn)
JDeleteSetting(hContact, "FullName");
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index dbe400af80..b04bba1ad1 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -278,16 +278,13 @@ void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbL if (hContact != NULL) {
char str[ 256 ];
DBVARIANT dbv;
- if ( !JGetStringUtf(hContact, "jid", &dbv)) {
+ if ( !db_get_utf(hContact, m_szModuleName, "jid", &dbv)) {
strncpy(str, dbv.pszVal, sizeof str);
str[ sizeof(str)-1 ] = 0;
db_free(&dbv);
}
else _i64toa((LONG_PTR)hContact, str, 10);
-
- char* hash = JabberSha1(str);
- mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S.%S"), hash, szFileType);
- mir_free(hash);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S.%S"), ptrA(JabberSha1(str)), szFileType);
}
else if (m_ThreadInfo != NULL) {
mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@%S avatar.%S"),
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp index 435eb17903..382c63cc98 100644 --- a/protocols/JabberG/src/jabber_notes.cpp +++ b/protocols/JabberG/src/jabber_notes.cpp @@ -853,14 +853,11 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleNotes(WPARAM, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM)
{
- if ( !wParam) return 0;
-
- TCHAR szClientJid[ JABBER_MAX_JID_LEN ];
- GetClientJID( JGetStringT((HANDLE)wParam, "jid"), szClientJid, SIZEOF(szClientJid));
-
- CNoteItem *pItem = new CNoteItem(NULL, szClientJid);
- CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote);
- pDlg->Show();
+ if (wParam) {
+ CNoteItem *pItem = new CNoteItem(NULL, ptrT( db_get_tsa((HANDLE)wParam, m_szModuleName, "jid")));
+ CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote);
+ pDlg->Show();
+ }
return 0;
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 6e2e1d0d84..04241de40e 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -850,7 +850,7 @@ HANDLE __cdecl CJabberProto::SearchBasic(const TCHAR *szJid) numericjid = (*i >= '0') && (*i <= '9');
mir_free(szServer);
- szServer = JGetStringT(NULL, "LoginServer");
+ szServer = db_get_tsa(NULL, m_szModuleName, "LoginServer");
if (szServer == NULL)
szServer = mir_tstrdup(_T("jabber.org"));
else if (numericjid && !_tcsicmp(szServer, _T("S.ms"))) {
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index d6edb36de7..ab737b4656 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -784,12 +784,7 @@ struct CJabberProto : public PROTO<CJabberProto> //---- jabber_std.cpp ----------------------------------------------
void JDeleteSetting(HANDLE hContact, const char* valueName);
- int JGetStringUtf(HANDLE hContact, char* valueName, DBVARIANT* dbv);
- TCHAR *JGetStringT(HANDLE hContact, char* valueName);
- TCHAR *JGetStringT(HANDLE hContact, char* valueName, TCHAR *&out);
- TCHAR *JGetStringT(HANDLE hContact, char* valueName, TCHAR *buf, int size);
void JLoginFailed(int errorCode);
- DWORD JSetStringUtf(HANDLE hContact, const char* valueName, const char* parValue);
TCHAR* JGetStringCrypt(HANDLE hContact, char* valueName);
DWORD JSetStringCrypt(HANDLE hContact, char* valueName, const TCHAR *parValue);
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index 409f0cc4df..12987053ef 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -701,9 +701,11 @@ static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPAR HWND __cdecl CJabberProto::CreateExtendedSearchUI(HWND parent)
{
- TCHAR szServer[128];
- if (parent && hInst && (!JGetStringT(NULL, "LoginServer", szServer, SIZEOF(szServer)) || _tcsicmp(szServer, _T("S.ms"))))
- return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this);
+ if (parent && hInst) {
+ ptrT szServer( db_get_tsa(NULL, m_szModuleName, "LoginServer"));
+ if (szServer == NULL || _tcsicmp(szServer, _T("S.ms")))
+ return CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, (LPARAM)this);
+ }
return 0; // Failure
}
diff --git a/protocols/JabberG/src/jabber_std.cpp b/protocols/JabberG/src/jabber_std.cpp index c7b206e5ef..ad01670e03 100644 --- a/protocols/JabberG/src/jabber_std.cpp +++ b/protocols/JabberG/src/jabber_std.cpp @@ -30,49 +30,12 @@ void CJabberProto::JDeleteSetting(HANDLE hContact, const char* valueName) db_unset(hContact, m_szModuleName, valueName);
}
-int CJabberProto::JGetStringUtf(HANDLE hContact, char* valueName, DBVARIANT* dbv)
-{
- return db_get_utf(hContact, m_szModuleName, valueName, dbv);
-}
-
-TCHAR *CJabberProto::JGetStringT(HANDLE hContact, char* valueName)
-{
- DBVARIANT dbv = {0};
- if (getTString(hContact, valueName, &dbv))
- return NULL;
-
- TCHAR *res = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- return res;
-}
-
-TCHAR *CJabberProto::JGetStringT(HANDLE hContact, char* valueName, TCHAR *&out)
-{
- return out = JGetStringT(hContact, valueName);
-}
-
-TCHAR *CJabberProto::JGetStringT(HANDLE hContact, char* valueName, TCHAR *buf, int size)
-{
- DBVARIANT dbv = {0};
- if (getTString(hContact, valueName, &dbv))
- return NULL;
-
- lstrcpyn(buf, dbv.ptszVal, size);
- db_free(&dbv);
- return buf;
-}
-
void CJabberProto::JLoginFailed(int errorCode)
{
*m_savedPassword = 0;
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, errorCode);
}
-DWORD CJabberProto::JSetStringUtf(HANDLE hContact, const char* valueName, const char* parValue)
-{
- return db_set_utf(hContact, m_szModuleName, valueName, parValue);
-}
-
// save/load crypted strings
void __forceinline sttCryptString(char *str)
{
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 6248a03a23..4a321f38a0 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -788,7 +788,7 @@ HANDLE CJabberSysInterface::ContactFromJID(LPCTSTR jid) LPTSTR CJabberSysInterface::ContactToJID(HANDLE hContact)
{
- return m_psProto->JGetStringT(hContact, m_psProto->getByte(hContact, "ChatRoom", 0) ? "ChatRoomID" : "jid");
+ return db_get_tsa(hContact, m_psProto->m_szModuleName, m_psProto->getByte(hContact, "ChatRoom", 0) ? "ChatRoomID" : "jid");
}
LPTSTR CJabberSysInterface::GetBestResourceName(LPCTSTR jid)
|