summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-04-22 11:11:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-04-22 11:11:39 +0000
commit5212643f256d5cf75b295aeb42783c81ce033519 (patch)
tree0b5e5bb0c5ebe0d0d692663f37327cefc80a5316 /protocols
parentbd9c37190715b10445fd3135b235062b33dc302c (diff)
preventing troubles with nick = NULL
git-svn-id: http://svn.miranda-ng.org/main/trunk@16743 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_list.cpp16
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp24
-rw-r--r--protocols/JabberG/src/jabber_proto.h1
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp2
-rw-r--r--protocols/JabberG/src/jabber_util.cpp2
5 files changed, 28 insertions, 17 deletions
diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp
index 25db1afe3e..e73e485194 100644
--- a/protocols/JabberG/src/jabber_list.cpp
+++ b/protocols/JabberG/src/jabber_list.cpp
@@ -87,6 +87,22 @@ void JABBER_RESOURCE_STATUS::Release()
delete this;
}
+void CJabberProto::ListInit(void)
+{
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (isChatRoom(hContact)) {
+ ptrT jid(getTStringA(hContact, "ChatRoomID"));
+ if (jid != NULL)
+ ListAdd(LIST_CHATROOM, jid, hContact);
+ }
+ else {
+ ptrT jid(getTStringA(hContact, "jid"));
+ if (jid != NULL)
+ ListAdd(LIST_ROSTER, jid, hContact);
+ }
+ }
+}
+
void CJabberProto::ListWipe(void)
{
mir_cslock lck(m_csLists);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 67b6c4bd22..c87952787a 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -241,25 +241,17 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
SetContactOfflineStatus(hContact);
- if (isChatRoom(hContact)) {
- ptrT jid(getTStringA(hContact, "ChatRoomID"));
- if (jid != NULL)
- ListAdd(LIST_CHATROOM, jid, hContact);
- continue;
- }
-
- ptrT jid(getTStringA(hContact, "jid"));
- if (jid == NULL)
- continue;
+ if (getByte(hContact, "IsTransport", 0)) {
+ ptrT jid(getTStringA(hContact, "jid"));
+ if (jid == NULL)
+ continue;
- ListAdd(LIST_ROSTER, jid, hContact);
+ TCHAR *resourcepos = _tcschr(jid, '/');
+ if (resourcepos != NULL)
+ *resourcepos = '\0';
- TCHAR *resourcepos = _tcschr(jid, '/');
- if (resourcepos != NULL)
- *resourcepos = '\0';
-
- if (getByte(hContact, "IsTransport", 0))
m_lstTransports.insert(mir_tstrdup(jid));
+ }
}
return 0;
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index cf496ba308..302205bbbc 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -530,6 +530,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
JABBER_LIST_ITEM* ListGetItemPtr(JABBER_LIST list, const TCHAR *jid);
JABBER_LIST_ITEM* ListGetItemPtrFromIndex(int index);
+ void ListInit(void);
void ListWipe(void);
void ListRemove(JABBER_LIST list, const TCHAR *jid);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index a909d017a2..4ab20dfab0 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -394,6 +394,8 @@ LBL_FatalError:
mir_sntprintf(m_szJabberJID, len + 1, _T("%s@%S"), info.conn.username, info.conn.server);
m_bSendKeepAlive = m_options.KeepAlive != 0;
setTString("jid", m_szJabberJID); // store jid in database
+
+ ListInit();
}
xmlStreamInitializeNow(&info);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index ccf4a8223b..0fe957a179 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -492,7 +492,7 @@ void CJabberProto::SendPresence(int status, bool bSendToAll)
LISTFOREACH(i, this, LIST_CHATROOM)
{
JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
- if (item != NULL) {
+ if (item != NULL && item->nick != NULL) {
TCHAR text[1024];
mir_sntprintf(text, _T("%s/%s"), item->jid, item->nick);
SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, text, NULL);